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());
}
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);
}
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();
}
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);
}
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);
}
Aggregations