Search in sources :

Example 31 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project kylo by Teradata.

the class MetadataClient method createObjectMapper.

private ObjectMapper createObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    // TODO Module dependency is causing a conflict somehow.
    // mapper.registerModule(new JavaTimeModule());
    mapper.setSerializationInclusion(Include.NON_NULL);
    return mapper;
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 32 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project kylo by Teradata.

the class IntegrationTestBase method setupRestAssured.

@Before
public void setupRestAssured() throws URISyntaxException {
    UserContext.setUser(UserContext.User.ADMIN);
    RestAssured.baseURI = kyloConfig.getProtocol() + kyloConfig.getHost();
    RestAssured.port = kyloConfig.getPort();
    RestAssured.basePath = kyloConfig.getBasePath();
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
    Jackson2ObjectMapperFactory factory = (aClass, s) -> {
        ObjectMapper om = new ObjectMapper();
        om.registerModule(new JodaModule());
        om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
        om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        configureObjectMapper(om);
        return om;
    };
    com.jayway.restassured.mapper.ObjectMapper objectMapper = new Jackson2Mapper(factory);
    RestAssured.objectMapper(objectMapper);
    startClean();
}
Also used : ConnectorController(com.thinkbiganalytics.kylo.catalog.rest.controller.ConnectorController) Arrays(java.util.Arrays) PartitionField(com.thinkbiganalytics.feedmgr.rest.model.schema.PartitionField) ReusableTemplateConnectionInfo(com.thinkbiganalytics.feedmgr.rest.model.ReusableTemplateConnectionInfo) StringUtils(org.apache.commons.lang3.StringUtils) MediaType(javax.ws.rs.core.MediaType) DefaultDataTypeDescriptor(com.thinkbiganalytics.discovery.model.DefaultDataTypeDescriptor) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) AlertsController(com.thinkbiganalytics.alerts.rest.controller.AlertsController) DataSource(com.thinkbiganalytics.kylo.catalog.rest.model.DataSource) SchedulerRestController(com.thinkbiganalytics.scheduler.rest.controller.SchedulerRestController) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) JsonNode(com.fasterxml.jackson.databind.JsonNode) Tag(com.thinkbiganalytics.discovery.schema.Tag) Scp(org.apache.tools.ant.taskdefs.optional.ssh.Scp) JsonPath(com.jayway.restassured.path.json.JsonPath) PermissionsChange(com.thinkbiganalytics.security.rest.model.PermissionsChange) FeedSchedule(com.thinkbiganalytics.feedmgr.rest.model.FeedSchedule) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) JobsRestController(com.thinkbiganalytics.jobrepo.rest.controller.JobsRestController) ActionGroup(com.thinkbiganalytics.security.rest.model.ActionGroup) Set(java.util.Set) ServiceLevelAssessment(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAssessment) EntityVersionDifference(com.thinkbiganalytics.feedmgr.rest.model.EntityVersionDifference) JobAction(com.thinkbiganalytics.jobrepo.repository.rest.model.JobAction) PortDTO(org.apache.nifi.web.api.dto.PortDTO) ImportTemplateOptions(com.thinkbiganalytics.feedmgr.rest.model.ImportTemplateOptions) RestAssured(com.jayway.restassured.RestAssured) RoleMembershipChange(com.thinkbiganalytics.security.rest.model.RoleMembershipChange) AdminControllerV2(com.thinkbiganalytics.feedmgr.rest.controller.AdminControllerV2) SearchResultImpl(com.thinkbiganalytics.rest.model.search.SearchResultImpl) AdminController(com.thinkbiganalytics.feedmgr.rest.controller.AdminController) DatasourceController(com.thinkbiganalytics.feedmgr.rest.controller.DatasourceController) RunWith(org.junit.runner.RunWith) LocalDateTime(java.time.LocalDateTime) Jackson2ObjectMapperFactory(com.jayway.restassured.mapper.factory.Jackson2ObjectMapperFactory) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) AccessControlController(com.thinkbiganalytics.security.rest.controller.AccessControlController) ArrayList(java.util.ArrayList) HTTP_OK(java.net.HttpURLConnection.HTTP_OK) FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) RestResponseStatus(com.thinkbiganalytics.rest.model.RestResponseStatus) JdbcDatasource(com.thinkbiganalytics.metadata.rest.model.data.JdbcDatasource) AlertRange(com.thinkbiganalytics.alerts.rest.model.AlertRange) DomainType(com.thinkbiganalytics.feedmgr.rest.model.DomainType) User(com.thinkbiganalytics.security.rest.model.User) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) ObligationGroup(com.thinkbiganalytics.metadata.sla.api.ObligationGroup) Before(org.junit.Before) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) FeedCategoryRestController(com.thinkbiganalytics.feedmgr.rest.controller.FeedCategoryRestController) ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) IOException(java.io.IOException) DefaultHiveSchema(com.thinkbiganalytics.discovery.model.DefaultHiveSchema) SearchResult(com.thinkbiganalytics.rest.model.search.SearchResult) InputStreamReader(java.io.InputStreamReader) File(java.io.File) DataSourceController(com.thinkbiganalytics.kylo.catalog.rest.controller.DataSourceController) ExecutedStep(com.thinkbiganalytics.jobrepo.query.model.ExecutedStep) NifiIntegrationRestController(com.thinkbiganalytics.feedmgr.rest.controller.NifiIntegrationRestController) HiveRestController(com.thinkbiganalytics.hive.rest.controller.HiveRestController) ContextConfiguration(org.springframework.test.context.ContextConfiguration) BufferedReader(java.io.BufferedReader) Assert(org.junit.Assert) ImportComponentOption(com.thinkbiganalytics.feedmgr.rest.model.ImportComponentOption) DefaultExecutedJob(com.thinkbiganalytics.jobrepo.query.model.DefaultExecutedJob) HTTP_BAD_REQUEST(java.net.HttpURLConnection.HTTP_BAD_REQUEST) DefaultExecutedStep(com.thinkbiganalytics.jobrepo.query.model.DefaultExecutedStep) ImportComponentOptionBuilder(com.thinkbiganalytics.feedmgr.rest.model.ImportComponentOptionBuilder) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) ServiceLevelAgreementRestController(com.thinkbiganalytics.feedmgr.rest.controller.ServiceLevelAgreementRestController) HTTP_NO_CONTENT(java.net.HttpURLConnection.HTTP_NO_CONTENT) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ObjectMapperSerializer(com.thinkbiganalytics.json.ObjectMapperSerializer) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ServiceLevelAssessmentsController(com.thinkbiganalytics.jobrepo.rest.controller.ServiceLevelAssessmentsController) FeedVersions(com.thinkbiganalytics.feedmgr.rest.model.FeedVersions) ServiceLevelAgreementGroup(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup) SSHBase(org.apache.tools.ant.taskdefs.optional.ssh.SSHBase) ImportTemplate(com.thinkbiganalytics.feedmgr.service.template.importing.model.ImportTemplate) FeedRestController(com.thinkbiganalytics.feedmgr.rest.controller.FeedRestController) JSON(com.jayway.restassured.http.ContentType.JSON) DefaultTag(com.thinkbiganalytics.discovery.model.DefaultTag) UUID(java.util.UUID) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Parser(com.jayway.restassured.parsing.Parser) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary) ScheduleIdentifier(com.thinkbiganalytics.scheduler.rest.model.ScheduleIdentifier) DomainTypesController(com.thinkbiganalytics.feedmgr.rest.controller.DomainTypesController) List(java.util.List) ImportFeed(com.thinkbiganalytics.feedmgr.service.feed.importing.model.ImportFeed) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ImportComponent(com.thinkbiganalytics.feedmgr.rest.ImportComponent) Jackson2Mapper(com.jayway.restassured.internal.mapping.Jackson2Mapper) ChronoField(java.time.temporal.ChronoField) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) HashMap(java.util.HashMap) Response(com.jayway.restassured.response.Response) DefaultField(com.thinkbiganalytics.discovery.model.DefaultField) UserProperty(com.thinkbiganalytics.feedmgr.rest.model.UserProperty) HashSet(java.util.HashSet) Inject(javax.inject.Inject) TemplatesRestController(com.thinkbiganalytics.feedmgr.rest.controller.TemplatesRestController) NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) Project(org.apache.tools.ant.Project) PrintStream(java.io.PrintStream) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) SSHExec(org.apache.tools.ant.taskdefs.optional.ssh.SSHExec) Datasource(com.thinkbiganalytics.metadata.rest.model.data.Datasource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SystemNamingService(com.thinkbiganalytics.feedmgr.rest.support.SystemNamingService) FieldRuleProperty(com.thinkbiganalytics.policy.rest.model.FieldRuleProperty) TimeUnit(java.util.concurrent.TimeUnit) ServiceLevelAgreementRule(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementRule) Connector(com.thinkbiganalytics.kylo.catalog.rest.model.Connector) DateTimeFormatter(java.time.format.DateTimeFormatter) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) InputStream(java.io.InputStream) Jackson2ObjectMapperFactory(com.jayway.restassured.mapper.factory.Jackson2ObjectMapperFactory) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Jackson2Mapper(com.jayway.restassured.internal.mapping.Jackson2Mapper) Before(org.junit.Before)

Example 33 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project killbill by killbill.

the class TestDefaultBroadcastInternalEvent method testBasic.

@Test(groups = "fast")
public void testBasic() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    final String eventJson = "\"{\"pluginName\":\"foo\",\"pluginVersion\":\"1.2.3\",\"properties\":[{\"key\":\"something\",\"value\":\"nothing\"}]}\"";
    final BroadcastInternalEvent broadcastEvent = new DefaultBroadcastInternalEvent("service", "PLUGIN_INSTALL", eventJson);
    final String broadcastEventStr = objectMapper.writeValueAsString(broadcastEvent);
    final BroadcastInternalEvent res = objectMapper.readValue(broadcastEventStr, DefaultBroadcastInternalEvent.class);
    Assert.assertEquals(res.getServiceName(), "service");
    Assert.assertEquals(res.getType(), "PLUGIN_INSTALL");
    Assert.assertEquals(res.getJsonEvent(), eventJson);
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) BroadcastInternalEvent(org.killbill.billing.events.BroadcastInternalEvent) ObjectMapper(org.killbill.billing.util.jackson.ObjectMapper) Test(org.testng.annotations.Test)

Example 34 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionSyncApp method getObjectMapper.

@Bean(name = "JodaMapper")
@Primary
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule()).configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false).configure(SerializationFeature.INDENT_OUTPUT, true).setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 35 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class BeanMapperTest method testConvertStudy.

@Test
public void testConvertStudy() {
    String dtoString = "{\n" + "      \"study_tag\": \"t1\",\n" + "      \"study_accession\": \"GCST90000116\",\n" + "      \"genotyping_technology\": \"Genome-wide genotyping array\",\n" + "      \"imputation\": false,\n" + "      \"variant_count\": 4,\n" + "      \"trait\": \"bmi\",\n" + "      \"summary_statistics_file\": \"abc123.tsv\",\n" + "      \"checksum\": \"a1195761f082f8cbc2f5a560743077cc\",\n" + "      \"summary_statistics_assembly\": \"GRCh38\",\n" + "      \"readme_file\": \"some text\"\n" + "    }";
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    DepositionStudyDto studyDto = null;
    try {
        studyDto = objectMapper.readValue(dtoString, DepositionStudyDto.class);
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    UnpublishedStudy study = BeanMapper.MAPPER.convert(studyDto);
    assertNotNull(study);
    assertNotNull(study.getSummaryStatsFile());
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) DepositionStudyDto(uk.ac.ebi.spot.goci.model.deposition.DepositionStudyDto) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)45 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)37 Test (org.junit.Test)15 IOException (java.io.IOException)14 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Resource (org.springframework.core.io.Resource)6 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)5 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)5 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Bean (org.springframework.context.annotation.Bean)4 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 Primary (org.springframework.context.annotation.Primary)3 MetricsModule (com.codahale.metrics.json.MetricsModule)2 PropertyNamingStrategy (com.fasterxml.jackson.databind.PropertyNamingStrategy)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)2