Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
oleanders committed Sep 27, 2024
2 parents f431d86 + d6d56d3 commit 2d4cc1f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import no.fintlabs.instance.gateway.model.vigo.IncomingInstance;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono;

import java.time.LocalDate;
Expand Down Expand Up @@ -54,23 +55,23 @@ private static Map<String, String> toValuePerKey(IncomingInstance incomingInstan
Stream.of(incomingInstance.getPersonalia().getFornavn(),
incomingInstance.getPersonalia().getMellomnavn(),
incomingInstance.getPersonalia().getEtternavn())
.filter(s -> s != null)
.filter(s -> StringUtils.hasLength(s))
.collect(Collectors.joining(" "))
));

entries.add(Map.entry("tilpassetNavn2",
Stream.of(incomingInstance.getPersonalia().getEtternavn(),
incomingInstance.getPersonalia().getFornavn(),
incomingInstance.getPersonalia().getMellomnavn())
.filter(s -> s != null)
.filter(s -> StringUtils.hasLength(s))
.collect(Collectors.joining(" "))
));

entries.add(Map.entry("tilpassetNavn3",
Stream.of(incomingInstance.getPersonalia().getEtternavn() + ",",
incomingInstance.getPersonalia().getFornavn(),
incomingInstance.getPersonalia().getMellomnavn())
.filter(s -> s != null)
.filter(s -> StringUtils.hasLength(s))
.collect(Collectors.joining(" "))
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,44 @@ void shouldCreateCustomizedFullNameWitoutMiddleName() {
assertEquals("Nordmannsen, Ola", result.getValuePerKey().get("tilpassetNavn3"));
}

@Test
void shouldCreateCustomizedFullNameWithEmptyMiddleName() {
InstanceObject result = incomingInstanceMappingService
.map(4L, createIncomingInstance()
.personalia(Personalia.builder()
.fodselsnummer("12345678901")
.fornavn("Ola")
.mellomnavn("")
.etternavn("Nordmannsen")
.fodselsdato("19-12-3100")
.build()).build(),
persistFile
).block();

assertEquals("Ola Nordmannsen", result.getValuePerKey().get("tilpassetNavn1"));
assertEquals("Nordmannsen Ola", result.getValuePerKey().get("tilpassetNavn2"));
assertEquals("Nordmannsen, Ola", result.getValuePerKey().get("tilpassetNavn3"));
}

@Test
void shouldCreateCustomizedFullNameWithNullMiddleName() {
InstanceObject result = incomingInstanceMappingService
.map(4L, createIncomingInstance()
.personalia(Personalia.builder()
.fodselsnummer("12345678901")
.fornavn("Ola")
.mellomnavn(null)
.etternavn("Nordmannsen")
.fodselsdato("19-12-3100")
.build()).build(),
persistFile
).block();

assertEquals("Ola Nordmannsen", result.getValuePerKey().get("tilpassetNavn1"));
assertEquals("Nordmannsen Ola", result.getValuePerKey().get("tilpassetNavn2"));
assertEquals("Nordmannsen, Ola", result.getValuePerKey().get("tilpassetNavn3"));
}

@Test
void shouldNotAcceptInvalidFodselsdato() {
InstanceObject result = incomingInstanceMappingService
Expand Down

0 comments on commit 2d4cc1f

Please sign in to comment.