Skip to content
Snippets Groups Projects
Commit e00a6f74 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-1513 adjust postfachModelAssembler to handle createdBy as null

parent 07bcc9dd
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,8 @@ class PostfachMailModelAssembler implements RepresentationModelAssembler<Postfac ...@@ -31,8 +31,8 @@ class PostfachMailModelAssembler implements RepresentationModelAssembler<Postfac
private static final Predicate<PostfachMail> HAS_ATTACHMENTS = nachricht -> !nachricht.getAttachments().isEmpty(); private static final Predicate<PostfachMail> HAS_ATTACHMENTS = nachricht -> !nachricht.getAttachments().isEmpty();
static final String SYSTEM_USER_IDENTIFIER = "system"; static final String SYSTEM_USER_IDENTIFIER = "system";
private static final Predicate<PostfachMail> SENT_BY_CLIENT_USER = postfachNachricht -> !postfachNachricht.getCreatedBy().toString() private static final Predicate<PostfachMail> SENT_BY_CLIENT_USER = postfachNachricht -> Optional.ofNullable(postfachNachricht.getCreatedBy())
.startsWith(SYSTEM_USER_IDENTIFIER); .map(createdBy -> !createdBy.toString().startsWith(SYSTEM_USER_IDENTIFIER)).orElse(false);
public CollectionModel<EntityModel<PostfachMail>> toCollectionModel(Stream<PostfachMail> entities, String vorgangId, long vorgangVersion, public CollectionModel<EntityModel<PostfachMail>> toCollectionModel(Stream<PostfachMail> entities, String vorgangId, long vorgangVersion,
Optional<String> postfachId) { Optional<String> postfachId) {
......
...@@ -102,8 +102,15 @@ class PostfachMailModelAssemblerTest { ...@@ -102,8 +102,15 @@ class PostfachMailModelAssemblerTest {
assertThat(link).isNotPresent(); assertThat(link).isNotPresent();
} }
}
@Test
void shouldNotBePresentOnNull() {
var link = modelAssembler.toModel(PostfachMailTestFactory.createBuilder().createdBy(null).build())
.getLink(PostfachMailModelAssembler.REL_CREATED_BY);
assertThat(link).isNotPresent();
}
}
} }
@Nested @Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment