diff --git a/klass-api/pom.xml b/klass-api/pom.xml
index b30fcb49..33bc2038 100644
--- a/klass-api/pom.xml
+++ b/klass-api/pom.xml
@@ -59,6 +59,12 @@
org.springframework.data
spring-data-solr
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+ 2.3.3
+ provided
+
@@ -77,10 +83,9 @@
- javax.servlet
- jstl
+ jakarta.servlet.jsp.jstl
+ jakarta.servlet.jsp.jstl-api
-
javax.el
javax.el-api
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..f5d6d01c 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,32 +4,33 @@
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")
- .antMatchers("/manage/**").denyAll()
+ .requestMatchers("/manage**").denyAll() // alt. hasIpAddress("127.0.0.1")
+ .requestMatchers("/manage/**").denyAll()
// MLO: Some endpoints might be useful, consider allowing non sensitive ones.
// .antMatchers("/manage/metrics").permitAll()
// allow rest API and health checks
- .antMatchers(RestConstants.API_VERSION_V1 + "/**").permitAll()
- .antMatchers(PingController.PATH).permitAll()
- .antMatchers(MonitorController.PATH).permitAll()
+ .requestMatchers(RestConstants.API_VERSION_V1 + "/**").permitAll()
+ .requestMatchers(PingController.PATH).permitAll()
+ .requestMatchers(MonitorController.PATH).permitAll()
.and()
.csrf().disable()
@@ -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..46291480 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
@@ -47,10 +47,11 @@
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.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;
@@ -68,7 +69,7 @@
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.web.servlet.view.RedirectView;
-import javax.transaction.Transactional;
+import jakarta.transaction.Transactional;
import java.beans.PropertyEditorSupport;
import java.net.MalformedURLException;
import java.net.URL;
@@ -145,7 +146,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 +161,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,11 +179,11 @@ 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)
@@ -196,8 +197,8 @@ public KlassPagedResources classifications(
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 +212,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 +486,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,10 +538,10 @@ 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() {
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..e4e89c6b 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
@@ -87,7 +87,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/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..bf401719 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,5 +1,6 @@
package no.ssb.klass.api.dto;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -8,12 +9,14 @@
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 +33,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 +51,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..c49ecb63 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,6 +1,6 @@
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;
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..3e54e8bc 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,9 +1,9 @@
package no.ssb.klass.api.dto.hal;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
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;
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..c52ff768 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
@@ -8,13 +8,13 @@
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 org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
@JacksonXmlRootElement(localName = "classification")
public class ClassificationResource extends ClassificationSummaryResource {
@@ -92,51 +92,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..5a02ea20 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,13 @@
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 org.springframework.hateoas.Link;
-import org.springframework.hateoas.core.Relation;
+import org.springframework.hateoas.server.core.Relation;
import com.fasterxml.jackson.annotation.JsonFormat;
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..d67f10a3 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,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;
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..5da488b1 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
@@ -18,7 +18,7 @@
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.*;
public class ClassificationVersionSummaryResource extends KlassResource {
private final String name;
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..d49f86b5 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;
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..e82604d5 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,28 +1,28 @@
package no.ssb.klass.api.dto.hal;
-import java.util.List;
-
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.ResourceSupport;
+import org.springframework.hateoas.Links;
+import org.springframework.hateoas.PagedModel;
+import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.UriTemplate;
-import org.springframework.hateoas.mvc.ControllerLinkBuilder;
+import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public abstract class KlassResource extends ResourceSupport {
+public abstract class KlassResource extends PagedModel> {
protected void addLink(Link link) {
- getLinks().add(link);
+ super.add(link);
}
- protected UriTemplate createUriTemplate(ControllerLinkBuilder linkBuilder, String... parameters) {
+ protected UriTemplate createUriTemplate(WebMvcLinkBuilder linkBuilder, String... parameters) {
return ResourceUtil.createUriTemplate(linkBuilder, parameters);
}
@Override
@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/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..32c48c18 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,13 +1,13 @@
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 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;
diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SsbSectionResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SsbSectionResource.java
index 08dc5a62..0790ce5a 100644
--- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SsbSectionResource.java
+++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/SsbSectionResource.java
@@ -1,6 +1,6 @@
package no.ssb.klass.api.dto.hal;
-import org.springframework.hateoas.core.Relation;
+import org.springframework.hateoas.server.core.Relation;
@Relation(collectionRelation = "ssbSections")
public class SsbSectionResource extends KlassResource {
diff --git a/klass-api/src/test/java/no/ssb/klass/api/ApiDocumentation.java b/klass-api/src/test/java/no/ssb/klass/api/ApiDocumentation.java
index ff13d965..c3ed9b24 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/ApiDocumentation.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/ApiDocumentation.java
@@ -27,11 +27,10 @@
import no.ssb.klass.core.util.Translatable;
import no.ssb.klass.core.config.ConfigurationProfiles;
import no.ssb.klass.testutil.TestUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-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.Test;
+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;
@@ -43,11 +42,12 @@
import org.springframework.data.solr.core.query.result.SolrResultPage;
import org.springframework.http.MediaType;
import org.springframework.restdocs.JUnitRestDocumentation;
+import org.springframework.restdocs.RestDocumentationExtension;
import org.springframework.restdocs.generate.RestDocumentationGenerator;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.restdocs.request.ParameterDescriptor;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -60,9 +60,8 @@
import java.util.Date;
import java.util.List;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.halLinks;
@@ -76,11 +75,11 @@
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.relaxedResponseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
-import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
+import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith({SpringExtension.class, RestDocumentationExtension.class})
@SpringBootTest(classes = { TestConfig.class, MockConfig.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles(ConfigurationProfiles.H2_INMEMORY)
public class ApiDocumentation {
@@ -92,7 +91,6 @@ public class ApiDocumentation {
private static final int CLASS_ID_BYDELSINNDELING = 103;
private static final int CLASS_ID_KOMMUNEINNDELING = 131;
private static final int CLASS_ID_FYLKEINNDELING = 104;
- @Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");
private RestDocumentationResultHandler documentationHandler;
@Autowired
@@ -109,7 +107,7 @@ public class ApiDocumentation {
@Value("${klass.env.api.path}")
private String contextPath;
- @Before
+ @BeforeEach
public void setup() {
this.documentationHandler = document("{method-name}", preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
@@ -122,14 +120,14 @@ public void setup() {
.alwaysDo(this.documentationHandler).build();
}
- @After
+ @AfterEach
public void teardown() {
reset(classificationServiceMock);
}
@Test
public void errorExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenThrow(
+ when(classificationServiceMock.getClassificationSeries(any())).thenThrow(
new KlassResourceNotFoundException("Classification not found with id = 99999"));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/99999"))
@@ -170,7 +168,7 @@ public void classificationFamiliesOptionalParametersExample() throws Exception {
this.mockMvc.perform(getWithContext("/classificationfamilies?ssbSection=714&includeCodelists=true&language=nb")
.accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
ssbSectionParameterDescription("counting number of"),
includeCodelistsParameterDescription("counting number of"),
languageDescription())))
@@ -204,7 +202,7 @@ public void classificationFamilyOptionalParametersExample() throws Exception {
this.mockMvc.perform(getWithContext("/classificationfamilies/" + CLASS_FAMILY_BEFOLKNING + "?ssbSection=714&includeCodelists=true&language=nb")
.accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
ssbSectionParameterDescription("listing"),
includeCodelistsParameterDescription("listing"),
languageDescription())))
@@ -236,7 +234,7 @@ public void classificationsExample() throws Exception {
createClassificationBydelsinndeling(),
createClassificationFamiliegruppering(TestUtil.createUser()));
when(classificationServiceMock.findAllPublic(anyBoolean(), any(Date.class), any(Pageable.class))).then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), classifications));
+ i -> createPage(i.getArgument(2, Pageable.class), classifications));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications").accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(links(
@@ -257,12 +255,12 @@ public void classificationsExample() throws Exception {
@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))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
includeCodelistsDescription(),
changedSinceDescription())))
.andExpect(status().isOk());
@@ -272,7 +270,7 @@ 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)));
+ .then(i -> createSearchPage(i.getArgument(2, Pageable.class)));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/search?query=kommuner").accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
@@ -294,12 +292,12 @@ 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))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
parameterWithName("query").description("[Mandatory] specifies search terms"),
includeCodelistsDescription(),
ssbSectionParameterDescription("searching"))))
@@ -309,7 +307,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,14 +348,14 @@ public void classificationExample() throws Exception {
@Test
public void classificationOptionalParametersExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenReturn(
+ when(classificationServiceMock.getClassificationSeries(any())).thenReturn(
createClassificationKommuneinndeling());
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications/" + CLASS_ID_KOMMUNEINNDELING + "?language=nb&includeFuture=true")
.accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
- requestParameters(languageDescription(),includeFutureDescription(""))))
+ queryParameters(languageDescription(),includeFutureDescription(""))))
.andExpect(status().isOk());
// @formatter:on
}
@@ -402,7 +400,7 @@ public void versionsRequestParametersExample() throws Exception {
this.mockMvc.perform(getWithContext("/versions/" + CLASS_ID_KOMMUNEINNDELING + "?language=nb&includeFuture=true")
.accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
- requestParameters(languageDescription(),includeFutureDescription(""))))
+ queryParameters(languageDescription(),includeFutureDescription(""))))
.andExpect(status().isOk());
// @formatter:on
}
@@ -460,7 +458,7 @@ public void codesOptionalParametersExample() throws Exception {
.accept("text/csv"))
.andDo(this.documentationHandler
.document(
- requestParameters(
+ queryParameters(
fromParameterDescription(),
toParameterDescription(),
csvSeparatorParameterDescription(),
@@ -511,7 +509,7 @@ public void codesAtOptionalParametersExample() throws Exception {
+ "/codesAt?date=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(
+ queryParameters(
dateParameterDescription(),
csvSeparatorParameterDescription(),
csvFieldsParameterDescription(),
@@ -574,7 +572,7 @@ public void variantOptionalParametersExample() throws Exception {
preprocessRequest(prettyPrint()),
preprocessResponse(/*prettyPrint()*/)))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
variantNameParameterDescription(),
fromParameterDescription(),
toParameterDescription(),
@@ -637,7 +635,7 @@ public void variantAtOptionalParametersExample() throws Exception {
preprocessRequest(prettyPrint()),
preprocessResponse(/*prettyPrint()*/)))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
variantNameParameterDescription(),
dateParameterDescription(),
csvSeparatorParameterDescription(),
@@ -689,7 +687,7 @@ public void variantsRequestParametersExample() throws Exception {
this.mockMvc.perform(getWithContext("/variants/" + 1111L + "?language=nb")
.accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
- requestParameters(languageDescription())))
+ queryParameters(languageDescription())))
.andExpect(status().isOk());
// @formatter:on
}
@@ -745,7 +743,7 @@ public void correspondsOptionalParametersExample() throws Exception {
preprocessRequest(prettyPrint()),
preprocessResponse(/*prettyPrint()*/)))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
targetClassificationIdParameterDescription(),
fromParameterDescription(),
toParameterDescription(),
@@ -790,7 +788,7 @@ public void correspondsAtOptionalParametersExample() throws Exception {
preprocessRequest(prettyPrint()),
preprocessResponse(/*prettyPrint()*/)))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
targetClassificationIdParameterDescription(),
dateParameterDescription(),
csvSeparatorParameterDescription(),
@@ -853,14 +851,14 @@ public void correspondenceTablesOptionalParametersExample() throws Exception {
this.mockMvc.perform(getWithContext("/correspondencetables/" + 1L + "?language=nb")
.accept(MediaType.APPLICATION_JSON))
.andDo(this.documentationHandler.document(
- requestParameters(languageDescription())))
+ queryParameters(languageDescription())))
.andExpect(status().isOk());
// @formatter:on
}
@Test
public void changesExample() throws Exception {
- when(classificationServiceMock.getClassificationSeries(anyObject())).thenReturn(
+ when(classificationServiceMock.getClassificationSeries(any())).thenReturn(
createClassificationKommuneinndeling());
// @formatter:off
this.mockMvc.perform(
@@ -875,7 +873,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(
@@ -886,7 +884,7 @@ public void changesOptionalParametersExample() throws Exception {
preprocessRequest(prettyPrint()),
preprocessResponse(/*prettyPrint()*/)))
.andDo(this.documentationHandler.document(
- requestParameters(
+ queryParameters(
fromParameterDescription(),
toParameterDescription(),
csvSeparatorParameterDescription(),
@@ -986,7 +984,7 @@ public void changedSinceExample() throws Exception {
createClassificationFamiliegruppering(TestUtil.createUser()));
when(classificationServiceMock.findAllPublic(anyBoolean(), any(Date.class), any(Pageable.class))).then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), classifications));
+ i -> createPage(i.getArgument(2, Pageable.class), classifications));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications?changedSince=2015-03-01T01:30:00.000-0200")
@@ -1109,7 +1107,7 @@ public void pageExample() throws Exception {
createClassificationFamiliegruppering(TestUtil.createUser()));
when(classificationServiceMock.findAllPublic(any(Boolean.class), any(Date.class), any(Pageable.class)))
.then(
- i -> createPage(i.getArgumentAt(2, Pageable.class), classifications));
+ i -> createPage(i.getArgument(2, Pageable.class), classifications));
// @formatter:off
this.mockMvc.perform(getWithContext("/classifications?size=2").accept(MediaType.APPLICATION_JSON))
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..5a90f1ec 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)
@@ -129,7 +129,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..e2e4b547 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
@@ -4,7 +4,7 @@
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;
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..f6dd409e 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
@@ -3,7 +3,7 @@
import static com.jayway.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;
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..5398bc76 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
@@ -4,7 +4,7 @@
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;
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..61e24f24 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
@@ -2,7 +2,7 @@
import com.jayway.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;
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..5599d1da 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
@@ -2,7 +2,7 @@
import com.jayway.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;
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..18630014 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,7 +1,7 @@
package no.ssb.klass.api.applicationtest;
import com.jayway.restassured.http.ContentType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import static com.jayway.restassured.RestAssured.given;
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..a076e564 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
@@ -2,7 +2,7 @@
import com.jayway.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;
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..390a087a 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
@@ -4,8 +4,8 @@
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;
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..aeb74474 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
@@ -4,8 +4,8 @@
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;
@@ -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..147b50cd 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
@@ -2,7 +2,7 @@
import static com.jayway.restassured.RestAssured.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import com.jayway.restassured.http.ContentType;
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..00131aee 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
@@ -3,7 +3,7 @@
import static com.jayway.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;
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..0b08cd58 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
@@ -4,7 +4,7 @@
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;
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..8ab475e8 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
@@ -3,7 +3,7 @@
import static com.jayway.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;
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..6f3fbdd0 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
@@ -4,7 +4,7 @@
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;
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..a8173ee7 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
@@ -2,7 +2,7 @@
import com.jayway.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;
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..9e17263d 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
@@ -2,7 +2,7 @@
import com.jayway.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;
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..54191620 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,7 +10,6 @@
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;
@@ -18,6 +17,7 @@
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.
@@ -49,10 +49,11 @@ public ApplicationTestUtil applicationTestUtil() {
}
@Configuration
- static class TestSecurityConfiguration extends WebSecurityConfigurerAdapter {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests().antMatchers("/**").permitAll();
+ static class TestSecurityConfiguration {
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
+ http.authorizeRequests().requestMatchers("/**").permitAll();
+ return http.build();
}
}
}
diff --git a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/utils/ApplicationTestUtil.java b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/utils/ApplicationTestUtil.java
index fda08b85..c5bc1b04 100644
--- a/klass-api/src/test/java/no/ssb/klass/api/applicationtest/utils/ApplicationTestUtil.java
+++ b/klass-api/src/test/java/no/ssb/klass/api/applicationtest/utils/ApplicationTestUtil.java
@@ -2,8 +2,8 @@
import java.io.IOException;
-import javax.persistence.EntityManager;
-import javax.transaction.Transactional;
+import jakarta.persistence.EntityManager;
+import jakarta.transaction.Transactional;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
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..4f0f6181 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()));
}
@@ -32,8 +32,7 @@ public void create() {
// then
assertEquals(name, subject.getName());
- assertEquals("http://localhost" + RestConstants.API_VERSION_V1 + "/classifications/" + id, subject.getLink("self")
- .getHref());
+ assertEquals("http://localhost" + RestConstants.API_VERSION_V1 + "/classifications/" + id, subject.getLink("self"));
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..65b12b3e 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,8 @@ 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" + RestConstants.API_VERSION_V1 + "/versions/1", subject.getLink("self").orElseThrow());
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/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 29f25959..1664be10 100644
--- a/klass-forvaltning/pom.xml
+++ b/klass-forvaltning/pom.xml
@@ -79,10 +79,9 @@
- javax.servlet
- jstl
+ jakarta.servlet.jsp.jstl
+ jakarta.servlet.jsp.jstl-api
-
javax.el
javax.el-api
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..72f4b48c 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/KlassForvaltningApplication.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/KlassForvaltningApplication.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 KlassForvaltningApplication extends SpringBootServletInitializer {
// TODO kmgv if using embedded container (e.g. Tomcat) remove below method and extends SpringBootServletInitializer
@Override
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/designer/ClassificationSearchView.java b/klass-forvaltning/src/main/java/no/ssb/klass/designer/ClassificationSearchView.java
index d2229105..4c038ce2 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/designer/ClassificationSearchView.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/designer/ClassificationSearchView.java
@@ -82,7 +82,7 @@ public ClassificationSearchView() {
}
private FacetAndHighlightPage getPage(String searchQuery, int page) {
- return searchService.internalSearch(searchQuery, new PageRequest(page, resultsPerPage),
+ return searchService.internalSearch(searchQuery, PageRequest.of(page, resultsPerPage),
classificationFilter.getCurrentSection(), classificationFilter.getCurrentClassificationType(), facets);
}
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/DetailedUseReportView.java b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/DetailedUseReportView.java
index 76a5b9d2..e1fbe664 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/DetailedUseReportView.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/DetailedUseReportView.java
@@ -65,7 +65,7 @@ public void makeDetailedReport(StatisticsService statisticsService,
detailedUseReport.setColumnHeader("Value", "" + header + "");
pagingButtons.removeAllComponents();
headingText.setValue(getHeadingText(reportMode, fromSearchDate, toSearchDate));
- PageRequest pageRequest = new PageRequest(0, LINES_PER_PAGE);
+ PageRequest pageRequest = PageRequest.of(0, LINES_PER_PAGE);
Page reportData = showReportPage(pageRequest);
numberOfRowsHeader.setValue("Totalt antall: " + reportData.getTotalElements());
if (reportData.getTotalPages() > 1) {
@@ -91,7 +91,7 @@ private void nextButton(ClickEvent e) {
}
}
int pageNumber = (int)e.getButton().getData();
- showReportPage(new PageRequest(pageNumber, LINES_PER_PAGE));
+ showReportPage(PageRequest.of(pageNumber, LINES_PER_PAGE));
}
private Page showReportPage(PageRequest pageRequest) {
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/StatisticalUnitView.java b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/StatisticalUnitView.java
index 3e92f917..447b35a0 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/StatisticalUnitView.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/StatisticalUnitView.java
@@ -81,7 +81,7 @@ private void printRow(UsageStatisticsData usageStatisticsData) {
private UsageStatisticsData getReportData() {
- Page overView = statisticsService.getStaticalUnitsOverView(new PageRequest(0, Integer.MAX_VALUE));
+ Page overView = statisticsService.getStaticalUnitsOverView(PageRequest.of(0, Integer.MAX_VALUE));
return new UsageStatisticsData(overView);
}
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/UseStatisticsView.java b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/UseStatisticsView.java
index ab983721..cb657633 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/UseStatisticsView.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/UseStatisticsView.java
@@ -125,7 +125,7 @@ private InputStream generateReport(UseStatisticsModeChoice useStatisticsModeChoi
LocalDate fromSearchDate = TimeUtil.toLocalDate(fromDate.getValue());
LocalDate toSearchDate = TimeUtil.toLocalDate(toDate.getValue());
usageStatisticsData = new UsageStatisticsData(statisticsService.getUsageStatistics(fromSearchDate, toSearchDate,
- ChoiceMapper.map(choice), new PageRequest(0, Integer.MAX_VALUE)));
+ ChoiceMapper.map(choice), PageRequest.of(0, Integer.MAX_VALUE)));
reports.put(choice, usageStatisticsData);
}
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/tabs/SubscriberUnitTab.java b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/tabs/SubscriberUnitTab.java
index a691abe5..96425a9a 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/tabs/SubscriberUnitTab.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/designer/admin/tabs/SubscriberUnitTab.java
@@ -154,20 +154,20 @@ private InputStream generateReport(SubscriberModeChoice subscriberModeChoice) {
// subscribers
Page subscriberStatisticsData =
- statisticsService.getSubscriberReport(ChoiceMapper.map(choice), new PageRequest(0, Integer.MAX_VALUE));
+ statisticsService.getSubscriberReport(ChoiceMapper.map(choice), PageRequest.of(0, Integer.MAX_VALUE));
excelData.append("Brukernavn").append(CSV_SEPARATOR).append("Antall abonnementer").append('\n');
excelData.append(formatForExcel(subscriberStatisticsData));
// domains
subscriberStatisticsData =
- statisticsService.getSubscriberDomainReport(ChoiceMapper.map(choice), new PageRequest(0, Integer.MAX_VALUE));
+ statisticsService.getSubscriberDomainReport(ChoiceMapper.map(choice), PageRequest.of(0, Integer.MAX_VALUE));
excelData.append('\n');
excelData.append("Domene").append(CSV_SEPARATOR).append("Antall abonnementer").append('\n');
excelData.append(formatForExcel(subscriberStatisticsData));
// classifications
subscriberStatisticsData =
- statisticsService.getSubscriberClassificationReport(ChoiceMapper.map(choice), new PageRequest(0, Integer.MAX_VALUE));
+ statisticsService.getSubscriberClassificationReport(ChoiceMapper.map(choice), PageRequest.of(0, Integer.MAX_VALUE));
excelData.append('\n');
excelData.append("Klassifikasjon").append(CSV_SEPARATOR).append("Antall abonnementer").append('\n');
excelData.append(formatForExcel(subscriberStatisticsData));
@@ -224,7 +224,7 @@ private void createSubscriberDetailedReport(SubscriberReportDescription" + "Antall abonnementer" + "");
pagingButtons.removeAllComponents();
headingText.setValue(getHeadingText(reportDescription));
- PageRequest pageRequest = new PageRequest(0, LINES_PER_PAGE);
+ PageRequest pageRequest = PageRequest.of(0, LINES_PER_PAGE);
Page reportData = showReportPage(reportDescription, type, pageRequest);
numberOfRowsHeader.setValue("Totalt antall: " + reportData.getTotalElements());
if (reportData.getTotalPages() > 1) {
@@ -251,7 +251,7 @@ private void nextButton(Button.ClickEvent e) {
}
}
int pageNumber = (int) e.getButton().getData();
- showReportPage(choice, type, new PageRequest(pageNumber, LINES_PER_PAGE));
+ showReportPage(choice, type, PageRequest.of(pageNumber, LINES_PER_PAGE));
}
private Page showReportPage(SubscriberReportDescription reportDescription,
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/designer/windows/NewVersionWindow.java b/klass-forvaltning/src/main/java/no/ssb/klass/designer/windows/NewVersionWindow.java
index bc07f0ef..405df198 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/designer/windows/NewVersionWindow.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/designer/windows/NewVersionWindow.java
@@ -3,7 +3,7 @@
import java.time.LocalDate;
import java.util.List;
-import javax.validation.ValidationException;
+import jakarta.validation.ValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.annotation.PrototypeScope;
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassAuthenticationConfiguration.java b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassAuthenticationConfiguration.java
index 63e2a24a..aaca4a06 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassAuthenticationConfiguration.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassAuthenticationConfiguration.java
@@ -8,7 +8,7 @@
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
+import org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider;
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassSecurityConfiguration.java b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassSecurityConfiguration.java
index cd4e5d6f..929020af 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassSecurityConfiguration.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/production/KlassSecurityConfiguration.java
@@ -1,15 +1,15 @@
package no.ssb.klass.forvaltning.config.production;
-import no.ssb.klass.core.config.ConfigurationProfiles;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.builders.WebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
+import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.security.web.authentication.RememberMeServices;
import org.vaadin.spring.annotation.EnableVaadinExtensions;
@@ -29,7 +29,7 @@
@EnableVaadinSharedSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
@Import(KlassTestAuthenticationConfiguration.class)
-public class KlassSecurityConfiguration extends WebSecurityConfigurerAdapter {
+public class KlassSecurityConfiguration {
private static final String WILDCARD = "**";
@@ -44,13 +44,12 @@ public class KlassSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private RememberMeServices rememberMeServices;
- @Override
- public void configure(WebSecurity web) throws Exception {
- web.ignoring().antMatchers("/VAADIN/" + WILDCARD);
+ @Bean
+ public WebSecurityCustomizer webSecurityCustomizer() {
+ return (web) -> web.ignoring().requestMatchers("/VAADIN/" + WILDCARD);
}
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.exceptionHandling().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/" + LoginUI.PATH));
http.rememberMe()
.key(rememberKey)
@@ -60,15 +59,15 @@ protected void configure(HttpSecurity http) throws Exception {
// https
http.authorizeRequests()
- .antMatchers("/" + LoginUI.PATH).permitAll()
- .antMatchers("/vaadinServlet/UIDL/" + WILDCARD).permitAll()
- .antMatchers("/vaadinServlet/HEARTBEAT/" + WILDCARD).authenticated()
- .antMatchers("/" + KlassUI.PATH + "/" + WILDCARD).authenticated()
- .antMatchers("/manage/" + WILDCARD).hasRole("KLASS_ADMINISTRATOR")
- .antMatchers("/" + WILDCARD).permitAll()
+ .requestMatchers("/" + LoginUI.PATH).permitAll()
+ .requestMatchers("/vaadinServlet/UIDL/" + WILDCARD).permitAll()
+ .requestMatchers("/vaadinServlet/HEARTBEAT/" + WILDCARD).authenticated()
+ .requestMatchers("/" + KlassUI.PATH + "/" + WILDCARD).authenticated()
+ .requestMatchers("/manage/" + WILDCARD).hasRole("KLASS_ADMINISTRATOR")
+ .requestMatchers("/" + WILDCARD).permitAll()
- .antMatchers(PingController.PATH).permitAll()
- .antMatchers(MonitorController.PATH).permitAll()
+ .requestMatchers(PingController.PATH).permitAll()
+ .requestMatchers(MonitorController.PATH).permitAll()
.anyRequest().authenticated().and().sessionManagement()
.sessionFixation()
.migrateSession()
@@ -77,6 +76,6 @@ protected void configure(HttpSecurity http) throws Exception {
.csrf().disable()
.headers()
.frameOptions().disable();
-
+ return http.build();
}
}
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/test/KlassTestDatabaseConfiguration.java b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/test/KlassTestDatabaseConfiguration.java
index a976c79f..c8ef40e2 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/test/KlassTestDatabaseConfiguration.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/config/test/KlassTestDatabaseConfiguration.java
@@ -1,6 +1,6 @@
package no.ssb.klass.forvaltning.config.test;
-import org.h2.server.web.WebServlet;
+import org.h2.server.web.JakartaWebServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -17,7 +17,7 @@ public class KlassTestDatabaseConfiguration extends KlassVaadinConfiguration {
@Profile({ ConfigurationProfiles.H2, ConfigurationProfiles.H2_INMEMORY })
ServletRegistrationBean h2servletRegistration() {
// H2 console (database) is reached at http://localhost:8080/console
- ServletRegistrationBean registrationBean = new ServletRegistrationBean(new WebServlet());
+ ServletRegistrationBean registrationBean = new ServletRegistrationBean(new JakartaWebServlet());
registrationBean.addUrlMappings("/console/*");
return registrationBean;
}
diff --git a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/controllers/monitor/MonitorController.java b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/controllers/monitor/MonitorController.java
index a4fc3a66..b85bc873 100644
--- a/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/controllers/monitor/MonitorController.java
+++ b/klass-forvaltning/src/main/java/no/ssb/klass/forvaltning/controllers/monitor/MonitorController.java
@@ -92,7 +92,7 @@ private MonitorStatus testForvaltning(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-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..b75cdeb3 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
@@ -3,9 +3,9 @@
import java.io.File;
import no.ssb.klass.solr.config.KlassSearchTestConfiguration;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
@@ -22,7 +22,7 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
@@ -35,7 +35,7 @@
import no.ssb.klass.designer.testbench.pages.ClassificationFamilyPage;
import no.ssb.klass.designer.testbench.pages.LoginPage;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { AbstractTestBench.Config.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = { KlassSearchTestConfiguration.class })
@ActiveProfiles({ ConfigurationProfiles.H2_INMEMORY, ConfigurationProfiles.AD_AUTHENTICATE_OFFLINE,
@@ -62,14 +62,16 @@ public abstract class AbstractTestBench implements HasDriver {
@Rule
public ScreenshotOnFailureRule screenshotOnFailure = new ScreenshotOnFailureRule(this, true);
- @Before
+ @BeforeEach
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 928cb8ca..5b584b10 100644
--- a/klass-shared/pom.xml
+++ b/klass-shared/pom.xml
@@ -26,7 +26,7 @@
UTF-8
UTF-8
- 1.8
+ 11
3.0.5
3.3.0
@@ -38,23 +38,8 @@
2.9.0
1.5.5
1.6.0
- 0.15.2
+ 0.15.3
2.2
-
-
-
- 5.2.3.Final
-
-
-
- 4.1.1
-
- 1.2.1.RELEASE
-
@@ -93,7 +78,7 @@
org.apache.solr
solr-dataimporthandler
- 5.5.0
+ 8.11.2
@@ -138,8 +123,9 @@
provided
- javax.servlet
- jstl
+ jakarta.servlet.jsp.jstl
+ jakarta.servlet.jsp.jstl-api
+ 3.0.0
org.springframework.boot
@@ -221,6 +207,12 @@
${rest-assured-version}
test
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+ 2.3.3
+ provided
+
@@ -304,13 +296,6 @@
org.jvnet.jaxb2.maven2
maven-jaxb2-plugin
${maven-jaxb2-plugin-version}
-
-
-
- generate
-
-
-
src/main/resources/xsd/ssb
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..2a5cebe1 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
@@ -3,12 +3,12 @@
import java.util.Date;
import java.util.UUID;
-import javax.persistence.Column;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-import javax.persistence.PreUpdate;
-import javax.persistence.Version;
+import jakarta.persistence.Column;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.MappedSuperclass;
+import jakarta.persistence.PreUpdate;
+import jakarta.persistence.Version;
import no.ssb.klass.core.util.TimeUtil;
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..5dce7c36 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
@@ -4,8 +4,8 @@
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
import no.ssb.klass.core.util.TimeUtil;
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..facbf222 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
@@ -2,11 +2,11 @@
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToOne;
@Entity
public class ClassificationAccessCounter {
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..e8595a80 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
@@ -6,13 +6,12 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Index;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Index;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import org.hibernate.Hibernate;
import no.ssb.klass.core.util.Translatable;
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..c312edca 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
@@ -4,8 +4,8 @@
import java.time.LocalDate;
-import javax.persistence.Entity;
-import javax.persistence.ManyToOne;
+import jakarta.persistence.Entity;
+import jakarta.persistence.ManyToOne;
@Entity
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..da722439 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
@@ -10,17 +10,17 @@
import java.util.List;
import java.util.Optional;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Index;
-import javax.persistence.Lob;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.Index;
+import jakarta.persistence.Lob;
+import jakarta.persistence.ManyToMany;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import org.apache.commons.lang.StringUtils;
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..bd5054f9 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
@@ -2,9 +2,9 @@
import static com.google.common.base.Preconditions.*;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-import javax.persistence.ManyToOne;
+import jakarta.persistence.DiscriminatorValue;
+import jakarta.persistence.Entity;
+import jakarta.persistence.ManyToOne;
import no.ssb.klass.core.util.Translatable;
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..2137bad4 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
@@ -6,14 +6,13 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-
-import jdk.nashorn.internal.ir.annotations.Ignore;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.DiscriminatorValue;
+import jakarta.persistence.Entity;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToMany;
+
import org.springframework.util.StringUtils;
import no.ssb.klass.core.util.DateRange;
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..1a0e9ea0 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
@@ -4,8 +4,8 @@
import java.time.LocalDate;
-import javax.persistence.Column;
-import javax.persistence.Entity;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
import com.google.common.base.Strings;
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..0776159b 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
@@ -3,11 +3,11 @@
import java.util.Comparator;
import java.util.Optional;
-import javax.persistence.Entity;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
+import jakarta.persistence.Entity;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToOne;
+import jakarta.persistence.Table;
+import jakarta.persistence.UniqueConstraint;
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "source_id", "target_id", "correspondence_table_id" }))
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..c629d117 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
@@ -8,17 +8,17 @@
import java.util.List;
import java.util.Optional;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Index;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Index;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.Lob;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import com.google.common.collect.Lists;
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..988fe8da 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
@@ -5,12 +5,12 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToMany;
import no.ssb.klass.core.util.Translatable;
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/Published.java b/klass-shared/src/main/java/no/ssb/klass/core/model/Published.java
index 48cb705d..42753a24 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/Published.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/Published.java
@@ -1,7 +1,7 @@
package no.ssb.klass.core.model;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
@Embeddable
public class Published {
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/ReferencingClassificationItem.java b/klass-shared/src/main/java/no/ssb/klass/core/model/ReferencingClassificationItem.java
index 41d47ddb..e8b6fdb2 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/ReferencingClassificationItem.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/ReferencingClassificationItem.java
@@ -4,8 +4,8 @@
import java.time.LocalDate;
-import javax.persistence.Entity;
-import javax.persistence.OneToOne;
+import jakarta.persistence.Entity;
+import jakarta.persistence.OneToOne;
@Entity
public class ReferencingClassificationItem extends 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..f3a5fccb 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
@@ -2,10 +2,10 @@
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
@Entity
public class SearchWords {
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..06c003da 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
@@ -12,13 +12,13 @@
import java.util.Optional;
import java.util.StringJoiner;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.Lob;
-import javax.persistence.OneToMany;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.Lob;
+import jakarta.persistence.OneToMany;
import com.google.common.base.Strings;
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..834b941b 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
@@ -2,8 +2,8 @@
import static com.google.common.base.Preconditions.*;
-import javax.persistence.Column;
-import javax.persistence.Entity;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
import no.ssb.klass.core.util.Translatable;
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/model/Subscriber.java b/klass-shared/src/main/java/no/ssb/klass/core/model/Subscriber.java
index 77a6fe08..7bbd703a 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/model/Subscriber.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/model/Subscriber.java
@@ -7,14 +7,14 @@
import java.util.Objects;
import java.util.Optional;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Index;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Index;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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..2720833f 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
@@ -6,11 +6,11 @@
import java.util.Date;
import java.util.UUID;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.ManyToOne;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.ManyToOne;
import no.ssb.klass.core.util.ClientException;
import no.ssb.klass.core.util.TimeUtil;
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..09ca0cfd 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
@@ -5,11 +5,11 @@
import java.util.HashSet;
import java.util.Set;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Index;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Index;
+import jakarta.persistence.ManyToMany;
+import jakarta.persistence.Table;
@Entity
@Table(indexes = {
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..8b06009c 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
@@ -4,8 +4,8 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.PersistenceContext;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesSpecification.java b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesSpecification.java
index 9ca5e0aa..12db93a2 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesSpecification.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/repository/ClassificationSeriesSpecification.java
@@ -4,12 +4,12 @@
import java.util.Date;
import java.util.List;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.JoinType;
+import jakarta.persistence.criteria.Path;
+import jakarta.persistence.criteria.Predicate;
+import jakarta.persistence.criteria.Root;
import org.springframework.data.jpa.domain.Specification;
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..716d2793 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,9 +13,9 @@
@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]
@Query(value = "SELECT DISTINCT(u.id) FROM user AS u, classification_series AS c"
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..2a7f6734 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,7 @@ 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(); // get attached object
checkAllowedToDelete(user, classification);
classification.setDeleted();
saveNotIndexClassification(classification);
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/service/MailServiceImpl.java b/klass-shared/src/main/java/no/ssb/klass/core/service/MailServiceImpl.java
index cc84689d..3e50e7e8 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/service/MailServiceImpl.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/service/MailServiceImpl.java
@@ -1,10 +1,10 @@
package no.ssb.klass.core.service;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
+import jakarta.mail.Message;
+import jakarta.mail.MessagingException;
+import jakarta.mail.Session;
+import jakarta.mail.internet.InternetAddress;
+import jakarta.mail.internet.MimeMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
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..cfa1bf1b 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,11 +2,13 @@
import java.math.BigInteger;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -49,7 +51,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 +67,13 @@ 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());
}
- Hibernate.initialize(user.getFavorites());
- return user;
+ return user.get();
}
}
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/util/BaseEntityInterceptor.java b/klass-shared/src/main/java/no/ssb/klass/core/util/BaseEntityInterceptor.java
index cdbedf83..94fb655c 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/util/BaseEntityInterceptor.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/util/BaseEntityInterceptor.java
@@ -6,7 +6,7 @@
import java.util.concurrent.ConcurrentHashMap;
import org.hibernate.EmptyInterceptor;
-import org.hibernate.EntityMode;
+import org.hibernate.metamodel.RepresentationMode;
import org.objenesis.Objenesis;
import org.objenesis.ObjenesisStd;
@@ -28,8 +28,7 @@ public BaseEntityInterceptor() {
clazzCache = new ConcurrentHashMap>>();
}
- @Override
- public BaseEntity instantiate(String entityName, EntityMode entityMode, Serializable id) {
+ public BaseEntity instantiate(String entityName, RepresentationMode entityMode, Serializable id) {
Optional> clazz = getOrUpdate(entityName);
if (!clazz.isPresent()) {
return null;
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/util/LocalDatePersistenceConverter.java b/klass-shared/src/main/java/no/ssb/klass/core/util/LocalDatePersistenceConverter.java
index 03763885..941df860 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/util/LocalDatePersistenceConverter.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/util/LocalDatePersistenceConverter.java
@@ -3,8 +3,8 @@
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
+import jakarta.persistence.AttributeConverter;
+import jakarta.persistence.Converter;
/**
* Used by Hibernate to persists {@link LocalDate}s
diff --git a/klass-shared/src/main/java/no/ssb/klass/core/util/TranslatablePersistenceConverter.java b/klass-shared/src/main/java/no/ssb/klass/core/util/TranslatablePersistenceConverter.java
index 6c0eb7a1..80e418c0 100644
--- a/klass-shared/src/main/java/no/ssb/klass/core/util/TranslatablePersistenceConverter.java
+++ b/klass-shared/src/main/java/no/ssb/klass/core/util/TranslatablePersistenceConverter.java
@@ -3,8 +3,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
+import jakarta.persistence.AttributeConverter;
+import jakarta.persistence.Converter;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.stereotype.Component;
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..62f070f9 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,13 +11,13 @@
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.xml.datatype.XMLGregorianCalendar;
+import jakarta.persistence.EntityManager;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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..26a3ab0e 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,7 +42,7 @@ public class ActiveDirectoryServiceTest {
@InjectMocks
private ActiveDirectoryServiceImpl adService;
- @Before
+ @BeforeEach
public void configureUserServiceMock() {
when(userService.saveUser(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
}
@@ -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..2f6e4b06 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, subject::getDateRange);
}
@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..2192aca8 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,16 +1,16 @@
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;
-import javax.persistence.EntityManager;
-import javax.transaction.Transactional;
+import jakarta.persistence.EntityManager;
+import jakarta.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..053ea3ba 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 jakarta.persistence.EntityManager;
+import jakarta.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,7 @@ public void verifyMapping() {
entityManager.detach(family);
// when
- ClassificationFamily result = subject.findOne(family.getId());
+ ClassificationFamily result = subject.findById(family.getId()).orElseThrow();
// 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..f3788bc4 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,18 +1,19 @@
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;
-import javax.persistence.EntityManager;
-import javax.transaction.Transactional;
+import jakarta.persistence.EntityManager;
+import jakarta.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.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 +23,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 +32,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 +54,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 +78,7 @@ public void verifyMapping() {
entityManager.detach(classification);
// when
- ClassificationSeries result = subject.findOne(classification.getId());
+ ClassificationSeries result = subject.findById(classification.getId()).orElseThrow();
// 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..cadaf545 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 jakarta.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..29158d93 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 jakarta.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..eec1f055 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,14 @@
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 jakarta.transaction.Transactional;
+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 +16,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 +37,7 @@
/**
* @author Mads Lundemo, SSB.
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest
@ActiveProfiles(ConfigurationProfiles.H2_INMEMORY)
@Transactional
@@ -63,7 +62,7 @@ public class ReferencingClassificationItemRepositoryTest {
private ClassificationVariant secondNormalVariant;
private ClassificationVariant secondDeletedVariant;
- @Before
+ @BeforeEach
public void setup() {
user = userRepository.save(TestUtil.createUser());
classificationFamily = classificationFamilyRepository
@@ -89,16 +88,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 +113,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 +136,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);
}
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..cc4a4118 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,16 +1,16 @@
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;
import java.util.Date;
import java.util.List;
-import javax.transaction.Transactional;
+import jakarta.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..af053f2a 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 jakarta.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,7 +58,7 @@ 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();
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..cf4f1c19 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 jakarta.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,7 @@ public void init() {
@Test
public void testEntity() {
// when
- Subscriber result = subject.findOne(subscriberId);
+ Subscriber result = subject.findById(subscriberId).orElseThrow();
// 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..23ce49d8 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
@@ -6,12 +6,12 @@
import java.math.BigInteger;
import java.util.Set;
-import javax.transaction.Transactional;
+import jakarta.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..3b751b1f 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(anyLong())).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..19b2eb8a 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.hibernate.metamodel.RepresentationMode;
+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();
}
@@ -23,7 +23,7 @@ public void instantiate() {
final Long id = 1L;
// when
- ClassificationSeries result = (ClassificationSeries) subject.instantiate(entityName, EntityMode.POJO, id);
+ ClassificationSeries result = (ClassificationSeries) subject.instantiate(entityName, RepresentationMode.POJO, id);
// then
assertEquals(id, result.getId());
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 162cf447..4f57fb9f 100644
--- a/klass-solr/pom.xml
+++ b/klass-solr/pom.xml
@@ -54,7 +54,7 @@
org.apache.solr
solr-dataimporthandler
- 5.5.0
+ 8.11.2
@@ -65,6 +65,10 @@
+
+ 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..e3a4a960 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(Path.of(solrTempWorkspace), null));
coreContainer.load();
} catch (Exception e) {
e.printStackTrace(System.err);
diff --git a/klass-solr/src/test/java/no/ssb/klass/solr/config/KlassSearchTestConfiguration.java b/klass-solr/src/test/java/no/ssb/klass/solr/config/KlassSearchTestConfiguration.java
index 5b221db9..8f3e29c3 100644
--- a/klass-solr/src/test/java/no/ssb/klass/solr/config/KlassSearchTestConfiguration.java
+++ b/klass-solr/src/test/java/no/ssb/klass/solr/config/KlassSearchTestConfiguration.java
@@ -3,12 +3,14 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
import org.apache.commons.io.FileUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrXmlConfig;
import org.springframework.context.annotation.*;
/**
@@ -31,7 +33,7 @@ public SolrClient embeddedSolrServerAndClient() throws IOException, SolrServerEx
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(Path.of(solrTempWorkspace), null));
coreContainer.load();
} catch (Exception e) {
e.printStackTrace(System.err);
diff --git a/pom.xml b/pom.xml
index 1660ad2d..15dc3625 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
- 1.4.4.RELEASE
+ 3.2.0
@@ -37,10 +37,8 @@
false
-
-
- 1.8
+ 11
UTF-8
UTF-8
3.0.2
@@ -60,22 +58,17 @@
2.9.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
true