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

OZG-1513 adjust CommandBodyMapper -> map Enum as *enum*.name()

parent 55905990
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,14 @@ public interface CommandBodyMapper {
return new BeanMap(object).entrySet().stream()
.filter(HAS_NOT_NULL_VALUE)
.filter(IS_NOT_CLASS_VALUE)
.collect(Collectors.toMap(entry -> entry.getKey().toString(), Entry::getValue));
.collect(Collectors.toMap(entry -> entry.getKey().toString(), this::checkEnumValue));
}
private Object checkEnumValue(Entry<Object, Object> entry) {
if (entry.getValue() instanceof Enum<?> enumValue) {
return enumValue.name();
}
return entry.getValue();
}
default GrpcCommandBody mapToBody(Map<String, String> bodyMap) {
......
......@@ -52,7 +52,7 @@ class CommandBodyMapperTest {
assertThat(mappedMap)
.hasSize(4)
.doesNotContainKey("status")
.containsEntry("order", CommandTestFactory.ORDER)
.containsEntry("order", CommandTestFactory.ORDER.name())
.containsEntry("relationId", CommandTestFactory.RELATION_ID)
.containsEntry("vorgangId", CommandTestFactory.VORGANG_ID);
}
......@@ -65,8 +65,8 @@ class CommandBodyMapperTest {
assertThat(mappedMap)
.hasSize(5)
.containsEntry("status", CommandTestFactory.STATUS)
.containsEntry("order", CommandTestFactory.ORDER)
.containsEntry("status", CommandTestFactory.STATUS.name())
.containsEntry("order", CommandTestFactory.ORDER.name())
.containsEntry("relationId", CommandTestFactory.RELATION_ID)
.containsEntry("vorgangId", CommandTestFactory.VORGANG_ID);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment