use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project tutorials by eugenp.
the class JacksonDateUnitTest method whenSerializingJava8Date_thenCorrect.
@Test
public void whenSerializingJava8Date_thenCorrect() throws JsonProcessingException {
final LocalDateTime date = LocalDateTime.of(2014, 12, 20, 2, 30);
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JSR310Module());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
final String result = mapper.writeValueAsString(date);
assertThat(result, containsString("2014-12-20T02:30"));
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class ElasticSearchIndexUpdater method addOrUpdateIndex.
@Override
public void addOrUpdateIndex(String typeName, Map<String, Object> entity) {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JSR310Module());
String json;
try {
json = mapper.writeValueAsString(entity);
String id = entity.get("id").toString();
@SuppressWarnings("unused") IndexResponse response = elasticClient.prepareIndex("muikku", typeName, id).setSource(json).execute().actionGet();
} catch (IOException e) {
logger.log(Level.WARNING, "Adding to index failed because of exception", e);
}
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractUITest method createWorkspaceFolder.
protected WorkspaceFolder createWorkspaceFolder(Long workspaceEntityId, Long parentId, Boolean hidden, Integer orderNumber, String title, String folderType) throws IOException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
WorkspaceFolder payload = new WorkspaceFolder(null, hidden, orderNumber, null, title, parentId);
Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces/{WORKSPACEENTITYIID}/folders", workspaceEntityId);
response.then().statusCode(200);
WorkspaceFolder result = objectMapper.readValue(response.asString(), WorkspaceFolder.class);
assertNotNull(result);
assertNotNull(result.getId());
return result;
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractUITest method createWorkspaceHtmlMaterial.
protected WorkspaceHtmlMaterial createWorkspaceHtmlMaterial(Long workspaceEntityId, Long parentId, String title, String contentType, String html, Long revisionNumber, String assignmentType) throws IOException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
WorkspaceHtmlMaterial payload = new WorkspaceHtmlMaterial(null, parentId, title, contentType, html, revisionNumber, assignmentType, null);
Response response = asAdmin().contentType("application/json;charset=UTF-8").body(payload).post("/test/workspaces/{WORKSPACEENTITYIID}/htmlmaterials", workspaceEntityId);
response.then().statusCode(200);
WorkspaceHtmlMaterial result = objectMapper.readValue(response.asString(), WorkspaceHtmlMaterial.class);
assertNotNull(result);
assertNotNull(result.getId());
return result;
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractUITest method createWorkspaceDiscussion.
protected Discussion createWorkspaceDiscussion(Long workspaceEntityId, Long groupId, String name) throws IOException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Discussion payload = new Discussion(null, name, null, groupId);
Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions", workspaceEntityId, groupId);
response.then().statusCode(200);
Discussion workspaceDiscussion = objectMapper.readValue(response.asString(), Discussion.class);
assertNotNull(workspaceDiscussion);
assertNotNull(workspaceDiscussion.getId());
return workspaceDiscussion;
}
Aggregations