Search in sources :

Example 1 with JsonMapperProvider

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

the class SubWorkflowParamsTest method testWorkflowDefJson.

@Test
public void testWorkflowDefJson() throws Exception {
    // name is null
    SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName("dummy-name");
    WorkflowDef def = new WorkflowDef();
    def.setName("test_workflow");
    def.setVersion(1);
    WorkflowTask task = new WorkflowTask();
    task.setName("test_task");
    task.setTaskReferenceName("t1");
    def.getTasks().add(task);
    subWorkflowParams.setWorkflowDefinition(def);
    String expected = "{\n" + "  \"name\" : \"test_workflow\",\n" + "  \"version\" : 1,\n" + "  \"workflowDefinition\" : {\n" + "    \"inputParameters\" : [ ],\n" + "    \"name\" : \"test_workflow\",\n" + "    \"outputParameters\" : { },\n" + "    \"restartable\" : true,\n" + "    \"schemaVersion\" : 2,\n" + "    \"tasks\" : [ {\n" + "      \"asyncComplete\" : false,\n" + "      \"decisionCases\" : { },\n" + "      \"defaultCase\" : [ ],\n" + "      \"defaultExclusiveJoinTask\" : [ ],\n" + "      \"forkTasks\" : [ ],\n" + "      \"inputParameters\" : { },\n" + "      \"joinOn\" : [ ],\n" + "      \"loopOver\" : [ ],\n" + "      \"name\" : \"test_task\",\n" + "      \"optional\" : false,\n" + "      \"retryLogic\" : \"UNSPECIFIED\",\n" + "      \"startDelay\" : 0,\n" + "      \"taskReferenceName\" : \"t1\",\n" + "      \"type\" : \"SIMPLE\"\n" + "    } ],\n" + "    \"timeoutPolicy\" : \"ALERT_ONLY\",\n" + "    \"timeoutSeconds\" : 0,\n" + "    \"variables\" : { },\n" + "    \"version\" : 1,\n" + "    \"workflowStatusListenerEnabled\" : false\n" + "  }\n" + "}";
    ObjectMapper objectMapper = new JsonMapperProvider().get();
    objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    objectMapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
    objectMapper.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
    assertEquals(expected, objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(subWorkflowParams));
    SubWorkflowParams actualSubWorkflowParam = objectMapper.readValue(expected, SubWorkflowParams.class);
    assertEquals(subWorkflowParams, actualSubWorkflowParam);
    assertEquals(def, actualSubWorkflowParam.getWorkflowDefinition());
    assertEquals(def, actualSubWorkflowParam.getWorkflowDef());
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Test(org.junit.Test)

Example 2 with JsonMapperProvider

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

the class TestWorkflowExecutor method init.

@Before
public void init() {
    TestConfiguration config = new TestConfiguration();
    executionDAOFacade = mock(ExecutionDAOFacade.class);
    metadataDAO = mock(MetadataDAO.class);
    queueDAO = mock(QueueDAO.class);
    workflowStatusListener = mock(WorkflowStatusListener.class);
    ExternalPayloadStorageUtils externalPayloadStorageUtils = mock(ExternalPayloadStorageUtils.class);
    executionLockService = mock(ExecutionLockService.class);
    ObjectMapper objectMapper = new JsonMapperProvider().get();
    ParametersUtils parametersUtils = new ParametersUtils();
    Map<String, TaskMapper> taskMappers = new HashMap<>();
    taskMappers.put("DECISION", new DecisionTaskMapper());
    taskMappers.put("DYNAMIC", new DynamicTaskMapper(parametersUtils, metadataDAO));
    taskMappers.put("FORK_JOIN", new ForkJoinTaskMapper());
    taskMappers.put("JOIN", new JoinTaskMapper());
    taskMappers.put("FORK_JOIN_DYNAMIC", new ForkJoinDynamicTaskMapper(parametersUtils, objectMapper, metadataDAO));
    taskMappers.put("USER_DEFINED", new UserDefinedTaskMapper(parametersUtils, metadataDAO));
    taskMappers.put("SIMPLE", new SimpleTaskMapper(parametersUtils));
    taskMappers.put("SUB_WORKFLOW", new SubWorkflowTaskMapper(parametersUtils, metadataDAO));
    taskMappers.put("EVENT", new EventTaskMapper(parametersUtils));
    taskMappers.put("WAIT", new WaitTaskMapper(parametersUtils));
    taskMappers.put("HTTP", new HTTPTaskMapper(parametersUtils, metadataDAO));
    taskMappers.put("LAMBDA", new LambdaTaskMapper(parametersUtils, metadataDAO));
    new SubWorkflow(new JsonMapperProvider().get());
    new Lambda();
    DeciderService deciderService = new DeciderService(parametersUtils, metadataDAO, externalPayloadStorageUtils, taskMappers, config);
    MetadataMapperService metadataMapperService = new MetadataMapperService(metadataDAO);
    workflowExecutor = new WorkflowExecutor(deciderService, metadataDAO, queueDAO, metadataMapperService, workflowStatusListener, executionDAOFacade, config, executionLockService, parametersUtils);
}
Also used : LambdaTaskMapper(com.netflix.conductor.core.execution.mapper.LambdaTaskMapper) SubWorkflowTaskMapper(com.netflix.conductor.core.execution.mapper.SubWorkflowTaskMapper) HashMap(java.util.HashMap) WaitTaskMapper(com.netflix.conductor.core.execution.mapper.WaitTaskMapper) ExternalPayloadStorageUtils(com.netflix.conductor.core.utils.ExternalPayloadStorageUtils) SimpleTaskMapper(com.netflix.conductor.core.execution.mapper.SimpleTaskMapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ExecutionLockService(com.netflix.conductor.service.ExecutionLockService) QueueDAO(com.netflix.conductor.dao.QueueDAO) ForkJoinDynamicTaskMapper(com.netflix.conductor.core.execution.mapper.ForkJoinDynamicTaskMapper) Lambda(com.netflix.conductor.core.execution.tasks.Lambda) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MetadataDAO(com.netflix.conductor.dao.MetadataDAO) SimpleTaskMapper(com.netflix.conductor.core.execution.mapper.SimpleTaskMapper) LambdaTaskMapper(com.netflix.conductor.core.execution.mapper.LambdaTaskMapper) ForkJoinTaskMapper(com.netflix.conductor.core.execution.mapper.ForkJoinTaskMapper) HTTPTaskMapper(com.netflix.conductor.core.execution.mapper.HTTPTaskMapper) TaskMapper(com.netflix.conductor.core.execution.mapper.TaskMapper) ForkJoinDynamicTaskMapper(com.netflix.conductor.core.execution.mapper.ForkJoinDynamicTaskMapper) UserDefinedTaskMapper(com.netflix.conductor.core.execution.mapper.UserDefinedTaskMapper) WaitTaskMapper(com.netflix.conductor.core.execution.mapper.WaitTaskMapper) JoinTaskMapper(com.netflix.conductor.core.execution.mapper.JoinTaskMapper) SubWorkflowTaskMapper(com.netflix.conductor.core.execution.mapper.SubWorkflowTaskMapper) DecisionTaskMapper(com.netflix.conductor.core.execution.mapper.DecisionTaskMapper) DynamicTaskMapper(com.netflix.conductor.core.execution.mapper.DynamicTaskMapper) EventTaskMapper(com.netflix.conductor.core.execution.mapper.EventTaskMapper) EventTaskMapper(com.netflix.conductor.core.execution.mapper.EventTaskMapper) SubWorkflow(com.netflix.conductor.core.execution.tasks.SubWorkflow) UserDefinedTaskMapper(com.netflix.conductor.core.execution.mapper.UserDefinedTaskMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) ForkJoinTaskMapper(com.netflix.conductor.core.execution.mapper.ForkJoinTaskMapper) DecisionTaskMapper(com.netflix.conductor.core.execution.mapper.DecisionTaskMapper) MetadataMapperService(com.netflix.conductor.core.metadata.MetadataMapperService) HTTPTaskMapper(com.netflix.conductor.core.execution.mapper.HTTPTaskMapper) ForkJoinDynamicTaskMapper(com.netflix.conductor.core.execution.mapper.ForkJoinDynamicTaskMapper) DynamicTaskMapper(com.netflix.conductor.core.execution.mapper.DynamicTaskMapper) ForkJoinTaskMapper(com.netflix.conductor.core.execution.mapper.ForkJoinTaskMapper) JoinTaskMapper(com.netflix.conductor.core.execution.mapper.JoinTaskMapper) ExecutionDAOFacade(com.netflix.conductor.core.orchestration.ExecutionDAOFacade) Before(org.junit.Before)

Example 3 with JsonMapperProvider

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

the class TestParametersUtils method setup.

@Before
public void setup() {
    parametersUtils = new ParametersUtils();
    jsonUtils = new JsonUtils();
    objectMapper = new JsonMapperProvider().get();
}
Also used : JsonUtils(com.netflix.conductor.core.utils.JsonUtils) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Before(org.junit.Before)

Example 4 with JsonMapperProvider

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

the class TestElasticSearchRestDAOV5 method startElasticSearchWithBatchSize.

private void startElasticSearchWithBatchSize(int i) throws Exception {
    System.setProperty(ElasticSearchConfiguration.ELASTIC_SEARCH_INDEX_BATCH_SIZE_PROPERTY_NAME, String.valueOf(i));
    configuration = new SystemPropertiesElasticSearchConfiguration();
    String host = configuration.getEmbeddedHost();
    int port = configuration.getEmbeddedPort();
    String clusterName = configuration.getEmbeddedClusterName();
    embeddedElasticSearch = new EmbeddedElasticSearchV5(clusterName, host, port);
    embeddedElasticSearch.start();
    ElasticSearchRestClientProvider restClientProvider = new ElasticSearchRestClientProvider(configuration);
    restClient = restClientProvider.get();
    elasticSearchClient = new RestHighLevelClient(restClient);
    Map<String, String> params = new HashMap<>();
    params.put("wait_for_status", "yellow");
    params.put("timeout", "30s");
    restClient.performRequest("GET", "/_cluster/health", params);
    objectMapper = new JsonMapperProvider().get();
    indexDAO = new ElasticSearchRestDAOV5(restClient, configuration, objectMapper);
}
Also used : EmbeddedElasticSearchV5(com.netflix.conductor.elasticsearch.es5.EmbeddedElasticSearchV5) HashMap(java.util.HashMap) SystemPropertiesElasticSearchConfiguration(com.netflix.conductor.elasticsearch.SystemPropertiesElasticSearchConfiguration) RestHighLevelClient(org.elasticsearch.client.RestHighLevelClient) ElasticSearchRestClientProvider(com.netflix.conductor.elasticsearch.ElasticSearchRestClientProvider) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider)

Example 5 with JsonMapperProvider

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

the class TestElasticSearchDAOV5 method startElasticSearchWithBatchSize.

private void startElasticSearchWithBatchSize(int i) throws Exception {
    System.setProperty(ElasticSearchConfiguration.ELASTIC_SEARCH_INDEX_BATCH_SIZE_PROPERTY_NAME, String.valueOf(i));
    configuration = new SystemPropertiesElasticSearchConfiguration();
    String host = configuration.getEmbeddedHost();
    int port = configuration.getEmbeddedPort();
    String clusterName = configuration.getEmbeddedClusterName();
    embeddedElasticSearch = new EmbeddedElasticSearchV5(clusterName, host, port);
    embeddedElasticSearch.start();
    ElasticSearchTransportClientProvider transportClientProvider = new ElasticSearchTransportClientProvider(configuration);
    elasticSearchClient = transportClientProvider.get();
    elasticSearchClient.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().get();
    ObjectMapper objectMapper = new JsonMapperProvider().get();
    indexDAO = new ElasticSearchDAOV5(elasticSearchClient, configuration, objectMapper);
}
Also used : ElasticSearchTransportClientProvider(com.netflix.conductor.elasticsearch.ElasticSearchTransportClientProvider) EmbeddedElasticSearchV5(com.netflix.conductor.elasticsearch.es5.EmbeddedElasticSearchV5) SystemPropertiesElasticSearchConfiguration(com.netflix.conductor.elasticsearch.SystemPropertiesElasticSearchConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider)

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