diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index c108f45b..e08ec3fd 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -37,11 +37,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- - name: Set up JDK 1.8
+ - name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
- java-version: '8'
+ java-version: '17'
+ cache: maven
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
@@ -68,8 +69,31 @@ jobs:
#- run: |
# make bootstrap
# make release
+ # Build all modules except klass-forvaltning since it is not compatible with JDK 17
- name: Build with Maven
- run: mvn -B clean install --settings=.maven.settings.xml --file pom.xml
+ run: mvn -B clean install --settings=.maven.settings.xml -pl '!:klass-forvaltning'
+
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'zulu'
+ java-version: '8'
+ cache: maven
+
+ # Need to downgrade Maven in order to allow HTTP (not HTTPS) packages to be downloaded.
+ # This is necessary as HTTP repositories were blocked in Maven 3.8.1
+ # HTTP repositories are used in some outdated dependenciesns
+ # This step can be removed once KLASS packages have been updated to more recent versions
+ - name: Set up Maven
+ uses: stCarolas/setup-maven@v4.5
+ with:
+ maven-version: 3.6.3
+
+ # Build only klass-forvaltning with JDK 1.8
+ - name: Build, test and package with Maven
+ run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am -P github
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index fb324ed8..de74b413 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -17,6 +17,18 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'zulu'
+ java-version: '17'
+ cache: maven
+
+ # Build all modules except klass-forvaltning since it is not compatible with JDK 17
+ - name: Build, test and package with Maven
+ run: mvn --batch-mode --update-snapshots package -pl '!:klass-forvaltning' -P nexus
+
- uses: actions/checkout@v3
- name: Set up JDK 1.8
uses: actions/setup-java@v3
@@ -34,8 +46,11 @@ jobs:
with:
maven-version: 3.6.3
+ # Build only klass-forvaltning with JDK 1.8
- name: Build, test and package with Maven
- run: mvn --batch-mode --update-snapshots package -P nexus
+ run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am -P github
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-latest
@@ -46,14 +61,14 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v3
- - name: Set up JDK 1.8
+ - name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
- java-version: '8'
+ java-version: '17'
cache: maven
- name: Publish to GitHub Packages
- run: mvn --batch-mode deploy -P github -DskipTests
+ run: mvn --batch-mode deploy -pl '!:klass-forvaltning' -P github -DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/Makefile b/Makefile
index 71cfada6..eb2a956b 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ build-all:
.PHONY: run-klass-forvaltning-local
run-klass-forvaltning-local:
- pushd klass-forvaltning && mvn spring-boot\:run -P nexus && popd
+ pushd klass-forvaltning && mvn spring-boot\:run --settings=../.maven.settings.xml -P nexus && popd
.PHONY: run-klass-forvaltning-local-mariadb
# Requires that a MariaDB instance is already running with a database called klass and a user called klass.
diff --git a/klass-api/doc/requests/README.md b/klass-api/doc/requests/README.md
new file mode 100644
index 00000000..a8922d5c
--- /dev/null
+++ b/klass-api/doc/requests/README.md
@@ -0,0 +1,21 @@
+# HTTP Client tests
+
+This folder contains files for Jetbrains'
+[HTTP Client plugin](https://www.jetbrains.com/help/idea/2023.1/http-client-in-product-code-editor.html). With these
+you can create, edit, and execute HTTP requests directly in the IntelliJ IDEA code editor.
+
+To be able to run these requests you should have an environment file called `http-client.env.json`
+inside this folder. The file should have
+the following structure:
+
+```
+{
+ "local": {
+ "base_url": "http://localhost:8080/api/klass/v1",
+ "other": "..."
+ },
+ "prod": {
+ "base_url": "https://data.ssb.no/api/klass/v1",
+ "other": "..."
+}
+```
diff --git a/klass-api/doc/requests/examples-classifications.http b/klass-api/doc/requests/examples-classifications.http
new file mode 100644
index 00000000..f4f6a9fc
--- /dev/null
+++ b/klass-api/doc/requests/examples-classifications.http
@@ -0,0 +1,54 @@
+### Get all classificationfamilies
+GET {{base_url}}/classificationfamilies
+Accept: application/json
+
+### Get single classificationfamily
+GET {{base_url}}/classificationfamilies/15
+Accept: application/json
+
+### Get all classifications
+GET {{base_url}}/classifications
+Accept: application/json
+
+### Get a single classification
+GET {{base_url}}/classifications/1
+Accept: application/json
+
+### Get classification codes
+GET {{base_url}}/classifications/1/codes?from=2020-01-01&to=2021-01-01&includeFuture=true
+Accept: application/json
+
+### Get classification codes
+GET {{base_url}}/classifications/1/codes?from=2020-01-01&includeFuture=true
+Accept: application/json
+
+### Get classification codes
+GET {{base_url}}/classifications/1/codesAt?date=2020-06-01
+Accept: application/json
+
+### Get classification changes
+GET {{base_url}}/classifications/1/changes
+Accept: application/json
+
+### Search for classifications
+GET {{base_url}}/classifications/search?query=kommune
+Accept: application/json
+
+### Search for classifications within a ssb section
+GET {{base_url}}/classifications/search?query=kommune&includeCodelists=true&ssbSection=320
+Accept: application/json
+
+### Get all classifications with size
+GET {{base_url}}/classifications?size=2
+Accept: application/json
+
+### Get all classifications with size and page
+GET {{base_url}}/classifications?size=2&page=2
+Accept: application/json
+
+### Get a single correspondencetable
+GET {{base_url}}/correspondencetables/1
+Accept: application/json
+
+### Get a single correspondencetable with suffix pattern matching
+GET {{base_url}}/correspondencetables/1.csv
diff --git a/klass-api/doc/requests/http-client.env.json b/klass-api/doc/requests/http-client.env.json
new file mode 100644
index 00000000..10d917c1
--- /dev/null
+++ b/klass-api/doc/requests/http-client.env.json
@@ -0,0 +1,8 @@
+{
+ "local": {
+ "base_url": "http://localhost:8080/api/klass/v1"
+ },
+ "prod": {
+ "base_url": "https://data.ssb.no/api/klass/v1"
+ }
+}
\ No newline at end of file
diff --git a/klass-api/pom.xml b/klass-api/pom.xml
index bfe90ce5..dc04131e 100644
--- a/klass-api/pom.xml
+++ b/klass-api/pom.xml
@@ -10,8 +10,7 @@
no.ssb.klassklass-root
- 2.1.8-SNAPSHOT
-
+ 3.0.0-SNAPSHOT
@@ -30,8 +29,19 @@
no.ssb.klassklass-solr${project.parent.version}
+
+
+ org.antlr
+ antlr4-runtime
+
+
-
+
+ com.h2database
+ h2
+ runtime
+
+
org.springframework.boot
@@ -58,7 +68,12 @@
org.springframework.dataspring-data-solr
-
+
+ javax.xml.bind
+ jaxb-api
+ ${jaxb-api-version}
+ provided
+
@@ -79,7 +94,6 @@
javax.servletjstl
-
javax.eljavax.el-api
@@ -107,6 +121,11 @@
test${project.parent.version}
+
+ jakarta.ws.rs
+ jakarta.ws.rs-api
+ ${jakarta-rs-api-version}
+
@@ -122,17 +141,43 @@
org.springframework.restdocsspring-restdocs-mockmvc
+ ${spring-restdocs-version}
+ test
+
+
+ org.springframework.restdocs
+ spring-restdocs-core
+
+
+
+
+ org.springframework.restdocs
+ spring-restdocs-core
+ ${spring-restdocs-version}testcom.jayway.jsonpathjson-path
- test
- com.jayway.restassured
+ io.rest-assuredrest-assuredtest
+
+
+
+ org.apache.groovy
+ groovy-xml
+
+
+
+
+
+ io.rest-assured
+ xml-path
+ test
diff --git a/klass-api/src/main/asciidoc/api-guide.adoc b/klass-api/src/main/asciidoc/api-guide.adoc
index d91cdedc..6c7a7ec1 100644
--- a/klass-api/src/main/asciidoc/api-guide.adoc
+++ b/klass-api/src/main/asciidoc/api-guide.adoc
@@ -49,7 +49,7 @@ include::{snippets}/error-example/http-response.adoc[]
=== Output formats
Default output format is XML. JSON is optional, and in many cases CSV. It is possible to get output in the supported output formats without using Curl `-H` (`--header`). Add the dot-prefix `.json`, `.csv` or `.xml` in the URL before the request parameters,
-e.g. json: http://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01[http://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01]. When adding this in the URL you only get the default character sets.
+e.g. json: https://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01[https://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01]. When adding this in the URL you only get the default character sets.
=== Character sets
Charset for the formats XML and JSON are UTF-8. Default charset for CSV is ISO 8859-1. This can be changed in Accept header to UTF-8.
diff --git a/klass-api/src/main/java/no/ssb/klass/KlassApiApplication.java b/klass-api/src/main/java/no/ssb/klass/KlassApiApplication.java
index 80f1ee2e..d2eae9ac 100644
--- a/klass-api/src/main/java/no/ssb/klass/KlassApiApplication.java
+++ b/klass-api/src/main/java/no/ssb/klass/KlassApiApplication.java
@@ -2,16 +2,14 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
+import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer;
import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
-import org.springframework.context.annotation.Bean;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Import;
// CHECKSTYLE:OFF
@SpringBootApplication
-@Import(EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat.class)
+@Import(TomcatServletWebServerFactoryCustomizer.class)
public class KlassApiApplication extends SpringBootServletInitializer {
// TODO kmgv if using embedded container (e.g. Tomcat) remove below method and extends SpringBootServletInitializer
@Override
diff --git a/klass-api/src/main/java/no/ssb/klass/api/config/KlassApiConfiguration.java b/klass-api/src/main/java/no/ssb/klass/api/config/KlassApiConfiguration.java
index 21afc967..2afd3877 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/config/KlassApiConfiguration.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/config/KlassApiConfiguration.java
@@ -4,20 +4,21 @@
import no.ssb.klass.api.controllers.MonitorController;
import no.ssb.klass.api.controllers.PingController;
import no.ssb.klass.api.util.RestConstants;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.SecurityFilterChain;
/**
* @author Mads Lundemo, SSB.
*/
@Configuration
@Profile(value = { ConfigurationProfiles.API_ONLY }) // makes config disabled for tests
-public class KlassApiConfiguration extends WebSecurityConfigurerAdapter {
+public class KlassApiConfiguration {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests()
// block sensitive endpoints (actuator)
.antMatchers("/manage**").denyAll() // alt. hasIpAddress("127.0.0.1")
@@ -35,7 +36,7 @@ protected void configure(HttpSecurity http) throws Exception {
.csrf().disable()
.headers()
.addHeaderWriter((request, response) -> {
- if (request.getServletPath().startsWith(RestConstants.API_VERSION_V1)) {
+ if (request.getServletPath().startsWith(RestConstants.PREFIX_AND_API_VERSION_V1)) {
// Workaround to Force CORS header all the time for API
response.addHeader("Access-Control-Allow-Origin", "*");
// Header telling cache server what is varying in our responses
@@ -44,6 +45,6 @@ protected void configure(HttpSecurity http) throws Exception {
}
})
.frameOptions().disable();
-
+ return http.build();
}
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java b/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java
index cf2fae2d..da81db36 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java
@@ -41,16 +41,19 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.result.FacetAndHighlightPage;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
+import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.PagedResources;
-import org.springframework.hateoas.Resources;
-import org.springframework.hateoas.mvc.ControllerLinkBuilder;
+import org.springframework.hateoas.MediaTypes;
+import org.springframework.hateoas.PagedModel;
+import org.springframework.hateoas.CollectionModel;
+import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -82,7 +85,8 @@
@RestController
// NOTE: CrossOrigin config moved to KlassSecurityConfiguration
// due to conditional behavior where some requests didn't get CORS headers and cause cache problems
-@RequestMapping(value = { RestConstants.API_VERSION_V1,"/api/klass"+RestConstants.API_VERSION_V1, "/rest/v1" })
+@RequestMapping(value = {RestConstants.PREFIX_AND_API_VERSION_V1, RestConstants.API_VERSION_V1, "/rest/v1" },
+ produces = {MediaTypes.HAL_JSON_VALUE, "application/*", "text/csv"})
public class ClassificationController {
private static final Logger log = LoggerFactory.getLogger(ClassificationController.class);
private final ClassificationService classificationService;
@@ -91,6 +95,9 @@ public class ClassificationController {
private final StatisticsService statisticsService;
private final CsvFieldsValidator csvFieldsValidator;
+ @Value("${spring.data.rest.base-path:}")
+ private String basePath;
+
@Autowired
public ClassificationController(ClassificationService classificationService,
SubscriberService subscriberService,
@@ -145,7 +152,7 @@ public RedirectView localRedirect() {
}
@RequestMapping(value = "/classificationfamilies", method = RequestMethod.GET)
- public Resources classificationFamilies(
+ public CollectionModel classificationFamilies(
// @formatter:off
@RequestParam(value = "ssbSection", required = false) String ssbSection,
@RequestParam(value = "includeCodelists", defaultValue = "false") boolean includeCodelists,
@@ -160,7 +167,7 @@ public Resources classificationFamilies(
.map(summary -> new ClassificationFamilySummaryResource(summary, language))
.collect(toList());
- return new KlassResources<>(summaryResources, new Link(getCurrentRequest(), Link.REL_SELF));
+ return new KlassResources<>(summaryResources, Link.of(getCurrentRequest(), IanaLinkRelations.SELF));
}
@RequestMapping(value = "/classificationfamilies/{id}", method = RequestMethod.GET)
@@ -178,26 +185,27 @@ public ClassificationFamilyResource classificationFamily(
}
@RequestMapping(value = "/ssbsections", method = RequestMethod.GET)
- public Resources ssbsections() {
+ public CollectionModel ssbsections() {
List ssbSectionResources = classificationService
.findResponsibleSectionsWithPublishedVersions().stream()
.sorted().map(SsbSectionResource::new).collect(toList());
- return new KlassResources<>(ssbSectionResources, new Link(getCurrentRequest(), Link.REL_SELF));
+ return new KlassResources<>(ssbSectionResources, Link.of(getCurrentRequest(), IanaLinkRelations.SELF));
}
@RequestMapping(value = "/classifications", method = RequestMethod.GET)
public KlassPagedResources classifications(
// @formatter:off
@RequestParam(value = "includeCodelists", defaultValue = "false") boolean includeCodelists,
- @RequestParam(value = "changedSince", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) Date changedSince,
+ @RequestParam(value = "changedSince", required = false)
+ @DateTimeFormat(iso = ISO.DATE_TIME, fallbackPatterns = "yyyy-MM-dd'T'HH:mm:ss.ssZ") Date changedSince,
Pageable pageable, PagedResourcesAssembler assembler) {
// @formatter:on
Page classifications = classificationService.findAllPublic(
includeCodelists, changedSince, pageable);
- Link self = new Link(getCurrentRequest(), Link.REL_SELF);
- PagedResources response = assembler.toResource(classifications,
+ Link self = Link.of(getCurrentRequest(), IanaLinkRelations.SELF);
+ PagedModel response = assembler.toModel(classifications,
ClassificationSummaryResource::new, self);
addSearchLink(response);
return new KlassPagedResources<>(response);
@@ -211,12 +219,12 @@ public KlassPagedResources search(
@RequestParam(value = "includeCodelists", defaultValue = "false") boolean includeCodelists,
Pageable pageable, PagedResourcesAssembler assembler) {
// @formatter:on
- Link self = new Link(getCurrentRequest(), Link.REL_SELF);
+ Link self = Link.of(getCurrentRequest(), IanaLinkRelations.SELF);
ssbSection = extractSsbSection(ssbSection);
FacetAndHighlightPage page =
searchService.publicSearch(query, pageable, ssbSection, includeCodelists);
- PagedResources response = assembler.toResource(page,
+ PagedModel response = assembler.toModel(page,
searchResult -> new SearchResultResource(searchResult, page.getHighlights(searchResult)),
self);
@@ -485,12 +493,12 @@ public ResponseEntity trackChanges(@PathVariable Long classif
if (subscriberService.containsTracking(email, classification)) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(SubscribeResponse.EXISTS);
} else {
- URL endSubscriptionUrl = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class)
+ URL endSubscriptionUrl = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class)
.removeTracking(classificationId, email)).toUri().toURL();
String token = subscriberService.trackChanges(email, classification, endSubscriptionUrl);
- URL verifySubscriptionUrl = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class)
+ URL verifySubscriptionUrl = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class)
.verifyTracking(email, token)).toUri().toURL();
subscriberService.sendVerificationMail(email, verifySubscriptionUrl, classification);
@@ -537,12 +545,13 @@ public ResponseEntity verifyTracking(@PathVariable String email, @PathVa
return ResponseEntity.ok("Subscription is verified.");
}
- private void addSearchLink(PagedResources response) {
- ControllerLinkBuilder linkBuilder = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).search("query", null, true,
+ private void addSearchLink(PagedModel response) {
+ WebMvcLinkBuilder linkBuilder = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).search("query", null, true,
null, null));
- response.add(new Link(ResourceUtil.createUriTemplate(linkBuilder, "query", "includeCodelists"), "search"));
+ response.add(Link.of(ResourceUtil.createUriTemplate(linkBuilder, "query", "includeCodelists"), "search"));
}
+
private String getCurrentRequest() {
return ServletUriComponentsBuilder.fromCurrentRequest().build().toString();
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/controllers/MonitorController.java b/klass-api/src/main/java/no/ssb/klass/api/controllers/MonitorController.java
index 6ee20f16..7792fea7 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/controllers/MonitorController.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/controllers/MonitorController.java
@@ -1,8 +1,10 @@
package no.ssb.klass.api.controllers;
+import no.ssb.klass.api.util.RestConstants;
import no.ssb.klass.core.service.SearchService;
import no.ssb.klass.core.service.UserService;
import no.ssb.klass.core.service.search.SolrSearchResult;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
@@ -21,26 +23,31 @@
* @author Mads Lundemo, SSB.
*/
@Controller
-@RequestMapping(MonitorController.PATH)
public class MonitorController {
- private static final String REST_URL_PREFIX = "/api/klass/v1";
- public static final String PATH = "/monitor/";
+ public static final String PATH = "/monitor";
private static final String DATABASE_TILKOBLING = "Database tilkobling";
private static final String REST_API = "Rest API";
private static final String SOLR_SEARCH = "solr søk";
-
@Value("${info.build.version:Unknown}")
private String version;
-
+
+ @Value("${spring.data.rest.base-path:}")
+ private String basePath;
+
@Autowired
private UserService userService;
@Autowired
private SearchService searchService;
- @RequestMapping(value = "/", method = RequestMethod.GET)
+ @RequestMapping(value = {
+ "/api/klass" + MonitorController.PATH,
+ "/api/klass" + MonitorController.PATH + "/",
+ MonitorController.PATH,
+ MonitorController.PATH + "/",
+ }, method = RequestMethod.GET)
public String render(HttpServletRequest request, ModelMap model) {
List statusList = new LinkedList<>();
@@ -67,8 +74,11 @@ private MonitorStatus testDatabaseConnection() {
private MonitorStatus testRestAPI(HttpServletRequest request) {
try {
String currentUrl = getCurrentUrl(request);
+ if (StringUtils.isNotBlank(basePath)) {
+ currentUrl = currentUrl + "/" + basePath;
+ }
- String testUrl = currentUrl + REST_URL_PREFIX + "/classifications";
+ String testUrl = currentUrl + RestConstants.API_VERSION_V1 + "/classifications";
URL url = new URL(testUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int responseCode = connection.getResponseCode();
@@ -87,7 +97,7 @@ private MonitorStatus testRestAPI(HttpServletRequest request) {
private MonitorStatus testSearch() {
try {
FacetAndHighlightPage solrSearchResults =
- searchService.publicSearch("*",new PageRequest(0,10),null,true);
+ searchService.publicSearch("*",PageRequest.of(0,10),null,true);
int results = solrSearchResults.getSize();
if (results>0) {
return new MonitorStatus(SOLR_SEARCH, true, "Søk fungerer");
diff --git a/klass-api/src/main/java/no/ssb/klass/api/controllers/PingController.java b/klass-api/src/main/java/no/ssb/klass/api/controllers/PingController.java
index b20742a4..714219b0 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/controllers/PingController.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/controllers/PingController.java
@@ -10,15 +10,19 @@
* @author Mads Lundemo, SSB.
*/
@Controller
-@RequestMapping(PingController.PATH)
public class PingController {
- public static final String PATH = "/ping/";
+ public static final String PATH = "/ping";
@Value("${info.build.version:Unknown}")
private String version;
@ResponseBody
- @RequestMapping(value = "/", method = RequestMethod.GET, produces = "application/xml")
+ @RequestMapping(value = {
+ "/api/klass" + PingController.PATH,
+ "/api/klass" + PingController.PATH + "/",
+ PingController.PATH,
+ PingController.PATH + "/"
+ }, method = RequestMethod.GET, produces = "application/xml")
public String ping() {
return "\n"
+ "\n"
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/KlassPagedResources.java b/klass-api/src/main/java/no/ssb/klass/api/dto/KlassPagedResources.java
index 8c225c99..3af5d9fb 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/KlassPagedResources.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/KlassPagedResources.java
@@ -4,14 +4,14 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.PagedResources;
+import org.springframework.hateoas.Links;
+import org.springframework.hateoas.PagedModel;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collection;
-import java.util.List;
/**
* @author Mads Lundemo, SSB.
@@ -27,9 +27,9 @@
*/
@JacksonXmlRootElement(localName = "pagedEntities")
@XmlRootElement(name = "pagedEntities")
-public class KlassPagedResources extends PagedResources {
+public class KlassPagedResources extends PagedModel {
- public KlassPagedResources(PagedResources p) {
+ public KlassPagedResources(PagedModel p) {
super(p.getContent(), p.getMetadata(), p.getLinks());
}
@@ -45,7 +45,7 @@ public Collection getContent() {
@XmlElement(name = "link", namespace = Link.ATOM_NAMESPACE)
@JacksonXmlElementWrapper(localName = "links")
@JacksonXmlProperty(localName = "link")
- public List getLinks() {
+ public Links getLinks() {
return super.getLinks();
}
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/KlassResources.java b/klass-api/src/main/java/no/ssb/klass/api/dto/KlassResources.java
index 333680f6..9eb837ad 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/KlassResources.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/KlassResources.java
@@ -1,19 +1,21 @@
package no.ssb.klass.api.dto;
+import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+import org.springframework.core.ResolvableType;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.Resources;
+import org.springframework.hateoas.CollectionModel;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.springframework.hateoas.Links;
/**
* This class overrides the XML anotations for content and links, We do this so we can change tag names and distinguish
@@ -30,10 +32,10 @@
*/
@JacksonXmlRootElement(localName = "entities")
@XmlRootElement(name = "entities")
-public class KlassResources extends Resources {
+public class KlassResources extends CollectionModel {
public KlassResources(Iterable content, Link... links) {
- super(content, links);
+ super(content, (Iterable) Arrays.asList(links), (ResolvableType) null);
}
@Override
@@ -48,7 +50,7 @@ public Collection getContent() {
@XmlElement(name = "link", namespace = Link.ATOM_NAMESPACE)
@JacksonXmlElementWrapper(localName = "links")
@JacksonXmlProperty(localName = "link")
- public List getLinks() {
+ public Links getLinks() {
return super.getLinks();
}
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilyResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilyResource.java
index 98a2907d..e9573669 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilyResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilyResource.java
@@ -1,9 +1,10 @@
package no.ssb.klass.api.dto.hal;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.springframework.hateoas.Link;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
@@ -17,6 +18,7 @@
import no.ssb.klass.api.controllers.ClassificationController;
@JacksonXmlRootElement(localName = "classificationFamily")
+@JsonPropertyOrder({"name", "classifications", "links"})
public class ClassificationFamilyResource extends KlassResource {
private final String name;
private final List classifications;
@@ -42,6 +44,6 @@ public List getClassifications() {
private Link createSelfLink(Long id) {
return linkTo(methodOn(ClassificationController.class).classificationFamily(id, null, null, null))
- .withSelfRel();
+ .withSelfRel().expand();
}
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilySummaryResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilySummaryResource.java
index e33f4659..518202e7 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilySummaryResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationFamilySummaryResource.java
@@ -1,15 +1,17 @@
package no.ssb.klass.api.dto.hal;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.core.Relation;
+import org.springframework.hateoas.server.core.Relation;
import no.ssb.klass.core.model.Language;
import no.ssb.klass.core.repository.ClassificationFamilySummary;
import no.ssb.klass.api.controllers.ClassificationController;
@Relation(collectionRelation = "classificationFamilies")
+@JsonPropertyOrder({"name", "numberOfClassifications", "links"})
public class ClassificationFamilySummaryResource extends KlassResource {
private String name;
private int numberOfClassifications;
@@ -22,7 +24,7 @@ public ClassificationFamilySummaryResource(ClassificationFamilySummary summary,
private Link createSelfLink(Long id) {
return linkTo(methodOn(ClassificationController.class).classificationFamily(id, null, null, null))
- .withSelfRel();
+ .withSelfRel().expand();
}
public String getName() {
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationResource.java
index 557966f6..35750eee 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationResource.java
@@ -1,5 +1,6 @@
package no.ssb.klass.api.dto.hal;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -8,15 +9,19 @@
import no.ssb.klass.core.model.ClassificationSeries;
import no.ssb.klass.core.model.Language;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.mvc.ControllerLinkBuilder;
+import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import java.time.LocalDate;
import java.util.List;
import static java.util.stream.Collectors.toList;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
+ import static no.ssb.klass.api.dto.hal.ResourceUtil.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
@JacksonXmlRootElement(localName = "classification")
+@JsonPropertyOrder({"name", "classificationType", "lastModified", "description", "primaryLanguage","copyrighted",
+ "includeShortName", "includeNotes", "contactPerson", "owningSection", "statisticalUnits", "versions",
+ "links"})
public class ClassificationResource extends ClassificationSummaryResource {
private final String description;
private final String primaryLanguage;
@@ -92,51 +97,51 @@ public List getVersions() {
}
private Link createVariantAtRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).variantAt(id, "name",
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).variantAt(id, "name",
LocalDate.now(), ",", null, "level", "selectCodes", "presentationNamePattern", Language.getDefault(), null));
- return new Link(createUriTemplate(linkBuilder, "variantName", date(), "csvSeparator", "level", "selectCodes",
+ return Link.of(createUriTemplate(linkBuilder, "variantName", date(), "csvSeparator", "level", "selectCodes",
"presentationNamePattern"), "variantAt");
}
private Link createVariantRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).variant(id, "name",
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).variant(id, "name",
LocalDate.now(), LocalDate.now(), ",",null, "level", "selectCodes", "presentationNamePattern", Language
.getDefault(), null));
- return new Link(createUriTemplate(linkBuilder, "variantName", from(), to(), "csvSeparator", "level",
+ return Link.of(createUriTemplate(linkBuilder, "variantName", from(), to(), "csvSeparator", "level",
"selectCodes", "presentationNamePattern"), "variant");
}
private Link createCodesAtRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).codesAt(id, LocalDate.now(),
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).codesAt(id, LocalDate.now(),
",",null, "level", "selectCodes", "presentationNamePattern", Language.getDefault(), null));
- return new Link(createUriTemplate(linkBuilder, date(), "csvSeparator", "level", "selectCodes",
+ return Link.of(createUriTemplate(linkBuilder, date(), "csvSeparator", "level", "selectCodes",
"presentationNamePattern"), "codesAt");
}
private Link createCodesRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).codes(id, LocalDate.now(),
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).codes(id, LocalDate.now(),
LocalDate.now(), ",",null, "level", "selectCodes", "presentationNamePattern", Language.getDefault(), null));
- return new Link(createUriTemplate(linkBuilder, from(), to(), "csvSeparator", "level", "selectCodes",
+ return Link.of(createUriTemplate(linkBuilder, from(), to(), "csvSeparator", "level", "selectCodes",
"presentationNamePattern"), "codes");
}
private Link createChangesRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).changes(id, LocalDate.now(),
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).changes(id, LocalDate.now(),
LocalDate.now(), ",",null, Language.getDefault(), null));
- return new Link(createUriTemplate(linkBuilder, from(), to(), "csvSeparator"), "changes");
+ return Link.of(createUriTemplate(linkBuilder, from(), to(), "csvSeparator"), "changes");
}
private Link createCorrespondsAtRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).correspondsAt(id, 2L,
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).correspondsAt(id, 2L,
LocalDate.now(), ",",null, Language.getDefault(), null, null));
- return new Link(createUriTemplate(linkBuilder, "targetClassificationId", date(), "csvSeparator"),
+ return Link.of(createUriTemplate(linkBuilder, "targetClassificationId", date(), "csvSeparator"),
"correspondsAt");
}
private Link createCorrespondsRelation(Long id) {
- ControllerLinkBuilder linkBuilder = linkTo(ControllerLinkBuilder.methodOn(ClassificationController.class).corresponds(id, 2L,
+ WebMvcLinkBuilder linkBuilder = linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).corresponds(id, 2L,
LocalDate.now(), LocalDate.now(), ",",null, Language.getDefault(), null));
- return new Link(createUriTemplate(linkBuilder, "targetClassificationId", from(), to(), "csvSeparator"),
+ return Link.of(createUriTemplate(linkBuilder, "targetClassificationId", from(), to(), "csvSeparator"),
"corresponds");
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationSummaryResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationSummaryResource.java
index 2437e3d5..e34f8f6a 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationSummaryResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationSummaryResource.java
@@ -1,13 +1,14 @@
package no.ssb.klass.api.dto.hal;
import static java.util.stream.Collectors.*;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import java.util.Date;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.core.Relation;
+import org.springframework.hateoas.server.core.Relation;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -16,6 +17,7 @@
import no.ssb.klass.api.controllers.ClassificationController;
@Relation(collectionRelation = "classifications")
+@JsonPropertyOrder({"name", "classificationType", "lastModified", "links"})
public class ClassificationSummaryResource extends KlassResource {
private final String name;
private final String classificationType;
@@ -33,7 +35,7 @@ public ClassificationSummaryResource(ClassificationSeries classification) {
}
private Link createSelfLink(Long id) {
- return linkTo(methodOn(ClassificationController.class).classification(id, null, null)).withSelfRel();
+ return linkTo(methodOn(ClassificationController.class).classification(id, null, null)).withSelfRel().expand();
}
public String getClassificationType() {
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantResource.java
index 02f12551..4f63907f 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantResource.java
@@ -4,6 +4,7 @@
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@@ -14,6 +15,9 @@
import no.ssb.klass.api.util.CustomLocalDateSerializer;
@JacksonXmlRootElement(localName = "classificationVariant")
+@JsonPropertyOrder({"name", "contactPerson", "owningSection", "lastModified", "published", "validFrom", "validTo",
+ "introduction", "contactPerson", "owningSection", "correspondenceTables", "changelogs", "levels",
+ "classificationItems", "links"})
public class ClassificationVariantResource extends ClassificationVariantSummaryResource {
private final LocalDate validFrom;
private final LocalDate validTo;
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantSummaryResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantSummaryResource.java
index 33cf180a..3be2915a 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantSummaryResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVariantSummaryResource.java
@@ -1,13 +1,14 @@
package no.ssb.klass.api.dto.hal;
import static java.util.stream.Collectors.*;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.springframework.hateoas.Link;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -18,6 +19,7 @@
import no.ssb.klass.core.model.Language;
import no.ssb.klass.api.controllers.ClassificationController;
+@JsonPropertyOrder({"name", "contactPerson", "owningSection", "lastModified", "published", "links"})
public class ClassificationVariantSummaryResource extends KlassResource {
private final String name;
private final ContactPersonResource contactPerson;
@@ -38,7 +40,7 @@ protected ClassificationVariantSummaryResource(ClassificationVariant variant, La
}
private Link createSelfLink(long id) {
- return linkTo(methodOn(ClassificationController.class).variants(id, null)).withSelfRel();
+ return linkTo(methodOn(ClassificationController.class).variants(id, null)).withSelfRel().expand();
}
public String getName() {
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionResource.java
index 38def599..43db58d7 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionResource.java
@@ -5,6 +5,7 @@
import java.util.List;
import java.util.stream.Collectors;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -15,6 +16,10 @@
import no.ssb.klass.core.util.AlphaNumericalComparator;
@JacksonXmlRootElement(localName = "classificationVersion")
+@JsonPropertyOrder({"name", "validFrom", "validTo", "lastModified", "published", "introduction", "contactPerson",
+ "owningSection", "legalBase", "publications", "derivedFrom", "correspondenceTables", "classificationVariants",
+ "changelogs", "levels", "classificationItems", "links"})
+
public class ClassificationVersionResource extends ClassificationVersionSummaryResource {
private final String introduction;
private final ContactPersonResource contactPerson;
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionSummaryResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionSummaryResource.java
index 22ba33a1..786e1a9f 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionSummaryResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ClassificationVersionSummaryResource.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@@ -18,8 +19,9 @@
import java.util.stream.Collectors;
import static java.util.stream.Collectors.*;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
+@JsonPropertyOrder({"name", "validFrom", "validTo", "lastModified", "published", "links"})
public class ClassificationVersionSummaryResource extends KlassResource {
private final String name;
private final LocalDate validFrom;
@@ -52,7 +54,7 @@ public LocalDate getValidTo() {
}
private Link createSelfLink(long id) {
- return linkTo(methodOn(ClassificationController.class).versions(id, null, null)).withSelfRel();
+ return linkTo(methodOn(ClassificationController.class).versions(id, null, null)).withSelfRel().expand();
}
@JacksonXmlElementWrapper(localName = "publishedLanguages")
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java
index 9f085904..4265b92e 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java
@@ -2,6 +2,7 @@
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -10,6 +11,9 @@
import no.ssb.klass.core.model.Language;
@JacksonXmlRootElement(localName = "correspondenceTable")
+@JsonPropertyOrder({"name", "contactPerson", "owningSection", "source", "sourceId", "target", "targetId", "changeTable",
+ "lastModified", "published", "sourceLevel", "targetLevel", "description", "changelogs", "correspondenceMaps",
+ "links"})
public class CorrespondenceTableResource extends CorrespondenceTableSummaryResource {
private final String description;
private final List changelogs;
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java
index 9cd6f2ac..93cf2f03 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java
@@ -1,7 +1,7 @@
package no.ssb.klass.api.dto.hal;
import static java.util.stream.Collectors.*;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import java.util.Arrays;
import java.util.Date;
@@ -9,6 +9,7 @@
import java.util.Objects;
import java.util.stream.Collectors;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.springframework.hateoas.Link;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -19,6 +20,8 @@
import no.ssb.klass.core.model.Language;
import no.ssb.klass.api.controllers.ClassificationController;
+@JsonPropertyOrder({"name", "contactPerson", "owningSection", "source", "sourceId", "target", "targetId", "changeTable",
+ "lastModified", "published", "sourceLevel", "targetLevel", "links"})
public class CorrespondenceTableSummaryResource extends KlassResource {
private final String name;
private final ContactPersonResource contactPerson;
@@ -58,7 +61,7 @@ protected CorrespondenceTableSummaryResource(CorrespondenceTable correspondenceT
}
private Link createSelfLink(long id) {
- return linkTo(methodOn(ClassificationController.class).correspondenceTables(id, null)).withSelfRel();
+ return linkTo(methodOn(ClassificationController.class).correspondenceTables(id, null)).withSelfRel().expand();
}
private Link createSourceLink(long id) {
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/KlassResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/KlassResource.java
index ed3286d0..ebc559a1 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/KlassResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/KlassResource.java
@@ -1,29 +1,33 @@
package no.ssb.klass.api.dto.hal;
-import java.util.List;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.ResourceSupport;
-import org.springframework.hateoas.UriTemplate;
-import org.springframework.hateoas.mvc.ControllerLinkBuilder;
+import org.springframework.hateoas.Links;
+import org.springframework.hateoas.PagedModel;
+import org.springframework.hateoas.RepresentationModel;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import org.springframework.lang.Nullable;
-public abstract class KlassResource extends ResourceSupport {
+public abstract class KlassResource extends PagedModel> {
protected void addLink(Link link) {
- getLinks().add(link);
- }
-
- protected UriTemplate createUriTemplate(ControllerLinkBuilder linkBuilder, String... parameters) {
- return ResourceUtil.createUriTemplate(linkBuilder, parameters);
+ super.add(link);
}
@Override
@JacksonXmlElementWrapper(localName = "links")
@JacksonXmlProperty(localName = "link")
- public List getLinks() {
+ public Links getLinks() {
return super.getLinks();
}
+ @Override
+ @JsonProperty("page")
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @Nullable
+ public PageMetadata getMetadata() {
+ return super.getMetadata();
+ }
}
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ResourceUtil.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ResourceUtil.java
index b313a562..1cc80ca8 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ResourceUtil.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/ResourceUtil.java
@@ -6,17 +6,17 @@
import org.springframework.hateoas.TemplateVariable;
import org.springframework.hateoas.TemplateVariables;
import org.springframework.hateoas.UriTemplate;
-import org.springframework.hateoas.mvc.ControllerLinkBuilder;
+import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
public final class ResourceUtil {
private ResourceUtil() {
// Utility class
}
- public static UriTemplate createUriTemplate(ControllerLinkBuilder linkBuilder, String... parameters) {
+ public static UriTemplate createUriTemplate(WebMvcLinkBuilder linkBuilder, String... parameters) {
String baseUri = linkBuilder.toUriComponentsBuilder().replaceQuery(null).build().toUriString();
- return new UriTemplate(baseUri, createParameters(parameters));
+ return UriTemplate.of(baseUri, createParameters(parameters));
}
private static TemplateVariables createParameters(String... parameters) {
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SearchResultResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SearchResultResource.java
index 471aaee0..bd5429a0 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SearchResultResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SearchResultResource.java
@@ -1,18 +1,20 @@
package no.ssb.klass.api.dto.hal;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import java.util.List;
import java.util.StringJoiner;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.springframework.data.solr.core.query.result.HighlightEntry;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.core.Relation;
+import org.springframework.hateoas.server.core.Relation;
import no.ssb.klass.core.service.search.SolrSearchResult;
import no.ssb.klass.api.controllers.ClassificationController;
@Relation(collectionRelation = "searchResults")
+@JsonPropertyOrder({"name", "snippet", "searchScore", "links"})
public class SearchResultResource extends KlassResource {
private String name;
@@ -49,7 +51,7 @@ public SearchResultResource(SolrSearchResult searchResult, List> to other resources"))))
.andExpect(status().isOk());
// @formatter:on
+ verify(classificationServiceMock).findPublicClassificationFamilySummaries(isNull(), eq(
+ ClassificationType.CLASSIFICATION));
}
@Test
@@ -178,10 +174,10 @@ public void classificationFamiliesOptionalParametersExample() throws Exception {
// @formatter:on
}
- @Test
- public void classificationFamilyExample() throws Exception {
- ClassificationFamily family = createClassificationFamily();
- when(classificationServiceMock.getClassificationFamily(any(Long.class))).thenReturn(family);
+ @Test
+ public void classificationFamilyExample() throws Exception {
+ ClassificationFamily family = createClassificationFamily();
+ when(classificationServiceMock.getClassificationFamily(any(Long.class))).thenReturn(family);
// @formatter:off
this.mockMvc.perform(getWithContext("/classificationfamilies/" + CLASS_FAMILY_BEFOLKNING).accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
@@ -194,12 +190,12 @@ public void classificationFamilyExample() throws Exception {
fieldWithPath("_links").description("<> to operations on classificationFamily"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void classificationFamilyOptionalParametersExample() throws Exception {
- ClassificationFamily family = createClassificationFamily();
- when(classificationServiceMock.getClassificationFamily(any(Long.class))).thenReturn(family);
+ @Test
+ public void classificationFamilyOptionalParametersExample() throws Exception {
+ ClassificationFamily family = createClassificationFamily();
+ when(classificationServiceMock.getClassificationFamily(any(Long.class))).thenReturn(family);
// @formatter:off
this.mockMvc.perform(getWithContext("/classificationfamilies/" + CLASS_FAMILY_BEFOLKNING + "?ssbSection=714&includeCodelists=true&language=nb")
.accept(MediaType.APPLICATION_JSON))
@@ -210,7 +206,7 @@ public void classificationFamilyOptionalParametersExample() throws Exception {
languageDescription())))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
@Test
public void ssbSectionsExample() throws Exception {
@@ -230,13 +226,13 @@ public void ssbSectionsExample() throws Exception {
// @formatter:on
}
- @Test
- public void classificationsExample() throws Exception {
- List classifications = Lists.newArrayList(createClassificationKommuneinndeling(),
- createClassificationBydelsinndeling(),
- createClassificationFamiliegruppering(TestUtil.createUser()));
- when(classificationServiceMock.findAllPublic(anyBoolean(), any(Date.class), any(Pageable.class))).then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), classifications));
+ @Test
+ public void classificationsExample() throws Exception {
+ List classifications = Lists.newArrayList(createClassificationKommuneinndeling(),
+ createClassificationBydelsinndeling(),
+ createClassificationFamiliegruppering(TestUtil.createUser()));
+ when(classificationServiceMock.findAllPublic(anyBoolean(), isNull(), any(Pageable.class))).then(
+ i -> createPage(i.getArgument(2, Pageable.class), classifications));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications").accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(links(
@@ -252,12 +248,12 @@ public void classificationsExample() throws Exception {
fieldWithPath("page").description("Describes number of classifications returned, see <<_page, page>>"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
@Test
public void classificationsOptionalParametersExample() throws Exception {
when(classificationServiceMock.findAllPublic(anyBoolean(), any(Date.class), any(Pageable.class))).then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), new ArrayList<>()));
+ i -> createPage(i.getArgument(2, Pageable.class), new ArrayList<>()));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications?includeCodelists=true&changedSince=2015-01-01T00:00:00.000-0000")
.accept(MediaType.APPLICATION_JSON))
@@ -271,8 +267,8 @@ public void classificationsOptionalParametersExample() throws Exception {
@Test
public void searchExample() throws Exception {
- when(searchServiceMock.publicSearch(any(String.class), any(Pageable.class), any(String.class), anyBoolean()))
- .then(i -> createSearchPage(i.getArgumentAt(2, Pageable.class)));
+ when(searchServiceMock.publicSearch(any(String.class), any(Pageable.class), isNull(), anyBoolean()))
+ .then(i -> createSearchPage(Pageable.unpaged()));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/search?query=kommuner").accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
@@ -294,7 +290,7 @@ public void searchExample() throws Exception {
@Test
public void searchOptionalParametersExample() throws Exception {
when(searchServiceMock.publicSearch(any(String.class), any(Pageable.class), any(String.class), anyBoolean()))
- .then(i -> createSearchPage(i.getArgumentAt(1, Pageable.class)));
+ .then(i -> createSearchPage(i.getArgument(1, Pageable.class)));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/search?query=kommuner&includeCodelists=true&ssbSection=370")
.accept(MediaType.APPLICATION_JSON))
@@ -309,7 +305,7 @@ public void searchOptionalParametersExample() throws Exception {
@Test
public void classificationExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenReturn(
+ when(classificationServiceMock.getClassificationSeries(any())).thenReturn(
createClassificationKommuneinndeling());
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING).accept(MediaType.APPLICATION_JSON))
@@ -350,7 +346,7 @@ public void classificationExample() throws Exception {
@Test
public void classificationOptionalParametersExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenReturn(
+ when(classificationServiceMock.getClassificationSeries(any())).thenReturn(
createClassificationKommuneinndeling());
// @formatter:off
@@ -362,11 +358,11 @@ public void classificationOptionalParametersExample() throws Exception {
// @formatter:on
}
- @Test
- public void versionsExampleJson() throws Exception {
- ClassificationVersion version = createClassificationKommuneinndeling().getClassificationVersions()
- .get(1);
- when(classificationServiceMock.getClassificationVersion(any(Long.class))).thenReturn(version);
+ @Test
+ public void versionsExampleJson() throws Exception {
+ ClassificationVersion version = createClassificationKommuneinndeling().getClassificationVersions()
+ .get(1);
+ when(classificationServiceMock.getClassificationVersion(any(Long.class))).thenReturn(version);
// @formatter:off
this.mockMvc.perform(getWithContext("/versions/" + CLASS_ID_KOMMUNEINNDELING).accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
@@ -391,13 +387,13 @@ public void versionsExampleJson() throws Exception {
fieldWithPath("_links").description("Links to operations on the version"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void versionsRequestParametersExample() throws Exception {
- ClassificationVersion version = createClassificationKommuneinndeling().getClassificationVersions()
- .get(1);
- when(classificationServiceMock.getClassificationVersion(any(Long.class))).thenReturn(version);
+ @Test
+ public void versionsRequestParametersExample() throws Exception {
+ ClassificationVersion version = createClassificationKommuneinndeling().getClassificationVersions()
+ .get(1);
+ when(classificationServiceMock.getClassificationVersion(any(Long.class))).thenReturn(version);
// @formatter:off
this.mockMvc.perform(getWithContext("/versions/" + CLASS_ID_KOMMUNEINNDELING + "?language=nb&includeFuture=true")
.accept(MediaType.APPLICATION_JSON))
@@ -405,13 +401,13 @@ public void versionsRequestParametersExample() throws Exception {
requestParameters(languageDescription(),includeFutureDescription(""))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void versionsExampleCsv() throws Exception {
- ClassificationVersion version = createClassificationKommuneinndeling().getClassificationVersions()
- .get(1);
- when(classificationServiceMock.getClassificationVersion(any(Long.class))).thenReturn(version);
+ @Test
+ public void versionsExampleCsv() throws Exception {
+ ClassificationVersion version = createClassificationKommuneinndeling().getClassificationVersions()
+ .get(1);
+ when(classificationServiceMock.getClassificationVersion(any(Long.class))).thenReturn(version);
// @formatter:off
this.mockMvc.perform(getWithContext("/versions/" + CLASS_ID_KOMMUNEINNDELING)
.header("Accept", "text/csv; charset=ISO-8859-1"))
@@ -420,25 +416,25 @@ public void versionsExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void codesExampleJson() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void codesExampleJson() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING + "/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;")
.header("Accept", MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void codesExampleCsv() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void codesExampleCsv() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING + "/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;")
.header("Accept", "text/csv; charset=ISO-8859-1"))
@@ -447,20 +443,20 @@ public void codesExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void codesOptionalParametersExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void codesOptionalParametersExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContextUri("/classifications/" + CLASS_ID_KOMMUNEINNDELING + "/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;&csvFields=name,code"
+ "&selectLevel=1&selectCodes=01*&presentationNamePattern={code}-{name}&language=nb&includeFuture=true")
.accept("text/csv"))
.andDo(this.documentationHandler
.document(
- requestParameters(
+ requestParameters(
fromParameterDescription(),
toParameterDescription(),
csvSeparatorParameterDescription(),
@@ -472,13 +468,13 @@ public void codesOptionalParametersExample() throws Exception {
includeFutureDescription("codes from the"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void codesAtExampleCsv() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createFylkeInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void codesAtExampleCsv() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createFylkeInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_FYLKEINNDELING + "/codesAt?date=2020-01-01")
.header("Accept", "text/csv; charset=UTF-8"))
@@ -487,25 +483,25 @@ public void codesAtExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void codesAtExampleJson() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createFylkeInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void codesAtExampleJson() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createFylkeInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING + "/codesAt?date=2020-01-01")
.header("Accept", MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void codesAtOptionalParametersExample() throws Exception {
- DateRange dateRange = DateRange.create("2021-01-01", "2022-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void codesAtOptionalParametersExample() throws Exception {
+ DateRange dateRange = DateRange.create("2021-01-01", "2022-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContextUri("/classifications/" + CLASS_ID_KOMMUNEINNDELING
+ "/codesAt?date=2021-01-01&csvSeparator=;&csvFields=name,code&selectLevel=1&selectCodes=01*"
@@ -522,14 +518,14 @@ public void codesAtOptionalParametersExample() throws Exception {
includeFutureDescription("variants of the"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantExampleCsv() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createGreenhouseGasesCodes(dateRange);
- when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
- .thenReturn(codes);
+ @Test
+ public void variantExampleCsv() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createGreenhouseGasesCodes(dateRange);
+ when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
+ .thenReturn(codes);
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_GREENHOUSE_GASES
@@ -540,14 +536,14 @@ public void variantExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantExampleJson() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createGreenhouseGasesCodes(dateRange);
- when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
- .thenReturn(codes);
+ @Test
+ public void variantExampleJson() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createGreenhouseGasesCodes(dateRange);
+ when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
+ .thenReturn(codes);
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_GREENHOUSE_GASES
@@ -555,14 +551,14 @@ public void variantExampleJson() throws Exception {
.header("Accept", MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantOptionalParametersExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
- .thenReturn(
- createFamilieInndelingCodes(dateRange));
+ @Test
+ public void variantOptionalParametersExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
+ .thenReturn(
+ createFamilieInndelingCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContextUri("/classifications/" + CLASS_ID_GREENHOUSE_GASES
@@ -587,14 +583,14 @@ public void variantOptionalParametersExample() throws Exception {
includeFutureDescription("variants of the"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantAtExampleCsv() throws Exception {
- DateRange dateRange = DateRange.create("2015-01-01", null);
- when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
- .thenReturn(
- createGreenhouseGasesCodes(dateRange));
+ @Test
+ public void variantAtExampleCsv() throws Exception {
+ DateRange dateRange = DateRange.create("2015-01-01", null);
+ when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
+ .thenReturn(
+ createGreenhouseGasesCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_GREENHOUSE_GASES
@@ -605,14 +601,14 @@ public void variantAtExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantAtExampleJson() throws Exception {
- DateRange dateRange = DateRange.create("2015-01-01", null);
- when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
- .thenReturn(
- createGreenhouseGasesCodes(dateRange));
+ @Test
+ public void variantAtExampleJson() throws Exception {
+ DateRange dateRange = DateRange.create("2015-01-01", null);
+ when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
+ .thenReturn(
+ createGreenhouseGasesCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_GREENHOUSE_GASES
@@ -620,13 +616,13 @@ public void variantAtExampleJson() throws Exception {
.header("Accept", MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantAtOptionalParametersExample() throws Exception {
- DateRange dateRange = DateRange.create("2015-01-01", null);
- when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
- .thenReturn(createGreenhouseGasesCodes(dateRange));
+ @Test
+ public void variantAtOptionalParametersExample() throws Exception {
+ DateRange dateRange = DateRange.create("2015-01-01", null);
+ when(classificationServiceMock.findVariantClassificationCodes(any(), any(), any(), any(), any()))
+ .thenReturn(createGreenhouseGasesCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContextUri("/classifications/" + CLASS_ID_GREENHOUSE_GASES
@@ -649,13 +645,13 @@ public void variantAtOptionalParametersExample() throws Exception {
includeFutureDescription("variants of the"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantsExampleJson() throws Exception {
- ClassificationVariant variant = createClassificationFamiliegruppering(TestUtil.createUser())
- .getClassificationVersions().get(0).getClassificationVariants().get(0);
- when(classificationServiceMock.getClassificationVariant(any(Long.class))).thenReturn(variant);
+ @Test
+ public void variantsExampleJson() throws Exception {
+ ClassificationVariant variant = createClassificationFamiliegruppering(TestUtil.createUser())
+ .getClassificationVersions().get(0).getClassificationVariants().get(0);
+ when(classificationServiceMock.getClassificationVariant(any(Long.class))).thenReturn(variant);
// @formatter:off
this.mockMvc.perform(getWithContext("/variants/" + 1111L).accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
@@ -678,13 +674,13 @@ public void variantsExampleJson() throws Exception {
fieldWithPath("_links").description("Links to operations on the variant"))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantsRequestParametersExample() throws Exception {
- ClassificationVariant variant = createClassificationFamiliegruppering(TestUtil.createUser())
- .getClassificationVersions().get(0).getClassificationVariants().get(0);
- when(classificationServiceMock.getClassificationVariant(any(Long.class))).thenReturn(variant);
+ @Test
+ public void variantsRequestParametersExample() throws Exception {
+ ClassificationVariant variant = createClassificationFamiliegruppering(TestUtil.createUser())
+ .getClassificationVersions().get(0).getClassificationVariants().get(0);
+ when(classificationServiceMock.getClassificationVariant(any(Long.class))).thenReturn(variant);
// @formatter:off
this.mockMvc.perform(getWithContext("/variants/" + 1111L + "?language=nb")
.accept(MediaType.APPLICATION_JSON))
@@ -692,13 +688,13 @@ public void variantsRequestParametersExample() throws Exception {
requestParameters(languageDescription())))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void variantsExampleCsv() throws Exception {
- ClassificationVariant variant = createClassificationFamiliegruppering(TestUtil.createUser())
- .getClassificationVersions().get(0).getClassificationVariants().get(0);
- when(classificationServiceMock.getClassificationVariant(any(Long.class))).thenReturn(variant);
+ @Test
+ public void variantsExampleCsv() throws Exception {
+ ClassificationVariant variant = createClassificationFamiliegruppering(TestUtil.createUser())
+ .getClassificationVersions().get(0).getClassificationVariants().get(0);
+ when(classificationServiceMock.getClassificationVariant(any(Long.class))).thenReturn(variant);
// @formatter:off
this.mockMvc.perform(getWithContext("/variants/" + 1111L)
.header("Accept", "text/csv; charset=ISO-8859-1"))
@@ -707,14 +703,14 @@ public void variantsExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void correspondsExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
- .thenReturn(
- createKommuneToBydelCorrespondences(dateRange));
+ @Test
+ public void correspondsExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
+ .thenReturn(
+ createKommuneToBydelCorrespondences(dateRange));
// @formatter:off
this.mockMvc.perform(
@@ -727,14 +723,14 @@ public void correspondsExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void correspondsOptionalParametersExample() throws Exception {
- DateRange dateRange = DateRange.create("2018-01-01", "2019-01-01");
- when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
- .thenReturn(
- createKommuneToBydelCorrespondences(dateRange));
+ @Test
+ public void correspondsOptionalParametersExample() throws Exception {
+ DateRange dateRange = DateRange.create("2018-01-01", "2019-01-01");
+ when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
+ .thenReturn(
+ createKommuneToBydelCorrespondences(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -755,14 +751,14 @@ public void correspondsOptionalParametersExample() throws Exception {
includeFutureDescription(""))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void correspondsAtExample() throws Exception {
- DateRange dateRange = DateRange.create("2018-01-01", "2019-01-01");
- when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
- .thenReturn(
- createKommuneToBydelCorrespondences(dateRange));
+ @Test
+ public void correspondsAtExample() throws Exception {
+ DateRange dateRange = DateRange.create("2018-01-01", "2019-01-01");
+ when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
+ .thenReturn(
+ createKommuneToBydelCorrespondences(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -773,14 +769,14 @@ public void correspondsAtExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void correspondsAtOptionalParametersExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
- .thenReturn(
- createKommuneToBydelCorrespondences(dateRange));
+ @Test
+ public void correspondsAtOptionalParametersExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findCorrespondences(any(), any(), any(), any(), any(), any()))
+ .thenReturn(
+ createKommuneToBydelCorrespondences(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -799,7 +795,7 @@ public void correspondsAtOptionalParametersExample() throws Exception {
includeFutureDescription(""))))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
@Test
public void correspondenceTablesExampleCsv() throws Exception {
@@ -860,7 +856,7 @@ public void correspondenceTablesOptionalParametersExample() throws Exception {
@Test
public void changesExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenReturn(
+ when(classificationServiceMock.getClassificationSeries(any())).thenReturn(
createClassificationKommuneinndeling());
// @formatter:off
this.mockMvc.perform(
@@ -875,7 +871,7 @@ public void changesExample() throws Exception {
@Test
public void changesOptionalParametersExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenReturn(
+ when(classificationServiceMock.getClassificationSeries(any())).thenReturn(
createClassificationKommuneinndeling());
// @formatter:off
this.mockMvc.perform(
@@ -896,11 +892,11 @@ public void changesOptionalParametersExample() throws Exception {
// @formatter:on
}
- @Test
- public void csvSeparatorExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
- createKommuneInndelingCodes(dateRange));
+ @Test
+ public void csvSeparatorExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
+ createKommuneInndelingCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -911,13 +907,13 @@ public void csvSeparatorExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void csvFieldsCodesExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
- createKommuneInndelingCodes(dateRange));
+ @Test
+ public void csvFieldsCodesExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
+ createKommuneInndelingCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -928,13 +924,13 @@ public void csvFieldsCodesExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void csvFieldsCodesAtExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
- createKommuneInndelingCodes(dateRange));
+ @Test
+ public void csvFieldsCodesAtExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
+ createKommuneInndelingCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -945,13 +941,13 @@ public void csvFieldsCodesAtExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void selectLevelExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
- createFamilieInndelingCodes(dateRange));
+ @Test
+ public void selectLevelExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
+ createFamilieInndelingCodes(dateRange));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_FAMILIEGRUPPERING
+ "/codes?from=2020-01-01&to=2021-01-01&selectLevel=2").accept("text/csv"))
@@ -960,13 +956,13 @@ public void selectLevelExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void presentationNamePatternExample() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
- createKommuneInndelingCodes(dateRange));
+ @Test
+ public void presentationNamePatternExample() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(
+ createKommuneInndelingCodes(dateRange));
// @formatter:off
this.mockMvc.perform(
getWithContextUri("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -977,35 +973,35 @@ public void presentationNamePatternExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void changedSinceExample() throws Exception {
- List classifications = Lists.newArrayList(createClassificationKommuneinndeling(),
- createClassificationBydelsinndeling(),
- createClassificationFamiliegruppering(TestUtil.createUser()));
+ @Test
+ public void changedSinceExample() throws Exception {
+ List classifications = Lists.newArrayList(createClassificationKommuneinndeling(),
+ createClassificationBydelsinndeling(),
+ createClassificationFamiliegruppering(TestUtil.createUser()));
- when(classificationServiceMock.findAllPublic(anyBoolean(), any(Date.class), any(Pageable.class))).then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), classifications));
+ when(classificationServiceMock.findAllPublic(anyBoolean(), any(Date.class), any(Pageable.class))).then(
+ i -> createPage(i.getArgument(2, Pageable.class), classifications));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications?changedSince=2015-03-01T01:30:00.000-0200")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void rangeExample() throws Exception {
- DateRange dateRange = DateRange.create("2019-01-01", "2020-01-01");
- List codes = new ArrayList<>();
- codes.add(createCode(1, "0101", "Halden", dateRange));
- codes.add(createCode(1, "0104", "Moss", dateRange));
- codes.add(createCode(1, "1515", "Herøy", dateRange));
- codes.add(createCode(1, "1825", "Grane", dateRange));
- codes.add(createCode(1, "1826", "Hattfjelldal", dateRange));
-
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void rangeExample() throws Exception {
+ DateRange dateRange = DateRange.create("2019-01-01", "2020-01-01");
+ List codes = new ArrayList<>();
+ codes.add(createCode(1, "0101", "Halden", dateRange));
+ codes.add(createCode(1, "0104", "Moss", dateRange));
+ codes.add(createCode(1, "1515", "Herøy", dateRange));
+ codes.add(createCode(1, "1825", "Grane", dateRange));
+ codes.add(createCode(1, "1826", "Hattfjelldal", dateRange));
+
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
+ "/codes?from=2019-01-01&to=2020-01-01").accept("text/csv"))
@@ -1014,25 +1010,25 @@ public void rangeExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void rangeExtendedExample() throws Exception {
- DateRange dateRange = DateRange.create("2019-01-01", "2021-01-01");
- DateRange startRange = DateRange.create("2019-01-01", "2020-01-01");
- DateRange endRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = new ArrayList<>();
- codes.add(createCode(1, "0101", "Halden", startRange));
- codes.add(createCode(1, "3001", "Halden", endRange));
- codes.add(createCode(1, "0104", "Moss", startRange));
- codes.add(createCode(1, "3002", "Moss", endRange));
- codes.add(createCode(1, "1515", "Herøy", startRange));
- codes.add(createCode(1, "1515", "Herøy (Møre og Romsdal)", endRange));
- codes.add(createCode(1, "1825", "Grane", dateRange));
- codes.add(createCode(1, "1826", "Hattfjelldal", startRange));
- codes.add(createCode(1, "1826", "Aarborte - Hattfjelldal", endRange));
-
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void rangeExtendedExample() throws Exception {
+ DateRange dateRange = DateRange.create("2019-01-01", "2021-01-01");
+ DateRange startRange = DateRange.create("2019-01-01", "2020-01-01");
+ DateRange endRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = new ArrayList<>();
+ codes.add(createCode(1, "0101", "Halden", startRange));
+ codes.add(createCode(1, "3001", "Halden", endRange));
+ codes.add(createCode(1, "0104", "Moss", startRange));
+ codes.add(createCode(1, "3002", "Moss", endRange));
+ codes.add(createCode(1, "1515", "Herøy", startRange));
+ codes.add(createCode(1, "1515", "Herøy (Møre og Romsdal)", endRange));
+ codes.add(createCode(1, "1825", "Grane", dateRange));
+ codes.add(createCode(1, "1826", "Hattfjelldal", startRange));
+ codes.add(createCode(1, "1826", "Aarborte - Hattfjelldal", endRange));
+
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -1043,20 +1039,20 @@ public void rangeExtendedExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void selectCodesExampleCsv() throws Exception {
- DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- codes.add(createCode(1, "3005", "Drammen", dateRange));
- codes.add(createCode(1, "3006", "Kongsberg", dateRange));
- codes.add(createCode(1, "3007", "Ringerike", dateRange));
- codes.add(createCode(1, "3415", "Sør-Odal", dateRange));
- codes.add(createCode(1, "3416", "Eidskog", dateRange));
- codes.add(createCode(1, "3417", "Grue", dateRange));
- codes.add(createCode(1, "3418", "Åsnes", dateRange));
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void selectCodesExampleCsv() throws Exception {
+ DateRange dateRange = DateRange.create("2020-01-01", "2021-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ codes.add(createCode(1, "3005", "Drammen", dateRange));
+ codes.add(createCode(1, "3006", "Kongsberg", dateRange));
+ codes.add(createCode(1, "3007", "Ringerike", dateRange));
+ codes.add(createCode(1, "3415", "Sør-Odal", dateRange));
+ codes.add(createCode(1, "3416", "Eidskog", dateRange));
+ codes.add(createCode(1, "3417", "Grue", dateRange));
+ codes.add(createCode(1, "3418", "Åsnes", dateRange));
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -1067,15 +1063,15 @@ public void selectCodesExampleCsv() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void selectCodesExampleJson() throws Exception {
- DateRange dateRange = DateRange.create("2015-01-01", "2016-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- codes.add(createCode(1, "0301", "Oslo", dateRange));
- codes.add(createCode(1, "0304", "Oslo", dateRange));
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void selectCodesExampleJson() throws Exception {
+ DateRange dateRange = DateRange.create("2015-01-01", "2016-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ codes.add(createCode(1, "0301", "Oslo", dateRange));
+ codes.add(createCode(1, "0304", "Oslo", dateRange));
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -1083,13 +1079,13 @@ public void selectCodesExampleJson() throws Exception {
.accept(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void languageExample() throws Exception {
- DateRange dateRange = DateRange.create("2015-01-01", "2016-01-01");
- List codes = createKommuneInndelingCodes(dateRange);
- when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
+ @Test
+ public void languageExample() throws Exception {
+ DateRange dateRange = DateRange.create("2015-01-01", "2016-01-01");
+ List codes = createKommuneInndelingCodes(dateRange);
+ when(classificationServiceMock.findClassificationCodes(any(), any(), any(), any())).thenReturn(codes);
// @formatter:off
this.mockMvc.perform(
getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING
@@ -1100,16 +1096,16 @@ public void languageExample() throws Exception {
preprocessResponse(/*prettyPrint()*/)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- @Test
- public void pageExample() throws Exception {
- List classifications = Lists.newArrayList(createClassificationKommuneinndeling(),
- createClassificationBydelsinndeling(),
- createClassificationFamiliegruppering(TestUtil.createUser()));
- when(classificationServiceMock.findAllPublic(any(Boolean.class), any(Date.class), any(Pageable.class)))
- .then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), classifications));
+ @Test
+ public void pageExample() throws Exception {
+ List classifications = Lists.newArrayList(createClassificationKommuneinndeling(),
+ createClassificationBydelsinndeling(),
+ createClassificationFamiliegruppering(TestUtil.createUser()));
+ when(classificationServiceMock.findAllPublic(any(Boolean.class), isNull(), any(Pageable.class)))
+ .then(
+ i -> createPage(i.getArgument(2, Pageable.class), classifications));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications?size=2").accept(MediaType.APPLICATION_JSON))
@@ -1132,335 +1128,336 @@ public void pageExample() throws Exception {
)))
.andExpect(status().isOk());
// @formatter:on
- }
+ }
- private ParameterDescriptor includeCodelistsDescription() {
- return parameterWithName("includeCodelists").description(
- "[Optional] include ssb codelists. Default is false.");
- }
+ private ParameterDescriptor includeCodelistsDescription() {
+ return parameterWithName("includeCodelists").description(
+ "[Optional] include ssb codelists. Default is false.");
+ }
- private ParameterDescriptor languageDescription() {
- return parameterWithName("language").description(
- "[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see <<_language, language>>");
- }
+ private ParameterDescriptor languageDescription() {
+ return parameterWithName("language").description(
+ "[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see <<_language, language>>");
+ }
- private ParameterDescriptor changedSinceDescription() {
- return parameterWithName("changedSince").description(
- "[Optional] specifies that only classifications that have been changed since changedSince shall be included in the response."
- +
- " For details see <<_changedsince, changedSince>>");
- }
+ private ParameterDescriptor changedSinceDescription() {
+ return parameterWithName("changedSince").description(
+ "[Optional] specifies that only classifications that have been changed since changedSince shall be included in the response."
+ +
+ " For details see <<_changedsince, changedSince>>");
+ }
- private ParameterDescriptor fromParameterDescription() {
- return parameterWithName("from").description(
- "[Mandatory] specifies beginning of range with format ``. For details see <<_range, range>>");
- }
+ private ParameterDescriptor fromParameterDescription() {
+ return parameterWithName("from").description(
+ "[Mandatory] specifies beginning of range with format ``. For details see <<_range, range>>");
+ }
- private ParameterDescriptor toParameterDescription() {
- return parameterWithName("to")
- .description("[Optional] specifies end of range with format ``. "
- + "If not set means that to is indefinite. For details see <<_range, range>>");
- }
+ private ParameterDescriptor toParameterDescription() {
+ return parameterWithName("to")
+ .description("[Optional] specifies end of range with format ``. "
+ + "If not set means that to is indefinite. For details see <<_range, range>>");
+ }
- private ParameterDescriptor dateParameterDescription() {
- return parameterWithName("date").description(
- "[Mandatory] specifies codes at a certain date with format ``.");
- }
+ private ParameterDescriptor dateParameterDescription() {
+ return parameterWithName("date").description(
+ "[Mandatory] specifies codes at a certain date with format ``.");
+ }
- private ParameterDescriptor targetClassificationIdParameterDescription() {
- return parameterWithName("targetClassificationId").description(
- "[Mandatory] specifies id of target classification");
- }
+ private ParameterDescriptor targetClassificationIdParameterDescription() {
+ return parameterWithName("targetClassificationId").description(
+ "[Mandatory] specifies id of target classification");
+ }
- private ParameterDescriptor variantNameParameterDescription() {
- return parameterWithName("variantName")
- .description("[Mandatory] specifies name of classification variant\n\n"
- + "NOTE: If you want to look up codes from variants across multiple versions do not include the year "
- + "(or year month) and do not include everything after that\n\n"
- + "Example for `Particulate matter 2009 - Variant of substances emitted to air 2009` would be `Particulate matter`");
- }
+ private ParameterDescriptor variantNameParameterDescription() {
+ return parameterWithName("variantName")
+ .description("[Mandatory] specifies name of classification variant\n\n"
+ + "NOTE: If you want to look up codes from variants across multiple versions do not include the year "
+ + "(or year month) and do not include everything after that\n\n"
+ + "Example for `Particulate matter 2009 - Variant of substances emitted to air 2009` would be `Particulate matter`");
+ }
- private ParameterDescriptor csvSeparatorParameterDescription() {
- return parameterWithName("csvSeparator").description(
- "[Optional] specifies separator to be used for csv format. For details see <<_csvseparator, csvSeparator>>");
- }
+ private ParameterDescriptor csvSeparatorParameterDescription() {
+ return parameterWithName("csvSeparator").description(
+ "[Optional] specifies separator to be used for csv format. For details see <<_csvseparator, csvSeparator>>");
+ }
- private ParameterDescriptor csvFieldsParameterDescription() {
- return parameterWithName("csvFields").description(
- "[Optional] specifies which fields should be included in the csv output. For details see <<_csvfields, csvfields>>");
- }
+ private ParameterDescriptor csvFieldsParameterDescription() {
+ return parameterWithName("csvFields").description(
+ "[Optional] specifies which fields should be included in the csv output. For details see <<_csvfields, csvfields>>");
+ }
- private ParameterDescriptor selectCodesParameterDescription() {
- return parameterWithName("selectCodes").description(
- "[Optional] only return codes that match pattern given by selectCodes. For details see <<_selectcodes, selectCodes>>");
- }
+ private ParameterDescriptor selectCodesParameterDescription() {
+ return parameterWithName("selectCodes").description(
+ "[Optional] only return codes that match pattern given by selectCodes. For details see <<_selectcodes, selectCodes>>");
+ }
- private ParameterDescriptor selectLevelParameterDescription() {
- return parameterWithName("selectLevel").description(
- "[Optional] only return codes with matching level. For details see <<_selectlevel, selectLevel>>");
- }
+ private ParameterDescriptor selectLevelParameterDescription() {
+ return parameterWithName("selectLevel").description(
+ "[Optional] only return codes with matching level. For details see <<_selectlevel, selectLevel>>");
+ }
- private ParameterDescriptor presentationNamePatternParameterDescription() {
- return parameterWithName("presentationNamePattern").description(
- "[Optional] used to build a presentationName. For details see <<_presentationnamepattern, presentationNamePattern>>");
- }
+ private ParameterDescriptor presentationNamePatternParameterDescription() {
+ return parameterWithName("presentationNamePattern").description(
+ "[Optional] used to build a presentationName. For details see <<_presentationnamepattern, presentationNamePattern>>");
+ }
- private ParameterDescriptor ssbSectionParameterDescription(String part) {
- return parameterWithName("ssbSection").description(
- "[Optional] only include classifications belonging to specified SSB section when "
- + part
- + " classifications. Default is all SSB sections");
- }
+ private ParameterDescriptor ssbSectionParameterDescription(String part) {
+ return parameterWithName("ssbSection").description(
+ "[Optional] only include classifications belonging to specified SSB section when "
+ + part
+ + " classifications. Default is all SSB sections");
+ }
- private ParameterDescriptor includeCodelistsParameterDescription(String part) {
- return parameterWithName("includeCodelists").description("[Optional] include codelists when " + part
- + " classifications. Default is false");
- }
+ private ParameterDescriptor includeCodelistsParameterDescription(String part) {
+ return parameterWithName("includeCodelists").description("[Optional] include codelists when " + part
+ + " classifications. Default is false");
+ }
- private ParameterDescriptor includeFutureDescription(String part) {
- return parameterWithName("includeFuture").description(String.format(
- "[Optional] include %s future versions if available. Default is false.", part));
- }
+ private ParameterDescriptor includeFutureDescription(String part) {
+ return parameterWithName("includeFuture").description(String.format(
+ "[Optional] include %s future versions if available. Default is false.", part));
+ }
- private URI toUri(String url) {
- return UriComponentsBuilder.fromUriString(url).build().encode().toUri();
- }
+ private URI toUri(String url) {
+ return UriComponentsBuilder.fromUriString(url).build().encode().toUri();
+ }
- public MockHttpServletRequestBuilder getWithContext(String urlTemplate,
- Object... urlVariables) {
- return MockMvcRequestBuilders
- .get(contextPath + RestConstants.API_VERSION_V1 + urlTemplate, urlVariables)
- .requestAttr(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, urlTemplate)
- .contextPath(contextPath);
- }
+ public MockHttpServletRequestBuilder getWithContext(String urlTemplate,
+ Object... urlVariables) {
+ return MockMvcRequestBuilders
+ .get(contextPath + RestConstants.API_VERSION_V1 + urlTemplate, urlVariables)
+ .requestAttr(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, urlTemplate)
+ .contextPath(contextPath);
+ }
- public MockHttpServletRequestBuilder getWithContextUri(String url) {
- return MockMvcRequestBuilders.get(toUri(contextPath + RestConstants.API_VERSION_V1 + url))
- .contextPath(contextPath);
- }
+ public MockHttpServletRequestBuilder getWithContextUri(String url) {
+ return MockMvcRequestBuilders.get(toUri(contextPath + RestConstants.API_VERSION_V1 + url))
+ .requestAttr(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, url)
+ .contextPath(contextPath);
+ }
- private Page createSearchPage(Pageable pageable) {
- ClassificationSeries classification = createClassificationKommuneinndeling();
- SolrSearchResult searchResult = new SolrSearchResult();
- searchResult.setItemid(classification.getId());
- searchResult.setTitle(classification.getName(Language.getDefault()));
- searchResult.setLanguage(Language.getDefault().getLanguageCode());
- searchResult.setScore(8.0);
- searchResult.setType(ClassificationType.CLASSIFICATION.getDisplayName(Language.EN));
- searchResult.setDescription("Kommuneinndelingen er en administrativ inndeling av Norge");
- searchResult.setFamily("familie");
-
- SolrResultPage page = new SolrResultPage(Lists.newArrayList(searchResult), pageable, 1, 1.0f);
- HighlightEntry highlightResult = new HighlightEntry<>(searchResult);
- highlightResult.addSnipplets("Description", Lists.newArrayList(
- "Kommuneinndelingen er en administrativ inndeling av Norge"));
- page.setHighlighted(Lists.newArrayList(highlightResult));
- return page;
- }
+ private Page createSearchPage(Pageable pageable) {
+ ClassificationSeries classification = createClassificationKommuneinndeling();
+ SolrSearchResult searchResult = new SolrSearchResult();
+ searchResult.setItemid(classification.getId());
+ searchResult.setTitle(classification.getName(Language.getDefault()));
+ searchResult.setLanguage(Language.getDefault().getLanguageCode());
+ searchResult.setScore(8.0);
+ searchResult.setType(ClassificationType.CLASSIFICATION.getDisplayName(Language.EN));
+ searchResult.setDescription("Kommuneinndelingen er en administrativ inndeling av Norge");
+ searchResult.setFamily("familie");
+
+ SolrResultPage page = new SolrResultPage(Lists.newArrayList(searchResult), pageable, 1, 1.0f);
+ HighlightEntry highlightResult = new HighlightEntry<>(searchResult);
+ highlightResult.addSnipplets("Description", Lists.newArrayList(
+ "Kommuneinndelingen er en administrativ inndeling av Norge"));
+ page.setHighlighted(Lists.newArrayList(highlightResult));
+ return page;
+ }
- private Page createPage(Pageable pageable, List classifications) {
- int totalSize = classifications.size();
- if (pageable.getPageSize() < totalSize) {
- classifications = classifications.subList(0, pageable.getPageSize());
- }
- return new PageImpl<>(classifications, pageable, totalSize);
+ private Page createPage(Pageable pageable, List classifications) {
+ int totalSize = classifications.size();
+ if (pageable.getPageSize() < totalSize) {
+ classifications = classifications.subList(0, pageable.getPageSize());
}
+ return new PageImpl<>(classifications, pageable, totalSize);
+ }
- private List createKommuneInndelingCodes(DateRange dateRange) {
- List codes = new ArrayList<>();
- codes.add(createCode(1, "3001", "Halden", dateRange));
- codes.add(createCode(1, "3002", "Moss", dateRange));
- codes.add(createCode(1, "3003", "Sarpsborg", dateRange));
- codes.add(createCode(1, "3004", "Fredrikstad", dateRange));
- return codes;
- }
+ private List createKommuneInndelingCodes(DateRange dateRange) {
+ List codes = new ArrayList<>();
+ codes.add(createCode(1, "3001", "Halden", dateRange));
+ codes.add(createCode(1, "3002", "Moss", dateRange));
+ codes.add(createCode(1, "3003", "Sarpsborg", dateRange));
+ codes.add(createCode(1, "3004", "Fredrikstad", dateRange));
+ return codes;
+ }
- private List createFylkeInndelingCodes(DateRange dateRange) {
- List codes = new ArrayList<>();
- codes.add(createCode(1, "03", "Oslo", dateRange));
- codes.add(createCode(1, "11", "Rogaland", dateRange));
- codes.add(createCode(1, "15", "Møre og Romsdal", dateRange));
- codes.add(createCode(1, "18", "Nordland - Nordlánnda", dateRange));
- codes.add(createCode(1, "30", "Viken", dateRange));
- return codes;
- }
+ private List createFylkeInndelingCodes(DateRange dateRange) {
+ List codes = new ArrayList<>();
+ codes.add(createCode(1, "03", "Oslo", dateRange));
+ codes.add(createCode(1, "11", "Rogaland", dateRange));
+ codes.add(createCode(1, "15", "Møre og Romsdal", dateRange));
+ codes.add(createCode(1, "18", "Nordland - Nordlánnda", dateRange));
+ codes.add(createCode(1, "30", "Viken", dateRange));
+ return codes;
+ }
- private List createFamilieInndelingCodes(DateRange dateRange) {
- List codes = new ArrayList<>();
- codes.add(createCode(1, "A", "Enpersonfamilie", dateRange));
- codes.add(createCode(2, "A_", "Enpersonfamilie", dateRange));
- codes.add(createCode(1, "B", "Ektepar", dateRange));
- codes.add(createCode(2, "BA", "Ektepar med barn (yngste barn 0-17 år)", dateRange));
- codes.add(createCode(2, "BB", "Ektepar uten barn 0-17 år", dateRange));
- return codes;
- }
+ private List createFamilieInndelingCodes(DateRange dateRange) {
+ List codes = new ArrayList<>();
+ codes.add(createCode(1, "A", "Enpersonfamilie", dateRange));
+ codes.add(createCode(2, "A_", "Enpersonfamilie", dateRange));
+ codes.add(createCode(1, "B", "Ektepar", dateRange));
+ codes.add(createCode(2, "BA", "Ektepar med barn (yngste barn 0-17 år)", dateRange));
+ codes.add(createCode(2, "BB", "Ektepar uten barn 0-17 år", dateRange));
+ return codes;
+ }
- private List createGreenhouseGasesCodes(DateRange dateRange) {
- List codes = new ArrayList<>();
- codes.add(createCode(1, "01", "CO2 - karbondioksid", dateRange));
- codes.add(createCode(1, "02", "CH4 - metan", dateRange));
- codes.add(createCode(1, "03", "N2O - lystgass", dateRange));
- codes.add(createCode(1, "04", "Fluorgasser", dateRange));
- codes.add(createCode(2, "04.1", "HFK - hydrofluorkarboner", dateRange));
- return codes;
- }
+ private List createGreenhouseGasesCodes(DateRange dateRange) {
+ List codes = new ArrayList<>();
+ codes.add(createCode(1, "01", "CO2 - karbondioksid", dateRange));
+ codes.add(createCode(1, "02", "CH4 - metan", dateRange));
+ codes.add(createCode(1, "03", "N2O - lystgass", dateRange));
+ codes.add(createCode(1, "04", "Fluorgasser", dateRange));
+ codes.add(createCode(2, "04.1", "HFK - hydrofluorkarboner", dateRange));
+ return codes;
+ }
- private CodeDto createCode(int levelNumber, String code, String officialName, DateRange dateRange) {
- return new CodeDto(TestUtil.createLevel(levelNumber),
- TestUtil.createClassificationItem(code, officialName),
- dateRange, Language.getDefault());
- }
+ private CodeDto createCode(int levelNumber, String code, String officialName, DateRange dateRange) {
+ return new CodeDto(TestUtil.createLevel(levelNumber),
+ TestUtil.createClassificationItem(code, officialName),
+ dateRange, Language.getDefault());
+ }
- private List createKommuneToBydelCorrespondences(DateRange dateRange) {
- List correspondences = new ArrayList<>();
- correspondences.add(createCorrespondence("0301", "Oslo", "030101", "Gamle Oslo", dateRange));
- correspondences.add(createCorrespondence("0301", "Oslo", "030103", "Sagene", dateRange));
- correspondences.add(createCorrespondence("0301", "Oslo", "030105", "Frogner", dateRange));
- correspondences.add(createCorrespondence("1201", "Bergen", "120101", "Arna", dateRange));
- correspondences.add(createCorrespondence("1201", "Bergen", "120102", "Bergenhus", dateRange));
+ private List createKommuneToBydelCorrespondences(DateRange dateRange) {
+ List correspondences = new ArrayList<>();
+ correspondences.add(createCorrespondence("0301", "Oslo", "030101", "Gamle Oslo", dateRange));
+ correspondences.add(createCorrespondence("0301", "Oslo", "030103", "Sagene", dateRange));
+ correspondences.add(createCorrespondence("0301", "Oslo", "030105", "Frogner", dateRange));
+ correspondences.add(createCorrespondence("1201", "Bergen", "120101", "Arna", dateRange));
+ correspondences.add(createCorrespondence("1201", "Bergen", "120102", "Bergenhus", dateRange));
- return correspondences;
- }
+ return correspondences;
+ }
- private CorrespondenceDto createCorrespondence(String sourceCode, String sourceName, String targetCode,
- String targetName, DateRange dateRange) {
- ClassificationItem source = TestUtil.createClassificationItem(sourceCode, sourceName);
- ClassificationItem target = TestUtil.createClassificationItem(targetCode, targetName);
- return new CorrespondenceDto(source, target, dateRange, Language.getDefault());
- }
+ private CorrespondenceDto createCorrespondence(String sourceCode, String sourceName, String targetCode,
+ String targetName, DateRange dateRange) {
+ ClassificationItem source = TestUtil.createClassificationItem(sourceCode, sourceName);
+ ClassificationItem target = TestUtil.createClassificationItem(targetCode, targetName);
+ return new CorrespondenceDto(source, target, dateRange, Language.getDefault());
+ }
- private ClassificationSeries createClassificationKommuneinndeling() {
- ClassificationSeries classification = TestUtil.createClassificationWithId(CLASS_ID_KOMMUNEINNDELING,
- "Standard for kommuneinndeling",
- "Kommuneinndelingen er en administrativ inndeling av kommuner i Norge");
-
- ClassificationVersion version2014 = TestUtil
- .createClassificationVersion(DateRange.create("2014-01-01", null));
- version2014.setId(1L);
- Level level = TestUtil.createLevel(1);
- version2014.addLevel(level);
- version2014.addClassificationItem(TestUtil.createClassificationItem("0101", "Halden"),
- level.getLevelNumber(),
- null);
- version2014.addClassificationItem(TestUtil.createClassificationItem("0104", "Moss"),
- level.getLevelNumber(),
- null);
- version2014.addClassificationItem(TestUtil.createClassificationItem("0301", "Oslo"),
- level.getLevelNumber(),
- null);
- version2014.addClassificationItem(TestUtil.createClassificationItem("1739", "Raarvihke Røyrvik"), level
- .getLevelNumber(), null);
- version2014.addClassificationItem(
- TestUtil.createClassificationItem("1939", "Omasvuotna Storfjord Omasvuonon"),
- level.getLevelNumber(), null);
- classification.addClassificationVersion(version2014);
-
- ClassificationVersion version2012 = TestUtil.createClassificationVersion(DateRange.create("2012-01-01",
- "2014-01-01"));
- version2012.setId(1L);
- Level level2012 = TestUtil.createLevel(1);
- version2012.addLevel(level2012);
- version2012.addClassificationItem(TestUtil.createClassificationItem("0101", "Halden"), level2012
- .getLevelNumber(), null);
- version2012.addClassificationItem(TestUtil.createClassificationItem("0104", "Moss"),
- level2012.getLevelNumber(),
- null);
- version2012.addClassificationItem(TestUtil.createClassificationItem("0301", "Oslo"),
- level2012.getLevelNumber(),
- null);
- version2012.addClassificationItem(TestUtil.createClassificationItem("1739", "Røyrvik"), level2012
- .getLevelNumber(), null);
- version2012.addClassificationItem(TestUtil.createClassificationItem("1939", "Storfjord"), level2012
- .getLevelNumber(), null);
-
- classification.addClassificationVersion(version2012);
-
- CorrespondenceTable correspondenceTable = TestUtil.createCorrespondenceTable(version2014, version2012);
- version2014.addCorrespondenceTable(correspondenceTable);
- correspondenceTable.addCorrespondenceMap(new CorrespondenceMap(version2014.findItem("1739"), version2012
- .findItem("1739")));
- correspondenceTable.addCorrespondenceMap(new CorrespondenceMap(version2014.findItem("1939"), version2012
- .findItem("1939")));
-
- return classification;
- }
+ private ClassificationSeries createClassificationKommuneinndeling() {
+ ClassificationSeries classification = TestUtil.createClassificationWithId(CLASS_ID_KOMMUNEINNDELING,
+ "Standard for kommuneinndeling",
+ "Kommuneinndelingen er en administrativ inndeling av kommuner i Norge");
+
+ ClassificationVersion version2014 = TestUtil
+ .createClassificationVersion(DateRange.create("2014-01-01", null));
+ version2014.setId(1L);
+ Level level = TestUtil.createLevel(1);
+ version2014.addLevel(level);
+ version2014.addClassificationItem(TestUtil.createClassificationItem("0101", "Halden"),
+ level.getLevelNumber(),
+ null);
+ version2014.addClassificationItem(TestUtil.createClassificationItem("0104", "Moss"),
+ level.getLevelNumber(),
+ null);
+ version2014.addClassificationItem(TestUtil.createClassificationItem("0301", "Oslo"),
+ level.getLevelNumber(),
+ null);
+ version2014.addClassificationItem(TestUtil.createClassificationItem("1739", "Raarvihke Røyrvik"), level
+ .getLevelNumber(), null);
+ version2014.addClassificationItem(
+ TestUtil.createClassificationItem("1939", "Omasvuotna Storfjord Omasvuonon"),
+ level.getLevelNumber(), null);
+ classification.addClassificationVersion(version2014);
+
+ ClassificationVersion version2012 = TestUtil.createClassificationVersion(DateRange.create("2012-01-01",
+ "2014-01-01"));
+ version2012.setId(1L);
+ Level level2012 = TestUtil.createLevel(1);
+ version2012.addLevel(level2012);
+ version2012.addClassificationItem(TestUtil.createClassificationItem("0101", "Halden"), level2012
+ .getLevelNumber(), null);
+ version2012.addClassificationItem(TestUtil.createClassificationItem("0104", "Moss"),
+ level2012.getLevelNumber(),
+ null);
+ version2012.addClassificationItem(TestUtil.createClassificationItem("0301", "Oslo"),
+ level2012.getLevelNumber(),
+ null);
+ version2012.addClassificationItem(TestUtil.createClassificationItem("1739", "Røyrvik"), level2012
+ .getLevelNumber(), null);
+ version2012.addClassificationItem(TestUtil.createClassificationItem("1939", "Storfjord"), level2012
+ .getLevelNumber(), null);
+
+ classification.addClassificationVersion(version2012);
+
+ CorrespondenceTable correspondenceTable = TestUtil.createCorrespondenceTable(version2014, version2012);
+ version2014.addCorrespondenceTable(correspondenceTable);
+ correspondenceTable.addCorrespondenceMap(new CorrespondenceMap(version2014.findItem("1739"), version2012
+ .findItem("1739")));
+ correspondenceTable.addCorrespondenceMap(new CorrespondenceMap(version2014.findItem("1939"), version2012
+ .findItem("1939")));
+
+ return classification;
+ }
- private ClassificationSeries createClassificationBydelsinndeling() {
- ClassificationSeries classification = TestUtil.createClassificationWithId(CLASS_ID_BYDELSINNDELING,
- "Standard for bydelsinndeling",
- "Bydel utgjør geografiske områder i en kommune");
-
- ClassificationVersion version = TestUtil
- .createClassificationVersion(DateRange.create("2004-01-01", null));
- Level level = TestUtil.createLevel(1);
- version.addLevel(level);
- version.addClassificationItem(TestUtil.createClassificationItem("030101", "Gamle Oslo"),
- level.getLevelNumber(),
- null);
- version.addClassificationItem(TestUtil.createClassificationItem("030102", "Grünerløkka"), level
- .getLevelNumber(), null);
- version.addClassificationItem(TestUtil.createClassificationItem("030103", "Sagene"),
- level.getLevelNumber(),
- null);
- version.addClassificationItem(TestUtil.createClassificationItem("030104", "St. Hanshaugen"), level
- .getLevelNumber(), null);
- version.addClassificationItem(TestUtil.createClassificationItem("030105", "Frogner"),
- level.getLevelNumber(),
- null);
- classification.addClassificationVersion(version);
- return classification;
- }
+ private ClassificationSeries createClassificationBydelsinndeling() {
+ ClassificationSeries classification = TestUtil.createClassificationWithId(CLASS_ID_BYDELSINNDELING,
+ "Standard for bydelsinndeling",
+ "Bydel utgjør geografiske områder i en kommune");
+
+ ClassificationVersion version = TestUtil
+ .createClassificationVersion(DateRange.create("2004-01-01", null));
+ Level level = TestUtil.createLevel(1);
+ version.addLevel(level);
+ version.addClassificationItem(TestUtil.createClassificationItem("030101", "Gamle Oslo"),
+ level.getLevelNumber(),
+ null);
+ version.addClassificationItem(TestUtil.createClassificationItem("030102", "Grünerløkka"), level
+ .getLevelNumber(), null);
+ version.addClassificationItem(TestUtil.createClassificationItem("030103", "Sagene"),
+ level.getLevelNumber(),
+ null);
+ version.addClassificationItem(TestUtil.createClassificationItem("030104", "St. Hanshaugen"), level
+ .getLevelNumber(), null);
+ version.addClassificationItem(TestUtil.createClassificationItem("030105", "Frogner"),
+ level.getLevelNumber(),
+ null);
+ classification.addClassificationVersion(version);
+ return classification;
+ }
- private ClassificationSeries createClassificationFamiliegruppering(User user) {
- ClassificationSeries classification = TestUtil.createClassificationWithId(CLASS_ID_FAMILIEGRUPPERING,
- "Standard for gruppering av familier",
- "Standarden beskriver de ulike familitypene som i dag brukes i SSBs familistatistikk");
- classification.setContactPerson(user);
- ClassificationVersion version = TestUtil
- .createClassificationVersion(DateRange.create("2006-01-01", null));
- Level level = TestUtil.createLevel(1);
- version.addLevel(level);
- version.addClassificationItem(
- TestUtil.createClassificationItem("1.1.1", "Enpersonfamilie, person under 30 år"),
- level.getLevelNumber(), null);
- ClassificationVariant variant = TestUtil.createClassificationVariant(
- "Variant - Tilleggsinndeling for familier",
- user);
- variant.setId(1111L);
- variant.addClassificationItem(TestUtil.createClassificationItem("A", "Enpersonfamilie"), 1, null);
- variant.addClassificationItem(TestUtil.createClassificationItem("B", "Ektepar"), 1, null);
- variant.addClassificationItem(TestUtil.createClassificationItem("A_", "Enpersonfamilie"), 2,
- variant.findItem(
- "A"));
- variant.addClassificationItem(
- TestUtil.createClassificationItem("BA", "Ektepar med barn (yngste barn 0-17 år)"),
- 2, variant.findItem("B"));
- variant.addClassificationItem(TestUtil.createClassificationItem("BB", "Ektepar uten barn 0-17 år"), 2,
- variant
- .findItem("B"));
- version.addClassificationVariant(variant);
- classification.addClassificationVersion(version);
- return classification;
- }
+ private ClassificationSeries createClassificationFamiliegruppering(User user) {
+ ClassificationSeries classification = TestUtil.createClassificationWithId(CLASS_ID_FAMILIEGRUPPERING,
+ "Standard for gruppering av familier",
+ "Standarden beskriver de ulike familitypene som i dag brukes i SSBs familistatistikk");
+ classification.setContactPerson(user);
+ ClassificationVersion version = TestUtil
+ .createClassificationVersion(DateRange.create("2006-01-01", null));
+ Level level = TestUtil.createLevel(1);
+ version.addLevel(level);
+ version.addClassificationItem(
+ TestUtil.createClassificationItem("1.1.1", "Enpersonfamilie, person under 30 år"),
+ level.getLevelNumber(), null);
+ ClassificationVariant variant = TestUtil.createClassificationVariant(
+ "Variant - Tilleggsinndeling for familier",
+ user);
+ variant.setId(1111L);
+ variant.addClassificationItem(TestUtil.createClassificationItem("A", "Enpersonfamilie"), 1, null);
+ variant.addClassificationItem(TestUtil.createClassificationItem("B", "Ektepar"), 1, null);
+ variant.addClassificationItem(TestUtil.createClassificationItem("A_", "Enpersonfamilie"), 2,
+ variant.findItem(
+ "A"));
+ variant.addClassificationItem(
+ TestUtil.createClassificationItem("BA", "Ektepar med barn (yngste barn 0-17 år)"),
+ 2, variant.findItem("B"));
+ variant.addClassificationItem(TestUtil.createClassificationItem("BB", "Ektepar uten barn 0-17 år"), 2,
+ variant
+ .findItem("B"));
+ version.addClassificationVariant(variant);
+ classification.addClassificationVersion(version);
+ return classification;
+ }
- private ClassificationFamily createClassificationFamily() {
- ClassificationFamily family = TestUtil.createClassificationFamily("Befolkning");
- family.setId(CLASS_FAMILY_BEFOLKNING);
- family.addClassificationSeries(createClassificationKommuneinndeling());
- return family;
- }
+ private ClassificationFamily createClassificationFamily() {
+ ClassificationFamily family = TestUtil.createClassificationFamily("Befolkning");
+ family.setId(CLASS_FAMILY_BEFOLKNING);
+ family.addClassificationSeries(createClassificationKommuneinndeling());
+ return family;
+ }
- private CorrespondenceTable createCorrespondenceTable(Long id) {
- CorrespondenceTable table = TestUtil.createCorrespondenceTable(
- "Mapping Arbeidsgiveravgiftssoner - Kommuneinndeling",
- TestUtil.createClassificationVersionWithTable(CLASS_VARIANT_POLITIDISTRIKT,
- TestUtil.anyDateRange(), "Arbeidsgiveravgiftssoner"),
- TestUtil.createClassificationVersionWithTable(CLASS_VARIANT_KOMMUNEINNDELING,
- TestUtil.anyDateRange(), "Kommuneinndeling"));
- table.setId(id);
- table.addCorrespondenceMap(new CorrespondenceMap(
- TestUtil.createClassificationItem("01", "Oslo"),
- TestUtil.createClassificationItem("0301", "Oslo")));
- return table;
- }
+ private CorrespondenceTable createCorrespondenceTable(Long id) {
+ CorrespondenceTable table = TestUtil.createCorrespondenceTable(
+ "Mapping Arbeidsgiveravgiftssoner - Kommuneinndeling",
+ TestUtil.createClassificationVersionWithTable(CLASS_VARIANT_POLITIDISTRIKT,
+ TestUtil.anyDateRange(), "Arbeidsgiveravgiftssoner"),
+ TestUtil.createClassificationVersionWithTable(CLASS_VARIANT_KOMMUNEINNDELING,
+ TestUtil.anyDateRange(), "Kommuneinndeling"));
+ table.setId(id);
+ table.addCorrespondenceMap(new CorrespondenceMap(
+ TestUtil.createClassificationItem("01", "Oslo"),
+ TestUtil.createClassificationItem("0301", "Oslo")));
+ return table;
+ }
}
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/AbstractRestApiApplicationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/AbstractRestApiApplicationTest.java
index 8ffc1183..a7eec277 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/AbstractRestApiApplicationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/AbstractRestApiApplicationTest.java
@@ -6,15 +6,15 @@
import no.ssb.klass.core.model.CorrespondenceTable;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionTemplate;
@@ -35,7 +35,7 @@
import no.ssb.klass.testutil.ConstantClockSource;
import no.ssb.klass.testutil.TestUtil;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { ApplicationTestConfig.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles(profiles = { ConfigurationProfiles.H2_INMEMORY, ConfigurationProfiles.MOCK_SEARCH })
@ComponentScan(basePackageClasses = TranslatablePersistenceConverter.class)
@@ -87,6 +87,7 @@ public abstract class AbstractRestApiApplicationTest {
public static final String JSON_LINKS = "_links";
public static final String XML_LINKS = "PagedResources.links";
+ public static final String XML_ROOT = "PagedResources";
public static final String JSON_CODES = "codes";
public static final String XML_CODES = "codeList.codeItem";
@@ -129,7 +130,7 @@ public abstract class AbstractRestApiApplicationTest {
@Value("${local.server.port}")
protected int port;
- @Before
+ @BeforeEach
public void prepareTestData() {
applicationTestUtil.clearDatabase();
applicationTestUtil.clearSearch();
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiChangesIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiChangesIntegrationTest.java
index de5dc077..4e652c84 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiChangesIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiChangesIntegrationTest.java
@@ -1,13 +1,13 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
/**
* @author Mads Lundemo, SSB.
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationFamilyIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationFamilyIntegrationTest.java
index 147a8b5b..0dd71129 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationFamilyIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationFamilyIntegrationTest.java
@@ -1,12 +1,12 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.core.model.ClassificationType;
@@ -25,7 +25,7 @@ public void restServiceReturnClassificationFamily() {
// classificationFamily
.assertThat().body("name", equalTo(classificationFamily.getName()))
// classifications
- .assertThat().body("classifications.size", equalTo(classificationFamily.getClassificationSeriesBySectionAndClassificationType(null,
+ .assertThat().body("classifications.size()", equalTo(classificationFamily.getClassificationSeriesBySectionAndClassificationType(null,
ClassificationType.CLASSIFICATION).size()))
// links
@@ -46,7 +46,7 @@ public void restServiceClassificationFamilyFiltersClassificationType() {
// classificationFamily
.assertThat().body("name", equalTo(classificationFamily.getName()))
// classifications
- .assertThat().body("classifications.size", equalTo(classificationFamily.getClassificationSeriesBySectionAndClassificationType(null,
+ .assertThat().body("classifications.size()", equalTo(classificationFamily.getClassificationSeriesBySectionAndClassificationType(null,
null).size()))
// links
@@ -68,7 +68,7 @@ public void restServiceClassificationFamilyFiltersSsbSection() {
// classificationFamily
.assertThat().body("name", equalTo(classificationFamily.getName()))
// classifications
- .assertThat().body("classifications.size", equalTo(0))
+ .assertThat().body("classifications.size()", equalTo(0))
// links
.body(JSON_LINKS + ".self.href", containsString(urlParts));
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationIntegrationTest.java
index f74ac844..933469a5 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiClassificationIntegrationTest.java
@@ -1,13 +1,13 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
/**
@@ -31,7 +31,7 @@ public void restServiceReturnClassification() {
.assertThat().body("lastModified", notNullValue())
.assertThat().body(JSON_LINKS + ".self.href", containsString("classifications/" + kommuneinndeling.getId()))
// versions
- .assertThat().body("versions.size", equalTo(3))
+ .assertThat().body("versions.size()", equalTo(3))
//
.assertThat().body("versions[0].name", equalTo("Kommuneinndeling 2014"))
.assertThat().body("versions[0]._links.self.href", containsString("versions/"))
@@ -72,7 +72,7 @@ public void restServiceReturnClassificationIncludeFutureVersions() {
.assertThat().body("lastModified", notNullValue())
.assertThat().body(JSON_LINKS + ".self.href", containsString("classifications/" + kommuneinndeling.getId()))
// versions
- .assertThat().body("versions.size", equalTo(4))
+ .assertThat().body("versions.size()", equalTo(4))
//
.assertThat().body("versions[0].name", equalTo("Kommuneinndeling "+TestDataProvider.TEN_YEARS_LATER))
.assertThat().body("versions[0]._links.self.href", containsString("versions/"))
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeAtIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeAtIntegrationTest.java
index d79bb1dc..add17d75 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeAtIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeAtIntegrationTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.api.applicationtest;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -205,7 +205,7 @@ public void restServiceCodesAt2015CSV() {
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n"
+ "\"0101\",,\"1\",\"Halden\",\"\",\"\",,,\"\"\n"
+ "\"0104\",,\"1\",\"Moss\",\"\",\"\",,,\"\"\n"
@@ -225,7 +225,7 @@ public void restServiceCodesAtFutureDateIncludedFutureVersionCSV() {
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n"
+ "\"0101\",,\"1\",\"Halden\",\"\",\"\",,,\"\"\n"
+ "\"0104\",,\"1\",\"Moss\",\"\",\"\",,,\"\"\n"
@@ -250,7 +250,7 @@ public void restServiceCodesAt2012CSV() {
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n" + "\"0101\",,\"1\",\"Halden\",\"\",\"\",,,\"\"\n"
+ "\"0104\",,\"1\",\"Moss\",\"\",\"\",,,\"\"\n"
+ "\"0301\",,\"1\",\"Oslo\",\"\",\"\",,,\"\"\n"
@@ -274,7 +274,7 @@ public void restServiceCodesAtAlternativeCSVSeparator() {
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\";\"parentCode\";\"level\";\"name\";\"shortName\";\"presentationName\";\"validFrom\";\"validTo\";\"notes\"\n"
+ "\"0101\";;\"1\";\"Halden\";\"\";\"\";;;\"\"\n"
+ "\"0104\";;\"1\";\"Moss\";\"\";\"\";;;\"\"\n"
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeIntegrationTest.java
index f0ec2f3d..7f71894b 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCodeIntegrationTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.api.applicationtest;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -172,7 +172,7 @@ public void restServiceCodesCSV() {
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\","
+ "\"validFrom\",\"validTo\",\"validFromInRequestedRange\",\"validToInRequestedRange\",\"notes\"\n"
+ "\"0101\",,\"1\",\"Halden\",\"\",\"\",,,\"2014-01-01\",\"2015-01-01\",\"\"\n"
@@ -193,7 +193,7 @@ public void restServiceCodesIncludeFutureVersionCSV() {
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\","
+ "\"validFrom\",\"validTo\",\"validFromInRequestedRange\",\"validToInRequestedRange\",\"notes\"\n"
+ "\"0101\",,\"1\",\"Halden\",\"\",\"\",,,\""+TestDataProvider.TEN_YEARS_LATER_DATE+"\",\""+TestDataProvider.FIFTEEN_YEARS_LATER_DATE+"\",\"\"\n"
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondenceTablesIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondenceTablesIntegrationTest.java
index 922753ff..8d56e575 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondenceTablesIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondenceTablesIntegrationTest.java
@@ -1,10 +1,10 @@
package no.ssb.klass.api.applicationtest;
-import com.jayway.restassured.http.ContentType;
-import org.junit.Test;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
public class RestApiCorrespondenceTablesIntegrationTest extends AbstractRestApiApplicationTest {
@@ -29,14 +29,17 @@ public void restServiceCorrespondenceTablesJSON() {
.body("sourceLevel", isEmptyOrNullString())
.body("targetLevel", isEmptyOrNullString())
.body("changelogs", notNullValue())
- .body("correspondenceMaps.size", is(3))
+ .body("correspondenceMaps.size()", is(3))
.body("correspondenceMaps[0].sourceCode", is("0301"))
.body("correspondenceMaps[0].sourceName", is("Oslo"))
.body("correspondenceMaps[0].targetCode", is("030101"))
.body("correspondenceMaps[0].targetName", is("Gamle Oslo"))
- .body(JSON_LINKS + ".self.href", endsWith("/correspondencetables/" + correspondenceTable.getId().intValue()))
- .body(JSON_LINKS + ".source.href", endsWith("/versions/" + correspondenceTable.getSource().getId().intValue()))
- .body(JSON_LINKS + ".target.href", endsWith("/versions/" + correspondenceTable.getTarget().getId().intValue()));
+ .body(JSON_LINKS + ".self.href", endsWith("/correspondencetables/"
+ + correspondenceTable.getId().intValue()))
+ .body(JSON_LINKS + ".source.href", endsWith("/versions/"
+ + correspondenceTable.getSource().getId().intValue() + "{?language,includeFuture}"))
+ .body(JSON_LINKS + ".target.href", endsWith("/versions/"
+ + correspondenceTable.getTarget().getId().intValue() + "{?language,includeFuture}"));
}
@Test
@@ -64,12 +67,15 @@ public void restServiceCorrespondenceTablesXML() {
.body(XML_CORRESPONDENCETABLE_MAP + "[0].sourceName", is("Oslo"))
.body(XML_CORRESPONDENCETABLE_MAP + "[0].targetCode", is("030101"))
.body(XML_CORRESPONDENCETABLE_MAP + "[0].targetName", is("Gamle Oslo"))
- .body(XML_CORRESPONDENCETABLE + ".links.link[0].rel", is("self"))
- .body(XML_CORRESPONDENCETABLE + ".links.link[0].href", endsWith("/correspondencetables/" + correspondenceTable.getId().intValue()))
- .body(XML_CORRESPONDENCETABLE + ".links.link[1].rel", is("source"))
- .body(XML_CORRESPONDENCETABLE + ".links.link[1].href", endsWith("/versions/" + correspondenceTable.getSource().getId().intValue()))
- .body(XML_CORRESPONDENCETABLE + ".links.link[2].rel", is("target"))
- .body(XML_CORRESPONDENCETABLE + ".links.link[2].href", endsWith("/versions/" + correspondenceTable.getTarget().getId().intValue()));
+ .body(XML_CORRESPONDENCETABLE + ".link[0].rel", is("self"))
+ .body(XML_CORRESPONDENCETABLE + ".link[0].href", endsWith("/correspondencetables/"
+ + correspondenceTable.getId().intValue()))
+ .body(XML_CORRESPONDENCETABLE + ".link[1].rel", is("source"))
+ .body(XML_CORRESPONDENCETABLE + ".link[1].href", endsWith("/versions/"
+ + correspondenceTable.getSource().getId().intValue() + "{?language,includeFuture}"))
+ .body(XML_CORRESPONDENCETABLE + ".link[2].rel", is("target"))
+ .body(XML_CORRESPONDENCETABLE + ".link[2].href", endsWith("/versions/"
+ + correspondenceTable.getTarget().getId().intValue() + "{?language,includeFuture}"));
}
@Test
@@ -79,7 +85,7 @@ public void restServiceCorrespondenceTablesCSV() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"sourceCode\";\"sourceName\";\"targetCode\";\"targetName\"\n" +
"\"0301\";\"Oslo\";\"030101\";\"Gamle Oslo\"\n" +
"\"0301\";\"Oslo\";\"030102\";\"Grünerløkka\"\n" +
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsAtIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsAtIntegrationTest.java
index 000932eb..b412d204 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsAtIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsAtIntegrationTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.api.applicationtest;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -169,7 +169,7 @@ public void restServiceCorrespondsCSV() {
// .prettyPeek()
.then()
.statusCode(HttpStatus.OK.value())
- .content(containsString(
+ .body(containsString(
"\"sourceCode\",\"sourceName\",\"sourceShortName\",\"targetCode\",\"targetName\",\"targetShortName\"\n"
+ "\"0301\",\"Oslo\",\"\",\"030101\",\"Gamle Oslo\",\"\"\n"
+ "\"0301\",\"Oslo\",\"\",\"030102\",\"Grünerløkka\",\"\"\n"
@@ -187,7 +187,7 @@ public void restServiceCorrespondsIncludeFutureVersionCSV() {
// .prettyPeek()
.then()
.statusCode(HttpStatus.OK.value())
- .content(containsString(
+ .body(containsString(
"\"sourceCode\",\"sourceName\",\"sourceShortName\",\"targetCode\",\"targetName\",\"targetShortName\"\n"
+ "\"0301\",\"Oslo\",\"\",\"030101\",\"Gamle Oslo\",\"\"\n"
+ "\"0301\",\"Oslo\",\"\",\"030102\",\"Grünerløkka\",\"\"\n"
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsIntegrationTest.java
index 84355215..cd935f27 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiCorrespondsIntegrationTest.java
@@ -1,14 +1,14 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
/**
* @author Mads Lundemo, SSB.
@@ -174,7 +174,7 @@ public void restServiceCorrespondsCSV() {
// .prettyPeek()
.then()
.statusCode(HttpStatus.OK.value())
- .content(containsString(
+ .body(containsString(
"\"sourceCode\",\"sourceName\",\"sourceShortName\",\"targetCode\",\"targetName\","
+ "\"targetShortName\",\"validFrom\",\"validTo\"\n"
+ "\"0301\",\"Oslo\",\"\",\"030101\",\"Gamle Oslo\",\"\",\"2015-01-01\",\n"
@@ -193,7 +193,7 @@ public void restServiceCorrespondsIncludeFutureVersionCSV() {
// .prettyPeek()
.then()
.statusCode(HttpStatus.OK.value())
- .content(containsString(
+ .body(containsString(
"\"sourceCode\",\"sourceName\",\"sourceShortName\",\"targetCode\",\"targetName\","
+ "\"targetShortName\",\"validFrom\",\"validTo\"\n"
+ "\"0301\",\"Oslo\",\"\",\"030101\",\"Gamle Oslo\",\"\",\"2015-01-01\",\n"
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiDraftIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiDraftIntegrationTest.java
index 62342202..26ee58fb 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiDraftIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiDraftIntegrationTest.java
@@ -1,14 +1,14 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.core.model.ClassificationFamily;
import no.ssb.klass.core.model.ClassificationVariant;
@@ -24,7 +24,7 @@ public class RestApiDraftIntegrationTest extends AbstractRestApiApplicationTest
private ClassificationVariant variant;
- @Before
+ @BeforeEach
public void addDrafts() {
applicationTestUtil.clearDatabase();
applicationTestUtil.clearSearch();
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiErrorHandlingIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiErrorHandlingIntegrationTest.java
index bffa0096..f7ffd6cf 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiErrorHandlingIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiErrorHandlingIntegrationTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
/**
* @author Mads Lundemo, SSB.
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationFamilyIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationFamilyIntegrationTest.java
index ecd94285..54aa0f4f 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationFamilyIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationFamilyIntegrationTest.java
@@ -1,12 +1,12 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.core.model.ClassificationType;
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationIntegrationTest.java
index 277d4c59..fb48dce5 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListClassificationIntegrationTest.java
@@ -1,13 +1,13 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
/**
@@ -72,8 +72,12 @@ public void restServiceListClassificationsIncludeCodelistsJSON() {
@Test
public void restServiceListClassificationsChangedSinceJSON() {
+ // Spring's DateTimeFormat parser har changed the timezone offset format from ssZ to SSSXXX.
+ given().port(port).accept(ContentType.JSON).param("changedSince", "2015-10-31T01:30:00.000-02:00").get(REQUEST)
+ .then()
+ .statusCode(HttpStatus.OK.value());
+
given().port(port).accept(ContentType.JSON).param("changedSince", "2015-10-31T01:30:00.000-0200").get(REQUEST)
-// .prettyPeek()
.then()
.statusCode(HttpStatus.OK.value())
.contentType(ContentType.JSON)
@@ -93,25 +97,27 @@ public void restServiceListClassificationsChangedSinceJSON() {
@Test
public void restServiceListClassificationsXML() {
+ given().port(port).accept(ContentType.XML).get(REQUEST).prettyPrint();
+
given().port(port).accept(ContentType.XML).get(REQUEST)
// .prettyPeek()
- .then()
+ .prettyPeek().then()
.statusCode(HttpStatus.OK.value())
.contentType(ContentType.XML)
.body(XML_CLASSIFICATIONS + ".size()", equalTo(2))
// result 1
.body(XML_CLASSIFICATION1 + ".name", equalTo(TestDataProvider.KOMMUNEINNDELING_NAVN_NO))
- .body(XML_CLASSIFICATION1 + ".links.link.rel", equalTo("self"))
- .body(XML_CLASSIFICATION1 + ".links.link.href", containsString(REQUEST + "/" + kommuneinndeling.getId()))
+ .body(XML_CLASSIFICATION1 + ".link.rel", equalTo("self"))
+ .body(XML_CLASSIFICATION1 + ".link.href", containsString(REQUEST + "/" + kommuneinndeling.getId()))
//result 2
.body(XML_CLASSIFICATION2 + ".name", equalTo(TestDataProvider.BYDELSINNDELING_NAVN_NO))
- .body(XML_CLASSIFICATION2 + ".links.link.rel", equalTo("self"))
- .body(XML_CLASSIFICATION2 + ".links.link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
+ .body(XML_CLASSIFICATION2 + ".link.rel", equalTo("self"))
+ .body(XML_CLASSIFICATION2 + ".link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
// links
- .body(XML_LINKS + ".link[0].rel", equalTo("self"))
- .body(XML_LINKS + ".link[0].href", containsString(REQUEST))
- .body(XML_LINKS + ".link[1].rel", equalTo("search"))
- .body(XML_LINKS + ".link[1].href", containsString(REQUEST_SEARCH))
+ .body(XML_ROOT + ".link[0].rel", equalTo("self"))
+ .body(XML_ROOT + ".link[0].href", containsString(REQUEST))
+ .body(XML_ROOT + ".link[1].rel", equalTo("search"))
+ .body(XML_ROOT + ".link[1].href", containsString(REQUEST_SEARCH))
// paging
.body(XML_PAGE + ".size.toInteger();", equalTo(20))
.body(XML_PAGE + ".totalElements.toInteger();", equalTo(2))
@@ -130,22 +136,22 @@ public void restServiceListClassificationsIncludeCodelistXML() {
.body(XML_CLASSIFICATIONS + ".size()", equalTo(3))
// result 1
.body(XML_CLASSIFICATION1 + ".name", equalTo(TestDataProvider.FAMILIEGRUPPERING_NAVN_NO))
- .body(XML_CLASSIFICATION1 + ".links.link.rel", equalTo("self"))
- .body(XML_CLASSIFICATION1 + ".links.link.href", containsString(REQUEST + "/" + familieGrupperingCodelist.getId()))
+ .body(XML_CLASSIFICATION1 + ".link.rel", equalTo("self"))
+ .body(XML_CLASSIFICATION1 + ".link.href", containsString(REQUEST + "/" + familieGrupperingCodelist.getId()))
//result 2
.body(XML_CLASSIFICATION2 + ".name", equalTo(TestDataProvider.KOMMUNEINNDELING_NAVN_NO))
- .body(XML_CLASSIFICATION2 + ".links.link.rel", equalTo("self"))
- .body(XML_CLASSIFICATION2 + ".links.link.href", containsString(REQUEST + "/" + kommuneinndeling.getId()))
+ .body(XML_CLASSIFICATION2 + ".link.rel", equalTo("self"))
+ .body(XML_CLASSIFICATION2 + ".link.href", containsString(REQUEST + "/" + kommuneinndeling.getId()))
//result 3
.body(XML_CLASSIFICATION3 + ".name", equalTo(TestDataProvider.BYDELSINNDELING_NAVN_NO))
- .body(XML_CLASSIFICATION3 + ".links.link.rel", equalTo("self"))
- .body(XML_CLASSIFICATION3 + ".links.link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
+ .body(XML_CLASSIFICATION3 + ".link.rel", equalTo("self"))
+ .body(XML_CLASSIFICATION3 + ".link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
// links
- .body(XML_LINKS + ".link[0].rel", equalTo("self"))
- .body(XML_LINKS + ".link[0].href", containsString(REQUEST))
- .body(XML_LINKS + ".link[1].rel", equalTo("search"))
- .body(XML_LINKS + ".link[1].href", containsString(REQUEST_SEARCH))
+ .body(XML_ROOT + ".link[0].rel", equalTo("self"))
+ .body(XML_ROOT + ".link[0].href", containsString(REQUEST))
+ .body(XML_ROOT + ".link[1].rel", equalTo("search"))
+ .body(XML_ROOT + ".link[1].href", containsString(REQUEST_SEARCH))
// paging
.body(XML_PAGE + ".size.toInteger();", equalTo(20))
.body(XML_PAGE + ".totalElements.toInteger();", equalTo(3))
@@ -163,13 +169,13 @@ public void restServiceListClassificationsChangedSinceXML() {
.body(XML_CLASSIFICATIONS + ".size()", equalTo(1))
//result 1
.body(XML_CLASSIFICATION1 + ".name", equalTo(TestDataProvider.BYDELSINNDELING_NAVN_NO))
- .body(XML_CLASSIFICATION1 + ".links.link.rel", equalTo("self"))
- .body(XML_CLASSIFICATION1 + ".links.link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
+ .body(XML_CLASSIFICATION1 + ".link.rel", equalTo("self"))
+ .body(XML_CLASSIFICATION1 + ".link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
// links
- .body(XML_LINKS + ".link[0].rel", equalTo("self"))
- .body(XML_LINKS + ".link[0].href", containsString(REQUEST))
- .body(XML_LINKS + ".link[1].rel", equalTo("search"))
- .body(XML_LINKS + ".link[1].href", containsString(REQUEST_SEARCH))
+ .body(XML_ROOT + ".link[0].rel", equalTo("self"))
+ .body(XML_ROOT + ".link[0].href", containsString(REQUEST))
+ .body(XML_ROOT + ".link[1].rel", equalTo("search"))
+ .body(XML_ROOT + ".link[1].href", containsString(REQUEST_SEARCH))
// paging
.body(XML_PAGE + ".size.toInteger();", equalTo(20))
.body(XML_PAGE + ".totalElements.toInteger();", equalTo(1))
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListSsbSectionIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListSsbSectionIntegrationTest.java
index ea173ac9..dd4c5ca8 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListSsbSectionIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiListSsbSectionIntegrationTest.java
@@ -1,12 +1,12 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
/**
* Testsuite that test the list (all) ssb sections
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiSearchIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiSearchIntegrationTest.java
index 87ddd0d2..2df61f3d 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiSearchIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiSearchIntegrationTest.java
@@ -1,14 +1,14 @@
package no.ssb.klass.api.applicationtest;
-import static com.jayway.restassured.RestAssured.*;
+import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ActiveProfiles;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.core.config.ConfigurationProfiles;
@@ -60,16 +60,16 @@ public void restServiceSearchClassificationsXML() {
.body(XML_SEARCH_RESULT1 + ".name", equalTo(TestDataProvider.KOMMUNEINNDELING_NAVN_NO))
.body(XML_SEARCH_RESULT1 + ".snippet", containsString("kommune"))
.body(XML_SEARCH_RESULT1 + ".searchScore.toFloat()", greaterThan(0.0f))
- .body(XML_SEARCH_RESULT1 + ".links.link.rel", equalTo("self"))
- .body(XML_SEARCH_RESULT1 + ".links.link.href", containsString(REQUEST + "/" + kommuneinndeling.getId()))
+ .body(XML_SEARCH_RESULT1 + ".link.rel", equalTo("self"))
+ .body(XML_SEARCH_RESULT1 + ".link.href", containsString(REQUEST + "/" + kommuneinndeling.getId()))
//result 2
.body(XML_SEARCH_RESULT2 + ".name", equalTo(TestDataProvider.BYDELSINNDELING_NAVN_NO))
.body(XML_SEARCH_RESULT2 + ".snippet", containsString("kommune"))
.body(XML_SEARCH_RESULT2 + ".searchScore.toFloat();", greaterThan(0.0f))
- .body(XML_SEARCH_RESULT2 + ".links.link.rel", equalTo("self"))
- .body(XML_SEARCH_RESULT2 + ".links.link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
+ .body(XML_SEARCH_RESULT2 + ".link.rel", equalTo("self"))
+ .body(XML_SEARCH_RESULT2 + ".link.href", containsString(REQUEST + "/" + bydelsinndeling.getId()))
// footer
- .body(XML_LINKS + ".link.href", containsString(REQUEST_SEARCH))
+ .body(XML_ROOT + ".link.href", containsString(REQUEST_SEARCH))
.body(XML_PAGE + ".size.toInteger();", equalTo(PAGE_SIZE))
.body(XML_PAGE + ".totalElements.toInteger();", equalTo(2))
.body(XML_PAGE + ".totalPages.toInteger();", equalTo(1))
@@ -140,7 +140,7 @@ public void restServiceSearchClassificationsWithCodelistXML() {
.body(XML_SEARCH_RESULT1 + ".name", equalTo(TestDataProvider.FAMILIEGRUPPERING_NAVN_NO))
.body(XML_SEARCH_RESULT1 + ".snippet", containsString("familie"))
.body(XML_SEARCH_RESULT1 + ".searchScore.toFloat();", greaterThan(0.0f))
- .body(XML_SEARCH_RESULT1 + ".links.link.href", containsString(REQUEST + "/" + familieGrupperingCodelist.getId()));
+ .body(XML_SEARCH_RESULT1 + ".link.href", containsString(REQUEST + "/" + familieGrupperingCodelist.getId()));
}
// @formatter:on
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantAtIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantAtIntegrationTest.java
index 2ed5b6ff..848e8bff 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantAtIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantAtIntegrationTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.api.applicationtest;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -154,7 +154,7 @@ public void restServiceVariantAtCSV() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n"
+ "\"A\",,\"1\",\"Enpersonfamilie\",\"\",\"\",,,\"\"\n"
+ "\"A_\",\"A\",\"2\",\"Enpersonfamilie\",\"\",\"\",,,\"\"\n"
@@ -174,7 +174,7 @@ public void restServiceVariantAtIncludedFutureVersionsCSV() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n"
+ "\"C\",,\"1\",\"Enslig person med barn\",\"\",\"\",,,\"\"\n"
+ "\"CA\",\"C\",\"2\",\"Enslig person med barn 0-5 år\",\"\",\"\",,,\"\"\n"
@@ -194,7 +194,7 @@ public void restServiceVariantAtCSVFullVariantName() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n"
+ "\"A\",,\"1\",\"Enpersonfamilie\",\"\",\"\",,,\"\"\n"
+ "\"A_\",\"A\",\"2\",\"Enpersonfamilie\",\"\",\"\",,,\"\"\n"
@@ -217,7 +217,7 @@ public void restServiceVariantAtCSVFullVariantNameFutureVersion() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\",\"validFrom\",\"validTo\",\"notes\"\n"
+ "\"C\",,\"1\",\"Enslig person med barn\",\"\",\"\",,,\"\"\n"
+ "\"CA\",\"C\",\"2\",\"Enslig person med barn 0-5 år\",\"\",\"\",,,\"\"\n"
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantIntegrationTest.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantIntegrationTest.java
index 881479f9..30c18fe4 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantIntegrationTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiVariantIntegrationTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.api.applicationtest;
-import com.jayway.restassured.http.ContentType;
+import io.restassured.http.ContentType;
import no.ssb.klass.testutil.TestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -242,7 +242,7 @@ public void restServiceVariantCSV() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\","
+ "\"validFrom\",\"validTo\",\"validFromInRequestedRange\",\"validToInRequestedRange\",\"notes\"\n"
+ "\"A\",,\"1\",\"Enpersonfamilie\",\"\",\"\",,,\"2014-01-01\",,\"\"\n"
@@ -263,7 +263,7 @@ public void restServiceVariantIncludeFutureVersionsCSV() {
.then()
.statusCode(HttpStatus.OK.value())
.contentType(CONTENT_TYPE_CSV)
- .content(containsString(
+ .body(containsString(
"\"code\",\"parentCode\",\"level\",\"name\",\"shortName\",\"presentationName\","
+ "\"validFrom\",\"validTo\",\"validFromInRequestedRange\",\"validToInRequestedRange\",\"notes\"\n"
+ "\"A\",,\"1\",\"Enpersonfamilie\",\"\",\"\",,,\"2014-01-01\",\""+TestDataProvider.TEN_YEARS_LATER_DATE+"\",\"\"\n"
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/config/ApplicationTestConfig.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/config/ApplicationTestConfig.java
index 4c06711f..41b911d0 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/config/ApplicationTestConfig.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/config/ApplicationTestConfig.java
@@ -10,14 +10,13 @@
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import no.ssb.klass.core.repository.ClassificationSeriesRepository;
import no.ssb.klass.core.service.SearchService;
import no.ssb.klass.core.service.SearchServiceImpl;
import no.ssb.klass.core.service.UserService;
import no.ssb.klass.core.service.UserServiceMock;
-import no.ssb.klass.api.applicationtest.utils.ApplicationTestUtil;
+import org.springframework.security.web.SecurityFilterChain;
/**
* @author Mads Lundemo, SSB.
@@ -43,16 +42,12 @@ public SearchService searchService(ClassificationSeriesRepository seriesReposito
return new SearchServiceImpl(seriesRepository);
}
- @Bean
- public ApplicationTestUtil applicationTestUtil() {
- return new ApplicationTestUtil();
- }
-
@Configuration
- static class TestSecurityConfiguration extends WebSecurityConfigurerAdapter {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
+ static class TestSecurityConfiguration {
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").permitAll();
+ return http.build();
}
}
}
diff --git a/klass-api/src/test/java/no/ssb/klass/api/config/MockConfig.java b/klass-api/src/test/java/no/ssb/klass/api/config/MockConfig.java
index 3520f71e..a725373b 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/config/MockConfig.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/config/MockConfig.java
@@ -3,53 +3,51 @@
import no.ssb.klass.api.controllers.validators.CsvFieldsValidator;
import no.ssb.klass.core.service.*;
import no.ssb.klass.api.controllers.ClassificationController;
-import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
+import static org.mockito.Mockito.*;
+
public class MockConfig {
-
+
@Autowired
private ClassificationService classificationService;
-
+
@Autowired
private SubscriberService subscriberService;
-
+
@Autowired
private SearchService searchService;
-
- @Autowired
- private StatisticsService statisticsService;
@Autowired
- private UserService userService;
+ private StatisticsService statisticsService;
@Autowired
private CsvFieldsValidator csvFieldsValidator;
@Bean
public ClassificationService classificationService() {
- return Mockito.mock(ClassificationService.class);
+ return mock(ClassificationService.class);
}
@Bean
public SubscriberService subscriberService() {
- return Mockito.mock(SubscriberService.class);
+ return mock(SubscriberService.class);
}
@Bean
public SearchService searchService() {
- return Mockito.mock(SearchService.class);
+ return mock(SearchService.class);
}
@Bean
public StatisticsService statisticsService() {
- return Mockito.mock(StatisticsService.class);
+ return mock(StatisticsService.class);
}
@Bean
public UserService userService() {
- return Mockito.mock(UserService.class);
+ return mock(UserService.class);
}
@Bean
diff --git a/klass-api/src/test/java/no/ssb/klass/api/converters/CodeListCsvConverterTest.java b/klass-api/src/test/java/no/ssb/klass/api/converters/CodeListCsvConverterTest.java
index 0a874f7f..3242ff07 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/converters/CodeListCsvConverterTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/converters/CodeListCsvConverterTest.java
@@ -7,31 +7,30 @@
import no.ssb.klass.core.util.TimeUtil;
import no.ssb.klass.testutil.ConstantClockSource;
import no.ssb.klass.testutil.TestUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpOutputMessage;
import org.springframework.mock.http.MockHttpOutputMessage;
import java.util.Arrays;
import java.util.Date;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class CodeListCsvConverterTest {
private CodeListCsvConverter subject;
private Date now;
- @Before
+ @BeforeEach
public void setup() {
now = new Date();
TimeUtil.setClockSource(new ConstantClockSource(now));
subject = new CodeListCsvConverter();
}
- @After
+ @AfterEach
public void teardown() {
TimeUtil.revertClockSource();
}
@@ -42,9 +41,10 @@ public void supports() {
assertFalse(subject.supports(CodeListCsvConverterTest.class));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void readInternal() {
- subject.readInternal(null, null);
+ Assertions.assertThrows(UnsupportedOperationException.class, () ->
+ subject.readInternal(null, null));
}
@Test
diff --git a/klass-api/src/test/java/no/ssb/klass/api/dto/CodeChangeItemTest.java b/klass-api/src/test/java/no/ssb/klass/api/dto/CodeChangeItemTest.java
index ec49c4cb..f6c5a500 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/dto/CodeChangeItemTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/dto/CodeChangeItemTest.java
@@ -1,7 +1,7 @@
package no.ssb.klass.api.dto;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import no.ssb.klass.core.model.ClassificationItem;
import no.ssb.klass.core.model.ConcreteClassificationItem;
diff --git a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ChangelogResourceTest.java b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ChangelogResourceTest.java
index ecba6d6b..e568c201 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ChangelogResourceTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ChangelogResourceTest.java
@@ -1,10 +1,10 @@
package no.ssb.klass.api.dto.hal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.Lists;
diff --git a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationResourceTest.java b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationResourceTest.java
index 61de61cd..49faf368 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationResourceTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationResourceTest.java
@@ -1,9 +1,9 @@
package no.ssb.klass.api.dto.hal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -15,7 +15,7 @@
public class ClassificationResourceTest {
- @Before
+ @BeforeEach
public void setup() {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
}
@@ -25,6 +25,7 @@ public void create() {
// given
final long id = 1;
final String name = "name";
+ final String basePath = "/api/klass";
// when
ClassificationResource subject = new ClassificationResource(createClassification(id, name), Language
@@ -32,8 +33,16 @@ public void create() {
// then
assertEquals(name, subject.getName());
- assertEquals("http://localhost" + RestConstants.API_VERSION_V1 + "/classifications/" + id, subject.getLink("self")
- .getHref());
+ assertEquals("http://localhost" + basePath + RestConstants.API_VERSION_V1 + "/classifications/" + id, subject.getLink("self").orElseThrow(() ->
+ new RuntimeException("No link found")).getHref());
+ assertEquals("http://localhost" + basePath + RestConstants.API_VERSION_V1 + "/classifications/" + id + "/variant"
+ + "{?variantName,from=,to=,csvSeparator,level,selectCodes,presentationNamePattern}",
+ subject.getLink("variant").orElseThrow(() ->
+ new RuntimeException("No link found")).getHref());
+ assertEquals("http://localhost" + basePath + RestConstants.API_VERSION_V1 + "/classifications/" + id + "/variantAt"
+ + "{?variantName,date=,csvSeparator,level,selectCodes,presentationNamePattern}",
+ subject.getLink("variantAt").orElseThrow(() ->
+ new RuntimeException("No link found")).getHref());
assertEquals(0, subject.getVersions().size());
}
diff --git a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationVersionResourceTest.java b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationVersionResourceTest.java
index faf366f9..ce801cc7 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationVersionResourceTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ClassificationVersionResourceTest.java
@@ -1,12 +1,12 @@
package no.ssb.klass.api.dto.hal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.LinkedList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -20,7 +20,7 @@
public class ClassificationVersionResourceTest {
- @Before
+ @BeforeEach
public void before() {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
}
@@ -36,8 +36,9 @@ public void create() {
new LinkedList<>(), false);
// then
- assertEquals(1, subject.getLinks().size());
- assertEquals("http://localhost" + RestConstants.API_VERSION_V1 + "/versions/1", subject.getLink("self").getHref());
+ assertEquals(1, subject.getLinks().toList().size());
+ assertEquals("http://localhost/api/klass" + RestConstants.API_VERSION_V1 + "/versions/1",
+ subject.getLink("self").orElseThrow(() ->new RuntimeException("No link found")).getHref());
assertEquals(version.getName(Language.getDefault()), subject.getName());
}
diff --git a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/CorrespondenceItemListTest.java b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/CorrespondenceItemListTest.java
index ac35f1ea..5ed17feb 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/CorrespondenceItemListTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/CorrespondenceItemListTest.java
@@ -1,12 +1,12 @@
package no.ssb.klass.api.dto.hal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import no.ssb.klass.api.dto.CorrespondenceItem;
import no.ssb.klass.api.dto.CorrespondenceItem.RangedCorrespondenceItem;
import no.ssb.klass.api.dto.CorrespondenceItemList;
import no.ssb.klass.core.util.DateRange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
diff --git a/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ResourceUtilTest.java b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ResourceUtilTest.java
new file mode 100644
index 00000000..74b9f4e6
--- /dev/null
+++ b/klass-api/src/test/java/no/ssb/klass/api/dto/hal/ResourceUtilTest.java
@@ -0,0 +1,19 @@
+package no.ssb.klass.api.dto.hal;
+
+import no.ssb.klass.api.controllers.ClassificationController;
+import org.junit.jupiter.api.Test;
+import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class ResourceUtilTest {
+ @Test
+ public void createSearchLinkUsingTemplate() {
+ WebMvcLinkBuilder linkBuilder = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class)
+ .search("query", null, true, null, null));
+ String link = ResourceUtil.createUriTemplate(linkBuilder, "query", "includeCodelists").toString();
+ // For some reason, the link is different when running the test from command line and from IDE
+ link = link.replace("http://localhost", "");
+ assertEquals("/api/klass/v1/classifications/search{?query,includeCodelists}", link);
+ }
+}
diff --git a/klass-api/src/test/java/no/ssb/klass/api/util/PresentationNameBuilderTest.java b/klass-api/src/test/java/no/ssb/klass/api/util/PresentationNameBuilderTest.java
index 130fa252..c0a55ae7 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/util/PresentationNameBuilderTest.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/util/PresentationNameBuilderTest.java
@@ -1,8 +1,8 @@
package no.ssb.klass.api.util;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class PresentationNameBuilderTest {
diff --git a/klass-forvaltning/pom.xml b/klass-forvaltning/pom.xml
index fedc2ffd..83bdd69e 100644
--- a/klass-forvaltning/pom.xml
+++ b/klass-forvaltning/pom.xml
@@ -5,13 +5,44 @@
Klass ForvaltningForvaltningsgrensesnitt for Klassklass-forvaltning
+ 2.1.8-SNAPSHOTwar
+
+ 1.8
+ statisticsnorway/klass
+
+ 2.1.7
+
+ 7.7.17
+ 7.7.25
+ 7.7.14
+ local
+ 1.0.0
+ 0.0.7.RELEASE
+
+
+ 5.2.3.Final
+
+
+ 4.1.1
+
+ 1.2.1.RELEASE
+ 5.5.5
+ 2.1.0.RELEASE
+
+
- no.ssb.klass
- klass-root
- 2.1.8-SNAPSHOT
- ../
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.4.4.RELEASE
+
@@ -19,6 +50,10 @@
vaadin-addonshttps://maven.vaadin.com/vaadin-addons
+
+ github
+ https://maven.pkg.github.com/${github.repository}
+
@@ -26,12 +61,17 @@
no.ssb.klassklass-shared
- ${project.parent.version}
+ ${klass-version}no.ssb.klassklass-solr
- ${project.parent.version}
+ ${klass-version}
+
+
+ org.springframework.data
+ spring-data-solr
+ ${spring-data-solr-version}
@@ -98,7 +138,7 @@
klass-sharedtest-jartest
- ${project.parent.version}
+ ${klass-version}
@@ -106,7 +146,7 @@
klass-solrtest-jartest
- ${project.parent.version}
+ ${klass-version}
@@ -114,6 +154,18 @@
spring-boot-starter-testtest
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.8.2
+ test
+
+
+ org.mockito
+ mockito-junit-jupiter
+ 4.5.1
+ test
+ com.vaadin
@@ -128,6 +180,54 @@
+
+
+
+ com.vaadin
+ vaadin-bom
+ ${vaadin-version}
+ pom
+ import
+
+
+
+
+
+ nexus
+
+
+ releases
+ https://nexus.ssb.no/repository/maven-releases
+
+
+ snapshots
+ https://nexus.ssb.no/repository/maven-snapshots
+ false
+
+
+
+
+
+ ssb-repo
+ Nexus
+ https://nexus.ssb.no/repository/maven-public
+
+
+
+
+ github
+
+
+ github
+ GitHub Packages
+ https://maven.pkg.github.com/${github.repository}
+
+ true
+
+
+
+
+ klass#admin-${project.version}
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/KlassForvaltningApplication.java b/klass-forvaltning/src/main/java/no/ssb/klass/KlassForvaltningApplication.java
index 488ba1e9..1f71c8d8 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/KlassForvaltningApplication.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/KlassForvaltningApplication.java
@@ -4,9 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
// CHECKSTYLE:OFF
diff --git a/klass-forvaltning/src/main/resources/application-h2.properties b/klass-forvaltning/src/main/resources/application-h2.properties
index 5201e77b..f2bc22a7 100644
--- a/klass-forvaltning/src/main/resources/application-h2.properties
+++ b/klass-forvaltning/src/main/resources/application-h2.properties
@@ -1,4 +1,4 @@
-spring.datasource.url=jdbc:h2:~/.h2/klassdb;MODE=MySQL
+spring.datasource.url=jdbc:h2:~/.h2/klassdb;MODE=MySQL;INIT=CREATE SCHEMA IF NOT EXISTS "public"
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverclassName=org.h2.Driver
diff --git a/klass-forvaltning/src/main/resources/application.properties b/klass-forvaltning/src/main/resources/application.properties
index 2df9e715..ca4a2c3c 100644
--- a/klass-forvaltning/src/main/resources/application.properties
+++ b/klass-forvaltning/src/main/resources/application.properties
@@ -71,5 +71,5 @@ spring.mail.host=mail.example.com
spring.mail.properties.mail.from=noreply@example.com
-spring.jpa.properties.hibernate.ejb.interceptor=no.ssb.klass.core.util.BaseEntityInterceptor
+spring.jpa.properties.hibernate.session_factory.interceptor=no.ssb.klass.core.util.BaseEntityInterceptor
spring.jackson.serialization.indent_output=true
diff --git a/klass-forvaltning/src/main/webapp/VAADIN/themes/klasstheme/styles.css b/klass-forvaltning/src/main/webapp/VAADIN/themes/klasstheme/styles.css
index 9a211de5..f4700975 100644
--- a/klass-forvaltning/src/main/webapp/VAADIN/themes/klasstheme/styles.css
+++ b/klass-forvaltning/src/main/webapp/VAADIN/themes/klasstheme/styles.css
@@ -3070,7 +3070,7 @@ div.v-layout.v-horizontal.v-widget {
text-align: center;
top: 50%;
line-height: 1;
- margin-top: -0.47em;
+ margin-top: −0.47em;
}
.klasstheme .v-filterselect [class$="button"]:hover:before {
@@ -3547,7 +3547,7 @@ div.v-layout.v-horizontal.v-widget {
text-align: center;
top: 50%;
line-height: 1;
- margin-top: -0.47em;
+ margin-top: −0.47em;
}
.klasstheme .v-filterselect-tiny [class$="button"]:active:after {
@@ -3674,7 +3674,7 @@ div.v-layout.v-horizontal.v-widget {
text-align: center;
top: 50%;
line-height: 1;
- margin-top: -0.47em;
+ margin-top: −0.47em;
}
.klasstheme .v-filterselect-compact [class$="button"]:active:after, .klasstheme .v-filterselect-small [class$="button"]:active:after {
@@ -3806,7 +3806,7 @@ div.v-layout.v-horizontal.v-widget {
text-align: center;
top: 50%;
line-height: 1;
- margin-top: -0.47em;
+ margin-top: −0.47em;
}
.klasstheme .v-filterselect-large [class$="button"]:active:after {
@@ -3934,7 +3934,7 @@ div.v-layout.v-horizontal.v-widget {
text-align: center;
top: 50%;
line-height: 1;
- margin-top: -0.47em;
+ margin-top: −0.47em;
}
.klasstheme .v-filterselect-huge [class$="button"]:active:after {
@@ -4160,7 +4160,7 @@ div.v-layout.v-horizontal.v-widget {
left: 0;
right: 0;
width: auto !important;
- margin-top: -0.5em;
+ margin-top: −0.5em;
padding-bottom: 0.5em;
border-bottom: 1px solid #dfdfdf;
}
@@ -7516,12 +7516,12 @@ div.v-layout.v-horizontal.v-widget {
content: "\f078";
font-size: 0.7em;
vertical-align: 0.15em;
- margin: 0 -0.2em 0 0.5em;
+ margin: 0 −0.2em 0 0.5em;
opacity: 0.5;
}
.klasstheme .v-menubar .v-menubar-submenu-indicator + .v-menubar-menuitem-caption:empty:after {
- margin-left: -0.2em;
+ margin-left: −0.2em;
}
.klasstheme .v-menubar-popup {
@@ -8900,7 +8900,7 @@ div.v-layout.v-horizontal.v-widget {
.v-ie8 .klasstheme .v-tree-node:before {
position: static;
- margin-left: -1.9em;
+ margin-left: −1.9em;
vertical-align: top;
content: "\f0da";
font-family: ThemeIcons;
@@ -11394,7 +11394,7 @@ div.v-layout.v-horizontal.v-widget {
content: "\2022";
color: #197de1;
font-size: 22px;
- margin-left: -0.07em;
+ margin-left: −0.07em;
}
.klasstheme .v-calendar .v-daterange {
@@ -11652,7 +11652,7 @@ div.v-layout.v-horizontal.v-widget {
margin-top: 1.4em;
margin-bottom: 1em;
- letter-spacing: -0.03em;
+ letter-spacing: −0.03em;
}
.klasstheme h2, .klasstheme .v-label-h2 {
@@ -11660,7 +11660,7 @@ div.v-layout.v-horizontal.v-widget {
margin-top: 1.6em;
margin-bottom: 0.77em;
- letter-spacing: -0.02em;
+ letter-spacing: −0.02em;
}
.klasstheme h3, .klasstheme .v-label-h3 {
@@ -11691,7 +11691,7 @@ div.v-layout.v-horizontal.v-widget {
}
.klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h1, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h1, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h2, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h2, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h3, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h3, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h4, .klasstheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h4, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h1, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h1, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h2, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h2, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h3, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h3, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h4, .klasstheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h4 {
- margin-top: -0.5em;
+ margin-top: −0.5em;
}
.klasstheme h1.no-margin, .klasstheme .v-label-h1.no-margin, .klasstheme h2.no-margin, .klasstheme .v-label-h2.no-margin, .klasstheme h3.no-margin, .klasstheme .v-label-h3.no-margin, .klasstheme h4.no-margin, .klasstheme .v-label-h4.no-margin {
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/ClassificationFacadeTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/ClassificationFacadeTest.java
index 8c57704e..b5ed2343 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/ClassificationFacadeTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/ClassificationFacadeTest.java
@@ -1,12 +1,12 @@
package no.ssb.klass.designer.service;
-import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.any;
import static org.mockito.Mockito.*;
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.core.model.Changelog;
import no.ssb.klass.core.model.ClassificationSeries;
@@ -25,7 +25,7 @@ public class ClassificationFacadeTest {
private SubscriberService subscriberServiceMock;
private ChangeLogService ChangeLogServiceMock;
- @Before
+ @BeforeEach
public void setup() {
subscriberServiceMock = mock(SubscriberService.class);
ChangeLogServiceMock = mock(ChangeLogService.class);
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/InformSubscribersTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/InformSubscribersTest.java
index 95268977..bffce6ad 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/InformSubscribersTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/service/InformSubscribersTest.java
@@ -1,10 +1,10 @@
package no.ssb.klass.designer.service;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.core.model.Changelog;
import no.ssb.klass.core.model.ClassificationSeries;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/AbstractTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/AbstractTestBench.java
index f4462561..2a28719c 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/AbstractTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/AbstractTestBench.java
@@ -67,9 +67,11 @@ public void setUp() throws Exception {
if (Strings.nullToEmpty(System.getProperty("useHeadless")).equals("true")) {
driver = new PhantomJSDriver();
} else {
- // driver = new FirefoxDriver();
+ driver = new FirefoxDriver();
+ /*
driver = new FirefoxDriver(new FirefoxBinary(new File(
"C:\\Users\\mlo\\Downloads\\FirefoxPortable\\FirefoxPortable.exe")), new FirefoxProfile());
+ */
}
driver.manage().window().setSize(new Dimension(1280, 800));
Parameters.setScreenshotErrorDirectory("target/testbench/errors");
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/BreadcrumbTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/BreadcrumbTestBench.java
index a7d90eec..0d5fbf60 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/BreadcrumbTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/BreadcrumbTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.designer.testbench.pages.ClassificationFamilyPage;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ChangeTableTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ChangeTableTestBench.java
index 3034505a..4564e08a 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ChangeTableTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ChangeTableTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
import no.ssb.klass.designer.testbench.pages.CreateCorrespondenceTablePage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationFamilyTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationFamilyTestBench.java
index cd8ffc39..8a7856f5 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationFamilyTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationFamilyTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.designer.testbench.pages.ClassificationFamilyPage;
import no.ssb.klass.designer.testbench.pages.GlobalFilterPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationTestBench.java
index d43f3557..2c760d59 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.core.model.ClassificationType;
import no.ssb.klass.core.model.Language;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVariantTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVariantTestBench.java
index 1b6b176f..3fe837bc 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVariantTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVariantTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.core.model.Language;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVersionTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVersionTestBench.java
index cd0c0b9e..15e99887 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVersionTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ClassificationVersionTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.core.model.Language;
import no.ssb.klass.core.util.DateRange;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/CorrespondenceTableTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/CorrespondenceTableTestBench.java
index fc2b050a..67cbb4c2 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/CorrespondenceTableTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/CorrespondenceTableTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.core.model.Language;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/FavoritesTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/FavoritesTestBench.java
index 304997dd..9ed43c53 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/FavoritesTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/FavoritesTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.designer.testbench.pages.ClassificationFamilyPage;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ListClassificationsTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ListClassificationsTestBench.java
index eb820285..f2c0fbd4 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ListClassificationsTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/ListClassificationsTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
import no.ssb.klass.designer.testbench.pages.GlobalFilterPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/SearchTestBench.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/SearchTestBench.java
index 74426667..191627e8 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/SearchTestBench.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/testbench/SearchTestBench.java
@@ -1,8 +1,8 @@
package no.ssb.klass.designer.testbench;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.designer.testbench.pages.ClassificationFamilyPage;
import no.ssb.klass.designer.testbench.pages.ClassificationListPage;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/DomainPropertyTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/DomainPropertyTest.java
index 30bd3ce4..3ff93b40 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/DomainPropertyTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/DomainPropertyTest.java
@@ -1,10 +1,10 @@
package no.ssb.klass.designer.util;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.beans.PropertyDescriptor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.BeanUtils;
public class DomainPropertyTest {
@@ -14,8 +14,8 @@ public void checkDomainProperties() {
for (DomainProperty domainProperty : DomainProperty.values()) {
PropertyDescriptor property = BeanUtils.getPropertyDescriptor(domainProperty.getClazz(), domainProperty
.getProperty());
- assertNotNull(createErrorMessage("No property: ", domainProperty), property);
- assertNotNull(createErrorMessage("No read method for property: ", domainProperty), property.getReadMethod());
+ assertNotNull(property, createErrorMessage("No property: ", domainProperty));
+ assertNotNull(property.getReadMethod(), createErrorMessage("No read method for property: ", domainProperty));
}
}
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/VaadinUtilTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/VaadinUtilTest.java
index dc93d3db..5b337c33 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/VaadinUtilTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/designer/util/VaadinUtilTest.java
@@ -1,11 +1,11 @@
package no.ssb.klass.designer.util;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.time.LocalDate;
import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVariantXmlServiceTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVariantXmlServiceTest.java
index c33192cc..82f02174 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVariantXmlServiceTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVariantXmlServiceTest.java
@@ -8,11 +8,11 @@
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import no.ssb.klass.forvaltning.converting.exception.ImportException;
import no.ssb.klass.core.model.ClassificationVariant;
@@ -28,7 +28,7 @@
/**
* @author Mads Lundemo, SSB.
*/
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ClassificationVariantXmlServiceTest {
@Mock
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVersionXmlServiceTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVersionXmlServiceTest.java
index 974cca36..c78aa58a 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVersionXmlServiceTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/ClassificationVersionXmlServiceTest.java
@@ -8,7 +8,7 @@
import no.ssb.klass.testutil.TestDataProvider;
import org.apache.commons.io.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.forvaltning.converting.exception.ImportException;
import no.ssb.klass.core.model.ClassificationSeries;
diff --git a/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/CorrespondenceTableXmlServiceTest.java b/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/CorrespondenceTableXmlServiceTest.java
index f50cfb0e..b22671f1 100644
--- a/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/CorrespondenceTableXmlServiceTest.java
+++ b/klass-forvaltning/src/test/java/no/ssb/klass/forvaltning/converting/xml/CorrespondenceTableXmlServiceTest.java
@@ -10,7 +10,7 @@
import no.ssb.klass.testutil.TestDataProvider;
import org.apache.commons.io.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import no.ssb.klass.forvaltning.converting.exception.ImportException;
import no.ssb.klass.core.model.ClassificationSeries;
diff --git a/klass-shared/pom.xml b/klass-shared/pom.xml
index b5b9258c..58fb7dfc 100644
--- a/klass-shared/pom.xml
+++ b/klass-shared/pom.xml
@@ -11,7 +11,7 @@
no.ssb.klassklass-root
- 2.1.8-SNAPSHOT
+ 3.0.0-SNAPSHOT
@@ -26,8 +26,6 @@
UTF-8UTF-8
- 1.8
-
3.0.53.3.04.3.7.RELEASE
@@ -35,26 +33,10 @@
19.04.4.13.12.0
- 2.9.0
- 1.5.5
+ 2.0.0.AM271.6.0
- 0.15.2
+ 2.5.02.2
-
-
-
- 5.2.3.Final
-
-
-
- 4.1.1
-
- 1.2.1.RELEASE
-
@@ -62,49 +44,8 @@
org.springframework.dataspring-data-solr
- 2.1.0.RELEASE
-
-
-
- org.apache.solr
- solr-solrj
- 5.5.5
-
-
-
- org.codehaus.woodstox
- wstx-asl
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.solr
- solr-dataimporthandler
- 5.5.0
-
-
-
- org.codehaus.woodstox
- wstx-asl
-
-
-
-
org.springframework.bootspring-boot-starter-data-jpa
@@ -117,6 +58,7 @@
com.h2databaseh2
+ 2.1.210com.google.guava
@@ -138,8 +80,9 @@
provided
- javax.servlet
- jstl
+ jakarta.servlet.jsp.jstl
+ jakarta.servlet.jsp.jstl-api
+ 3.0.0org.springframework.boot
@@ -162,6 +105,10 @@
org.flywaydbflyway-core
+
+ org.flywaydb
+ flyway-mysql
+ org.mariadb.jdbcmariadb-java-client
@@ -171,6 +118,12 @@
org.apache.directory.serverapacheds-server-jndi${apacheds-server-jndi-version}
+
+
+ antlr
+ antlr
+
+ com.fasterxml.jackson.dataformat
@@ -202,6 +155,19 @@
org.springframework.restdocsspring-restdocs-mockmvc
+ ${spring-restdocs-version}
+ test
+
+
+ org.springframework.restdocs
+ spring-restdocs-core
+
+
+
+
+ org.springframework.restdocs
+ spring-restdocs-core
+ ${spring-restdocs-version}test
@@ -216,12 +182,40 @@
${woodstox-version}
- com.jayway.restassured
+ io.rest-assuredrest-assured
- ${rest-assured-version}
+ test
+
+
+
+ org.apache.groovy
+ groovy-xml
+
+
+
+
+
+ io.rest-assured
+ xml-pathtest
-
+
+ javax.xml.bind
+ jaxb-api
+ ${jaxb-api-version}
+ provided
+
+
+ commons-io
+ commons-io
+ ${commons-io-version}
+
+
+ javax.interceptor
+ javax.interceptor-api
+ 1.2.2
+
@@ -294,25 +288,27 @@
-
+
- org.jvnet.jaxb2.maven2
- maven-jaxb2-plugin
+ org.codehaus.mojo
+ jaxb2-maven-plugin${maven-jaxb2-plugin-version}
- generate
+ xjc
- src/main/resources/xsd/ssb
+
+
+
@@ -329,7 +325,7 @@
-
+
@@ -351,7 +347,7 @@
-Pdocumentation -Dmaven.javadoc.skip=true
-
+
org.apache.tomcat.maventomcat7-maven-plugin
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/ldap/KlassUserDetails.java b/klass-shared/src/main/java/no/ssb/klass/core/ldap/KlassUserDetails.java
index 6ac7ccf8..57296978 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/ldap/KlassUserDetails.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/ldap/KlassUserDetails.java
@@ -93,4 +93,9 @@ public boolean isEnabled() {
public String getDn() {
return ldapUserDetails.getDn();
}
+
+ @Override
+ public void eraseCredentials() {
+ ldapUserDetails.eraseCredentials();
+ }
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/BaseEntity.java b/klass-shared/src/main/java/no/ssb/klass/core/model/BaseEntity.java
index aec1eef8..2b56439d 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/BaseEntity.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/BaseEntity.java
@@ -5,6 +5,7 @@
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PreUpdate;
@@ -15,7 +16,7 @@
@MappedSuperclass
public abstract class BaseEntity {
@Id
- @GeneratedValue
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private final String uuid;
@@ -71,7 +72,8 @@ public boolean equals(Object other) {
}
/**
- * Any initialisation needed after Hibernate has recreated instance. Typically initialise any transient fields.
+ * Any initialisation needed after Hibernate has recreated instance. Typically
+ * initialise any transient fields.
*/
public void init() {
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/Changelog.java b/klass-shared/src/main/java/no/ssb/klass/core/model/Changelog.java
index e69e06de..a8502d52 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/Changelog.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/Changelog.java
@@ -12,11 +12,11 @@
@Entity
public class Changelog extends BaseEntity {
@Column(nullable = false)
- private final Date changeOccured;
+ private Date changeOccured;
@Column(nullable = false)
- private final String changedBy;
+ private String changedBy;
@Column(length = 4096, nullable = false)
- private final String description;
+ private String description;
public Changelog(String changedBy, String description) {
this.changeOccured = TimeUtil.now();
@@ -24,6 +24,9 @@ public Changelog(String changedBy, String description) {
this.description = checkNotNull(description);
}
+ protected Changelog() {
+ }
+
public Date getChangeOccured() {
return changeOccured;
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationAccessCounter.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationAccessCounter.java
index c045274b..1997f739 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationAccessCounter.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationAccessCounter.java
@@ -5,13 +5,14 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
@Entity
public class ClassificationAccessCounter {
@Id
- @GeneratedValue
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationFamily.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationFamily.java
index 7b7adb71..421c10ca 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationFamily.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationFamily.java
@@ -7,12 +7,13 @@
import java.util.List;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
import org.hibernate.Hibernate;
import no.ssb.klass.core.util.Translatable;
@@ -24,11 +25,15 @@
public class ClassificationFamily extends BaseEntity {
public static final String BASE_ICON_PATH = "/icons/";
@Column(nullable = false)
- private final Translatable name;
+ @Convert(converter = TranslatablePersistenceConverter.class)
+ private Translatable name;
@Column(nullable = false)
- private final String iconName;
+ private String iconName;
@OneToMany(mappedBy = "classificationFamily", fetch = FetchType.LAZY)
- private final List classificationSeriesList;
+ private List classificationSeriesList;
+
+ public ClassificationFamily() {
+ }
public ClassificationFamily(Translatable name, String iconName) {
this.name = checkNotNull(name);
@@ -78,6 +83,7 @@ public List getClassificationSeriesBySectionAndClassificat
String section, ClassificationType classificationType) {
return getClassificationSeriesBySectionAndClassificationType(section, classificationType, false);
}
+
public List getClassificationSeriesBySectionAndClassificationType(String section,
ClassificationType classificationType, boolean publicOnly) {
// @formatter:off
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationItem.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationItem.java
index f67f2f7a..52db1e6a 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationItem.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationItem.java
@@ -1,5 +1,6 @@
package no.ssb.klass.core.model;
+import javax.persistence.Column;
import no.ssb.klass.core.util.AlphaNumericCompareUtil;
import java.time.LocalDate;
@@ -25,6 +26,7 @@ void setParent(ClassificationItem parent) {
/**
* @return code, never null
*/
+ @Column(nullable = false)
public abstract String getCode();
/**
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationSeries.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationSeries.java
index a6b8996d..63a808a6 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationSeries.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationSeries.java
@@ -12,6 +12,7 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -30,11 +31,13 @@
import no.ssb.klass.core.util.KlassResourceNotFoundException;
import no.ssb.klass.core.util.TimeUtil;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
import no.ssb.klass.core.util.AlphaNumericalComparator;
@Entity
@Table(indexes = {
- // These must be case insensitive (JPA does not support specifying function based indexes)
+ // These must be case insensitive (JPA does not support specifying function
+ // based indexes)
@Index(columnList = "name_no", name = "cs_name_no_idx", unique = true),
@Index(columnList = "name_nn", name = "cs_name_nn_idx", unique = true),
@Index(columnList = "name_en", name = "cs_name_en_idx", unique = true)
@@ -49,7 +52,8 @@ public class ClassificationSeries extends BaseEntity implements ClassificationEn
private static final String PREFIX_CODELIST_NN = "Kodeliste for ";
private static final String PREFIX_CODELIST_EN = "Codelist for ";
- // name is not stored as a Translatable since name is used in db queries for sorting and filtering
+ // name is not stored as a Translatable since name is used in db queries for
+ // sorting and filtering
@Column(name = "name_no")
private String nameNo;
@Column(name = "name_nn")
@@ -58,8 +62,9 @@ public class ClassificationSeries extends BaseEntity implements ClassificationEn
private String nameEn;
@Lob
@Column(columnDefinition = "text", nullable = false)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable description;
- @Column(nullable = false)
+ @Column(nullable = false, columnDefinition = "integer")
private Language primaryLanguage;
@Column(nullable = false)
private boolean copyrighted;
@@ -184,9 +189,9 @@ public ClassificationVersion getClassificationVersionDraft() {
/**
* drafts are excluded as they do not have a real date range.
- *
+ *
* @param dateRange
- * that versions should overlap
+ * that versions should overlap
* @return list of version that overlap provided DateRange
*/
public List getClassificationVersionsInRange(DateRange dateRange) {
@@ -207,10 +212,11 @@ public List getClassificationVersionsInRange(DateRange da
* drafts are excluded as they do not have a real date range.
*
* @param dateRange
- * that versions should overlap
+ * that versions should overlap
* @param includeFuture
- * if future version is included
- * @return list of version that overlap provided DateRange and futured versions if value is true
+ * if future version is included
+ * @return list of version that overlap provided DateRange and futured versions
+ * if value is true
*/
public List getClassificationVersionsInRange(DateRange dateRange, Boolean includeFuture) {
checkNotNull(dateRange);
@@ -219,7 +225,8 @@ public List getClassificationVersionsInRange(DateRange da
if (classificationVersion.isDraft()) {
continue;
}
- if (classificationVersion.getDateRange().overlaps(dateRange) && classificationVersion.showVersion(includeFuture)) {
+ if (classificationVersion.getDateRange().overlaps(dateRange)
+ && classificationVersion.showVersion(includeFuture)) {
results.add(classificationVersion);
}
}
@@ -245,9 +252,10 @@ public ClassificationVersion getVersionByRange(DateRange dateRange) {
}
/**
- * Find correspondenceTables that describes changes between versions of same classification, referred to as
+ * Find correspondenceTables that describes changes between versions of same
+ * classification, referred to as
* changeTables. A changeTable list changes between two classification versions.
- *
+ *
* @param dateRange
* @return
*/
@@ -256,7 +264,8 @@ public List getChangeTables(DateRange dateRange, Boolean in
List changeTables = new ArrayList<>();
List versions = getClassificationVersionsInRange(dateRange, includeFuture);
if (versions.size() < 2) {
- // Must have at least 2 versions to have a changeTable describing changes between versions
+ // Must have at least 2 versions to have a changeTable describing changes
+ // between versions
return changeTables;
}
sortVersionsByFromDate(versions);
@@ -307,7 +316,8 @@ public List getClassificationVersionsSortedByFromDateReve
return versions;
}
- // dont want to add yet another sort argument for something that is only used for 1 administration view
+ // dont want to add yet another sort argument for something that is only used
+ // for 1 administration view
// the alphanumerical sort algorithm is all ready a bit slow
private void moveDraftToTop(List versions) {
Optional find = versions.stream().filter(StatisticalClassification::isDraft).findAny();
@@ -384,17 +394,17 @@ public List getStatisticalUnits() {
private void setName(String name, Language language) {
switch (language) {
- case NB:
- nameNo = name;
- break;
- case NN:
- nameNn = name;
- break;
- case EN:
- nameEn = name;
- break;
- default:
- throw new IllegalArgumentException("Unknown language: " + language);
+ case NB:
+ nameNo = name;
+ break;
+ case NN:
+ nameNn = name;
+ break;
+ case EN:
+ nameEn = name;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown language: " + language);
}
}
@@ -465,27 +475,27 @@ public static String getNamePrefix(Language language, ClassificationType classif
public static String getKlassifikasjonPrefix(Language language) {
switch (language) {
- case NB:
- return PREFIX_CLASSIFICATION_NB;
- case NN:
- return PREFIX_CLASSIFICATION_NN;
- case EN:
- return PREFIX_CLASSIFICATION_EN;
- default:
- return "";
+ case NB:
+ return PREFIX_CLASSIFICATION_NB;
+ case NN:
+ return PREFIX_CLASSIFICATION_NN;
+ case EN:
+ return PREFIX_CLASSIFICATION_EN;
+ default:
+ return "";
}
}
public static String getKodelistePrefix(Language language) {
switch (language) {
- case NB:
- return PREFIX_CODELIST_NB;
- case NN:
- return PREFIX_CODELIST_NN;
- case EN:
- return PREFIX_CODELIST_EN;
- default:
- return "";
+ case NB:
+ return PREFIX_CODELIST_NB;
+ case NN:
+ return PREFIX_CODELIST_NN;
+ case EN:
+ return PREFIX_CODELIST_EN;
+ default:
+ return "";
}
}
@@ -495,9 +505,12 @@ public boolean isDeleted() {
@Override
public void setDeleted() {
- // Soft delete (where classification is only marked as deleted and not actually deleted from database) causes
- // problems with unique constraint on classification name. To ensure that a deleted classification will not
- // block further use of a classification name, a timestamp is added to the name of the deleted classification
+ // Soft delete (where classification is only marked as deleted and not actually
+ // deleted from database) causes
+ // problems with unique constraint on classification name. To ensure that a
+ // deleted classification will not
+ // block further use of a classification name, a timestamp is added to the name
+ // of the deleted classification
Date now = TimeUtil.now();
for (Language language : Language.getAllSupportedLanguages()) {
String name = getName(language);
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVariant.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVariant.java
index 8869e9fd..94b5645e 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVariant.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVariant.java
@@ -37,6 +37,9 @@ public ClassificationVariant(Translatable name, User contactPerson) {
super.addLevel(new Level(2));
}
+ protected ClassificationVariant() {
+ }
+
public void setClassificationVersion(ClassificationVersion classificationVersion) {
this.classificationVersion = classificationVersion;
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVersion.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVersion.java
index b2bd85c9..40d67c20 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVersion.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ClassificationVersion.java
@@ -8,16 +8,17 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
-import jdk.nashorn.internal.ir.annotations.Ignore;
import org.springframework.util.StringUtils;
import no.ssb.klass.core.util.DateRange;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
@Entity
@DiscriminatorValue("version")
@@ -25,17 +26,20 @@ public class ClassificationVersion extends StatisticalClassification {
@ManyToOne
private ClassificationSeries classification;
-
@OneToMany(cascade = CascadeType.ALL, mappedBy = "classificationVersion")
private List classificationVariants;
@Column(length = 4000)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable legalBase;
@Column(length = 4000)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable publications;
@Column(length = 4000)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable derivedFrom;
@Column(length = 4000)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable alias;
// For Hibernate
@@ -96,8 +100,6 @@ public ClassificationVersion copyClassificationVersion(DateRange dateRange) {
return newClassificationVersion;
}
-
-
public ClassificationSeries getClassification() {
return classification;
}
@@ -116,7 +118,6 @@ public ClassificationVariant findVariantByFullName(String variantName, Language
.findFirst().orElse(null);
}
-
@Override
public Language getPrimaryLanguage() {
return classification.getPrimaryLanguage();
@@ -136,10 +137,12 @@ public boolean isPublishedInAnyLanguage() {
}
/**
- * Use this method for displaying version (formatted output) When more than one given version exists for a given
- * year, the year is prefixed with the month (Exs: Bydeler 03-2014), note that if given version contains an alias
+ * Use this method for displaying version (formatted output) When more than one
+ * given version exists for a given
+ * year, the year is prefixed with the month (Exs: Bydeler 03-2014), note that
+ * if given version contains an alias
* value then this will be returned instead.
- *
+ *
* @return Formatted name
*/
public String getName(Language language) {
@@ -156,8 +159,6 @@ private String getGeneratedName(Language language) {
return StringUtils.capitalize(classification.getNameWithoutPrefix(language)) + ' ' + datePostfix;
}
-
-
@Override
public String getNameInPrimaryLanguage() {
return getName(classification.getPrimaryLanguage());
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ConcreteClassificationItem.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ConcreteClassificationItem.java
index afff75ac..d8415727 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ConcreteClassificationItem.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ConcreteClassificationItem.java
@@ -5,20 +5,25 @@
import java.time.LocalDate;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import com.google.common.base.Strings;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
@Entity
public class ConcreteClassificationItem extends ClassificationItem {
private String code;
@Column(length = 2048)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable officialName;
@Column(length = 1024)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable shortName;
@Column(length = 6000)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable notes;
@Column
@@ -65,7 +70,8 @@ public void setCode(String code) {
}
/**
- * @return official name for specified language, if none empty string is returned, never null
+ * @return official name for specified language, if none empty string is
+ * returned, never null
*/
@Override
public String getOfficialName(Language language) {
@@ -78,7 +84,8 @@ public void setOfficialName(String officialName, Language language) {
}
/**
- * @return short name for specified language, if none empty string is returned, never null
+ * @return short name for specified language, if none empty string is returned,
+ * never null
*/
@Override
public String getShortName(Language language) {
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceMap.java b/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceMap.java
index db05f9a9..91951b5f 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceMap.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceMap.java
@@ -27,6 +27,9 @@ public CorrespondenceMap(ClassificationItem source, ClassificationItem target) {
this.target = target;
}
+ protected CorrespondenceMap() {
+ }
+
public Optional getSource() {
return Optional.ofNullable(source);
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceTable.java b/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceTable.java
index 34b03f53..674d0d79 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceTable.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/CorrespondenceTable.java
@@ -10,6 +10,7 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
@@ -25,6 +26,7 @@
import no.ssb.klass.core.util.DateRange;
import no.ssb.klass.core.util.TimeUtil;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
@Entity
@Table(indexes = { @Index(columnList = "source_id", name = "ct_source_idx"),
@@ -32,24 +34,28 @@
public class CorrespondenceTable extends BaseEntity implements ClassificationEntityOperations, Publishable, Draftable {
@Lob
@Column(columnDefinition = "text", nullable = false)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable description;
private Published published;
@ManyToOne(optional = false, fetch = FetchType.LAZY)
- private final ClassificationVersion source;
- private final int sourceLevelNumber;
+ private ClassificationVersion source;
+ private int sourceLevelNumber;
@ManyToOne(optional = false, fetch = FetchType.LAZY)
- private final ClassificationVersion target;
- private final int targetLevelNumber;
+ private ClassificationVersion target;
+ private int targetLevelNumber;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "correspondenceTable")
- private final List correspondenceMaps;
+ private List correspondenceMaps;
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "correspondencetable_changelog", joinColumns = @JoinColumn(name = "correspondencetable_id"), inverseJoinColumns = @JoinColumn(name = "changelog_id"))
- private final List changelogs;
+ private List changelogs;
@Column(nullable = false)
private boolean deleted;
@Column(nullable = false)
private boolean draft;
+ protected CorrespondenceTable() {
+ }
+
/**
* Creates a CorrespondenceTable
*
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/Level.java b/klass-shared/src/main/java/no/ssb/klass/core/model/Level.java
index 2e6fc1e4..e9efe84b 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/Level.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/Level.java
@@ -7,16 +7,19 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
@Entity
public class Level extends BaseEntity {
@Column(nullable = false, length = 1000)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable name;
@Column(nullable = false)
private final int levelNumber;
@@ -43,14 +46,16 @@ public Level(int levelNumber, Translatable name) {
}
/**
- * @return name for specified language, if no name an empty string is returned, never null
+ * @return name for specified language, if no name an empty string is returned,
+ * never null
*/
public String getName(Language language) {
return name.getString(language);
}
/**
- * Not public since clients should add classificationItems through owning version/variant. This so that
+ * Not public since clients should add classificationItems through owning
+ * version/variant. This so that
* version/variant can enforce no duplicated codes.
*/
void addClassificationItem(ClassificationItem classificationItem) {
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/SearchWords.java b/klass-shared/src/main/java/no/ssb/klass/core/model/SearchWords.java
index 68d2c5ab..defa79a4 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/SearchWords.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/SearchWords.java
@@ -5,26 +5,27 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class SearchWords {
@Id
- @GeneratedValue
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
-
+
@Column(nullable = false)
Date timeStamp;
-
+
@Column(nullable = false)
boolean hit;
-
+
@Column(nullable = false)
String searchString;
-
+
public SearchWords() {
}
-
+
public SearchWords(String searchString, boolean hit) {
this.timeStamp = new Date();
this.searchString = searchString;
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalClassification.java b/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalClassification.java
index a9002398..ffd4a8a3 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalClassification.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalClassification.java
@@ -14,6 +14,7 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
@@ -26,6 +27,7 @@
import no.ssb.klass.core.util.DraftUtil;
import no.ssb.klass.core.util.TimeUtil;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
@Entity
public abstract class StatisticalClassification extends BaseEntity implements ClassificationEntityOperations,
@@ -33,6 +35,7 @@ public abstract class StatisticalClassification extends BaseEntity implements Cl
public static final int FIRST_LEVEL_NUMBER = 1;
@Lob
@Column(columnDefinition = "text", nullable = false)
+ @Convert(converter = TranslatablePersistenceConverter.class)
protected Translatable introduction;
private Published published;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "statisticalClassification")
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalUnit.java b/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalUnit.java
index 260f3a85..1aa3768d 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalUnit.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/StatisticalUnit.java
@@ -3,9 +3,11 @@
import static com.google.common.base.Preconditions.*;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import no.ssb.klass.core.util.Translatable;
+import no.ssb.klass.core.util.TranslatablePersistenceConverter;
/**
* @author Mads Lundemo, SSB.
@@ -13,6 +15,7 @@
@Entity
public class StatisticalUnit extends BaseEntity {
@Column(nullable = false)
+ @Convert(converter = TranslatablePersistenceConverter.class)
private Translatable name;
public StatisticalUnit(Translatable name) {
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/Subscription.java b/klass-shared/src/main/java/no/ssb/klass/core/model/Subscription.java
index d3415cf4..b07f0b50 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/Subscription.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/Subscription.java
@@ -22,17 +22,20 @@ public class Subscription extends BaseEntity {
private static final long ONE_MINUTE_IN_MILLISECS = 60000;
@Column(nullable = false)
- private final Date expiryDate;
+ private Date expiryDate;
@Column(nullable = false)
- private final String token;
+ private String token;
@Column(nullable = false)
- private final URL endSubscriptionUrl;
+ private URL endSubscriptionUrl;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Verification verification;
@ManyToOne
- private final ClassificationSeries classification;
+ private ClassificationSeries classification;
+
+ public Subscription() {
+ }
public Subscription(ClassificationSeries classification, URL endSubscriptionUrl) {
this.classification = checkNotNull(classification);
@@ -74,4 +77,4 @@ Verification verify() {
}
return verification;
}
-}
\ No newline at end of file
+}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/User.java b/klass-shared/src/main/java/no/ssb/klass/core/model/User.java
index ccc70529..688e3315 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/User.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/User.java
@@ -18,12 +18,12 @@
})
public class User extends BaseEntity {
@Column(nullable = false)
- private final String username;
+ private String username;
@Column(nullable = false)
private String fullname;
@Column(nullable = false)
private String section;
- @Column(nullable = false)
+ @Column(nullable = false, columnDefinition = "integer")
private Role role;
@Column
private String email;
@@ -32,7 +32,7 @@ public class User extends BaseEntity {
@ManyToMany
// Uses Set instead of List, see http://lkumarjain.blogspot.no/2013/07/why-hibernate-does-delete-all-entries.html
- private final Set favorites;
+ private Set favorites;
public User(String username, String fullname, String section) {
this.username = checkNotNull(username);
@@ -42,6 +42,9 @@ public User(String username, String fullname, String section) {
this.favorites = new HashSet<>();
}
+ protected User() {
+ }
+
public String getSection() {
return section;
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryImpl.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryImpl.java
index 1b850770..c13aaa83 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryImpl.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryImpl.java
@@ -13,20 +13,24 @@
import no.ssb.klass.core.util.TranslatablePersistenceConverter;
/**
- * Note: this class is only needed due to bug in Hibernate, see https://hibernate.atlassian.net/browse/HHH-7321.
+ * Note: this class is only needed due to bug in Hibernate, see
+ * https://hibernate.atlassian.net/browse/HHH-7321.
*
- * Because of this bug in hql, we are using native sql instead, and need to do the result mapping to
+ * Because of this bug in hql, we are using native sql instead, and need to do
+ * the result mapping to
* ClassificationFamilySummary manually.
*
- * If above bug is fixed then this class and the custom interface should be deleted and an hql query should be used
+ * If above bug is fixed then this class and the custom interface should be
+ * deleted and an hql query should be used
* instead.
*
- * Note: Above mentioned bug is fixed in Hibernate and is included in version 5.1. However Spring Boot is not yet using
+ * Note: Above mentioned bug is fixed in Hibernate and is included in version
+ * 5.1. However Spring Boot is not yet using
* this version (currently 5.0 of Hibernate)
- *
+ *
*
* A possible HQL that can be included in ClassificationFamilyRepository if bug is fixed, is shown below;
- *
+ *
* @Query("select new no.ssb.klass.core.repository.ClassificationFamilySummary(family.name, family.iconName, count(classification)) "
* + "from ClassificationFamily family "
* + "left join family.classificationSeriesList as classification with classification.deleted <> '1' "
@@ -49,11 +53,11 @@ public List findClassificationFamilySummaries(Strin
ClassificationType classificationType) {
List result = new ArrayList<>();
List