Skip to content

Commit

Permalink
Udistub refaktor for spring 3.2
Browse files Browse the repository at this point in the history
#deploy-udi-stub
  • Loading branch information
stigus committed Jan 11, 2024
1 parent 86941bc commit a32027c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 65 deletions.
16 changes: 13 additions & 3 deletions apps/udi-stub/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id "org.sonarqube" version "4.0.0.2929"
id 'java'
id "uk.co.boothen.gradle.wsimport" version "0.18"
id "uk.co.boothen.gradle.wsimport" version "0.21"
id 'org.springframework.boot' version "3.2.1"
id 'io.spring.dependency-management' version "1.1.4"
id("org.openrewrite.rewrite") version("6.6.4")
id "jacoco"
}

Expand All @@ -18,6 +19,10 @@ jacocoTestReport {
}
}

rewrite {
activeRecipe("org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2")
}

sonarqube {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", "${project.layout.buildDirectory}/reports/jacoco/test/jacocoTestReport.xml"
Expand Down Expand Up @@ -51,6 +56,7 @@ configurations {
}

bootJar {
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
archiveFileName = "app.jar"
}

Expand All @@ -74,8 +80,11 @@ repositories {
}
dependencies {

rewrite("org.openrewrite.recipe:rewrite-spring:5.2.0")

implementation platform('org.testcontainers:testcontainers-bom:1.19.1')

implementation "com.sun.xml.ws:jaxws-rt:4.0.2"
implementation 'no.nav.testnav.libs:servlet-core'
implementation 'no.nav.testnav.libs:servlet-security'
implementation 'no.nav.testnav.libs:database'
Expand Down Expand Up @@ -105,12 +114,13 @@ dependencies {
implementation 'org.hibernate.validator:hibernate-validator'

testImplementation 'com.h2database:h2'
testImplementation "org.junit.jupiter:junit-jupiter:5.10.1"
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:postgresql'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock'
testImplementation 'junit:junit:4.13.2' //TODO upgrade to JUnit5
testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock' //TODO upgrade to JUnit5

testImplementation "org.mockito:mockito-junit-jupiter:4.11.0"
implementation 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ClientAuthentication clientAuthentication() {
}
var token = System.getProperty(VAULT_PROPERTY);
if (isBlank(token)) {
throw new IllegalArgumentException(String.format("Påkrevet property '%s' er ikke satt.", VAULT_PROPERTY));
throw new IllegalArgumentException("Påkrevet property '%s' er ikke satt.".formatted(VAULT_PROPERTY));
}
return new TokenAuthentication(System.getProperty(VAULT_PROPERTY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public List<Kodeverk> finnAlleMedType(String type) {
public Kodeverk finnMedKode(String kode) {
return kodeverkRepository.findByKode(kode).orElseThrow(() ->
new HttpClientErrorException(HttpStatus.NOT_FOUND,
String.format("Kunne ikke finne kode: %s i kodeverket", kode))
"Kunne ikke finne kode: %s i kodeverket".formatted(kode))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public UdiPerson finnPerson(String ident) {

return personRepository.findByIdent(ident)
.map(person -> mapperFacade.map(person, UdiPerson.class))
.orElseThrow(() -> new NotFoundException(String.format(IKKE_FUNNET, ident)));
.orElseThrow(() -> new NotFoundException(IKKE_FUNNET.formatted(ident)));
}

@Transactional
public void deletePerson(String ident) {

var slettePerson = personRepository.findByIdent(ident)
.orElseThrow(() -> new NotFoundException(String.format(IKKE_FUNNET, ident)));
.orElseThrow(() -> new NotFoundException(IKKE_FUNNET.formatted(ident)));
personRepository.deleteById(slettePerson.getId());
}
}
100 changes: 51 additions & 49 deletions apps/udi-stub/src/main/resources/wsdl/schema/Common_Headers_v2.xsd
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2011 rel. 3 sp1 (x64) (http://www.altova.com) by Utlendingsdirektoratet (Utlendingsdirektoratet) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://udi.no/Common/Headers/v2" targetNamespace="http://udi.no/Common/Headers/v2" elementFormDefault="qualified">
<xs:element name="RequestHeader" type="RequestHeaderType" nillable="true" />
<xs:complexType name="RequestHeaderType">
<xs:annotation>
<xs:documentation>Headeren som blir brukt av alle tjenester</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="UoW" type="UoWType" minOccurs="0" />
<xs:element name="Opphav" type="OpphavType" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="UoWType">
<xs:annotation>
<xs:documentation>Unit of Work. Benyttes i headers</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Id" type="xs:string" minOccurs="0">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://udi.no/Common/Headers/v2"
targetNamespace="http://udi.no/Common/Headers/v2" elementFormDefault="qualified">
<xs:element name="RequestHeader" type="RequestHeaderType" nillable="true"/>
<xs:complexType name="RequestHeaderType">
<xs:annotation>
<xs:documentation>Id til den logiske transaksjonen.</xs:documentation>
<xs:documentation>Headeren som blir brukt av alle tjenester</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MeldingsId" type="xs:string" minOccurs="0">
<xs:sequence>
<xs:element name="UoW" type="UoWType" minOccurs="0"/>
<xs:element name="Opphav" type="OpphavType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="UoWType">
<xs:annotation>
<xs:documentation>Id til meldingen.</xs:documentation>
<xs:documentation>Unit of Work. Benyttes i headers</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="OpphavType">
<xs:annotation>
<xs:documentation>Informasjon om kallets opphav. Benyttes i headers</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Brukernavn" type="xs:string" minOccurs="0">
<xs:sequence>
<xs:element name="Id" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Id til den logiske transaksjonen.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MeldingsId" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Id til meldingen.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="OpphavType">
<xs:annotation>
<xs:documentation>Active Directory brukernavn på formatet domain\user</xs:documentation>
<xs:documentation>Informasjon om kallets opphav. Benyttes i headers</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Systemtjenestenavn" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Navn på systemtjenesten som utførte det opprinnelige kallet</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Nettadresse" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>IP eller DNS -navn til maskinen som utførte det opprinnelige kallet</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Tidspunkt" type="xs:dateTime" minOccurs="0">
<xs:annotation>
<xs:documentation>Tidspunktet for det opprinnelige kallet</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:sequence>
<xs:element name="Brukernavn" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Active Directory brukernavn på formatet domain user</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Systemtjenestenavn" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Navn på systemtjenesten som utførte det opprinnelige kallet</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Nettadresse" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>IP eller DNS -navn til maskinen som utførte det opprinnelige kallet
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Tidspunkt" type="xs:dateTime" minOccurs="0">
<xs:annotation>
<xs:documentation>Tidspunktet for det opprinnelige kallet</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.udistub.converter;

import no.nav.udistub.converter.ws.ArbeidsadgangWsConverter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
Expand All @@ -10,6 +9,7 @@
import static no.nav.udistub.converter.DefaultTestData.TEST_ARBEIDOMGANGKATEGORI;
import static no.nav.udistub.converter.DefaultTestData.TEST_ARBEIDSADGANG;
import static no.nav.udistub.converter.DefaultTestData.TEST_ARBEIDSADGANG_TYPE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

Expand All @@ -23,9 +23,9 @@ class ArbeidsadgangPersonConverterTest extends ConverterTestBase {
void convertFromPersonToArbeidsadgangIfPresent() {
no.udi.mt_1067_nav_data.v1.Arbeidsadgang result = arbeidsadgangConverter.convert(defaultTestPerson.getArbeidsadgang());
assertNotNull(result);
Assertions.assertEquals(TEST_ARBEIDSADGANG, result.getHarArbeidsadgang());
Assertions.assertEquals(TEST_ARBEIDOMGANGKATEGORI, result.getArbeidsOmfang());
Assertions.assertEquals(TEST_ARBEIDSADGANG_TYPE, result.getTypeArbeidsadgang());
assertEquals(TEST_ARBEIDSADGANG, result.getHarArbeidsadgang());
assertEquals(TEST_ARBEIDOMGANGKATEGORI, result.getArbeidsOmfang());
assertEquals(TEST_ARBEIDSADGANG_TYPE, result.getTypeArbeidsadgang());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import no.udi.mt_1067_nav_data.v1.EOSellerEFTAGrunnlagskategoriOppholdstillatelse;
import no.udi.mt_1067_nav_data.v1.IkkeOppholdstillatelseIkkeOppholdsPaSammeVilkarIkkeVisum;
import no.udi.mt_1067_nav_data.v1.OppholdsgrunnlagKategori;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
Expand All @@ -28,10 +27,10 @@ void convertFromPersonToIkkeOppholdstillatelseIkkeOppholdsPaSammeVilkarIkkeVisum
defaultTestPerson.getOppholdStatus().getIkkeOppholdstilatelseIkkeVilkaarIkkeVisum());

assertNotNull(result);
Assertions.assertEquals(DefaultTestData.TEST_ovrigIkkeOppholdsKategori, result.getOvrigIkkeOpphold().getArsak());
assertEquals(DefaultTestData.TEST_ovrigIkkeOppholdsKategori, result.getOvrigIkkeOpphold().getArsak());

Assertions.assertEquals(DefaultTestData.TEST_INNREISEFORBUD, result.getUtvistMedInnreiseForbud().getInnreiseForbud());
Assertions.assertEquals(DefaultTestData.TEST_VARIGHET_UDI, result.getUtvistMedInnreiseForbud().getVarighet());
assertEquals(DefaultTestData.TEST_INNREISEFORBUD, result.getUtvistMedInnreiseForbud().getInnreiseForbud());
assertEquals(DefaultTestData.TEST_VARIGHET_UDI, result.getUtvistMedInnreiseForbud().getVarighet());

AvslagEllerBortfallAvPOBOSellerTilbakekallEllerFormeltVedtak avslagEllerBortfall = result.getAvslagEllerBortfallAvPOBOSellerTilbakekallEllerFormeltVedtak();
assertEquals(EOSellerEFTAGrunnlagskategoriOppholdsrett.FAMILIE, avslagEllerBortfall.getAvslagPaSoknadOmOppholdsrettRealitetsBehandlet().getAvslagsGrunnlagEOS());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class UdiStubITest {
private Flyway flyway;

@BeforeEach
public void setUp() throws IOException {
void setUp() throws IOException {


flyway.migrate();
Expand Down

0 comments on commit a32027c

Please sign in to comment.