Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Release 0.1.0 (develop) #8

Merged
merged 5 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
TAG_DEVELOP: develop
TAG_LATEST: latest
JDK_VERSION: 11
JDK_FILE: openjdk-11.0.2_linux-x64_bin.tar.gz
JDK_URL: https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz

services:
mongo:
Expand All @@ -37,25 +35,13 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Cache JDK folder
uses: actions/cache@v1
with:
path: ~/jdk
key: ${{ env.JDK_FILE }}

# (2) -> Prepare Java
- name: Download Oracle JDK
run: |
if [ ! -f ~/jdk/$JDK_FILE ]; then
wget --quiet $JDK_URL -O ~/jdk/$JDK_FILE
fi
cp ~/jdk/$JDK_FILE .

- name: Setup Java
uses: actions/setup-java@master
uses: actions/setup-java@v1
with:
version: ${{ env.JDK_VERSION }}
jdkFile: ${{ env.JDK_FILE }}
java-version: ${{ env.JDK_VERSION }}
java-package: jdk
architecture: x64

- name: Verify Maven and Java
run: |
Expand All @@ -64,11 +50,11 @@ jobs:
# (3) -> Test and build
- name: Run tests
run: |
mvn --quiet -U -B org.jacoco:jacoco-maven-plugin:prepare-agent test
mvn -U -B org.jacoco:jacoco-maven-plugin:prepare-agent test

- name: Build package and verify
run: |
mvn --quiet -B -U --fail-fast -DskipTests tidy:check com.github.spotbugs:spotbugs-maven-plugin:check license:check verify
mvn -U -B --fail-fast -DskipTests tidy:check com.github.spotbugs:spotbugs-maven-plugin:check license:check verify

# (4) -> Build Docker image
- name: Docker build
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0]

Initial version for simple list of FAIR Data Points.

### Added

- Endpoint for "call home" ping and storing entries in MongoDB
- REST API to retrieve entries list (both all and paged) documented using Swagger/OpenAPI
- Simple webpage with table to browse entries including sorting and pagination

[Unreleased]: /../../compare/v0.1.0...develop
[0.1.0]: /../../tree/v0.1.0
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<version>2.2.7.RELEASE</version>
<relativePath/>
</parent>

<groupId>solutions.fairdata</groupId>
<artifactId>fairdatapoint-index</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>

<inceptionYear>2020</inceptionYear>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = {"solutions.fairdata.fdp.index"})
@SpringBootApplication
public class FairDataPointIndexApplication {
public static void main(String[] args) {
SpringApplication.run(FairDataPointIndexApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@
package solutions.fairdata.fdp.index.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public class HomeController {

@GetMapping
public String home(Model model, @SortDefault(sort = "modificationTime", direction = Sort.Direction.DESC) Pageable pageable) {
Optional<Sort.Order> order = pageable.getSort().stream().findFirst();
String sort = order.map(o -> o.getProperty() + "," + o.getDirection().name().toLowerCase()).orElse("");
var sort = pageable.getSort().stream()
.findFirst()
.map(o -> o.getProperty() + "," + o.getDirection().name().toLowerCase())
.orElse("");

model.addAttribute("entries", service.getEntriesPage(pageable));
model.addAttribute("sort", sort);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@
<form th:action="@{'/'}" method="get" class="row mx-auto">
<div class="col-sm">
<div class="input-group">
<input type="number" class="form-control" id="size" name="size" min="1" th:value="${entries.size}">
<input type="number" class="form-control" id="size" name="size" min="1" th:value="${entries.size}" />
<div class="input-group-append">
<label class="input-group-text" for="size">per page</label>
</div>
</div>
</div>
<div class="col-sm">
<div class="input-group">
<input type="number" class="form-control" id="page" name="page" min="1" th:max="${entries.totalPages}" th:value="${entries.number + 1}">
<input type="number" class="form-control" id="page" name="page" min="1" th:max="${entries.totalPages}" th:value="${entries.number + 1}" />
<div class="input-group-append">
<label class="input-group-text" for="page">page</label>
</div>
</div>
</div>
<div>
<input type="hidden" name="sort" th:value="${sort}">
<input type="hidden" name="sort" th:value="${sort}" />
<button type="submit" class="btn btn-primary">Go</button>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package solutions.fairdata.fdp.index;

import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;

public class EntriesAll_GET extends WebIntegrationTest {
@DisplayName("GET /entries/all")
public class EntriesAll_GET_Test extends WebIntegrationTest {

@Autowired
private EntryRepository entryRepository;
@Autowired
private MongoTemplate mongoTemplate;

private final ParameterizedTypeReference<List<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {};

private URI url() {
return URI.create("/entries/all");
}
Expand All @@ -67,8 +70,6 @@ public void res200_listEmpty() {
.get(url())
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<List<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<List<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand All @@ -92,8 +93,6 @@ public void res200_listFew() {
.get(url())
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<List<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<List<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand All @@ -120,8 +119,6 @@ public void res200_listMany() {
.get(url())
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<List<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<List<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -46,12 +47,14 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;


public class EntriesPage_GET extends WebIntegrationTest {
@DisplayName("GET /entries")
public class EntriesPage_GET_Test extends WebIntegrationTest {

@Autowired
private EntryRepository entryRepository;

private final ParameterizedTypeReference<CustomPageImpl<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {};

private URI url() {
return URI.create("/entries");
}
Expand Down Expand Up @@ -80,8 +83,6 @@ public void res200_pageEmpty() {
.get(url())
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<CustomPageImpl<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<CustomPageImpl<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand All @@ -108,8 +109,6 @@ public void res200_outOfBoundsPage() {
.get(urlWithPage(7))
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<CustomPageImpl<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<CustomPageImpl<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand Down Expand Up @@ -138,8 +137,6 @@ public void res200_pageFew() {
.get(url())
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<CustomPageImpl<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<CustomPageImpl<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand Down Expand Up @@ -174,8 +171,6 @@ public void res200_pageManyMiddle() {
.get(urlWithPageSize(page, size))
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<CustomPageImpl<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<CustomPageImpl<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand Down Expand Up @@ -208,8 +203,6 @@ public void res200_pageManyLast() {
.get(urlWithPageSize(page, size))
.accept(MediaType.APPLICATION_JSON)
.build();
ParameterizedTypeReference<CustomPageImpl<IndexEntryDTO>> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<CustomPageImpl<IndexEntryDTO>> result = client.exchange(request, responseType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;

public class ReceivePing_POST extends WebIntegrationTest {
@DisplayName("POST /ping")
public class ReceivePing_POST_Test extends WebIntegrationTest {

@Autowired
private EntryRepository entryRepository;
@Autowired
private MongoTemplate mongoTemplate;

private final ParameterizedTypeReference<Void> responseType = new ParameterizedTypeReference<>() {};

private URI url() {
return URI.create("/");
}
Expand All @@ -74,8 +77,6 @@ public void res204_newEnty() {
.post(url())
.accept(MediaType.APPLICATION_JSON)
.body(reqDto);
ParameterizedTypeReference<Void> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
assertThat("Entry does not exist before the ping", entryRepository.findByClientUrl(clientUrl).isPresent(), is(Boolean.FALSE));
Expand All @@ -100,8 +101,6 @@ public void res204_existingEnty() {
.post(url())
.accept(MediaType.APPLICATION_JSON)
.body(reqDto);
ParameterizedTypeReference<Void> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
entryRepository.save(indexEntry);
Expand All @@ -124,8 +123,6 @@ public void res400_nullClientUrl() {
.post(url())
.accept(MediaType.APPLICATION_JSON)
.body(reqDto);
ParameterizedTypeReference<Void> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<Void> result = client.exchange(request, responseType);
Expand All @@ -145,8 +142,6 @@ public void res400_nonUrlClientUrl() {
.post(url())
.accept(MediaType.APPLICATION_JSON)
.body(reqDto);
ParameterizedTypeReference<Void> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<Void> result = client.exchange(request, responseType);
Expand All @@ -167,8 +162,6 @@ public void res400_differentBody() {
.post(url())
.accept(MediaType.APPLICATION_JSON)
.body(dummyData);
ParameterizedTypeReference<Void> responseType = new ParameterizedTypeReference<>() {
};

// WHEN
ResponseEntity<Void> result = client.exchange(request, responseType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

public class Home_GET extends WebIntegrationTest {
@DisplayName("Browse /")
public class Home_GET_Test extends WebIntegrationTest {

@Autowired
private EntryRepository entryRepository;
Expand Down