Search in sources :

Example 11 with JsonMapperProvider

use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.

the class JsonMapperProviderTest method testNullOnWrite.

@Test
public void testNullOnWrite() throws JsonProcessingException {
    Map<String, Object> data = new HashMap<>();
    data.put("someKey", null);
    data.put("someId", "abc123");
    ObjectMapper objectMapper = new JsonMapperProvider().get();
    String result = objectMapper.writeValueAsString(data);
    System.out.println(result);
    assertTrue(result.contains("null"));
}
Also used : HashMap(java.util.HashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Test(org.junit.Test)

Example 12 with JsonMapperProvider

use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.

the class PerformanceTest method setUp.

@Before
public void setUp() {
    TestConfiguration testConfiguration = new TestConfiguration();
    configuration = new TestPostgresConfiguration(testConfiguration, "jdbc:postgresql://localhost:54320/conductor?charset=utf8&parseTime=true&interpolateParams=true", 10, 2);
    PostgresDataSourceProvider dataSource = new PostgresDataSourceProvider(configuration);
    this.dataSource = dataSource.get();
    resetAllData(this.dataSource);
    flywayMigrate(this.dataSource);
    final ObjectMapper objectMapper = new JsonMapperProvider().get();
    Q = new PostgresQueueDAO(objectMapper, this.dataSource);
    E = new PostgresExecutionDAO(objectMapper, this.dataSource);
}
Also used : PostgresExecutionDAO(com.netflix.conductor.dao.postgres.PostgresExecutionDAO) TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) PostgresQueueDAO(com.netflix.conductor.dao.postgres.PostgresQueueDAO) PostgresDataSourceProvider(com.netflix.conductor.postgres.PostgresDataSourceProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Before(org.junit.Before)

Example 13 with JsonMapperProvider

use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.

the class JsonUtils method fromJson.

public static <T> T fromJson(String fileName, Class<T> classObject) throws Exception {
    ObjectMapper objectMapper = new JsonMapperProvider().get();
    InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);
    return objectMapper.readValue(inputStream, classObject);
}
Also used : InputStream(java.io.InputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider)

Example 14 with JsonMapperProvider

use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.

the class ExternalPayloadStorageUtilsTest method setup.

@Before
public void setup() {
    externalPayloadStorage = mock(ExternalPayloadStorage.class);
    Configuration configuration = new TestConfiguration();
    objectMapper = new JsonMapperProvider().get();
    location = new ExternalStorageLocation();
    location.setPath("some/test/path");
    externalPayloadStorageUtils = new ExternalPayloadStorageUtils(externalPayloadStorage, configuration, objectMapper);
}
Also used : TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) Configuration(com.netflix.conductor.core.config.Configuration) TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) ExternalPayloadStorage(com.netflix.conductor.common.utils.ExternalPayloadStorage) ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Before(org.junit.Before)

Example 15 with JsonMapperProvider

use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.

the class JsonMapperProviderTest method testSimpleMapping.

@Test
public void testSimpleMapping() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper m = new JsonMapperProvider().get();
    assertTrue(m.canSerialize(Any.class));
    Struct struct1 = Struct.newBuilder().putFields("some-key", Value.newBuilder().setStringValue("some-value").build()).build();
    Any source = Any.pack(struct1);
    StringWriter buf = new StringWriter();
    m.writer().writeValue(buf, source);
    Any dest = m.reader().forType(Any.class).readValue(buf.toString());
    assertEquals(source.getTypeUrl(), dest.getTypeUrl());
    Struct struct2 = dest.unpack(Struct.class);
    assertTrue(struct2.containsFields("some-key"));
    assertEquals(struct1.getFieldsOrThrow("some-key").getStringValue(), struct2.getFieldsOrThrow("some-key").getStringValue());
}
Also used : StringWriter(java.io.StringWriter) Any(com.google.protobuf.Any) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Struct(com.google.protobuf.Struct) Test(org.junit.Test)

Aggregations

JsonMapperProvider (com.netflix.conductor.common.utils.JsonMapperProvider)25 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)15 SystemPropertiesElasticSearchConfiguration (com.netflix.conductor.elasticsearch.SystemPropertiesElasticSearchConfiguration)10 HashMap (java.util.HashMap)9 Test (org.junit.Test)6 ElasticSearchTransportClientProvider (com.netflix.conductor.elasticsearch.ElasticSearchTransportClientProvider)4 EmbeddedElasticSearchV5 (com.netflix.conductor.elasticsearch.es5.EmbeddedElasticSearchV5)4 Before (org.junit.Before)4 BeforeClass (org.junit.BeforeClass)4 Configuration (com.netflix.conductor.core.config.Configuration)3 TestConfiguration (com.netflix.conductor.core.execution.TestConfiguration)3 ElasticSearchRestClientBuilderProvider (com.netflix.conductor.elasticsearch.ElasticSearchRestClientBuilderProvider)3 EmbeddedElasticSearchV6 (com.netflix.conductor.elasticsearch.es6.EmbeddedElasticSearchV6)3 RestClientBuilder (org.elasticsearch.client.RestClientBuilder)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)2 QueueDAO (com.netflix.conductor.dao.QueueDAO)2 EmbeddedElasticSearchV7 (com.netflix.conductor.elasticsearch.es7.EmbeddedElasticSearchV7)2 Request (org.elasticsearch.client.Request)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1