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

OZG-4846 skip null values

parent 86044f30
Branches
Tags
No related merge requests found
...@@ -2,10 +2,12 @@ package de.ozgcloud.nachrichten.postfach.bayernid; ...@@ -2,10 +2,12 @@ package de.ozgcloud.nachrichten.postfach.bayernid;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Objects;
import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.DatatypeFactory;
import org.mapstruct.Condition;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy; import org.mapstruct.ReportingPolicy;
...@@ -63,4 +65,9 @@ interface BayernIdPostfachNachrichtMapper { ...@@ -63,4 +65,9 @@ interface BayernIdPostfachNachrichtMapper {
return ((StringBasedIdentifier) postfachAddress.getIdentifier()).getPostfachId(); return ((StringBasedIdentifier) postfachAddress.getIdentifier()).getPostfachId();
} }
@Condition
default boolean nonNull(String value) {
return Objects.nonNull(value);
}
} }
...@@ -250,4 +250,23 @@ class BayernIdPostfachNachrichtMapperTest { ...@@ -250,4 +250,23 @@ class BayernIdPostfachNachrichtMapperTest {
assertThat(result.getMessage()).isEqualTo(GrpcSendBayernIdMessageResponseTestFactory.MESSAGE_TEXT); assertThat(result.getMessage()).isEqualTo(GrpcSendBayernIdMessageResponseTestFactory.MESSAGE_TEXT);
} }
} }
@Nested
class TestSkipNulls {
@Test
void shouldNotSetNull() {
var bayernIdMessageMetadata = mapper.toBayernIdMessageMetadata(PostfachNachrichtTestFactory.createBuilder().messageId(null).build(),
AbsenderTestFactory.create());
assertThat(bayernIdMessageMetadata.getMessageId()).isEmpty();
}
@Test
void shouldReturnTrueIfNotNull() {
var result = mapper.nonNull("test");
assertThat(result).isTrue();
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment