-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TestConfig and Oppdragsdata utility classes
Added TestConfig.java to provide Spring test configuration, including beans for OppdragService, OppdragConsumer, and MapperFacade. Created Oppdragsdata.java in utility package to facilitate the construction of OppdragRequest and SendInnOppdragResponse objects, enhancing the testing structure.
- Loading branch information
Showing
15 changed files
with
1,108 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
...oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/consumer/OppdragConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
package no.nav.testnav.oppdragservice.consumer; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragRequest; | ||
import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragResponse; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.ws.client.core.support.WebServiceGatewaySupport; | ||
import org.springframework.ws.soap.client.core.SoapActionCallback; | ||
|
||
@Slf4j | ||
@Service | ||
public class OppdragConsumer { | ||
public class OppdragConsumer extends WebServiceGatewaySupport { | ||
|
||
public void sendOppdrag(String xmlPayload) { | ||
public SendInnOppdragResponse sendOppdrag(SendInnOppdragRequest melding) { | ||
|
||
return (SendInnOppdragResponse) getWebServiceTemplate().marshalSendAndReceive("", melding, | ||
new SoapActionCallback("no.nav.testnav.oppdragservice.wsdl.SendInnOppdragResponse")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ce/src/main/java/no/nav/testnav/oppdragservice/mapper/OppdragResponseMappingStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package no.nav.testnav.oppdragservice.mapper; | ||
|
||
import ma.glasnost.orika.CustomMapper; | ||
import ma.glasnost.orika.MapperFactory; | ||
import ma.glasnost.orika.MappingContext; | ||
import no.nav.testnav.libs.dto.oppdragservice.v1.Oppdrag; | ||
import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragResponse; | ||
import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragResponse; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static java.util.Objects.nonNull; | ||
|
||
@Component | ||
public class OppdragResponseMappingStrategy implements MappingStrategy{ | ||
|
||
@Override | ||
public void register(MapperFactory factory) { | ||
|
||
factory.classMap(SendInnOppdragResponse.class, OppdragResponse.class) | ||
.customize(new CustomMapper<>() { | ||
@Override | ||
public void mapAtoB(SendInnOppdragResponse source, | ||
OppdragResponse destination, | ||
MappingContext context) { | ||
|
||
var oppdrag = source.getResponse().getOppdrag(); | ||
if (nonNull(oppdrag.getUtbetFrekvens())) { | ||
oppdrag.setUtbetFrekvens(oppdrag.getUtbetFrekvens() | ||
.replace("14DG", "_14DG")); | ||
} | ||
|
||
oppdrag.getOppdragslinje().stream() | ||
.filter(oppdragslinje -> nonNull(oppdragslinje.getTypeSats())) | ||
.forEach(oppdragslinje -> | ||
oppdragslinje.setTypeSats(oppdragslinje.getTypeSats() | ||
.replace("14DB","_14DB"))); | ||
|
||
destination.setOppdrag(mapperFacade.map(oppdrag, Oppdrag.class, context)); | ||
} | ||
}) | ||
.register(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/config/TestConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package no.nav.testnav.oppdragservice.config; | ||
|
||
import jakarta.xml.bind.JAXBException; | ||
import ma.glasnost.orika.MapperFacade; | ||
import no.nav.testnav.oppdragservice.consumer.OppdragConsumer; | ||
import no.nav.testnav.oppdragservice.mapper.LocalDateCustomMapping; | ||
import no.nav.testnav.oppdragservice.mapper.LocalDateTimeCustomMapping; | ||
import no.nav.testnav.oppdragservice.mapper.MapperTestUtils; | ||
import no.nav.testnav.oppdragservice.mapper.OppdragRequestMappingStrategy; | ||
import no.nav.testnav.oppdragservice.service.OppdragService; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.List; | ||
|
||
@Configuration | ||
public class TestConfig { | ||
|
||
@Bean | ||
public OppdragService oppdragService() throws JAXBException { | ||
return new OppdragService(oppdragConsumer(), mapperFacade()); | ||
} | ||
|
||
@Bean | ||
public OppdragConsumer oppdragConsumer() { | ||
return new OppdragConsumer(); | ||
} | ||
|
||
@Bean | ||
public MapperFacade mapperFacade() { | ||
|
||
return MapperTestUtils.createMapperFacadeForMappingStrategy( | ||
List.of(new LocalDateCustomMapping(), | ||
new LocalDateTimeCustomMapping()), | ||
new OppdragRequestMappingStrategy()); | ||
} | ||
} |
Oops, something went wrong.