use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project keywhiz by square.
the class CliModule method generalMapper.
@Provides
public ObjectMapper generalMapper() {
/**
* Customizes ObjectMapper for common settings.
*
* @param objectMapper to be customized
* @return customized input factory
*/
ObjectMapper objectMapper = Jackson.newObjectMapper();
objectMapper.registerModule(new Jdk8Module());
objectMapper.registerModules(new JavaTimeModule());
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return objectMapper;
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project uplace.es by Uplace.
the class TestUtil method convertObjectToJsonBytes.
/**
* Convert an object to JSON byte array.
*
* @param object
* the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JavaTimeModule module = new JavaTimeModule();
mapper.registerModule(module);
return mapper.writeValueAsBytes(object);
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project vft-capture by videofirst.
the class FileSystemCaptureDaoTest method setUp.
@Before
public void setUp() throws IOException {
// clean out any videos generated
VfCaptureTesting.initTestFolders();
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(WRITE_DATES_AS_TIMESTAMPS);
target = new FileSystemCaptureDao(objectMapper, VfCaptureTesting.VF_VIDEO_FOLDER);
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project drools by kiegroup.
the class AnnotationsTest method testNextDays.
@Test
public void testNextDays() throws Exception {
final DMNRuntime runtime = createRuntime("nextDays.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_8A1F9719-02AA-4517-97D4-5C4F5D22FE82", "nextDays");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
if (!isTypeSafe()) {
context.set("few dates", Arrays.asList(LocalDate.of(2019, 12, 31), LocalDate.of(2020, 2, 21)));
} else {
JsonMapper mapper = JsonMapper.builder().addModule(new JavaTimeModule()).build();
final String JSON = "{\n" + " \"few dates\": [ \"2019-12-31\", \"2020-02-21\" ]\n" + "}";
Class<?> inputSetClass = getStronglyClassByName(dmnModel, "InputSet");
FEELPropertyAccessible inputSet = (FEELPropertyAccessible) mapper.readValue(JSON, inputSetClass);
context = new DMNContextFPAImpl(inputSet);
}
final DMNResult dmnResult = evaluateModel(runtime, dmnModel, context);
LOG.debug("{}", dmnResult);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
assertThat(dmnResult.getDecisionResultByName("Decision-1").getResult(), is(Arrays.asList(LocalDate.of(2020, 1, 1), LocalDate.of(2020, 2, 22))));
if (strongly) {
Class<?> inputSetClass = getStronglyClassByName(dmnModel, "InputSet");
Field directionAsField = inputSetClass.getDeclaredField("few_32dates");
org.eclipse.microprofile.openapi.annotations.media.Schema annMP = directionAsField.getDeclaredAnnotation(org.eclipse.microprofile.openapi.annotations.media.Schema.class);
Assertions.assertThat(annMP).isNotNull();
Assertions.assertThat(annMP.type()).isEqualTo(org.eclipse.microprofile.openapi.annotations.enums.SchemaType.ARRAY);
io.swagger.v3.oas.annotations.media.Schema annIOSwagger = directionAsField.getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
Assertions.assertThat(annIOSwagger).isNotNull();
Assertions.assertThat(annIOSwagger.type()).isEqualTo("array");
}
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project paascloud-master by paascloud.
the class PcObjectMapper method buidMvcMessageConverter.
public static void buidMvcMessageConverter(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
ObjectMapper objectMapper = new ObjectMapper().registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(new JavaTimeModule()).registerModule(simpleModule);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
jackson2HttpMessageConverter.setObjectMapper(objectMapper);
converters.add(jackson2HttpMessageConverter);
}
Aggregations