Skip to content

Commit

Permalink
ARKIV-259 Uten fiktivt dokument
Browse files Browse the repository at this point in the history
  • Loading branch information
oleanders committed May 30, 2024
1 parent 247e9f0 commit ed8546d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ https://github.com/FINTLabs/fint-flyt-instance-gateway-template (or call a frien

1. Install Bruno: `brew install --cask bruno`
2. Open folder `bruno` in Bruno
3. Get `user_session` cookie from https://flyt.vigoiks.no
3. Get `user_session` cookie from https://flyt.vigoiks.no (NB! To make this work, you need to disable 'Send Cookies automatically' in the settings).
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,20 @@ public IncomingInstanceMappingService(
@Override
public Mono<InstanceObject> map(Long sourceApplicationId, IncomingInstance incomingInstance) {
if (incomingInstance.getDokument() == null) {
IncomingInstance fiktivInstance = IncomingInstance.builder()
.instansId(incomingInstance.getInstansId())
.dokumenttype(incomingInstance.getDokumenttype())
.personalia(incomingInstance.getPersonalia())
.kontaktinformasjon(incomingInstance.getKontaktinformasjon())
.inntaksadresse(incomingInstance.getInntaksadresse())
.dokument(Dokument.builder()
.tittel("Fiktivt dokument")
.dato("1970-01-01")
.filnavn("fiktiv.pdf")
.format("application/pdf")
.fil("RXQgdmFubGlnIHZlZGxlZ2cK")
.build())
.tilleggsinformasjon(incomingInstance.getTilleggsinformasjon())
.build();
return postFile(sourceApplicationId, fiktivInstance)
.map(uuid -> InstanceObject.builder()
.valuePerKey(toValuePerKey(fiktivInstance, uuid))
.build());
}else {
return Mono.just(InstanceObject.builder()
.valuePerKey(toValuePerKey(incomingInstance, null))
.build());
} else {
return postFile(sourceApplicationId, incomingInstance)
.map(uuid -> InstanceObject.builder()
.valuePerKey(toValuePerKey(incomingInstance, uuid))
.build());
}

}

private static Map<String, String> toValuePerKey(IncomingInstance incomingInstance, UUID uuid) {
Set<Map.Entry<String, String>> entries = new HashSet<>();


entries.add(Map.entry("personaliaFodselsnummer", incomingInstance.getPersonalia().getFodselsnummer()));
entries.add(Map.entry("personaliaFornavn", incomingInstance.getPersonalia().getFornavn()));
entries.add(Map.entry("personaliaMellomnavn", incomingInstance.getPersonalia().getMellomnavn()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ void shouldReturnInstanceObjectWhenIncomingInstanceDoesHaveSomeTilleggsinformasj
assertEquals("Oslo katedralskole", valuePerKey.get("tilleggsinformasjonSkolenavn"));
assertNull(valuePerKey.get("tilleggsinformasjonSkolenummer"));
}

//@Test - Prøver oss med fiktivt dokument på instanser uten dokument
@Test
void shouldReturnInstanceObjectWhenIncomingInstanceDoesNotHaveDocument() {
UUID uuid = UUID.randomUUID();
when(fileClient.postFile(any(File.class))).thenReturn(Mono.just(uuid));
Expand Down

0 comments on commit ed8546d

Please sign in to comment.