use of org.kie.server.api.marshalling.objects.DateObjectUnannotated in project droolsjbpm-integration by kiegroup.
the class JSONMarshallerTest method testMarshallDateObjectUnannotated.
@Test
public void testMarshallDateObjectUnannotated() {
String expectedString = String.format("{%n" + " \"localDate\" : \"2017-01-01\",%n" + " \"localDateTime\" : \"2017-01-01T10:10:10\",%n" + " \"localTime\" : \"10:10:10\",%n" + " \"offsetDateTime\" : \"2017-01-01T10:10:10+0100\"%n" + "}");
Marshaller marshaller = MarshallerFactory.getMarshaller(MarshallingFormat.JSON, getClass().getClassLoader());
DateObjectUnannotated dateObject = new DateObjectUnannotated();
dateObject.setLocalDate(LocalDate.of(2017, 1, 1));
dateObject.setLocalDateTime(LocalDateTime.of(2017, 1, 1, 10, 10, 10));
dateObject.setLocalTime(LocalTime.of(10, 10, 10));
dateObject.setOffsetDateTime(OffsetDateTime.of(2017, 1, 1, 10, 10, 10, 0, ZoneOffset.ofHours(1)));
String dateObjectString = marshaller.marshall(dateObject);
assertNotNull(dateObjectString);
assertEquals(expectedString, dateObjectString);
}
use of org.kie.server.api.marshalling.objects.DateObjectUnannotated in project droolsjbpm-integration by kiegroup.
the class JSONMarshallerTest method testUnmarshallDateObjectUnannotated.
@Test
public void testUnmarshallDateObjectUnannotated() {
String expectedString = "{\n" + " \"localDate\" : \"2017-01-01\",\n" + " \"localDateTime\" : \"2017-01-01T10:10:10\",\n" + " \"localTime\" : \"10:10:10\",\n" + " \"offsetDateTime\" : \"2017-01-01T10:10:10+0100\"\n" + "}";
Marshaller marshaller = MarshallerFactory.getMarshaller(MarshallingFormat.JSON, getClass().getClassLoader());
DateObjectUnannotated dateObject = marshaller.unmarshall(expectedString, DateObjectUnannotated.class);
assertNotNull(dateObject);
assertEquals(LocalDate.of(2017, 1, 1), dateObject.getLocalDate());
assertEquals(LocalDateTime.of(2017, 1, 1, 10, 10, 10), dateObject.getLocalDateTime());
assertEquals(LocalTime.of(10, 10, 10), dateObject.getLocalTime());
assertEquals(OffsetDateTime.of(2017, 1, 1, 10, 10, 10, 0, ZoneOffset.ofHours(1)), dateObject.getOffsetDateTime());
}
use of org.kie.server.api.marshalling.objects.DateObjectUnannotated in project droolsjbpm-integration by kiegroup.
the class SolutionMarshallingTest method testMarshallHardSoftScore.
@Test
public void testMarshallHardSoftScore() {
SolverInstance solverInstance = new SolverInstance();
DateObjectUnannotated dateObject = new DateObjectUnannotated();
dateObject.setLocalDate(LocalDate.of(2018, 8, 18));
dateObject.setLocalDateTime(LocalDateTime.of(2017, 7, 17, 17, 17, 17));
dateObject.setLocalTime(LocalTime.of(12, 34, 56));
dateObject.setOffsetDateTime(OffsetDateTime.of(2019, 2, 4, 20, 57, 11, 0, ZoneOffset.ofHours(1)));
solverInstance.setBestSolution(dateObject);
Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, Thread.currentThread().getContextClassLoader());
String marshalledSolverInstance = marshaller.marshall(solverInstance);
logger.debug("Marshalled SolverInstance ({}): {}", marshallingFormat, marshalledSolverInstance);
assertThat(marshalledSolverInstance).as("Dates should be formatted").contains("2018-08-18", "2017-07-17T17:17:17", "12:34:56", "2019-02-04T20:57:11+01");
SolverInstance unmarshalledSolverInstance = marshaller.unmarshall(marshalledSolverInstance, SolverInstance.class);
DateObjectUnannotated bestSolution = (DateObjectUnannotated) unmarshalledSolverInstance.getBestSolution();
assertThat(bestSolution.getLocalDate()).isEqualTo(dateObject.getLocalDate());
assertThat(bestSolution.getLocalDateTime()).isEqualTo(dateObject.getLocalDateTime());
assertThat(bestSolution.getLocalTime()).isEqualTo(dateObject.getLocalTime());
assertThat(bestSolution.getOffsetDateTime()).isEqualTo(dateObject.getOffsetDateTime());
}
use of org.kie.server.api.marshalling.objects.DateObjectUnannotated in project droolsjbpm-integration by kiegroup.
the class Person method testMarshallDateObjectUnannotated.
@Test
public void testMarshallDateObjectUnannotated() {
String expectedString = String.format("{%n" + " \"localDate\" : \"2017-01-01\",%n" + " \"localDateTime\" : \"2017-01-01T10:10:10\",%n" + " \"localTime\" : \"10:10:10\",%n" + " \"offsetDateTime\" : \"2017-01-01T10:10:10+0100\"%n" + "}");
Marshaller marshaller = MarshallerFactory.getMarshaller(MarshallingFormat.JSON, getClass().getClassLoader());
DateObjectUnannotated dateObject = new DateObjectUnannotated();
dateObject.setLocalDate(LocalDate.of(2017, 1, 1));
dateObject.setLocalDateTime(LocalDateTime.of(2017, 1, 1, 10, 10, 10));
dateObject.setLocalTime(LocalTime.of(10, 10, 10));
dateObject.setOffsetDateTime(OffsetDateTime.of(2017, 1, 1, 10, 10, 10, 0, ZoneOffset.ofHours(1)));
String dateObjectString = marshaller.marshall(dateObject);
assertNotNull(dateObjectString);
assertEquals(expectedString, dateObjectString);
}
use of org.kie.server.api.marshalling.objects.DateObjectUnannotated in project droolsjbpm-integration by kiegroup.
the class Person method testUnmarshallDateObjectUnannotated.
@Test
public void testUnmarshallDateObjectUnannotated() {
String expectedString = "{\n" + " \"localDate\" : \"2017-01-01\",\n" + " \"localDateTime\" : \"2017-01-01T10:10:10\",\n" + " \"localTime\" : \"10:10:10\",\n" + " \"offsetDateTime\" : \"2017-01-01T10:10:10+0100\"\n" + "}";
Marshaller marshaller = MarshallerFactory.getMarshaller(MarshallingFormat.JSON, getClass().getClassLoader());
DateObjectUnannotated dateObject = marshaller.unmarshall(expectedString, DateObjectUnannotated.class);
assertNotNull(dateObject);
assertEquals(LocalDate.of(2017, 1, 1), dateObject.getLocalDate());
assertEquals(LocalDateTime.of(2017, 1, 1, 10, 10, 10), dateObject.getLocalDateTime());
assertEquals(LocalTime.of(10, 10, 10), dateObject.getLocalTime());
assertEquals(OffsetDateTime.of(2017, 1, 1, 10, 10, 10, 0, ZoneOffset.ofHours(1)), dateObject.getOffsetDateTime());
}
Aggregations