From 0f5b4138df1be1075aaf0250e515fed68bc2a1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn-Andre=20Skaar?= <31540110+bjornandre@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:01:22 +0100 Subject: [PATCH] Bump supported Java version and several libraries (#153) * Bump spring-boot-starter-parent from 1.4.4 ->2.7.8 (with Spring 5.3.31 and Solr 8.5.2). * Bump Java 8 -> Java 17 * Keep Java 8 for klass-forvaltning * Fix incorrect sql syntax * Upgrade jaxb2-maven-plugin * Removed solr-dataimporthandler as it conflicted with ANTLR version (and is hopefully not used) * Fix boolean comparison operator in JPA queries * Fix issues with H2 and reserved keywords * Fix JPQL boolean comparison * Fixed antlr conflicts * Specify Converter for fields of type Translatable * Implement no-args constructor for entity classes * Fixed native sqls for the user table and fixed an improper test. * Bump rest-assured version * Tables should be nullable * Fix changes in Spring HATEOAS * Fix tests due to changes in Spring HATEOAS * Fix CodeQL Analysis * Share maven cache * Make all classes Java 1.8 compatible in order to build klass-forvaltning. * Since klass-forvaltning uses Vaadin7 we must remove dependency to klass-root and continue using Spring Boot 1.4.4. * Use spring-data-solr 2.1.0.RELEASE * Turn off hibernate ddl validation since it appears buggy * Add http examples * Solr Core name must be part of the baseURL for some reason * Fix search links to include the base path * Add separate profiles for nexus and github * Add github packages repo * Add auth to github packages repo * Fix monitoring and ping paths to be less strict. Also fix links where basePath was missing. * Fix ordering of json structure * Use application/hal+json by default * Keep suffix pattern matching which Spring has disabled by default * Bump apacheds-server-jndi-version and set CORS header for klass-web * Expand self links so that klass-web can use the links directly * Ensure that links inherit https when running behind a LB/reverse proxy * Enforce https in API docs --------- Co-authored-by: mmwinther --- .github/workflows/codeql-analysis.yml | 30 +- .github/workflows/tests.yml | 23 +- Makefile | 2 +- klass-api/doc/requests/README.md | 21 + .../requests/examples-classifications.http | 54 + klass-api/doc/requests/http-client.env.json | 8 + klass-api/pom.xml | 59 +- klass-api/src/main/asciidoc/api-guide.adoc | 2 +- .../no/ssb/klass/KlassApiApplication.java | 8 +- .../api/config/KlassApiConfiguration.java | 13 +- .../controllers/ClassificationController.java | 45 +- .../api/controllers/MonitorController.java | 26 +- .../klass/api/controllers/PingController.java | 10 +- .../klass/api/dto/KlassPagedResources.java | 10 +- .../no/ssb/klass/api/dto/KlassResources.java | 12 +- .../dto/hal/ClassificationFamilyResource.java | 6 +- .../ClassificationFamilySummaryResource.java | 8 +- .../api/dto/hal/ClassificationResource.java | 37 +- .../hal/ClassificationSummaryResource.java | 8 +- .../hal/ClassificationVariantResource.java | 4 + .../ClassificationVariantSummaryResource.java | 6 +- .../hal/ClassificationVersionResource.java | 5 + .../ClassificationVersionSummaryResource.java | 6 +- .../dto/hal/CorrespondenceTableResource.java | 4 + .../CorrespondenceTableSummaryResource.java | 7 +- .../ssb/klass/api/dto/hal/KlassResource.java | 28 +- .../ssb/klass/api/dto/hal/ResourceUtil.java | 6 +- .../api/dto/hal/SearchResultResource.java | 8 +- .../klass/api/dto/hal/SsbSectionResource.java | 2 +- .../no/ssb/klass/api/util/RestConstants.java | 1 + .../application-h2-inmemory.properties | 2 +- .../main/resources/application-h2.properties | 4 +- .../application-remote-solr.properties | 2 +- .../src/main/resources/application.properties | 22 +- .../no/ssb/klass/api/ApiDocumentation.java | 1245 ++++++++--------- .../AbstractRestApiApplicationTest.java | 11 +- .../RestApiChangesIntegrationTest.java | 6 +- ...piClassificationFamilyIntegrationTest.java | 12 +- .../RestApiClassificationIntegrationTest.java | 10 +- .../RestApiCodeAtIntegrationTest.java | 14 +- .../RestApiCodeIntegrationTest.java | 10 +- ...piCorrespondenceTablesIntegrationTest.java | 34 +- .../RestApiCorrespondsAtIntegrationTest.java | 10 +- .../RestApiCorrespondsIntegrationTest.java | 12 +- .../RestApiDraftIntegrationTest.java | 10 +- .../RestApiErrorHandlingIntegrationTest.java | 6 +- ...stClassificationFamilyIntegrationTest.java | 6 +- ...tApiListClassificationIntegrationTest.java | 64 +- .../RestApiListSsbSectionIntegrationTest.java | 6 +- .../RestApiSearchIntegrationTest.java | 18 +- .../RestApiVariantAtIntegrationTest.java | 14 +- .../RestApiVariantIntegrationTest.java | 10 +- .../config/ApplicationTestConfig.java | 15 +- .../no/ssb/klass/api/config/MockConfig.java | 24 +- .../converters/CodeListCsvConverterTest.java | 20 +- .../ssb/klass/api/dto/CodeChangeItemTest.java | 4 +- .../api/dto/hal/ChangelogResourceTest.java | 4 +- .../dto/hal/ClassificationResourceTest.java | 21 +- .../ClassificationVersionResourceTest.java | 13 +- .../dto/hal/CorrespondenceItemListTest.java | 4 +- .../klass/api/dto/hal/ResourceUtilTest.java | 19 + .../api/util/PresentationNameBuilderTest.java | 4 +- klass-forvaltning/pom.xml | 116 +- .../klass/KlassForvaltningApplication.java | 2 - .../main/resources/application-h2.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../VAADIN/themes/klasstheme/styles.css | 26 +- .../service/ClassificationFacadeTest.java | 8 +- .../service/InformSubscribersTest.java | 4 +- .../designer/testbench/AbstractTestBench.java | 4 +- .../testbench/BreadcrumbTestBench.java | 4 +- .../testbench/ChangeTableTestBench.java | 4 +- .../ClassificationFamilyTestBench.java | 4 +- .../testbench/ClassificationTestBench.java | 4 +- .../ClassificationVariantTestBench.java | 4 +- .../ClassificationVersionTestBench.java | 4 +- .../CorrespondenceTableTestBench.java | 4 +- .../testbench/FavoritesTestBench.java | 4 +- .../ListClassificationsTestBench.java | 4 +- .../designer/testbench/SearchTestBench.java | 4 +- .../designer/util/DomainPropertyTest.java | 8 +- .../klass/designer/util/VaadinUtilTest.java | 4 +- .../ClassificationVariantXmlServiceTest.java | 8 +- .../ClassificationVersionXmlServiceTest.java | 2 +- .../CorrespondenceTableXmlServiceTest.java | 2 +- klass-shared/pom.xml | 144 +- .../ssb/klass/core/ldap/KlassUserDetails.java | 5 + .../no/ssb/klass/core/model/BaseEntity.java | 6 +- .../no/ssb/klass/core/model/Changelog.java | 9 +- .../model/ClassificationAccessCounter.java | 3 +- .../core/model/ClassificationFamily.java | 14 +- .../klass/core/model/ClassificationItem.java | 2 + .../core/model/ClassificationSeries.java | 99 +- .../core/model/ClassificationVariant.java | 3 + .../core/model/ClassificationVersion.java | 21 +- .../model/ConcreteClassificationItem.java | 11 +- .../klass/core/model/CorrespondenceMap.java | 3 + .../klass/core/model/CorrespondenceTable.java | 18 +- .../java/no/ssb/klass/core/model/Level.java | 9 +- .../no/ssb/klass/core/model/SearchWords.java | 13 +- .../core/model/StatisticalClassification.java | 3 + .../ssb/klass/core/model/StatisticalUnit.java | 3 + .../no/ssb/klass/core/model/Subscription.java | 13 +- .../java/no/ssb/klass/core/model/User.java | 9 +- .../ClassificationFamilyRepositoryImpl.java | 32 +- .../ClassificationSeriesRepository.java | 44 +- .../ClassificationVariantRepository.java | 2 +- .../repository/SearchWordsRepository.java | 4 +- .../repository/StatisticalUnitRepository.java | 4 +- .../core/repository/SubscriberRepository.java | 24 +- .../klass/core/repository/UserRepository.java | 18 +- .../service/ClassificationServiceImpl.java | 29 +- .../klass/core/service/SearchServiceImpl.java | 13 +- .../klass/core/service/UserServiceImpl.java | 15 +- .../initializer/stabas/StabasInitializer.java | 3 +- .../application-h2-inmemory.properties | 2 + .../src/main/resources/application.properties | 2 +- ...10__drop_column_in_correspondencetable.sql | 2 +- .../migration/V12__increase_column_size.sql | 2 +- ...correspondencetable_uses_level_numbers.sql | 12 +- ..._adding_phonenumber_and_email_to_users.sql | 4 +- .../V18__subscription_verify_column.sql | 2 +- .../main/resources/db/migration/V1__init.sql | 12 +- .../V20__adding_hierachy_timstamp.sql | 2 +- ...g_fields_to_make_room_for_longer_names.sql | 8 +- .../V25__remove_favorite_constraint.sql | 2 +- .../migration/V27__change_varchar_to_text.sql | 6 +- ...icalclassification_level_bidirectional.sql | 6 +- ...etable_correspondencemap_bidirectional.sql | 6 +- .../db/migration/V4__drop_deleted_columns.sql | 4 +- ..._remove_constraints_classificationitem.sql | 4 +- .../migration/V9__increase_column_sizes.sql | 14 +- .../core/ldap/ActiveDirectoryServiceTest.java | 24 +- .../core/model/ClassificationFamilyTest.java | 14 +- .../core/model/ClassificationSeriesTest.java | 15 +- .../core/model/ClassificationVariantTest.java | 4 +- .../core/model/ClassificationVersionTest.java | 31 +- .../core/model/CorrespondenceTableTest.java | 58 +- .../no/ssb/klass/core/model/LanguageTest.java | 4 +- .../ssb/klass/core/model/SubscriberTest.java | 45 +- .../klass/core/model/SubscriptionTest.java | 17 +- .../ClassificationAccessRepositoryTest.java | 16 +- .../ClassificationFamilyRepositoryTest.java | 17 +- .../ClassificationSeriesRepositoryTest.java | 37 +- .../CorrespondenceMapRepositoryTest.java | 31 +- .../CorrespondenceTableRepositoryTest.java | 14 +- ...ncingClassificationItemRepositoryTest.java | 43 +- .../repository/SearchWordsRepositoryTest.java | 14 +- .../StatisticalUnitRepositoryTest.java | 24 +- .../repository/SubscriberRepositoryTest.java | 17 +- .../core/repository/UserRepositoryTest.java | 12 +- .../ClassificationServiceImplTest.java | 112 +- .../service/StatisticsServiceImplTest.java | 26 +- .../core/service/SubscriberServiceTest.java | 19 +- .../core/util/BaseEntityInterceptorTest.java | 8 +- .../no/ssb/klass/core/util/DateRangeTest.java | 33 +- .../no/ssb/klass/core/util/TimeUtilTest.java | 4 +- .../TranslatablePersistenceConverterTest.java | 8 +- .../no/ssb/klass/datadok/DatadokTest.java | 6 +- klass-solr/pom.xml | 41 +- .../ssb/klass/solr/KlassSolrApplication.java | 1 - .../solr/config/KlassSearchConfiguration.java | 8 +- .../resources/solr/embedded/Klass/schema.xml | 11 +- .../solr/embedded/Klass/solrconfig.xml | 10 +- .../config/KlassSearchTestConfiguration.java | 4 +- pom.xml | 50 +- 166 files changed, 2129 insertions(+), 1658 deletions(-) create mode 100644 klass-api/doc/requests/README.md create mode 100644 klass-api/doc/requests/examples-classifications.http create mode 100644 klass-api/doc/requests/http-client.env.json create mode 100644 klass-api/src/test/java/no/ssb/klass/api/dto/hal/ResourceUtilTest.java create mode 100644 klass-shared/src/main/resources/application-h2-inmemory.properties 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.klass klass-root - 2.1.8-SNAPSHOT - + 3.0.0-SNAPSHOT @@ -30,8 +29,19 @@ no.ssb.klass klass-solr ${project.parent.version} + + + org.antlr + antlr4-runtime + + - + + com.h2database + h2 + runtime + + org.springframework.boot @@ -58,7 +68,12 @@ org.springframework.data spring-data-solr - + + javax.xml.bind + jaxb-api + ${jaxb-api-version} + provided + @@ -79,7 +94,6 @@ javax.servlet jstl - javax.el javax.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.restdocs spring-restdocs-mockmvc + ${spring-restdocs-version} + test + + + org.springframework.restdocs + spring-restdocs-core + + + + + org.springframework.restdocs + spring-restdocs-core + ${spring-restdocs-version} test com.jayway.jsonpath json-path - test - com.jayway.restassured + io.rest-assured rest-assured test + + + + 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 Forvaltning Forvaltningsgrensesnitt for Klass klass-forvaltning + 2.1.8-SNAPSHOT war + + 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-addons https://maven.vaadin.com/vaadin-addons + + github + https://maven.pkg.github.com/${github.repository} + @@ -26,12 +61,17 @@ no.ssb.klass klass-shared - ${project.parent.version} + ${klass-version} no.ssb.klass klass-solr - ${project.parent.version} + ${klass-version} + + + org.springframework.data + spring-data-solr + ${spring-data-solr-version} @@ -98,7 +138,7 @@ klass-shared test-jar test - ${project.parent.version} + ${klass-version} @@ -106,7 +146,7 @@ klass-solr test-jar test - ${project.parent.version} + ${klass-version} @@ -114,6 +154,18 @@ spring-boot-starter-test test + + 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.klass klass-root - 2.1.8-SNAPSHOT + 3.0.0-SNAPSHOT @@ -26,8 +26,6 @@ UTF-8 UTF-8 - 1.8 - 3.0.5 3.3.0 4.3.7.RELEASE @@ -35,26 +33,10 @@ 19.0 4.4.1 3.12.0 - 2.9.0 - 1.5.5 + 2.0.0.AM27 1.6.0 - 0.15.2 + 2.5.0 2.2 - - - - 5.2.3.Final - - - - 4.1.1 - - 1.2.1.RELEASE - @@ -62,49 +44,8 @@ org.springframework.data spring-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.boot spring-boot-starter-data-jpa @@ -117,6 +58,7 @@ com.h2database h2 + 2.1.210 com.google.guava @@ -138,8 +80,9 @@ provided - javax.servlet - jstl + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + 3.0.0 org.springframework.boot @@ -162,6 +105,10 @@ org.flywaydb flyway-core + + org.flywaydb + flyway-mysql + org.mariadb.jdbc mariadb-java-client @@ -171,6 +118,12 @@ org.apache.directory.server apacheds-server-jndi ${apacheds-server-jndi-version} + + + antlr + antlr + + com.fasterxml.jackson.dataformat @@ -202,6 +155,19 @@ org.springframework.restdocs spring-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-assured rest-assured - ${rest-assured-version} + test + + + + org.apache.groovy + groovy-xml + + + + + + io.rest-assured + xml-path test - + + 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 + + src/main/resources/xsd/ssb + @@ -329,7 +325,7 @@ - + @@ -351,7 +347,7 @@ -Pdocumentation -Dmaven.javadoc.skip=true - + org.apache.tomcat.maven tomcat7-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 rows = em.createNativeQuery(
-                // @formatter:off
+        // @formatter:off
                        "select family.id, family.name, family.icon_name, count(classification.id) from classification_family family "
                      + "left outer join classification_series classification on classification.classification_family_id=family.id "
-                     + "  and classification.deleted <> '1' "
-                     + "  and (:section is null or :section = (select user.section from user user where user.id = classification.contact_person_id)) "
+                     + "  and classification.deleted = false"
+                     + "  and (:section is null or :section = (select usr.section from user usr where usr.id = classification.contact_person_id)) "
                      + "  and (:classificationType is null or :classificationType = classification.classification_type) "
                      + "group by family.id"
                 // @formatter:on
@@ -78,13 +82,13 @@ public List findPublicClassificationFamilySummaries
       "select family.id, family.name, family.icon_name, count(DISTINCT(classification.id)) from classification_family family "
       + "  left outer join classification_series classification on classification.classification_family_id=family.id "
       + "  left outer join statistical_classification version on version.classification_id=classification.id "
-      + " where (version.published_en = '1' or version.published_no = '1' or version.published_nn = '1') "
-      + "    and version.deleted <> '1' "
-      + "    and classification.deleted <> '1' "
-      + "    and classification.copyrighted <> '1' "
+      + " where (version.published_en is true or version.published_no is true or version.published_nn is true) "
+      + "    and version.deleted is false "
+      + "    and classification.deleted is false "
+      + "    and classification.copyrighted is false "
       + "    and (:classificationType is null or :classificationType = classification.classification_type) "
       + "    and (:section is null or :section "
-      + "           = (select user.section from user user where user.id = classification.contact_person_id)) "
+      + "           = (select usr.section from user usr where usr.id = classification.contact_person_id)) "
       + "  group by family.id"
     // @formatter:on
         ).setParameter("section", section).setParameter("classificationType", classificationType == null ? null
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesRepository.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesRepository.java
index 3d0649ca..ea7a4c36 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesRepository.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesRepository.java
@@ -41,42 +41,42 @@ public interface ClassificationSeriesRepository extends JpaRepository findResponsibleSectionsWithPublishedVersions();
 
     @Query(value = "select count(*) from ClassificationSeries classification join classification.contactPerson user where "
-            + "classification.deleted is false" + CHECKPARAMETERS)
+            + "classification.deleted = false" + CHECKPARAMETERS)
     int finNumberOfClassifications(@Param("classificationType") ClassificationType classificationType,
             @Param("section") String section);
 
     @Query(value = "select count(distinct classification.id) from ClassificationVersion version join version.classification classification join "
-            + "classification.contactPerson user where classification.deleted is false and version.deleted is false "
-            + "and (version.published.published_no is true or "
-            + "version.published.published_nn is true or version.published.published_en is true)" + CHECKPARAMETERS)
+            + "classification.contactPerson user where classification.deleted = false and version.deleted = false "
+            + "and (version.published.published_no = true or "
+            + "version.published.published_nn = true or version.published.published_en = true)" + CHECKPARAMETERS)
     int findNumberOfPublishedClassifications(@Param("classificationType") ClassificationType classificationType,
             @Param("section") String section);
 
     @Query(value = "select count(version.id) from ClassificationVersion version join version.classification classification join "
-            + "classification.contactPerson user where classification.deleted is false and version.deleted is false "
-            + "and (version.published.published_no is true "
-            + "or version.published.published_nn is true or version.published.published_en is true)" + CHECKPARAMETERS)
+            + "classification.contactPerson user where classification.deleted = false and version.deleted = false "
+            + "and (version.published.published_no = true "
+            + "or version.published.published_nn = true or version.published.published_en = true)" + CHECKPARAMETERS)
     int findNumberOfPublishedVersionsAnyLanguages(@Param("classificationType") ClassificationType classificationType,
             @Param("section") String section);
 
     @Query(value = "select count(version.id) from ClassificationVersion version join version.classification classification join "
-            + "classification.contactPerson user where classification.deleted is false and version.deleted is false "
-            + "and version.published.published_no is true "
-            + "and version.published.published_nn is true and version.published.published_en is true" + CHECKPARAMETERS)
+            + "classification.contactPerson user where classification.deleted = false and version.deleted = false "
+            + "and version.published.published_no = true "
+            + "and version.published.published_nn = true and version.published.published_en = true" + CHECKPARAMETERS)
     int findNumberOfPublishedVersionsAllLanguages(@Param("classificationType") ClassificationType classificationType,
             @Param("section") String section);
 
     @Query(value = "select new no.ssb.klass.core.service.dto.ClassificationReportDto(classification, user) "
             + "from ClassificationSeries classification join classification.contactPerson user where "
-            + "classification.deleted is false" + CHECKPARAMETERS + " order by classification.id")
+            + "classification.deleted = false" + CHECKPARAMETERS + " order by classification.id")
     List getClassificationReport(
             @Param("classificationType") ClassificationType classificationType,
             @Param("section") String section);
 
     @Query(value = "select new no.ssb.klass.core.service.dto.ClassificationReportDto(classification, user) "
             + "from ClassificationVersion version join version.classification classification join "
-            + "classification.contactPerson user where classification.deleted is false and (version.published.published_no is true or "
-            + "version.published.published_nn is true or version.published.published_en is true)" + CHECKPARAMETERS
+            + "classification.contactPerson user where classification.deleted = false and (version.published.published_no = true or "
+            + "version.published.published_nn = true or version.published.published_en = true)" + CHECKPARAMETERS
             + " order by classification.id")
     List getPublishedClassificationReport(
             @Param("classificationType") ClassificationType classificationType,
@@ -84,9 +84,9 @@ List getPublishedClassificationReport(
 
     @Query(value = "select new no.ssb.klass.core.service.dto.ClassificationVersionReportDto(version, classification, user) "
             + "from ClassificationVersion version join version.classification classification join "
-            + "classification.contactPerson user where classification.deleted is false and version.deleted is false "
-            + "and (version.published.published_no is true "
-            + "or version.published.published_nn is true or version.published.published_en is true)" + CHECKPARAMETERS
+            + "classification.contactPerson user where classification.deleted = false and version.deleted = false "
+            + "and (version.published.published_no = true "
+            + "or version.published.published_nn = true or version.published.published_en = true)" + CHECKPARAMETERS
             + " order by version.id")
     List getPublishedVersionsAnyLanguages(
             @Param("classificationType") ClassificationType classificationType,
@@ -96,20 +96,20 @@ List getPublishedVersionsAnyLanguages(
             + "from ClassificationVersion version "
             + "  join version.classification classification "
             + "  join classification.contactPerson user "
-            + "where classification.deleted is false and version.deleted is false "
-            + "  and version.published.published_no is true "
-            + "  and version.published.published_nn is true and version.published.published_en is true "
+            + "where classification.deleted = false and version.deleted = false "
+            + "  and version.published.published_no = true "
+            + "  and version.published.published_nn = true and version.published.published_en = true "
             + CHECKPARAMETERS
             + "  order by version.id")
     List getPublishedVersionsAllLanguages(
             @Param("classificationType") ClassificationType classificationType,
             @Param("section") String section);
 
-    @Query(value = "select count(id) from ClassificationSeries where deleted is false and :user = contactPerson")
+    @Query(value = "select count(id) from ClassificationSeries where deleted = false and :user = contactPerson")
     int getNumberOfClassificationForUser(@Param("user") User user);
 
     @Modifying
-    @Query("update ClassificationSeries set contactPerson = :newUser where contactPerson = :oldUser and deleted is false")
+    @Query("update ClassificationSeries set contactPerson = :newUser where contactPerson = :oldUser and deleted = false")
     void updateUser(@Param("oldUser") User oldUser, @Param("newUser") User newUser);
 
     ClassificationSeries findByNameNoIgnoreCase(@Param("name") String name);
@@ -130,6 +130,6 @@ List getPublishedVersionsAllLanguages(
     void updateClassificationLastModified(@Param("classificationId") Long classificationId,
             @Param("timeStamp") Date timeStamp);
 
-    @Query("select distinct statisticalUnits from ClassificationSeries where deleted is false")
+    @Query("select distinct statisticalUnits from ClassificationSeries where deleted = false")
     List findAllClassificationStatisticalUnits();
 }
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationVariantRepository.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationVariantRepository.java
index f94ef092..2db4be3d 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationVariantRepository.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationVariantRepository.java
@@ -16,7 +16,7 @@ public interface ClassificationVariantRepository extends JpaRepository findByContactPerson(User contactPerson);
 
     @Modifying
-    @Query("update ClassificationVariant set contactPerson = :newUser where contactPerson = :oldUser and deleted is false")
+    @Query("update ClassificationVariant set contactPerson = :newUser where contactPerson = :oldUser and deleted = false")
     void updateUser(@Param("oldUser") User oldUser, @Param("newUser") User newUser);
 
 }
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/SearchWordsRepository.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/SearchWordsRepository.java
index bcefef96..92ec1f63 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/SearchWordsRepository.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/SearchWordsRepository.java
@@ -17,12 +17,12 @@ public interface SearchWordsRepository extends JpaRepository
     int getNumberOfSearchWords(@Param("fromDate") Date fromDate, @Param("toDate") Date toDate);
 
     @Query(value = "select count(*) from SearchWords sw "
-            + "where sw.hit is false and sw.timeStamp between :fromDate and :toDate")
+            + "where sw.hit = false and sw.timeStamp between :fromDate and :toDate")
     int getNumberOfMiss(@Param("fromDate") Date fromDate, @Param("toDate") Date toDate);
 
     @Query(value = "select new no.ssb.klass.core.service.dto.AccessCounterDto(sw.searchString, count(sw.searchString)) "
             + "from SearchWords sw "
-            + "where sw.hit is :hit and sw.timeStamp between :fromDate and :toDate group by sw.searchString "
+            + "where sw.hit = :hit and sw.timeStamp between :fromDate and :toDate group by sw.searchString "
             + "order by count(sw.searchString) desc, sw.searchString")
     Page getSearchWords(@Param("hit") Boolean hit,
             @Param("fromDate") Date fromDate, @Param("toDate") Date toDate, Pageable p);
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/StatisticalUnitRepository.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/StatisticalUnitRepository.java
index 58b1bccb..184910b4 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/StatisticalUnitRepository.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/StatisticalUnitRepository.java
@@ -19,12 +19,12 @@
 @Repository
 public interface StatisticalUnitRepository extends JpaRepository {
     @Query(value = "select new no.ssb.klass.core.service.dto.StatisticalUnitDto(su, count(cs)) "
-            + "from ClassificationSeries cs join cs.statisticalUnits su where cs.deleted is false group by su.name order by su.name")
+            + "from ClassificationSeries cs join cs.statisticalUnits su where cs.deleted = false group by su.name order by su.name")
     Page getStaticalUnitsOverView(Pageable p);
 
     @Query(value = "select new no.ssb.klass.core.service.dto.ClassificationReportDto(cs, user) "
             + "from ClassificationSeries cs join cs.statisticalUnits su join cs.contactPerson user "
-            + "where su=:statisticalUnit and cs.deleted is false")
+            + "where su=:statisticalUnit and cs.deleted = false")
     List getAllClassificationSeriesForStaticalUnit(
             @Param("statisticalUnit") StatisticalUnit statisticalUnit);
 
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/SubscriberRepository.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/SubscriberRepository.java
index d8410129..e6619c38 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/SubscriberRepository.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/SubscriberRepository.java
@@ -13,7 +13,6 @@
 import no.ssb.klass.core.model.ClassificationSeries;
 import no.ssb.klass.core.model.Subscriber;
 
-
 @Repository
 public interface SubscriberRepository extends JpaRepository {
     Optional findOneByEmail(String email);
@@ -36,22 +35,24 @@ public interface SubscriberRepository extends JpaRepository {
     @Query(value = "select new no.ssb.klass.core.service.dto.AccessCounterDto(s.email,count(s.email)) "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "group by s.email "
             + "order by count(s.email) desc,s.email")
     Page getSubscriberReportAll(Pageable p);
+
     @Query(value = "select new no.ssb.klass.core.service.dto.AccessCounterDto(s.email,count(s.email)) "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "and s.email LIKE '%ssb.no%' "
             + "group by s.email "
             + "order by count(s.email) desc,s.email")
     Page getSubscriberReportInternal(Pageable p);
+
     @Query(value = "select new no.ssb.klass.core.service.dto.AccessCounterDto(s.email, count(s.email)) "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "and s.email NOT LIKE '%ssb.no%' "
             + "group by s.email "
             + "order by count(s.email) desc,s.email")
@@ -64,10 +65,11 @@ public interface SubscriberRepository extends JpaRepository {
             + ") "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "group by substring(s.email, LOCATE('@', s.email)+1) "
             + "order by sub_count desc,name")
     Page getSubscriberDomainReportAll(Pageable p);
+
     @Query(value = "select  new no.ssb.klass.core.service.dto.SubscriberCounterDto"
             + "("
             + "substring(s.email, LOCATE('@', s.email)+1) as name,"
@@ -75,11 +77,12 @@ public interface SubscriberRepository extends JpaRepository {
             + ") "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "and s.email LIKE '%ssb.no%' "
             + "group by substring(s.email, LOCATE('@', s.email)+1) "
             + "order by sub_count desc,name")
     Page getSubscriberDomainReportInternal(Pageable p);
+
     @Query(value = "select  new no.ssb.klass.core.service.dto.SubscriberCounterDto"
             + "("
             + "substring(s.email, LOCATE('@', s.email)+1) as name,"
@@ -87,7 +90,7 @@ public interface SubscriberRepository extends JpaRepository {
             + ") "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "and s.email NOT LIKE '%ssb.no%' "
             + "group by substring(s.email, LOCATE('@', s.email)+1) "
             + "order by sub_count desc,name")
@@ -100,7 +103,7 @@ public interface SubscriberRepository extends JpaRepository {
             + ") "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "group by case c.primaryLanguage when 0 then c.nameNo when 1 then c.nameNn when 2 then c.nameEn end "
             + "order by sub_count desc,name")
     Page getSubscriberClassReportAll(Pageable p);
@@ -112,7 +115,7 @@ public interface SubscriberRepository extends JpaRepository {
             + ") "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "and s.email LIKE '%ssb.no%' "
             + "group by case c.primaryLanguage when 0 then c.nameNo when 1 then c.nameNn when 2 then c.nameEn end "
             + "order by sub_count desc,name")
@@ -125,11 +128,10 @@ public interface SubscriberRepository extends JpaRepository {
             + ") "
             + "from Subscriber s join s.subscriptions as su "
             + "join su.classification as c "
-            + "where c.deleted is false and su.verification = 'VALID' "
+            + "where c.deleted = false and su.verification = 'VALID' "
             + "and s.email NOT LIKE '%ssb.no%' "
             + "group by case c.primaryLanguage when 0 then c.nameNo when 1 then c.nameNn when 2 then c.nameEn end "
             + "order by sub_count desc,name")
     Page getSubscriberClassReportExternal(Pageable p);
 
-
 }
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/UserRepository.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/UserRepository.java
index 7ba6a255..d1d1bce5 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/UserRepository.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/UserRepository.java
@@ -1,6 +1,7 @@
 package no.ssb.klass.core.repository;
 
 import java.math.BigInteger;
+import java.util.Optional;
 import java.util.Set;
 
 import org.springframework.data.jpa.repository.JpaRepository;
@@ -12,11 +13,12 @@
 @Repository
 public interface UserRepository extends JpaRepository {
 
-    User findOneByUsername(String username);
+    Optional findOneByUsername(String username);
 
-    User findOneByFullname(String fullname);
+    Optional findOneByFullname(String fullname);
 
-    // Hibernate does not support UNION and other HQL alternatives might cause performance issues. [Using Native query]
+    // Hibernate does not support UNION and other HQL alternatives might cause
+    // performance issues. [Using Native query]
     @Query(value = "SELECT DISTINCT(u.id) FROM user AS u, classification_series AS c"
             + " WHERE c.deleted = false AND  c.contact_person_id = u.id"
             + " UNION "
@@ -28,11 +30,11 @@ public interface UserRepository extends JpaRepository {
             + " where"
             + "   variant.contact_person_id = u.id"
             + "   AND variant.dtype = 'variant'"
-            + "   And classification.deleted is false"
-            + "   And variant.deleted is false"
-            + "   AND version.deleted is false;",
-            nativeQuery = true)
-    // Native query returns BigInteger a Set definition wont change that, only confuse the reader.
+            + "   And classification.deleted = false"
+            + "   And variant.deleted = false"
+            + "   AND version.deleted = false;", nativeQuery = true)
+    // Native query returns BigInteger a Set definition wont change that, only
+    // confuse the reader.
     Set getUserIdsForUsersWithClassifications();
 
 }
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/service/ClassificationServiceImpl.java b/klass-shared/src/main/java/no/ssb/klass/core/service/ClassificationServiceImpl.java
index 90fea0a0..cfc8df04 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/service/ClassificationServiceImpl.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/service/ClassificationServiceImpl.java
@@ -115,8 +115,9 @@ public List findAllClassificationSeries() {
 
     @Override
     public ClassificationSeries getClassificationSeries(Long id) {
-        ClassificationSeries classificationSeries = classificationRepository.findOne(id);
-        if (classificationSeries == null || classificationSeries.isDeleted()) {
+        ClassificationSeries classificationSeries = classificationRepository.findById(id).orElseThrow(() -> new
+                KlassResourceNotFoundException("Classification not found with id = " + id));
+        if (classificationSeries.isDeleted()) {
             throw new KlassResourceNotFoundException("Classification not found with id = " + id);
         }
         Hibernate.initialize(classificationSeries.getClassificationVersions());
@@ -136,8 +137,9 @@ public ClassificationSeries getClassificationSeriesFullyInitialized(Long id) {
 
     @Override
     public ClassificationVariant getClassificationVariant(Long id) {
-        ClassificationVariant variant = classificationVariantRepository.findOne(id);
-        if (variant == null || variant.isDeleted()) {
+        ClassificationVariant variant = classificationVariantRepository.findById(id).orElseThrow(() -> new
+                KlassResourceNotFoundException("Classification Variant not found with id = " + id));
+        if (variant.isDeleted()) {
             throw new KlassResourceNotFoundException("Classification Variant not found with id = " + id);
         }
         Hibernate.initialize(variant.getLevels());
@@ -147,8 +149,9 @@ public ClassificationVariant getClassificationVariant(Long id) {
 
     @Override
     public ClassificationVersion getClassificationVersion(Long id) {
-        ClassificationVersion version = classificationVersionRepository.findOne(id);
-        if (version == null || version.isDeleted()) {
+        ClassificationVersion version = classificationVersionRepository.findById(id).orElseThrow(() -> new
+                KlassResourceNotFoundException("Classification Version not found with id = " + id));
+        if (version.isDeleted()) {
             throw new KlassResourceNotFoundException("Classification Version not found with id = " + id);
         }
         Hibernate.initialize(version.getLevels());
@@ -160,8 +163,9 @@ public ClassificationVersion getClassificationVersion(Long id) {
 
     @Override
     public CorrespondenceTable getCorrespondenceTable(long id) {
-        CorrespondenceTable correspondenceTable = correspondenceTableRepository.findOne(id);
-        if (correspondenceTable == null || correspondenceTable.isThisOrSourceOrTargetDeleted()) {
+        CorrespondenceTable correspondenceTable = correspondenceTableRepository.findById(id).orElseThrow(() -> new
+                KlassResourceNotFoundException("Correspondence Table not found with id = " + id));
+        if (correspondenceTable.isThisOrSourceOrTargetDeleted()) {
             throw new KlassResourceNotFoundException("Correspondence Table not found with id = " + id);
         }
         Hibernate.initialize(correspondenceTable.getSource().getLevels());
@@ -173,10 +177,8 @@ public CorrespondenceTable getCorrespondenceTable(long id) {
 
     @Override
     public ClassificationFamily getClassificationFamily(long id) {
-        ClassificationFamily classificationFamily = classificationFamilyRepository.findOne(id);
-        if (classificationFamily == null) {
-            throw new KlassResourceNotFoundException("ClassificationFamily not found with id = " + id);
-        }
+        ClassificationFamily classificationFamily = classificationFamilyRepository.findById(id).orElseThrow(() -> new
+                KlassResourceNotFoundException("ClassificationFamily not found with id = " + id));
         Hibernate.initialize(classificationFamily.getClassificationSeries());
         return classificationFamily;
     }
@@ -415,7 +417,8 @@ public Set findResponsibleSectionsWithPublishedVersions() {
     public void deleteNotIndexClassification(User user, ClassificationSeries classification)
             throws KlassMessageException {
         classification = reloadToAvoidLazyInitialization(classification);
-        user = userRepository.findOne(user.getId()); // get attached object
+        user = userRepository.findById(user.getId()).orElseThrow(() ->
+                new RuntimeException("User not found")); // get attached object
         checkAllowedToDelete(user, classification);
         classification.setDeleted();
         saveNotIndexClassification(classification);
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/service/SearchServiceImpl.java b/klass-shared/src/main/java/no/ssb/klass/core/service/SearchServiceImpl.java
index 233e3907..79c838ca 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/service/SearchServiceImpl.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/service/SearchServiceImpl.java
@@ -10,6 +10,7 @@
 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.Pageable;
 import org.springframework.data.solr.core.SolrTemplate;
 import org.springframework.data.solr.core.query.FacetAndHighlightQuery;
@@ -37,6 +38,8 @@
 @Service
 public class SearchServiceImpl implements SearchService {
     private static final Logger log = LoggerFactory.getLogger(SearchServiceImpl.class);
+    @Value("${klass.env.search.solr.core}")
+    protected String solrCore;
 
     private final ClassificationSeriesRepository classificationRepository;
 
@@ -51,7 +54,7 @@ public SearchServiceImpl(ClassificationSeriesRepository classificationRepository
     public FacetAndHighlightPage search(FacetAndHighlightQuery query) {
 
         Date start = TimeUtil.now();
-        FacetAndHighlightPage searchResults = solrTemplate.queryForFacetAndHighlightPage(query,
+        FacetAndHighlightPage searchResults = solrTemplate.queryForFacetAndHighlightPage(solrCore, query,
                 SolrSearchResult.class);
         log.info("Search for: '" + query + "' resulted in " + searchResults.getTotalElements() + " hits. Took (ms): "
                 + TimeUtil.millisecondsSince(start));
@@ -99,7 +102,7 @@ public FacetAndHighlightPage internalSearch(String query, Page
     }
 
     public void clearIndex() {
-        solrTemplate.delete(new SimpleQuery("*:*"));
+        solrTemplate.delete(solrCore, new SimpleQuery("*:*"));
     }
 
     @Async
@@ -146,7 +149,7 @@ public void indexSync(ClassificationSeries classification) {
             }
 
         }
-        solrTemplate.commit();
+        solrTemplate.commit(solrCore);
         log.info("Indexing: " + classification.getNameInPrimaryLanguage() + ". Took (ms): " + TimeUtil
                 .millisecondsSince(start));
     }
@@ -211,9 +214,9 @@ private void indexVariants(List variants, Language langua
 
     private void updateSolr(SoftDeletable entity, SolrInputDocument doc) {
         if (!entity.isDeleted()) {
-            solrTemplate.saveDocument(doc);
+            solrTemplate.saveDocument(solrCore, doc);
         } else {
-            solrTemplate.deleteById((String) doc.getField("uuid").getValue());
+            solrTemplate.deleteByIds(solrCore, (String) doc.getField("uuid").getValue());
         }
     }
 
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/service/UserServiceImpl.java b/klass-shared/src/main/java/no/ssb/klass/core/service/UserServiceImpl.java
index cdc631be..86dda318 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/service/UserServiceImpl.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/service/UserServiceImpl.java
@@ -2,6 +2,7 @@
 
 import java.math.BigInteger;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -49,7 +50,7 @@ public List getUsersWithClassifications() {
         Set userIds = userRepository.getUserIdsForUsersWithClassifications();
         List collect = userIds.stream().map(bigInteger -> bigInteger.longValueExact()).collect(Collectors
                 .toList());
-        return userRepository.findAll(collect);
+        return userRepository.findAllById(collect);
 
     }
 
@@ -65,14 +66,14 @@ public User getUserByUserName(String userName) {
 
     @Override
     public User getUserById(long userId) {
-        return initializeFavorites(userRepository.findOne(userId));
+        return initializeFavorites(userRepository.findById(userId));
     }
 
-    private User initializeFavorites(User user) {
-        if (user == null) {
-            return null;
+    private User initializeFavorites(Optional user) {
+        if (user.isPresent()) {
+            Hibernate.initialize(user.get().getFavorites());
+            return user.get();
         }
-        Hibernate.initialize(user.getFavorites());
-        return user;
+        return null;
     }
 }
diff --git a/klass-shared/src/main/java/no/ssb/klass/initializer/stabas/StabasInitializer.java b/klass-shared/src/main/java/no/ssb/klass/initializer/stabas/StabasInitializer.java
index 04c79a1d..d7865d08 100644
--- a/klass-shared/src/main/java/no/ssb/klass/initializer/stabas/StabasInitializer.java
+++ b/klass-shared/src/main/java/no/ssb/klass/initializer/stabas/StabasInitializer.java
@@ -11,11 +11,12 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import javax.persistence.EntityManager;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
+
+import javax.persistence.EntityManager;
 import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.apache.commons.lang3.StringUtils;
diff --git a/klass-shared/src/main/resources/application-h2-inmemory.properties b/klass-shared/src/main/resources/application-h2-inmemory.properties
new file mode 100644
index 00000000..47b48b42
--- /dev/null
+++ b/klass-shared/src/main/resources/application-h2-inmemory.properties
@@ -0,0 +1,2 @@
+# custom properties used when "h2-inmemory" Profile is used
+spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL;NON_KEYWORDS=user
diff --git a/klass-shared/src/main/resources/application.properties b/klass-shared/src/main/resources/application.properties
index 19aba98f..0ba3f962 100644
--- a/klass-shared/src/main/resources/application.properties
+++ b/klass-shared/src/main/resources/application.properties
@@ -1 +1 @@
-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
diff --git a/klass-shared/src/main/resources/db/migration/V10__drop_column_in_correspondencetable.sql b/klass-shared/src/main/resources/db/migration/V10__drop_column_in_correspondencetable.sql
index f5bd67a5..41adcefc 100644
--- a/klass-shared/src/main/resources/db/migration/V10__drop_column_in_correspondencetable.sql
+++ b/klass-shared/src/main/resources/db/migration/V10__drop_column_in_correspondencetable.sql
@@ -1,2 +1,2 @@
-ALTER TABLE correspondence_table DROP FOREIGN KEY fk_4tx0j45sopr6yj8wcedohj9w3;
+ALTER TABLE correspondence_table DROP CONSTRAINT fk_4tx0j45sopr6yj8wcedohj9w3;
 ALTER TABLE correspondence_table DROP COLUMN statistical_classification;
diff --git a/klass-shared/src/main/resources/db/migration/V12__increase_column_size.sql b/klass-shared/src/main/resources/db/migration/V12__increase_column_size.sql
index 324c0f05..3f11bb92 100644
--- a/klass-shared/src/main/resources/db/migration/V12__increase_column_size.sql
+++ b/klass-shared/src/main/resources/db/migration/V12__increase_column_size.sql
@@ -1,2 +1,2 @@
 -- Migrating classifications from Stabas requires some increased column sizes
-ALTER TABLE classification_item MODIFY official_name VARCHAR(2048);
+ALTER TABLE classification_item ALTER COLUMN official_name VARCHAR(2048);
diff --git a/klass-shared/src/main/resources/db/migration/V16__correspondencetable_uses_level_numbers.sql b/klass-shared/src/main/resources/db/migration/V16__correspondencetable_uses_level_numbers.sql
index 2abed74c..757a55ba 100644
--- a/klass-shared/src/main/resources/db/migration/V16__correspondencetable_uses_level_numbers.sql
+++ b/klass-shared/src/main/resources/db/migration/V16__correspondencetable_uses_level_numbers.sql
@@ -1,6 +1,6 @@
 -- CorrespondenceTables stores level number instead of a foreign key to level
-ALTER TABLE correspondence_table DROP FOREIGN KEY fk_cqdqwek3akelq2qqnhuydrkqr;
-ALTER TABLE correspondence_table DROP FOREIGN KEY fk_8bn11tm1gsou84v8kmoug6qyt;
+ALTER TABLE correspondence_table DROP CONSTRAINT fk_cqdqwek3akelq2qqnhuydrkqr;
+ALTER TABLE correspondence_table DROP CONSTRAINT fk_8bn11tm1gsou84v8kmoug6qyt;
 
 UPDATE correspondence_table ct SET ct.source_level_id = 
     COALESCE((SELECT l.level_number FROM level l WHERE l.id = ct.source_level_id), 0);
@@ -8,8 +8,8 @@ UPDATE correspondence_table ct SET ct.source_level_id =
 UPDATE correspondence_table ct SET ct.target_level_id = 
     COALESCE((SELECT l.level_number FROM level l WHERE l.id = ct.target_level_id), 0);
 
-ALTER TABLE correspondence_table CHANGE source_level_id source_level_number BIGINT;
-ALTER TABLE correspondence_table CHANGE target_level_id target_level_number BIGINT;
+ALTER TABLE correspondence_table ALTER COLUMN source_level_id RENAME TO source_level_number;
+ALTER TABLE correspondence_table ALTER COLUMN target_level_id RENAME TO target_level_number;
 
-ALTER TABLE correspondence_table MODIFY source_level_number INTEGER NOT NULL;
-ALTER TABLE correspondence_table MODIFY target_level_number INTEGER NOT NULL;
+ALTER TABLE correspondence_table ALTER COLUMN source_level_number INTEGER NOT NULL;
+ALTER TABLE correspondence_table ALTER COLUMN target_level_number INTEGER NOT NULL;
diff --git a/klass-shared/src/main/resources/db/migration/V17__adding_phonenumber_and_email_to_users.sql b/klass-shared/src/main/resources/db/migration/V17__adding_phonenumber_and_email_to_users.sql
index 20e21dea..04683456 100644
--- a/klass-shared/src/main/resources/db/migration/V17__adding_phonenumber_and_email_to_users.sql
+++ b/klass-shared/src/main/resources/db/migration/V17__adding_phonenumber_and_email_to_users.sql
@@ -1,2 +1,2 @@
-ALTER TABLE user ADD email VARCHAR(255) NULL;
-ALTER TABLE user ADD phone VARCHAR(255) NULL;
\ No newline at end of file
+ALTER TABLE "USER" ADD email VARCHAR(255) NULL;
+ALTER TABLE "USER" ADD phone VARCHAR(255) NULL;
diff --git a/klass-shared/src/main/resources/db/migration/V18__subscription_verify_column.sql b/klass-shared/src/main/resources/db/migration/V18__subscription_verify_column.sql
index e695e4f9..e081fdb1 100644
--- a/klass-shared/src/main/resources/db/migration/V18__subscription_verify_column.sql
+++ b/klass-shared/src/main/resources/db/migration/V18__subscription_verify_column.sql
@@ -1 +1 @@
-ALTER TABLE subscription MODIFY verification VARCHAR(255) NOT NULL;
+ALTER TABLE subscription ALTER COLUMN verification VARCHAR(255) NOT NULL;
diff --git a/klass-shared/src/main/resources/db/migration/V1__init.sql b/klass-shared/src/main/resources/db/migration/V1__init.sql
index 1a19a6ab..d7435579 100644
--- a/klass-shared/src/main/resources/db/migration/V1__init.sql
+++ b/klass-shared/src/main/resources/db/migration/V1__init.sql
@@ -166,7 +166,7 @@ CREATE TABLE subscription
      PRIMARY KEY (id)
   );
 
-CREATE TABLE user
+CREATE TABLE "USER"
   (
      id            BIGINT NOT NULL auto_increment,
      deleted       BIT NOT NULL,
@@ -205,10 +205,10 @@ CREATE INDEX ct_target_idx ON correspondence_table (target_id);
 ALTER TABLE subscriber
   ADD CONSTRAINT subscriber_email_idx UNIQUE (email);
 
-ALTER TABLE user
+ALTER TABLE "USER"
   ADD CONSTRAINT user_username_idx UNIQUE (username);
 
-CREATE INDEX user_fullname_idx ON user (fullname);
+CREATE INDEX user_fullname_idx ON "USER" (fullname);
 
 ALTER TABLE user_favorites
   ADD CONSTRAINT uk_dk8ngwbk9dgeuegrx1nuktdv1 UNIQUE (favorites_id);
@@ -231,7 +231,7 @@ ALTER TABLE classification_series
 
 ALTER TABLE classification_series
   ADD CONSTRAINT fk_jefvdo01kn4kq98m64ajli6y5 FOREIGN KEY (contact_person_id)
-  REFERENCES user (id);
+  REFERENCES "USER" (id);
 
 ALTER TABLE classification_series_statistical_units
   ADD CONSTRAINT fk_rfx4t7rjg3hykfr39xi8dvrdu FOREIGN KEY (statistical_units_id)
@@ -283,7 +283,7 @@ ALTER TABLE statistical_classification
 
 ALTER TABLE statistical_classification
   ADD CONSTRAINT fk_12hsnu91tsf1c8b4697tv1bts FOREIGN KEY (contact_person_id)
-  REFERENCES user (id);
+  REFERENCES "USER" (id);
 
 ALTER TABLE statistical_classification
   ADD CONSTRAINT fk_ie31cb245vkf1vhswws053s29 FOREIGN KEY (classification_id)
@@ -311,4 +311,4 @@ ALTER TABLE user_favorites
 
 ALTER TABLE user_favorites
   ADD CONSTRAINT fk_dx271ymxhckcafibaqijpda8h FOREIGN KEY (user_id) REFERENCES
-  user (id);
\ No newline at end of file
+  "USER" (id);
diff --git a/klass-shared/src/main/resources/db/migration/V20__adding_hierachy_timstamp.sql b/klass-shared/src/main/resources/db/migration/V20__adding_hierachy_timstamp.sql
index bb93cac0..03e6860a 100644
--- a/klass-shared/src/main/resources/db/migration/V20__adding_hierachy_timstamp.sql
+++ b/klass-shared/src/main/resources/db/migration/V20__adding_hierachy_timstamp.sql
@@ -1,3 +1,3 @@
 ALTER TABLE classification_series ADD hierarchy_last_modified DATETIME NULL;
 UPDATE classification_series SET hierarchy_last_modified = last_modified;
-ALTER TABLE classification_series MODIFY hierarchy_last_modified DATETIME NOT NULL;
\ No newline at end of file
+ALTER TABLE classification_series ALTER COLUMN hierarchy_last_modified DATETIME NOT NULL;
\ No newline at end of file
diff --git a/klass-shared/src/main/resources/db/migration/V24__resizing_fields_to_make_room_for_longer_names.sql b/klass-shared/src/main/resources/db/migration/V24__resizing_fields_to_make_room_for_longer_names.sql
index 6959157a..e343f674 100644
--- a/klass-shared/src/main/resources/db/migration/V24__resizing_fields_to_make_room_for_longer_names.sql
+++ b/klass-shared/src/main/resources/db/migration/V24__resizing_fields_to_make_room_for_longer_names.sql
@@ -1,8 +1,8 @@
 -- due to row limits of 65535  we need to reduce size for some fields to  be able to increase name field
 -- reduce
-ALTER TABLE statistical_classification MODIFY valid_from VARCHAR(16);
-ALTER TABLE statistical_classification MODIFY valid_to VARCHAR(16);
-ALTER TABLE statistical_classification MODIFY uuid VARCHAR(64) NOT NULL;
+ALTER TABLE statistical_classification ALTER COLUMN valid_from VARCHAR(16);
+ALTER TABLE statistical_classification ALTER COLUMN valid_to VARCHAR(16);
+ALTER TABLE statistical_classification ALTER COLUMN uuid VARCHAR(64) NOT NULL;
 
 -- increase
-ALTER TABLE statistical_classification MODIFY name VARCHAR(1000);
+ALTER TABLE statistical_classification ALTER COLUMN name VARCHAR(1000);
diff --git a/klass-shared/src/main/resources/db/migration/V25__remove_favorite_constraint.sql b/klass-shared/src/main/resources/db/migration/V25__remove_favorite_constraint.sql
index 8b7a8c65..d4eda067 100644
--- a/klass-shared/src/main/resources/db/migration/V25__remove_favorite_constraint.sql
+++ b/klass-shared/src/main/resources/db/migration/V25__remove_favorite_constraint.sql
@@ -9,7 +9,7 @@ CREATE TABLE user_favorites
   PRIMARY KEY (id)
 );
 ALTER TABLE user_favorites ADD CONSTRAINT fk_favorite_id FOREIGN KEY (favorites_id) REFERENCES classification_series (id);
-ALTER TABLE user_favorites ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES user (id);
+ALTER TABLE user_favorites ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES "USER" (id);
 INSERT INTO user_favorites (user_id, favorites_id) SELECT
                                                      user_id,
                                                      favorites_id
diff --git a/klass-shared/src/main/resources/db/migration/V27__change_varchar_to_text.sql b/klass-shared/src/main/resources/db/migration/V27__change_varchar_to_text.sql
index 85595158..69250e27 100644
--- a/klass-shared/src/main/resources/db/migration/V27__change_varchar_to_text.sql
+++ b/klass-shared/src/main/resources/db/migration/V27__change_varchar_to_text.sql
@@ -1,4 +1,4 @@
-ALTER TABLE correspondence_table MODIFY description TEXT NOT NULL;
-ALTER TABLE classification_series MODIFY description TEXT NOT NULL;
-ALTER TABLE statistical_classification MODIFY introduction TEXT NOT NULL;
+ALTER TABLE correspondence_table ALTER COLUMN description TEXT NOT NULL;
+ALTER TABLE classification_series ALTER COLUMN description TEXT NOT NULL;
+ALTER TABLE statistical_classification ALTER COLUMN introduction TEXT NOT NULL;
 
diff --git a/klass-shared/src/main/resources/db/migration/V2__statisticalclassification_level_bidirectional.sql b/klass-shared/src/main/resources/db/migration/V2__statisticalclassification_level_bidirectional.sql
index bda3e418..c47fc261 100644
--- a/klass-shared/src/main/resources/db/migration/V2__statisticalclassification_level_bidirectional.sql
+++ b/klass-shared/src/main/resources/db/migration/V2__statisticalclassification_level_bidirectional.sql
@@ -1,9 +1,11 @@
 -- renames a foreign key column
 
 ALTER TABLE level
-  DROP FOREIGN KEY fk_sxgu9ljubog3jnujn8fvohvn4;
+  DROP CONSTRAINT fk_sxgu9ljubog3jnujn8fvohvn4;
 
-ALTER TABLE level CHANGE statistical_classification statistical_classification_id BIGINT not null;
+ALTER TABLE level ALTER COLUMN statistical_classification RENAME TO statistical_classification_id;
+
+ALTER TABLE level ALTER COLUMN statistical_classification_id BIGINT not null;
 
 ALTER TABLE level
   ADD CONSTRAINT fk_sxgu9ljubog3jnujn8fvohvn4 FOREIGN KEY (
diff --git a/klass-shared/src/main/resources/db/migration/V3__correspondencetable_correspondencemap_bidirectional.sql b/klass-shared/src/main/resources/db/migration/V3__correspondencetable_correspondencemap_bidirectional.sql
index da53038e..5304e7b0 100644
--- a/klass-shared/src/main/resources/db/migration/V3__correspondencetable_correspondencemap_bidirectional.sql
+++ b/klass-shared/src/main/resources/db/migration/V3__correspondencetable_correspondencemap_bidirectional.sql
@@ -1,9 +1,11 @@
 -- renames a foreign key column
 
 ALTER TABLE correspondence_map
-  DROP FOREIGN KEY fk_74gwtjl4rjw3gw4x9idj4ux98;
+  DROP CONSTRAINT fk_74gwtjl4rjw3gw4x9idj4ux98;
 
-ALTER TABLE correspondence_map CHANGE correspondence_table correspondence_table_id BIGINT not null;
+ALTER TABLE correspondence_map ALTER COLUMN correspondence_table RENAME TO correspondence_table_id;
+
+ALTER TABLE correspondence_map ALTER COLUMN correspondence_table_id BIGINT not null;
 
 ALTER TABLE correspondence_map
   ADD CONSTRAINT fk_74gwtjl4rjw3gw4x9idj4ux98 FOREIGN KEY (correspondence_table_id)
diff --git a/klass-shared/src/main/resources/db/migration/V4__drop_deleted_columns.sql b/klass-shared/src/main/resources/db/migration/V4__drop_deleted_columns.sql
index ae09b1eb..29e13898 100644
--- a/klass-shared/src/main/resources/db/migration/V4__drop_deleted_columns.sql
+++ b/klass-shared/src/main/resources/db/migration/V4__drop_deleted_columns.sql
@@ -1,5 +1,5 @@
 -- Only classes(tables) implementing SoftDeletable shall have deleted column
- 
+
 ALTER TABLE classification_family DROP COLUMN deleted;
 ALTER TABLE classification_item DROP COLUMN deleted;
 ALTER TABLE correspondence_map DROP COLUMN deleted;
@@ -7,4 +7,4 @@ ALTER TABLE level DROP COLUMN deleted;
 ALTER TABLE statistical_unit DROP COLUMN deleted;
 ALTER TABLE subscriber DROP COLUMN deleted;
 ALTER TABLE subscription DROP COLUMN deleted;
-ALTER TABLE user DROP COLUMN deleted;
+ALTER TABLE "USER" DROP COLUMN deleted;
diff --git a/klass-shared/src/main/resources/db/migration/V7__remove_constraints_classificationitem.sql b/klass-shared/src/main/resources/db/migration/V7__remove_constraints_classificationitem.sql
index 5ffe6b26..1e2452ff 100644
--- a/klass-shared/src/main/resources/db/migration/V7__remove_constraints_classificationitem.sql
+++ b/klass-shared/src/main/resources/db/migration/V7__remove_constraints_classificationitem.sql
@@ -1,3 +1,3 @@
 -- Removed not null constraint since a ReferencingClassificationItem does not have these set
-ALTER TABLE classification_item MODIFY code VARCHAR(255);
-ALTER TABLE classification_item MODIFY official_name VARCHAR(1024);
+ALTER TABLE classification_item ALTER COLUMN code VARCHAR(255) null ;
+ALTER TABLE classification_item ALTER COLUMN official_name VARCHAR(1024) null;
diff --git a/klass-shared/src/main/resources/db/migration/V9__increase_column_sizes.sql b/klass-shared/src/main/resources/db/migration/V9__increase_column_sizes.sql
index 809d1434..c544194f 100644
--- a/klass-shared/src/main/resources/db/migration/V9__increase_column_sizes.sql
+++ b/klass-shared/src/main/resources/db/migration/V9__increase_column_sizes.sql
@@ -1,11 +1,11 @@
 -- Migrating classifications from Stabas requires some increased column sizes
-ALTER TABLE classification_item MODIFY notes VARCHAR(6000);
+ALTER TABLE classification_item ALTER COLUMN notes VARCHAR(6000);
 
-ALTER TABLE statistical_classification MODIFY introduction VARCHAR(7168) not null;
-ALTER TABLE statistical_classification MODIFY legal_base VARCHAR(4000);
-ALTER TABLE statistical_classification MODIFY publications VARCHAR(4000);
-ALTER TABLE statistical_classification MODIFY derived_from VARCHAR(4000);
+ALTER TABLE statistical_classification ALTER COLUMN introduction VARCHAR(7168) not null;
+ALTER TABLE statistical_classification ALTER COLUMN legal_base VARCHAR(4000);
+ALTER TABLE statistical_classification ALTER COLUMN publications VARCHAR(4000);
+ALTER TABLE statistical_classification ALTER COLUMN derived_from VARCHAR(4000);
 
-ALTER TABLE correspondence_table MODIFY description VARCHAR(4000) not null;
+ALTER TABLE correspondence_table ALTER COLUMN description VARCHAR(4000) not null;
 
-ALTER TABLE level MODIFY name VARCHAR(1000) not null;
+ALTER TABLE level ALTER COLUMN name VARCHAR(1000) not null;
diff --git a/klass-shared/src/test/java/no/ssb/klass/core/ldap/ActiveDirectoryServiceTest.java b/klass-shared/src/test/java/no/ssb/klass/core/ldap/ActiveDirectoryServiceTest.java
index 5a7c43a9..a9752112 100644
--- a/klass-shared/src/test/java/no/ssb/klass/core/ldap/ActiveDirectoryServiceTest.java
+++ b/klass-shared/src/test/java/no/ssb/klass/core/ldap/ActiveDirectoryServiceTest.java
@@ -4,20 +4,20 @@
 import static org.hamcrest.core.Is.*;
 import static org.hamcrest.core.IsNull.*;
 import static org.hamcrest.core.StringContains.*;
-import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.*;
 
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.springframework.ldap.core.DirContextAdapter;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.ldap.search.LdapUserSearch;
@@ -29,7 +29,7 @@
 /**
  * @author Mads Lundemo, SSB.
  */
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class ActiveDirectoryServiceTest {
 
     @Mock
@@ -42,9 +42,9 @@ public class ActiveDirectoryServiceTest {
     @InjectMocks
     private ActiveDirectoryServiceImpl adService;
 
-    @Before
+    @BeforeEach
     public void configureUserServiceMock() {
-        when(userService.saveUser(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
+        lenient().when(userService.saveUser(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
     }
 
     @Test
@@ -159,10 +159,12 @@ public void shouldCreateAndSaveNewUser() {
 
     }
 
-    @Test(expected = UsernameNotFoundException.class)
+    @Test
     public void shouldThrowExceptionIfUserDoesNotExistsInAd() {
-        when(userSearch.searchForUser("xxx")).thenThrow(new UsernameNotFoundException(""));
-        adService.createAndSaveNewUser("xxx");
+        Assertions.assertThrows(UsernameNotFoundException.class, () -> {
+            when(userSearch.searchForUser("xxx")).thenThrow(new UsernameNotFoundException(""));
+            adService.createAndSaveNewUser("xxx");
+        });
     }
 
     @Test
diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationFamilyTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationFamilyTest.java
index a38282cf..b285d22b 100644
--- a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationFamilyTest.java
+++ b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationFamilyTest.java
@@ -1,10 +1,10 @@
 package no.ssb.klass.core.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.springframework.core.io.ClassPathResource;
 
 import no.ssb.klass.testutil.TestUtil;
@@ -12,7 +12,7 @@
 public class ClassificationFamilyTest {
     private ClassificationFamily subject;
 
-    @Before
+    @BeforeEach
     public void setup() {
         subject = TestUtil.createClassificationFamily("name");
         ClassificationSeries classification = TestUtil.createClassification("classification");
@@ -20,13 +20,13 @@ public void setup() {
     }
 
     @Test
-    @Ignore("Icons moved to forvaltning module")
+    @Disabled("Icons moved to forvaltning module")
     public void getIconPath() {
         // when
         String result = subject.getIconPath();
 
         // then
-        assertTrue("icon path does not exist on classpath", new ClassPathResource(result).exists());
+        assertTrue(new ClassPathResource(result).exists(), "icon path does not exist on classpath");
     }
 
     @Test
diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationSeriesTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationSeriesTest.java
index 4076e2c1..6a59b522 100644
--- a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationSeriesTest.java
+++ b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationSeriesTest.java
@@ -1,13 +1,14 @@
 package no.ssb.klass.core.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
 
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.base.Strings;
 
@@ -67,7 +68,7 @@ public void getChangeTables() {
 
     }
 
-    @Test(expected = KlassResourceNotFoundException.class)
+    @Test
     public void getChangeTableNotFound() {
         // given
         LocalDate start = TimeUtil.createDate("2014-01-01");
@@ -79,10 +80,10 @@ public void getChangeTableNotFound() {
         subject.addClassificationVersion(firstVersion);
         subject.addClassificationVersion(secondVersion);
 
-        // when
-        subject.getChangeTables(DateRange.create(start, start.plusYears(4)), null);
+        Assertions.assertThrows(KlassResourceNotFoundException.class, () ->
+                subject.getChangeTables(DateRange.create(start, start.plusYears(4)), null)
+        );
 
-        // then expect exception
     }
 
     @Test
diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVariantTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVariantTest.java
index 6f74e47f..0e518c11 100644
--- a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVariantTest.java
+++ b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVariantTest.java
@@ -1,8 +1,8 @@
 package no.ssb.klass.core.model;
 
-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.util.Translatable;
 import no.ssb.klass.testutil.TestUtil;
diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVersionTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVersionTest.java
index 67108044..51646532 100644
--- a/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVersionTest.java
+++ b/klass-shared/src/test/java/no/ssb/klass/core/model/ClassificationVersionTest.java
@@ -1,13 +1,15 @@
 package no.ssb.klass.core.model;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.LocalDate;
 import java.util.List;
 import java.util.Optional;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import no.ssb.klass.core.util.DateRange;
 import no.ssb.klass.core.util.Translatable;
@@ -40,13 +42,14 @@ public void findItem() {
         assertEquals(item.getCode(), result.getCode());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void findItemNotFound() {
         // given
         ClassificationVersion subject = createVersionWithLevels();
 
         // when
-        subject.findItem("unknown");
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                subject.findItem("unknown"));
 
         // then expect exception
     }
@@ -165,14 +168,15 @@ public void findLevel() {
         assertEquals(false, version.hasLevel(3));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void addLevel() {
         // given
         ClassificationVersion version = createVersion();
         version.addNextLevel();
 
         // when
-        version.addLevel(TestUtil.createLevel(1));
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                version.addLevel(TestUtil.createLevel(1)));
 
         // then expect exception
     }
@@ -220,7 +224,7 @@ public void addClassificationItem() {
         assertEquals(level.getLevelNumber(), classificationItem.getLevel().getLevelNumber());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void addClassificationItemWithParentForFirstLevel() {
         // given
         ClassificationVersion version = createVersion();
@@ -230,12 +234,13 @@ public void addClassificationItemWithParentForFirstLevel() {
         ClassificationItem parent = TestUtil.createClassificationItem("parent", "officialName");
 
         // when
-        version.addClassificationItem(classificationItem, level.getLevelNumber(), parent);
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                version.addClassificationItem(classificationItem, level.getLevelNumber(), parent));
 
         // then expect exception
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void addClassificationItemWithNoParentForNotFirstLevel() {
         // given
         ClassificationVersion version = createVersion();
@@ -244,7 +249,8 @@ public void addClassificationItemWithNoParentForNotFirstLevel() {
         ClassificationItem classificationItem = TestUtil.createClassificationItem("code", "officialName");
 
         // when
-        version.addClassificationItem(classificationItem, 2, null);
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                version.addClassificationItem(classificationItem, 2, null));
 
         // then expect exception
     }
@@ -296,7 +302,7 @@ public void getNameInPrimaryLanguage() {
         assertEquals("Test 2016-11", classificationVersion5.getNameInPrimaryLanguage());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void removeLevelWhenNotEmpty() {
         // given
         ClassificationVersion version = createVersion();
@@ -306,7 +312,8 @@ public void removeLevelWhenNotEmpty() {
         version.addClassificationItem(classificationItem, level.getLevelNumber(), null);
 
         // when
-        version.deleteLevel(level);
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                version.deleteLevel(level));
 
         // then expect exception
     }
diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/CorrespondenceTableTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/CorrespondenceTableTest.java
index 089f4319..5f0e4d72 100644
--- a/klass-shared/src/test/java/no/ssb/klass/core/model/CorrespondenceTableTest.java
+++ b/klass-shared/src/test/java/no/ssb/klass/core/model/CorrespondenceTableTest.java
@@ -1,11 +1,12 @@
 package no.ssb.klass.core.model;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.time.LocalDate;
 
-import org.junit.Ignore;
-import org.junit.Test;
+import no.ssb.klass.core.util.ClientException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import no.ssb.klass.core.util.DateRange;
 import no.ssb.klass.core.util.TimeUtil;
@@ -36,18 +37,20 @@ public void correspondenceTableWithSpecificLevels() {
         assertEquals(true, subject.getTargetLevel().isPresent());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void correspondenceTableWithNotExistingSourceLevel() {
         // given
-        createCorrespondenceTable(NOT_EXISTING_LEVEL, EXISTING_LEVEL);
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                createCorrespondenceTable(NOT_EXISTING_LEVEL, EXISTING_LEVEL));
 
         // then expect exception
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void correspondenceTableWithNotExistingTargetLevel() {
         // given
-        createCorrespondenceTable(EXISTING_LEVEL, NOT_EXISTING_LEVEL);
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+                createCorrespondenceTable(EXISTING_LEVEL, NOT_EXISTING_LEVEL));
 
         // then expect exception
     }
@@ -165,17 +168,12 @@ public void getDateRangeContained() {
      *    expected  exception
      * 
*/ - @Test(expected = IllegalArgumentException.class) + @Test public void getDateRangeNotOverlaping() { - // given final DateRange sourceDateRange = DateRange.create("2010-01-01", "2012-01-01"); final DateRange targetDateRange = DateRange.create("2012-01-01", "2014-01-01"); - CorrespondenceTable subject = createCorrespondenceTable(sourceDateRange, targetDateRange); - - // when - subject.getDateRange(); - - // then expect exception + Assertions.assertThrows(IllegalArgumentException.class, () -> + createCorrespondenceTable(sourceDateRange, targetDateRange)); } @Test @@ -191,7 +189,7 @@ public void addChangelog() { assertEquals(1, subject.getChangelogs().size()); } - @Test(expected = IllegalStateException.class) + @Test public void addChangelogWhenNotPublished() { // given CorrespondenceTable subject = createCorrespondenceTable(); @@ -200,19 +198,21 @@ public void addChangelogWhenNotPublished() { } // when - subject.addChangelog(new Changelog("user", "description")); + Assertions.assertThrows(IllegalStateException.class, () -> + subject.addChangelog(new Changelog("user", "description"))); // then expect exception } - @Test(expected = IllegalArgumentException.class) + @Test public void addCorrespondenceMapVerifiesNotAlreadyPresent() { // given CorrespondenceTable subject = createCorrespondenceTable(); subject.addCorrespondenceMap(createCorrespondenceMap("source", "target")); // when - subject.addCorrespondenceMap(createCorrespondenceMap("source", "target")); + Assertions.assertThrows(IllegalArgumentException.class, () -> + subject.addCorrespondenceMap(createCorrespondenceMap("source", "target"))); // then expect exception } @@ -232,7 +232,7 @@ public void updateCorrespondenceMapSource() { assertEquals("newSource", correspondenceMap.getSource().get().getCode()); } - @Test(expected = IllegalArgumentException.class) + @Test public void updateCorrespondenceMapSourceVerifiesNotAlreadyPresent() { // given CorrespondenceTable subject = createCorrespondenceTable(); @@ -242,12 +242,13 @@ public void updateCorrespondenceMapSourceVerifiesNotAlreadyPresent() { ClassificationItem sourceItem = TestUtil.createClassificationItem("source", "source"); // when - subject.updateCorrespondenceMapSource(correspondenceMap, sourceItem); + Assertions.assertThrows(IllegalArgumentException.class, () -> + subject.updateCorrespondenceMapSource(correspondenceMap, sourceItem)); // then expect exception } - @Test(expected = IllegalArgumentException.class) + @Test public void updateCorrespondenceMapSourceDoesNotAllowBothSourceAndTargetToBeNull() { // given CorrespondenceTable subject = createCorrespondenceTable(); @@ -256,7 +257,8 @@ public void updateCorrespondenceMapSourceDoesNotAllowBothSourceAndTargetToBeNull subject.addCorrespondenceMap(correspondenceMap); // when - subject.updateCorrespondenceMapSource(correspondenceMap, null); + Assertions.assertThrows(IllegalArgumentException.class, () -> + subject.updateCorrespondenceMapSource(correspondenceMap, null)); // then expect exception } @@ -276,7 +278,7 @@ public void updateCorrespondenceMapTarget() { assertEquals("newTarget", correspondenceMap.getTarget().get().getCode()); } - @Test(expected = IllegalArgumentException.class) + @Test public void updateCorrespondenceMapTargetVerifiesNotAlreadyPresent() { // given CorrespondenceTable subject = createCorrespondenceTable(); @@ -286,12 +288,13 @@ public void updateCorrespondenceMapTargetVerifiesNotAlreadyPresent() { ClassificationItem targetItem = TestUtil.createClassificationItem("target", "target"); // when - subject.updateCorrespondenceMapTarget(correspondenceMap, targetItem); + Assertions.assertThrows(IllegalArgumentException.class, () -> + subject.updateCorrespondenceMapTarget(correspondenceMap, targetItem)); // then expect exception } - @Test(expected = IllegalArgumentException.class) + @Test public void updateCorrespondenceMapTargetDoesNotAllowBothSourceAndTargetToBeNull() { // given CorrespondenceTable subject = createCorrespondenceTable(); @@ -300,7 +303,8 @@ public void updateCorrespondenceMapTargetDoesNotAllowBothSourceAndTargetToBeNull subject.addCorrespondenceMap(correspondenceMap); // when - subject.updateCorrespondenceMapTarget(correspondenceMap, null); + Assertions.assertThrows(IllegalArgumentException.class, () -> + subject.updateCorrespondenceMapTarget(correspondenceMap, null)); // then expect exception } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/LanguageTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/LanguageTest.java index 97761602..37fb7ba7 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/model/LanguageTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/model/LanguageTest.java @@ -1,10 +1,10 @@ package no.ssb.klass.core.model; -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-shared/src/test/java/no/ssb/klass/core/model/SubscriberTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriberTest.java index 4442d9e3..12a59ea6 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriberTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriberTest.java @@ -1,11 +1,12 @@ package no.ssb.klass.core.model; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.net.URL; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import no.ssb.klass.core.util.ClientException; import no.ssb.klass.testutil.TestUtil; @@ -20,7 +21,7 @@ public class SubscriberTest { private ClassificationSeries classification; - @Before + @BeforeEach public void init() throws Exception { subject = new Subscriber(EMAIL); classification = TestUtil.createClassificationWithId(1, NAME); @@ -37,26 +38,29 @@ public void addSubscription() throws Exception { assertEquals(Verification.VALID, verification); } - @Test(expected = ClientException.class) - public void addSubscriptionExist() throws Exception { + @Test + public void addSubscriptionExist() { // when ClassificationSeries classification = TestUtil.createClassificationWithId(1, NAME); - subject.addSubscription(classification, new URL("http://test.url")); + Assertions.assertThrows(ClientException.class, () -> + subject.addSubscription(classification, new URL("http://test.url"))); // then exception } - @Test(expected = NullPointerException.class) - public void addSubscriptionNull() throws Exception { + @Test + public void addSubscriptionNull() { // when - subject.addSubscription(null, new URL("http://test.url")); + Assertions.assertThrows(NullPointerException.class, () -> + subject.addSubscription(null, new URL("http://test.url"))); // then exception } - @Test(expected = NullPointerException.class) - public void addEndSubscriptionNull() throws Exception { + @Test + public void addEndSubscriptionNull() { // when - subject.addSubscription(classification, null); + Assertions.assertThrows(NullPointerException.class, () -> + subject.addSubscription(classification, null)); // then exception } @@ -76,24 +80,27 @@ public void getEndSubscriptionUrl() { assertEquals(END_SUBSCRIPTION_URL, result); } - @Test(expected = ClientException.class) + @Test public void removeSubscriptionNotFound() { // when - subject.removeSubscription(TestUtil.createClassification(NAME)); + Assertions.assertThrows(ClientException.class, () -> + subject.removeSubscription(TestUtil.createClassification(NAME))); // then exception } - @Test(expected = NullPointerException.class) + @Test public void verifyNull() { // when - subject.verify(null); + Assertions.assertThrows(NullPointerException.class, () -> + subject.verify(null)); // then exception } - @Test(expected = ClientException.class) + @Test public void verifyNotFound() { // when - subject.verify(TOKEN); + Assertions.assertThrows(ClientException.class, () -> + subject.verify(TOKEN)); // then exception } } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriptionTest.java b/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriptionTest.java index 4b738e32..297d1775 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriptionTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/model/SubscriptionTest.java @@ -1,13 +1,14 @@ package no.ssb.klass.core.model; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.net.URL; import java.util.Date; -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 no.ssb.klass.core.util.ClientException; import no.ssb.klass.core.util.TimeUtil; @@ -22,14 +23,14 @@ public class SubscriptionTest { private Subscription subject; private UpdateableClockSource clockSource; - @Before + @BeforeEach public void init() throws Exception { clockSource = new UpdateableClockSource(new Date().getTime()); TimeUtil.setClockSource(clockSource); subject = new Subscription(TestUtil.createClassification("name"), new URL("http://test.url")); } - @After + @AfterEach public void teardown() { TimeUtil.revertClockSource(); } @@ -57,12 +58,12 @@ public void verifyValid() { assertEquals(Verification.VALID, subject.getVerification()); } - @Test(expected = ClientException.class) + @Test public void verifyExpired() { // when clockSource.updateTimeMillis(TimeUtil.now().getTime() + EXPIRY_TIME_IN_MINS * ONE_MINUTE_IN_MILLISECS + 1); - subject.verify(); // then exception + Assertions.assertThrows(Exception.class, () -> subject.verify()); } } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationAccessRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationAccessRepositoryTest.java index b1d6c469..1084064a 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationAccessRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationAccessRepositoryTest.java @@ -1,6 +1,6 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Date; import java.util.List; @@ -8,9 +8,9 @@ import javax.persistence.EntityManager; import javax.transaction.Transactional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -20,7 +20,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationAccessCounter; @@ -32,7 +32,7 @@ import no.ssb.klass.testutil.IncrementableClockSource; import no.ssb.klass.testutil.TestUtil; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -56,7 +56,7 @@ public class ClassificationAccessRepositoryTest { @Autowired private EntityManager entityManager; - @Before + @BeforeEach public void setup() { clockSource = new IncrementableClockSource(new Date().getTime()); TimeUtil.setClockSource(clockSource); @@ -77,7 +77,7 @@ public void getClassificationsCountTest() { createClassificationSeries("Test1"); createClassificationSeries("Test2"); Page getClassificationsCount = classificationAccessRepository.getClassificationsCount( - SearchWordsRepositoryTest.getFromDate(), SearchWordsRepositoryTest.getToDate(), new PageRequest(0, + SearchWordsRepositoryTest.getFromDate(), SearchWordsRepositoryTest.getToDate(), PageRequest.of(0, 100)); assertEquals(2, getClassificationsCount.getTotalElements()); List resultList = getClassificationsCount.getContent(); diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryTest.java index 8f66251f..f83286e8 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationFamilyRepositoryTest.java @@ -1,15 +1,15 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.List; import javax.persistence.EntityManager; import javax.transaction.Transactional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -17,7 +17,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationFamily; @@ -29,7 +29,7 @@ import no.ssb.klass.core.util.TranslatablePersistenceConverter; import no.ssb.klass.testutil.TestUtil; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -46,7 +46,7 @@ public class ClassificationFamilyRepositoryTest { private final ClassificationType allClassificationTypes = null; private User user; - @Before + @BeforeEach public void setup() { user = userRepository.save(TestUtil.createUser()); } @@ -60,7 +60,8 @@ public void verifyMapping() { entityManager.detach(family); // when - ClassificationFamily result = subject.findOne(family.getId()); + ClassificationFamily result = subject.findById(family.getId()).orElseThrow(() -> + new RuntimeException("ClassificationFamily not found")); // then assertEquals(1, result.getClassificationSeries().size()); diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationSeriesRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationSeriesRepositoryTest.java index 26e80ba3..64ad502e 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationSeriesRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/ClassificationSeriesRepositoryTest.java @@ -1,6 +1,6 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Date; import java.util.List; @@ -8,11 +8,11 @@ import javax.persistence.EntityManager; import javax.transaction.Transactional; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -22,7 +22,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationSeries; @@ -31,15 +31,13 @@ import no.ssb.klass.core.model.Language; import no.ssb.klass.core.model.Level; import no.ssb.klass.core.model.User; -import no.ssb.klass.core.service.dto.ClassificationReportDto; -import no.ssb.klass.core.service.dto.ClassificationVersionReportDto; 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.testutil.IncrementableClockSource; import no.ssb.klass.testutil.TestUtil; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -55,14 +53,14 @@ public class ClassificationSeriesRepositoryTest { private IncrementableClockSource clockSource; private User user; - @Before + @BeforeEach public void setup() { clockSource = new IncrementableClockSource(new Date().getTime()); TimeUtil.setClockSource(clockSource); user = userRepository.save(TestUtil.createUser()); } - @After + @AfterEach public void teardown() { TimeUtil.revertClockSource(); } @@ -79,7 +77,8 @@ public void verifyMapping() { entityManager.detach(classification); // when - ClassificationSeries result = subject.findOne(classification.getId()); + ClassificationSeries result = subject.findById(classification.getId()).orElseThrow(() -> + new RuntimeException("ClassificationSeries not found")); // then assertEquals(1, result.getClassificationVersions().size()); @@ -274,8 +273,8 @@ public void testNumberOfVersions() { } - @Test - @Ignore("skrevet om service laget") + @Test() + @Disabled("skrevet om service laget") public void testClassificationsReport() { // ClassificationSeries classification1 = // createClassificationSeriesWithVersion(user, "Duppeditt"); @@ -324,7 +323,7 @@ public void testClassificationsReport() { } @Test - @Ignore("skrevet om service laget") + @Disabled("skrevet om service laget") public void testPublishedClassificationReport() { // ClassificationSeries classification1 = // createClassificationSeriesWithVersion(user, "Duppeditt"); @@ -371,7 +370,7 @@ public void testPublishedClassificationReport() { } @Test - @Ignore("skrevet om service laget") + @Disabled("skrevet om service laget") public void testPublishedVersionsAnyLanguages() { // ClassificationSeries classification1 = // createClassificationSeriesWithVersion(user, "Duppeditt"); @@ -418,7 +417,7 @@ public void testPublishedVersionsAnyLanguages() { } @Test - @Ignore("skrevet om service laget") + @Disabled("skrevet om service laget") public void testPublishedVersionsAllLanguages() { // ClassificationSeries classification1 = // createClassificationSeriesWithVersion(user, "Duppeditt"); @@ -535,7 +534,7 @@ public static ClassificationSeries createClassificationSeriesWithVersion(User us } private Pageable createPageable() { - return new PageRequest(0, 3); + return PageRequest.of(0, 3); } @Configuration diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceMapRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceMapRepositoryTest.java index 4a9d504e..f72b4975 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceMapRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceMapRepositoryTest.java @@ -1,15 +1,16 @@ package no.ssb.klass.core.repository; import static org.hamcrest.core.Is.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Set; import javax.transaction.Transactional; +import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -17,7 +18,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationFamily; @@ -37,7 +38,7 @@ /** * @author Mads Lundemo, SSB. */ -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -62,7 +63,7 @@ public class CorrespondenceMapRepositoryTest { private CorrespondenceTable secondNormalCorrespondenceTable; private CorrespondenceTable secondDeletedCorrespondenceTable; - @Before + @BeforeEach public void setup() { user = userRepository.save(TestUtil.createUser()); classificationFamily = classificationFamilyRepository.save(TestUtil.createClassificationFamily("family")); @@ -84,8 +85,8 @@ public void findAllMapsUsingDeletedItems() { deletedTarget, deletedTarget.getAllClassificationItems()); // then - assertThat(sourceMapsUsingDeletedItems.size(), is(10)); - assertThat(targetMapsUsingDeletedItems.size(), is(10)); + assertThat(sourceMapsUsingDeletedItems.size()).isEqualTo(10); + assertThat(targetMapsUsingDeletedItems.size()).isEqualTo(10); sourceMapsUsingDeletedItems.forEach(map -> assertTrue(deletedSource.getAllClassificationItems().contains(map .getSource().get()))); @@ -102,8 +103,8 @@ public void findAllMapsUsingItems() { Set itemsUsingNormalTarget = correspondenceMapRepository.findAllMapsUsingItems(normalTarget); // then - assertThat(itemsUsingNormalSource.size(), is(12)); - assertThat(itemsUsingNormalTarget.size(), is(12)); + assertThat(itemsUsingNormalSource.size()).isEqualTo(12); + assertThat(itemsUsingNormalTarget.size()).isEqualTo(12); itemsUsingNormalSource.forEach(map -> assertTrue(normalSource.getAllClassificationItems().contains(map .getSource().get()))); itemsUsingNormalSource.forEach(map -> assertTrue(normalSource.getAllClassificationItems().contains(map @@ -129,11 +130,11 @@ public void findBySourceOrTarget() { deletedClassificationItem, false); // then - assertThat(deletedFromNormal.size(), is(0)); - assertThat(normalFromNormal.size(), is(1)); + assertThat(deletedFromNormal.size()).isEqualTo(0); + assertThat(normalFromNormal.size()).isEqualTo(1); - assertThat(deletedFromDeleted.size(), is(1)); - assertThat(normalFromDeleted.size(), is(0)); + assertThat(deletedFromDeleted.size()).isEqualTo(1); + assertThat(normalFromDeleted.size()).isEqualTo(0); } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceTableRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceTableRepositoryTest.java index e8f3c3e9..39674640 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceTableRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/CorrespondenceTableRepositoryTest.java @@ -1,15 +1,15 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.List; import javax.transaction.Transactional; import com.google.common.collect.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -17,7 +17,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationFamily; @@ -28,7 +28,7 @@ import no.ssb.klass.core.util.TranslatablePersistenceConverter; import no.ssb.klass.testutil.TestUtil; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -44,7 +44,7 @@ public class CorrespondenceTableRepositoryTest { private User user; private ClassificationFamily classificationFamily; - @Before + @BeforeEach public void setup() { user = userRepository.save(TestUtil.createUser()); classificationFamily = classificationFamilyRepository.save(TestUtil.createClassificationFamily("family")); diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/ReferencingClassificationItemRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/ReferencingClassificationItemRepositoryTest.java index 17eeb5a0..e6ab2765 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/ReferencingClassificationItemRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/ReferencingClassificationItemRepositoryTest.java @@ -1,15 +1,13 @@ package no.ssb.klass.core.repository; -import static org.hamcrest.core.Is.*; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.*; import java.util.List; import javax.transaction.Transactional; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -17,7 +15,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationFamily; @@ -38,7 +36,7 @@ /** * @author Mads Lundemo, SSB. */ -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -63,7 +61,7 @@ public class ReferencingClassificationItemRepositoryTest { private ClassificationVariant secondNormalVariant; private ClassificationVariant secondDeletedVariant; - @Before + @BeforeEach public void setup() { user = userRepository.save(TestUtil.createUser()); classificationFamily = classificationFamilyRepository @@ -89,16 +87,16 @@ public void findByReference() { List normalItemReferences = referencingItemRepository.findByReference( classificationItem, false); - assertThat(deletedItemReferences.size(), is(0)); - assertThat(normalItemReferences.size(), is(1)); + assertThat(deletedItemReferences.size()).isEqualTo(0); + assertThat(normalItemReferences.size()).isEqualTo(1); List deletedReferencesForDeletedVariant = referencingItemRepository .findByReference(deletedClassificationItem, true); List normalReferencesForDeletedVariant = referencingItemRepository .findByReference(deletedClassificationItem, false); - assertThat(deletedReferencesForDeletedVariant.size(), is(1)); - assertThat(normalReferencesForDeletedVariant.size(), is(0)); + assertThat(deletedReferencesForDeletedVariant.size()).isEqualTo(1); + assertThat(normalReferencesForDeletedVariant.size()).isEqualTo(0); } @Test @@ -114,16 +112,16 @@ public void findByReferenceInList() { .findByReferenceInList( normalVersion.getAllClassificationItems(), false); - assertThat(deletedItemReferences.size(), is(0)); - assertThat(normalItemReferences.size(), is(12)); + assertThat(deletedItemReferences.size()).isEqualTo(0); + assertThat(normalItemReferences.size()).isEqualTo(12); List deletedReferencesForDeletedVariant = referencingItemRepository .findByReferenceInList(deletedDeleted.getAllClassificationItems(), true); List normalReferencesForDeletedVariant = referencingItemRepository .findByReferenceInList(deletedDeleted.getAllClassificationItems(), false); - assertThat(deletedReferencesForDeletedVariant.size(), is(10)); - assertThat(normalReferencesForDeletedVariant.size(), is(0)); + assertThat(deletedReferencesForDeletedVariant.size()).isEqualTo(10); + assertThat(normalReferencesForDeletedVariant.size()).isEqualTo(0); } @@ -137,16 +135,16 @@ public void findItemReferences() { List normalReferences = referencingItemRepository.findItemReferences( versionForNormalVariant, false); - assertThat(deletedReferences.size(), is(0)); - assertThat(normalReferences.size(), is(12)); + assertThat(deletedReferences.size()).isEqualTo(0); + assertThat(normalReferences.size()).isEqualTo(12); List deletedReferencesForDeletedVariant = referencingItemRepository .findItemReferences(versionForDeletedVariant, true); List normalReferencesForDeletedVariant = referencingItemRepository .findItemReferences(versionForDeletedVariant, false); - assertThat(deletedReferencesForDeletedVariant.size(), is(10)); - assertThat(normalReferencesForDeletedVariant.size(), is(0)); + assertThat(deletedReferencesForDeletedVariant.size()).isEqualTo(10); + assertThat(normalReferencesForDeletedVariant.size()).isEqualTo(0); } @@ -163,8 +161,7 @@ private ClassificationVariant createAndSaveVariant(String name, int itemCount, b source.addClassificationVariant(variant); variant.setClassificationVersion(source); - for (int i = 0; i < itemCount; i++) { - ClassificationItem sourceItem = source.getAllClassificationItems().get(i); + for (ClassificationItem sourceItem: source.getAllClassificationItems()) { ClassificationItem item = new ReferencingClassificationItem(sourceItem); variant.addClassificationItem(item, 1, null); } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/SearchWordsRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/SearchWordsRepositoryTest.java index 69b0de87..983db614 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/SearchWordsRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/SearchWordsRepositoryTest.java @@ -1,6 +1,6 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.time.LocalDate; import java.time.ZoneId; @@ -9,8 +9,8 @@ import javax.transaction.Transactional; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -20,14 +20,14 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.SearchWords; import no.ssb.klass.core.service.dto.StatisticalEntity; import no.ssb.klass.core.util.TranslatablePersistenceConverter; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -68,7 +68,7 @@ public void findSearchWordsTest() { makeSerarchWord("A", true); Page result = searchWordsRepository.getSearchWords(getFromDate(), getToDate(), - new PageRequest(0, 100)); + PageRequest.of(0, 100)); assertEquals(3, result.getTotalElements()); List resultList = result.getContent(); assertEquals("A", resultList.get(0).getName()); @@ -90,7 +90,7 @@ public void findMissedSearchWordsTest() { makeSerarchWord("B", false); Page result = searchWordsRepository.getSearchWords(false, getFromDate(), getToDate(), - new PageRequest(0, 100)); + PageRequest.of(0, 100)); assertEquals(2, result.getTotalElements()); List resultList = result.getContent(); assertEquals("B", resultList.get(0).getName()); diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/StatisticalUnitRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/StatisticalUnitRepositoryTest.java index b9e02c21..55ad7b5a 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/StatisticalUnitRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/StatisticalUnitRepositoryTest.java @@ -1,14 +1,14 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.List; import javax.transaction.Transactional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -18,7 +18,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationSeries; @@ -30,7 +30,7 @@ import no.ssb.klass.core.util.TranslatablePersistenceConverter; import no.ssb.klass.testutil.TestUtil; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -50,7 +50,7 @@ public class StatisticalUnitRepositoryTest { private User user; - @Before + @BeforeEach public void setup() { user = userRepository.save(TestUtil.createUser()); } @@ -58,14 +58,14 @@ public void setup() { @Test public void getStaticalUnitsOverViewTest() { makeTestData(); - Page result = statisticalUnitRepository.getStaticalUnitsOverView(new PageRequest(0, + Page result = statisticalUnitRepository.getStaticalUnitsOverView(PageRequest.of(0, Integer.MAX_VALUE)); assertEquals(2, result.getContent().size()); List resultList = result.getContent(); - assertEquals("Duppeditt", resultList.get(0).getName()); - assertEquals(Long.valueOf(2), resultList.get(0).getCount()); - assertEquals("Dingseboms", resultList.get(1).getName()); - assertEquals(Long.valueOf(1), resultList.get(1).getCount()); + assertEquals("Dingseboms", resultList.get(0).getName()); + assertEquals(Long.valueOf(1), resultList.get(0).getCount()); + assertEquals("Duppeditt", resultList.get(1).getName()); + assertEquals(Long.valueOf(2), resultList.get(1).getCount()); } @Test diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/SubscriberRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/SubscriberRepositoryTest.java index c4283c85..8578e872 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/SubscriberRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/SubscriberRepositoryTest.java @@ -1,15 +1,15 @@ package no.ssb.klass.core.repository; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.net.URL; import java.util.List; import javax.transaction.Transactional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -17,7 +17,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationSeries; @@ -25,7 +25,7 @@ import no.ssb.klass.core.util.TranslatablePersistenceConverter; import no.ssb.klass.testutil.TestUtil; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -48,7 +48,7 @@ public class SubscriberRepositoryTest { private Subscriber subscriber; private Long subscriberId; - @Before + @BeforeEach public void init() { subscriber = new Subscriber(EMAIL); subject.save(subscriber); @@ -59,7 +59,8 @@ public void init() { @Test public void testEntity() { // when - Subscriber result = subject.findOne(subscriberId); + Subscriber result = subject.findById(subscriberId).orElseThrow(() -> + new RuntimeException("Subscriber not found")); // then assertEquals(subscriberId, result.getId()); } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/repository/UserRepositoryTest.java b/klass-shared/src/test/java/no/ssb/klass/core/repository/UserRepositoryTest.java index 76198e55..e3e7e48d 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/repository/UserRepositoryTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/repository/UserRepositoryTest.java @@ -9,9 +9,9 @@ import javax.transaction.Transactional; import no.ssb.klass.testutil.TestDataProvider; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -19,7 +19,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import no.ssb.klass.core.config.ConfigurationProfiles; import no.ssb.klass.core.model.ClassificationFamily; @@ -31,7 +31,7 @@ /** * @author Mads Lundemo, SSB. */ -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @ActiveProfiles(ConfigurationProfiles.H2_INMEMORY) @Transactional @@ -44,7 +44,7 @@ public class UserRepositoryTest { @Autowired private ClassificationFamilyRepository familyRepository; - @Before + @BeforeEach public void init() { User owner = new User("owner", "user with classification", "section"); User nonOwner = new User("non-owner", "user without classification", "section"); diff --git a/klass-shared/src/test/java/no/ssb/klass/core/service/ClassificationServiceImplTest.java b/klass-shared/src/test/java/no/ssb/klass/core/service/ClassificationServiceImplTest.java index f47ef46d..0593795d 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/service/ClassificationServiceImplTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/service/ClassificationServiceImplTest.java @@ -1,26 +1,20 @@ package no.ssb.klass.core.service; -import static org.hamcrest.core.Is.*; -import static org.hamcrest.core.IsNull.*; -import static org.junit.Assert.*; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyList; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; -import static org.mockito.Mockito.anyBoolean; import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.Optional; import java.util.Set; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -72,7 +66,7 @@ public class ClassificationServiceImplTest { private SearchService searchServiceMock; private UserRepository userRepositoryMock; - @Before + @BeforeEach public void setup() { classificationFamilyRepositoryMock = mock(ClassificationFamilyRepository.class); classificationSeriesRepositoryMock = mock(ClassificationSeriesRepository.class); @@ -124,27 +118,28 @@ public void findAllClassificationSeries() { public void getClassificationSeries() { // given final Long id = 1L; - when(classificationSeriesRepositoryMock.findOne(id)).thenReturn(TestUtil.createClassificationWithId(id, - "name")); + when(classificationSeriesRepositoryMock.findById(id)).thenReturn(Optional.of( + TestUtil.createClassificationWithId(id, "name"))); // when ClassificationSeries result = subject.getClassificationSeries(id); // then - verify(classificationSeriesRepositoryMock, times(1)).findOne(id); + verify(classificationSeriesRepositoryMock, times(1)).findById(id); assertEquals(id, result.getId()); } - @Test(expected = KlassResourceNotFoundException.class) + @Test public void getClassificationSeriesFiltersDeleted() { // given final Long id = 1L; ClassificationSeries classification = TestUtil.createClassificationWithId(id, "name"); classification.setDeleted(); - when(classificationSeriesRepositoryMock.findOne(id)).thenReturn(classification); + when(classificationSeriesRepositoryMock.findById(id)).thenReturn(Optional.of(classification)); // when - subject.getClassificationSeries(id); + Assertions.assertThrows(KlassResourceNotFoundException.class, () -> + subject.getClassificationSeries(id)); // then expect exception } @@ -156,27 +151,28 @@ public void getClassificationVariant() { ClassificationVariant variant = TestUtil.createClassificationVariant("name", TestUtil.createUser()); variant.setId(id); createClassificationVersion().addClassificationVariant(variant); - when(classificationVariantRepositoryMock.findOne(id)).thenReturn(variant); + when(classificationVariantRepositoryMock.findById(id)).thenReturn(Optional.of(variant)); // when ClassificationVariant result = subject.getClassificationVariant(id); // then - verify(classificationVariantRepositoryMock, times(1)).findOne(id); + verify(classificationVariantRepositoryMock, times(1)).findById(id); assertEquals(id, result.getId()); } - @Test(expected = KlassResourceNotFoundException.class) + @Test public void getClassificationVariantFiltersDeleted() { // given final Long id = 1L; ClassificationVariant variant = TestUtil.createClassificationVariant("name", TestUtil.createUser()); variant.setId(id); variant.setDeleted(); - when(classificationVariantRepositoryMock.findOne(id)).thenReturn(variant); + when(classificationVariantRepositoryMock.findById(id)).thenReturn(Optional.of(variant)); // when - subject.getClassificationVariant(id); + Assertions.assertThrows(KlassResourceNotFoundException.class, () -> + subject.getClassificationVariant(id)); // then expect exception } @@ -187,27 +183,28 @@ public void getClassificationVersion() { final Long id = 1L; ClassificationVersion version = createClassificationVersion(); version.setId(id); - when(classificationVersionRepositoryMock.findOne(id)).thenReturn(version); + when(classificationVersionRepositoryMock.findById(id)).thenReturn(Optional.of(version)); // when ClassificationVersion result = subject.getClassificationVersion(id); // then - verify(classificationVersionRepositoryMock, times(1)).findOne(id); + verify(classificationVersionRepositoryMock, times(1)).findById(id); assertEquals(id, result.getId()); } - @Test(expected = KlassResourceNotFoundException.class) + @Test public void getClassificationVersionFiltersDeleted() { // given final Long id = 1L; ClassificationVersion version = TestUtil.createClassificationVersionWithTable(id, TestUtil.anyDateRange(), "name"); version.setDeleted(); - when(classificationVersionRepositoryMock.findOne(id)).thenReturn(version); + when(classificationVersionRepositoryMock.findById(id)).thenReturn(Optional.of(version)); // when - subject.getClassificationVersion(id); + Assertions.assertThrows(KlassResourceNotFoundException.class, () -> + subject.getClassificationVersion(id)); // then expect exception } @@ -219,17 +216,17 @@ public void getCorrespondenceTable() { CorrespondenceTable correspondenceTable = TestUtil.createCorrespondenceTable(createClassificationVersion(), createClassificationVersion()); correspondenceTable.setId(id); - when(correspondenceTableRepositoryMock.findOne(id)).thenReturn(correspondenceTable); + when(correspondenceTableRepositoryMock.findById(id)).thenReturn(Optional.of(correspondenceTable)); // when CorrespondenceTable result = subject.getCorrespondenceTable(id); // then - verify(correspondenceTableRepositoryMock, times(1)).findOne(id); + verify(correspondenceTableRepositoryMock, times(1)).findById(id); assertEquals(id, result.getId()); } - @Test(expected = KlassResourceNotFoundException.class) + @Test public void getCorrespondenceTableFiltersDeleted() { // given final Long id = 1L; @@ -237,16 +234,17 @@ public void getCorrespondenceTableFiltersDeleted() { createClassificationVersion()); correspondenceTable.setId(id); correspondenceTable.setDeleted(); - when(correspondenceTableRepositoryMock.findOne(id)).thenReturn(correspondenceTable); + when(correspondenceTableRepositoryMock.findById(id)).thenReturn(Optional.of(correspondenceTable)); // when - subject.getCorrespondenceTable(id); + Assertions.assertThrows(KlassResourceNotFoundException.class, () -> + subject.getCorrespondenceTable(id)); // then expect exception } @Test - public void findOneClassificationSeriesWithName() { + public void findByIdClassificationSeriesWithName() { // given ClassificationSeries classification = TestUtil.createClassification("name"); when(classificationSeriesRepositoryMock.findByNameNoIgnoreCase(anyString())).thenReturn(classification); @@ -260,7 +258,7 @@ public void findOneClassificationSeriesWithName() { } @Test - public void findOneClassificationSeriesWithNameFiltersDeleted() { + public void findByIdClassificationSeriesWithNameFiltersDeleted() { // given ClassificationSeries classification = TestUtil.createClassification("name"); classification.setDeleted(); @@ -274,7 +272,7 @@ public void findOneClassificationSeriesWithNameFiltersDeleted() { assertEquals(false, subject.findOneClassificationSeriesWithName("name", Language.EN).isPresent()); } - @Test(expected = KlassMessageException.class) + @Test public void testDeleteClasificationWithWrongUser() throws Exception { User mockUser = mock(User.class); User mockOwner = mock(User.class); @@ -284,12 +282,13 @@ public void testDeleteClasificationWithWrongUser() throws Exception { when(classificationSeriesMock.getNameInPrimaryLanguage()).thenReturn("test"); when(classificationSeriesMock.getCategoryName()).thenReturn("test"); when(classificationSeriesMock.getContactPerson()).thenReturn(mockOwner); - when(classificationSeriesRepositoryMock.findOne(any(Long.class))).thenReturn(classificationSeriesMock); - when(userRepositoryMock.findOne(any(Long.class))).thenReturn(mockUser); - subject.deleteNotIndexClassification(mockUser, classificationSeriesMock); + when(classificationSeriesRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(classificationSeriesMock)); + when(userRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(mockUser)); + Assertions.assertThrows(KlassMessageException.class, () -> + subject.deleteNotIndexClassification(mockUser, classificationSeriesMock)); } - @Test(expected = KlassMessageException.class) + @Test public void testDeleteClasificationPublished() throws Exception { User mockUser = mock(User.class); ClassificationSeries classificationSeriesMock = mock(ClassificationSeries.class); @@ -298,9 +297,10 @@ public void testDeleteClasificationPublished() throws Exception { when(classificationSeriesMock.getNameInPrimaryLanguage()).thenReturn("test"); when(classificationSeriesMock.getCategoryName()).thenReturn("test"); when(classificationSeriesMock.isPublishedInAnyLanguage()).thenReturn(true); - when(classificationSeriesRepositoryMock.findOne(any(Long.class))).thenReturn(classificationSeriesMock); - when(userRepositoryMock.findOne(any(Long.class))).thenReturn(mockUser); - subject.deleteNotIndexClassification(mockUser, classificationSeriesMock); + when(classificationSeriesRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(classificationSeriesMock)); + when(userRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(mockUser)); + Assertions.assertThrows(KlassMessageException.class, () -> + subject.deleteNotIndexClassification(mockUser, classificationSeriesMock)); } @Test @@ -314,9 +314,9 @@ public void testDeleteNotOwnerClasificationWithSuperUser() throws Exception { when(classification.getContactPerson()).thenReturn(mockOwner); when(classification.isPublishedInAnyLanguage()).thenReturn(false); when(classification.getOwnerClassification()).thenReturn(classification); - when(classificationSeriesRepositoryMock.findOne(any(Long.class))).thenReturn(classification); + when(classificationSeriesRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(classification)); when(classificationSeriesRepositoryMock.save(classification)).thenReturn(classification); - when(userRepositoryMock.findOne(any(Long.class))).thenReturn(mockUser); + when(userRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(mockUser)); subject.deleteNotIndexClassification(mockUser, classification); verify(classificationSeriesRepositoryMock, times(1)).save(classification); } @@ -332,9 +332,9 @@ public void testDeletePublishedClasificationWithSuperUser() throws Exception { when(classification.getContactPerson()).thenReturn(mockOwner); when(classification.getOwnerClassification()).thenReturn(classification); when(classification.isPublishedInAnyLanguage()).thenReturn(true); - when(classificationSeriesRepositoryMock.findOne(any(Long.class))).thenReturn(classification); + when(classificationSeriesRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(classification)); when(classificationSeriesRepositoryMock.save(classification)).thenReturn(classification); - when(userRepositoryMock.findOne(any(Long.class))).thenReturn(mockUser); + when(userRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(mockUser)); subject.deleteNotIndexClassification(mockUser, classification); verify(classificationSeriesRepositoryMock, times(1)).save(classification); } @@ -347,8 +347,8 @@ public void testDeleteClasificationNotPublished() throws Exception { classification.setContactPerson(mockUser); classification.setId(1L); - when(classificationSeriesRepositoryMock.findOne(any(Long.class))).thenReturn(classification); - when(userRepositoryMock.findOne(any(Long.class))).thenReturn(mockUser); + when(classificationSeriesRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(classification)); + when(userRepositoryMock.findById(any(Long.class))).thenReturn(Optional.of(mockUser)); when(classificationSeriesRepositoryMock.save(classification)).thenReturn(classification); subject.deleteNotIndexClassification(classification.getContactPerson(), classification); verify(classificationSeriesRepositoryMock, times(1)).save(classification); @@ -403,11 +403,11 @@ public void testSaveStatisticalUnit() { answer.setId(1L); return answer; }); - assertThat(input.getId(), nullValue()); + assertThat(input.getId()).isNull(); StatisticalUnit output = subject.saveStatisticalUnit(input); verify(statisticalUnitRepositoryMock, times(1)).save(input); - assertThat(output.getId(), is(1L)); - assertThat(output.getName(Language.NN), is("test")); + assertThat(output.getId()).isEqualTo(1L); + assertThat(output.getName(Language.NN)).isEqualTo("test"); } @@ -418,7 +418,7 @@ public void testFindAllStatisticalUnits() { when(statisticalUnitRepositoryMock.findAll()).thenReturn(statisticalUnitsValues); List statisticalUnits = subject.findAllStatisticalUnits(); - assertThat(statisticalUnits.size(), is(2)); + assertThat(statisticalUnits.size()).isEqualTo(2); verify(statisticalUnitRepositoryMock, times(1)).findAll(); } @@ -467,7 +467,7 @@ public ClassificationVersion answer(InvocationOnMock invocation) throws Throwabl new User("Donald", "Doanld Duck", "Gakk")); classificationSeries.addClassificationVersion(classificationVersion); - when(classificationVersionRepositoryMock.findOne(anyLong())).thenReturn(classificationVersion); + when(classificationVersionRepositoryMock.findById(any())).thenReturn(Optional.of(classificationVersion)); ClassificationVersion classificationVersionCopy = subject.copyClassificationVersion(classificationVersion, rangeCopy); @@ -725,7 +725,7 @@ private boolean findEqualClassificationItem(List copyedItems } private Pageable createPageable() { - return new PageRequest(0, 3); + return PageRequest.of(0, 3); } } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/service/StatisticsServiceImplTest.java b/klass-shared/src/test/java/no/ssb/klass/core/service/StatisticsServiceImplTest.java index d69c4d2b..5e6320ba 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/service/StatisticsServiceImplTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/service/StatisticsServiceImplTest.java @@ -1,10 +1,10 @@ package no.ssb.klass.core.service; -import static org.junit.Assert.*; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyBoolean; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.eq; import static org.mockito.Mockito.*; import java.time.LocalDate; @@ -13,9 +13,9 @@ import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; @@ -43,7 +43,7 @@ //import no.ssb.klass.designer.admin.util.UsageStatisticsRows.ReportDescription; //import no.ssb.klass.designer.admin.util.UsageStatisticsRows.UseStatisticsModeChoice; -@Ignore ("API er omskrevet for å løskoble Vaadin komponenter/logikk disse restene må splittes i service og klient") +@Disabled ("API er omskrevet for å løskoble Vaadin komponenter/logikk disse restene må splittes i service og klient") public class StatisticsServiceImplTest { // private ClassificationSeriesRepository classificationSeriesRepositoryMock; // private SearchWordsRepository searchWordsRepositoryMock; @@ -52,7 +52,7 @@ public class StatisticsServiceImplTest { // private SubscriberRepository subscriberRepositoryMock; // private StatisticsServiceImpl subject; // -// @Before +// @BeforeEach // public void setup() { // classificationSeriesRepositoryMock = mock(ClassificationSeriesRepository.class); // searchWordsRepositoryMock = mock(SearchWordsRepository.class); @@ -163,7 +163,7 @@ public class StatisticsServiceImplTest { // .thenReturn(makeTestData()); // UsageStatisticsData result = subject.getUsageStatistics(getFromDate(), getToDate(), // UseStatisticsModeChoice.TOTAL_CLASSIFIC, -// new PageRequest(0, Integer.MAX_VALUE)); +// PageRequest.of(0, Integer.MAX_VALUE)); // checkResult(result); // } // @@ -174,7 +174,7 @@ public class StatisticsServiceImplTest { // .thenReturn(makeTestData()); // UsageStatisticsData result = subject.getUsageStatistics(getFromDate(), getToDate(), // UseStatisticsModeChoice.NUMBEROF_SEARCH_RETURNED_NULL, -// new PageRequest(0, Integer.MAX_VALUE)); +// PageRequest.of(0, Integer.MAX_VALUE)); // checkResult(result); // } // @@ -184,7 +184,7 @@ public class StatisticsServiceImplTest { // .thenReturn(makeTestData()); // UsageStatisticsData result = subject.getUsageStatistics(getFromDate(), getToDate(), // UseStatisticsModeChoice.TOTAL_SEARCH_WORDS, -// new PageRequest(0, Integer.MAX_VALUE)); +// PageRequest.of(0, Integer.MAX_VALUE)); // checkResult(result); // } // diff --git a/klass-shared/src/test/java/no/ssb/klass/core/service/SubscriberServiceTest.java b/klass-shared/src/test/java/no/ssb/klass/core/service/SubscriberServiceTest.java index 545076cb..6d1c2c02 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/service/SubscriberServiceTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/service/SubscriberServiceTest.java @@ -1,13 +1,14 @@ package no.ssb.klass.core.service; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; import java.net.URL; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import no.ssb.klass.core.model.ClassificationSeries; import no.ssb.klass.core.model.Subscriber; @@ -26,7 +27,7 @@ public class SubscriberServiceTest { private SubscriberRepository subscriberRepositoryMock; private MailService mailServiceMock; - @Before + @BeforeEach public void setup() { subscriberRepositoryMock = mock(SubscriberRepository.class); mailServiceMock = mock(MailService.class); @@ -69,14 +70,15 @@ public void removeTracking() throws Exception { assertEquals(true, result); } - @Test(expected = ClientException.class) + @Test public void removeTrackingClassificationNotExist() { // when Subscriber subscriber = new Subscriber(EMAIL); ClassificationSeries classification = TestUtil.createClassificationWithId(1, NAME); Optional opt = Optional.of(subscriber); when(subscriberRepositoryMock.findOneByEmail(EMAIL)).thenReturn(opt); - subject.removeTracking(EMAIL, classification); + Assertions.assertThrows(ClientException.class, () -> + subject.removeTracking(EMAIL, classification)); } @Test @@ -93,12 +95,13 @@ public void verifyTracking() throws Exception { assertEquals(Verification.VALID, verification); } - @Test(expected = RuntimeException.class) + @Test public void verifyTrackingNotExist() { // when Optional opt = Optional.empty(); when(subscriberRepositoryMock.findOneByEmail(EMAIL)).thenReturn(opt); - subject.verifyTracking(EMAIL, TOKEN); + Assertions.assertThrows(RuntimeException.class, () -> + subject.verifyTracking(EMAIL, TOKEN)); // then exception } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/util/BaseEntityInterceptorTest.java b/klass-shared/src/test/java/no/ssb/klass/core/util/BaseEntityInterceptorTest.java index 3b98af2c..13566747 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/util/BaseEntityInterceptorTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/util/BaseEntityInterceptorTest.java @@ -1,17 +1,17 @@ package no.ssb.klass.core.util; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.hibernate.EntityMode; -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.ClassificationSeries; public class BaseEntityInterceptorTest { private BaseEntityInterceptor subject; - @Before + @BeforeEach public void setup() { subject = new BaseEntityInterceptor(); } diff --git a/klass-shared/src/test/java/no/ssb/klass/core/util/DateRangeTest.java b/klass-shared/src/test/java/no/ssb/klass/core/util/DateRangeTest.java index a71f0a55..7d6e93cc 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/util/DateRangeTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/util/DateRangeTest.java @@ -1,11 +1,11 @@ package no.ssb.klass.core.util; -import static org.junit.Assert.*; import java.time.LocalDate; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class DateRangeTest { @@ -137,16 +137,13 @@ public void subRangeCommutativeTest() { * result none * */ - @Test(expected = IllegalArgumentException.class) + @Test public void subRangeNoOverlapTest() { - // given - DateRange subject = DateRange.create("2012-01-01", "2014-01-01"); - DateRange other = DateRange.create("2014-01-01", "2016-01-01"); - - // when - subject.subRange(other); - - // then expect exception + Assertions.assertThrows(IllegalArgumentException.class, () -> { + DateRange subject = DateRange.create("2012-01-01", "2014-01-01"); + DateRange other = DateRange.create("2014-01-01", "2016-01-01"); + subject.subRange(other); + }); } @Test @@ -164,14 +161,18 @@ public void containsTest() { assertFalse(subject.contains(end)); } - @Test(expected = IllegalArgumentException.class) + @Test public void fromAfterTo() { - DateRange.create("2018-01-01", "2016-01-01"); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + DateRange.create("2018-01-01", "2016-01-01"); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void fromEqualTo() { - DateRange.create("2016-01-01", "2016-01-01"); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + DateRange.create("2016-01-01", "2016-01-01"); + }); } /** diff --git a/klass-shared/src/test/java/no/ssb/klass/core/util/TimeUtilTest.java b/klass-shared/src/test/java/no/ssb/klass/core/util/TimeUtilTest.java index 66052f01..3d28ec18 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/util/TimeUtilTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/util/TimeUtilTest.java @@ -1,13 +1,13 @@ package no.ssb.klass.core.util; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.common.collect.Lists; diff --git a/klass-shared/src/test/java/no/ssb/klass/core/util/TranslatablePersistenceConverterTest.java b/klass-shared/src/test/java/no/ssb/klass/core/util/TranslatablePersistenceConverterTest.java index 53189d66..0bbfbee2 100644 --- a/klass-shared/src/test/java/no/ssb/klass/core/util/TranslatablePersistenceConverterTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/core/util/TranslatablePersistenceConverterTest.java @@ -1,14 +1,14 @@ package no.ssb.klass.core.util; -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; public class TranslatablePersistenceConverterTest { private TranslatablePersistenceConverter subject; - @Before + @BeforeEach public void setup() { subject = new TranslatablePersistenceConverter(); } diff --git a/klass-shared/src/test/java/no/ssb/klass/datadok/DatadokTest.java b/klass-shared/src/test/java/no/ssb/klass/datadok/DatadokTest.java index 67779d87..a040c2c0 100644 --- a/klass-shared/src/test/java/no/ssb/klass/datadok/DatadokTest.java +++ b/klass-shared/src/test/java/no/ssb/klass/datadok/DatadokTest.java @@ -15,8 +15,8 @@ import java.util.TreeMap; import org.apache.commons.lang3.StringUtils; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; @@ -36,7 +36,7 @@ // This test is used for filtering codelists from datadok. Probably delete after migration from Datadok, // if deleted remember to also delete resources datadoc_codes and datadok_metadata -@Ignore +@Disabled public class DatadokTest { private static final Logger log = LoggerFactory.getLogger(DatadokTest.class); diff --git a/klass-solr/pom.xml b/klass-solr/pom.xml index 23a4d4b8..ff685b77 100644 --- a/klass-solr/pom.xml +++ b/klass-solr/pom.xml @@ -9,7 +9,7 @@ no.ssb.klass klass-root - 2.1.8-SNAPSHOT + 3.0.0-SNAPSHOT @@ -31,36 +31,37 @@ org.springframework.data spring-data-solr - 2.1.0.RELEASE org.apache.solr - solr-solrj - ${solr-version} - + solr-core - org.codehaus.woodstox - wstx-asl + org.eclipse.jetty + jetty-client - - - - - org.apache.solr - solr-dataimporthandler - 5.5.0 - - - org.codehaus.woodstox - wstx-asl + org.apache.logging.log4j + log4j-slf4j-impl + - - + + commons-io + commons-io + ${commons-io-version} + + + javax.servlet + javax.servlet-api + 3.1.0 + + + org.hibernate.validator + hibernate-validator + org.springframework.boot spring-boot-starter-test diff --git a/klass-solr/src/main/java/no/ssb/klass/solr/KlassSolrApplication.java b/klass-solr/src/main/java/no/ssb/klass/solr/KlassSolrApplication.java index 980d54ee..ba41e142 100644 --- a/klass-solr/src/main/java/no/ssb/klass/solr/KlassSolrApplication.java +++ b/klass-solr/src/main/java/no/ssb/klass/solr/KlassSolrApplication.java @@ -2,7 +2,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.web.support.SpringBootServletInitializer; /** * Class made for test purposes. diff --git a/klass-solr/src/main/java/no/ssb/klass/solr/config/KlassSearchConfiguration.java b/klass-solr/src/main/java/no/ssb/klass/solr/config/KlassSearchConfiguration.java index 393bf019..bbc0d129 100644 --- a/klass-solr/src/main/java/no/ssb/klass/solr/config/KlassSearchConfiguration.java +++ b/klass-solr/src/main/java/no/ssb/klass/solr/config/KlassSearchConfiguration.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; import java.util.concurrent.Executor; import org.apache.commons.io.FileUtils; @@ -14,6 +15,7 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.request.RequestWriter; import org.apache.solr.core.CoreContainer; +import org.apache.solr.core.SolrXmlConfig; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; @@ -61,7 +63,7 @@ public SolrClient embeddedSolrServerAndClient() { exportResource("solr/embedded/Klass/solrconfig.xml", solrTempWorkspace + "/klass"); exportResource("solr/embedded/Klass/stoppord.txt", solrTempWorkspace + "/klass"); exportResource("solr/embedded/Klass/synonymer.txt", solrTempWorkspace + "/klass"); - coreContainer = new CoreContainer(solrTempWorkspace); + coreContainer = new CoreContainer(SolrXmlConfig.fromSolrHome(new File(solrTempWorkspace).toPath(), null)); coreContainer.load(); } catch (Exception e) { e.printStackTrace(System.err); @@ -79,7 +81,7 @@ private void exportResource(String resourcePath, String targetPath) throws Excep @Bean public SolrTemplate solrCore2Template(SolrClient solrClient) { - SolrTemplate solrTemplate = new SolrTemplate(solrClient, solrCore); + SolrTemplate solrTemplate = new SolrTemplate(solrClient); return solrTemplate; } @@ -101,7 +103,7 @@ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { protected static class SolrBackwardsCompatibleHttpClient extends HttpSolrClient { SolrBackwardsCompatibleHttpClient(String baseURL) { - super(baseURL); + super(new Builder(baseURL)); } /* Removing collection parameter since it causes wrong query URL */ diff --git a/klass-solr/src/main/resources/solr/embedded/Klass/schema.xml b/klass-solr/src/main/resources/solr/embedded/Klass/schema.xml index 449057b6..8d79ce3c 100644 --- a/klass-solr/src/main/resources/solr/embedded/Klass/schema.xml +++ b/klass-solr/src/main/resources/solr/embedded/Klass/schema.xml @@ -214,8 +214,7 @@ - + @@ -230,8 +229,7 @@ - + @@ -240,7 +238,6 @@ - @@ -307,10 +304,10 @@ uuid - content + text - + false + --> + --> @@ -28,57 +28,35 @@ - - 1.8 + 17 UTF-8 UTF-8 statisticsnorway/klass 3.0.2 2.17 - 5.5.5 - 4.3.7.RELEASE - 1.0.0 - 0.0.7.RELEASE + 8.5.2 2.4 19.0 - 7.7.17 - 7.7.25 - 7.7.14 - local 4.4.1 3.4 - 2.9.0 + 5.4.0 1.5.5 2.2.4 - 0.13.1 + 0.15.3 2.2 - - - - 5.2.3.Final - - - - 4.1.1 - - 1.2.1.RELEASE + 10.0.1 + 2.3.1 + 2.15.1 + 2.1.6 + 2.0.8.RELEASE - com.vaadin - vaadin-bom - ${vaadin-version} - pom - import - - - com.jayway.restassured + io.rest-assured rest-assured ${rest-assured-version} test @@ -86,7 +64,7 @@ org.springframework.data spring-data-solr - 2.1.0.RELEASE + 4.3.15