Skip to content

Commit

Permalink
Refactor Oppdrag components.
Browse files Browse the repository at this point in the history
#deploy-oppdrag-service

Correct enum naming from `ValuteType` to `ValutaType` in various classes, and add a new `KodeverkService` for retrieving code values. This also includes new mappings in `OppdragController` and `OppdragKodeverk` to handle these enums.
  • Loading branch information
krharum committed Nov 4, 2024
1 parent ad7f2ec commit 08bac2d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,39 @@

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragKodeverk;
import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragRequest;
import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragResponse;
import no.nav.testnav.oppdragservice.service.KodeverkService;
import no.nav.testnav.oppdragservice.service.OppdragService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/oppdrag")
@RequiredArgsConstructor
public class OppdragController {

private final OppdragService oppdragService;
private final KodeverkService kodeverkService;

@PostMapping
@Operation(summary = "Send inn oppdrag")
public OppdragResponse sendInnOppdrag(@RequestBody OppdragRequest oppdragRequest) {

return oppdragService.sendInnOppdrag(oppdragRequest);
}

@GetMapping("/kodeverk/{kodeverk}")
@Operation(summary = "Hent kodeverk")
public List<String> getKodeverk(@PathVariable OppdragKodeverk kodeverk) {

return kodeverkService.getKodeverk(kodeverk);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package no.nav.testnav.oppdragservice.service;

import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragKodeverk;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Stream;

@Service
public class KodeverkService {

public List<String> getKodeverk(OppdragKodeverk oppdragKodeverk) {

return Stream.of(oppdragKodeverk.getImplementasjon().getEnumConstants())
.map(Object::toString)
.sorted()
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ma.glasnost.orika.MapperFacade;
import no.nav.testnav.libs.dto.oppdragservice.v1.Oppdrag;
import no.nav.testnav.libs.dto.oppdragservice.v1.Oppdrag.ValuteType;
import no.nav.testnav.libs.dto.oppdragservice.v1.Oppdrag.ValutaType;
import no.nav.testnav.oppdragservice.utilty.Oppdragsdata;
import no.nav.testnav.oppdragservice.wsdl.FradragTillegg;
import no.nav.testnav.oppdragservice.wsdl.KodeArbeidsgiver;
Expand Down Expand Up @@ -152,7 +152,7 @@ void mapOppdragsLinjeRequest_OK() {
hasProperty("attestantId", is(equalTo(TEXT_VALUE))),
hasProperty("datoUgyldigFom", is(equalTo(TARGET_DATE_FORMAT)))))),
hasProperty("valuta", contains(allOf(
hasProperty("typeValuta", is(equalTo(ValuteType.FAKT.toString()))),
hasProperty("typeValuta", is(equalTo(ValutaType.FAKT.toString()))),
hasProperty("valuta", is(equalTo(TEXT_VALUE))),
hasProperty("datoValutaFom", is(equalTo(TARGET_DATE_FORMAT))),
hasProperty("feilreg", is(equalTo(TEXT_VALUE))))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void mapOppdragsLinjeResponse_OK() {
hasProperty("attestantId", is(equalTo(TEXT_VALUE))),
hasProperty("datoUgyldigFom", is(equalTo(LOCAL_DATE)))))),
hasProperty("valuta", contains(allOf(
hasProperty("typeValuta", is(equalTo(Oppdrag.ValuteType.FAKT))),
hasProperty("typeValuta", is(equalTo(Oppdrag.ValutaType.FAKT))),
hasProperty("valuta", is(equalTo(TEXT_VALUE))),
hasProperty("datoValutaFom", is(equalTo(LOCAL_DATE))),
hasProperty("feilreg", is(equalTo(TEXT_VALUE))))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static OppdragRequest buildOppdragsLinjeRequest() {
.datoUgyldigFom(LOCAL_DATE)
.build()))
.valuta(List.of(Oppdrag.Valuta.builder()
.typeValuta(Oppdrag.ValuteType.FAKT)
.typeValuta(Oppdrag.ValutaType.FAKT)
.valuta(TEXT_VALUE)
.datoValutaFom(LOCAL_DATE)
.feilreg(TEXT_VALUE)
Expand Down Expand Up @@ -302,7 +302,7 @@ public static SendInnOppdragResponse buildOppdragslinjeResponse() {
oppdragslinje.getAttestant().add(attestant);

var valuta = new no.nav.testnav.oppdragservice.wsdl.Valuta();
valuta.setTypeValuta(Oppdrag.ValuteType.FAKT.toString());
valuta.setTypeValuta(Oppdrag.ValutaType.FAKT.toString());
valuta.setValuta(TEXT_VALUE);
valuta.setDatoValutaFom(TARGET_DATE_FORMAT);
valuta.setFeilreg(TEXT_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public static class Attestant {
public static class Valuta {

@NotBlank
protected ValuteType typeValuta;
protected Oppdrag.ValutaType typeValuta;
@NotBlank
@Schema(minLength = 1, maxLength = 3)
protected String valuta;
Expand Down Expand Up @@ -431,7 +431,7 @@ public enum UtbetalingFrekvensType {
ENG
}

public enum ValuteType {
public enum ValutaType {

FAKT,
FRAM,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package no.nav.testnav.libs.dto.oppdragservice.v1;

import lombok.Getter;

@Getter
public enum OppdragKodeverk {

JA_NEI (Oppdrag.JaNei.class),
KODE_STATUS_LINJE(Oppdrag.KodeStatusLinje.class),
FRADRAG_TILLEGG(Oppdrag.FradragTillegg.class),
KODE_ARBEIDSGIVER(Oppdrag.KodeArbeidsgiver.class),
KODE_STATUS(Oppdrag.KodeStatus.class),
KODE_ENDRING(Oppdrag.KodeEndring.class),
KODE_ENDRING_TYPE(Oppdrag.KodeEndringType.class),
SATS_TYPE(Oppdrag.SatsType.class),
UTBETALING_FREKVENS_TYPE(Oppdrag.UtbetalingFrekvensType.class),
VALUTA_TYPE(Oppdrag.ValutaType.class);

private Class implementasjon;

private OppdragKodeverk(Class implementasjon) {
this.implementasjon = implementasjon;
}
}

0 comments on commit 08bac2d

Please sign in to comment.