Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Jul 17, 2024
1 parent 446ac56 commit 1f5d0c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public class JSONMarshaller implements Marshaller {
private boolean jsonHandleXmlAnyElementsNames = Boolean.getBoolean(KieServerConstants.JSON_HANDLE_XML_ANY_ELEMENTS_NAMES);
private final boolean STRICT_JAVABEANS_SERIALIZERS = Boolean.getBoolean(KieServerConstants.KIE_SERVER_STRICT_JAVABEANS_SERIALIZERS);

private static final String FIELDS = "fields";
private static final String NOT_NULL = "not_null";
public static final String FIELDS = "fields";
public static final String NOT_NULL = "not_null";

private boolean formatDate;
private String dateFormatStr = System.getProperty("org.kie.server.json.date_format", "yyyy-MM-dd'T'hh:mm:ss.SSSZ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.assertj.core.api.Assertions;
import org.drools.core.command.runtime.BatchExecutionCommandImpl;
import org.drools.core.command.runtime.rule.InsertObjectCommand;
Expand Down Expand Up @@ -112,10 +113,15 @@ public void testPolymorphicInsideCommand() throws IOException {
marshall = marshaller.marshall(command);
}

ObjectMapper mapper = new ObjectMapper();
JsonNode input = mapper.readTree(content);
JsonNode output = mapper.readTree(marshall);
assertThat(input.toPrettyString()).isEqualTo(output.toPrettyString());
BatchExecutionCommandImpl input = marshaller.unmarshall(content, BatchExecutionCommandImpl.class);
BatchExecutionCommandImpl output = marshaller.unmarshall(marshall, BatchExecutionCommandImpl.class);

ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL);
ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();

String inputStr = writer.writeValueAsString(input);
String outputStr = writer.writeValueAsString(output);
assertThat(inputStr).isEqualTo(outputStr);
}

@Test
Expand All @@ -136,9 +142,14 @@ public void testPolymorphicInsideCommandHandle() throws IOException {
marshall = marshaller.marshall(command);
}

ObjectMapper mapper = new ObjectMapper();
JsonNode input = mapper.readTree(content);
JsonNode output = mapper.readTree(marshall);
assertThat(input.toPrettyString()).isNotEqualTo(output.toPrettyString());
BatchExecutionCommandImpl input = marshaller.unmarshall(content, BatchExecutionCommandImpl.class);
BatchExecutionCommandImpl output = marshaller.unmarshall(marshall, BatchExecutionCommandImpl.class);

ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL);
ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();

String inputStr = writer.writeValueAsString(input);
String outputStr = writer.writeValueAsString(output);
assertThat(inputStr).isEqualTo(outputStr);
}
}

0 comments on commit 1f5d0c3

Please sign in to comment.