public void setJsonResponseAsWorkflowVariable(Object responseObject, String executionId, String activitiId) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(executionId, activitiId, VARIABLE_JSON_RESPONSE, jsonResponse); }
public void setJsonResponseAsWorkflowVariable(Object responseObject, String executionId, String activitiId) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(executionId, activitiId, VARIABLE_JSON_RESPONSE, jsonResponse); }
/** * Sets a JSON response object as a workflow variable. * * @param responseObject the JSON object. * @param execution the delegate execution. * * @throws Exception if any problems were encountered. */ public void setJsonResponseAsWorkflowVariable(Object responseObject, DelegateExecution execution) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(execution, VARIABLE_JSON_RESPONSE, jsonResponse); }
/** * Loops through all process variables and logs them. * * @param execution the execution information */ protected void logInputParameters(DelegateExecution execution) { LOGGER.info("{} Input parameters for {}: {}", activitiHelper.getProcessIdentifyingInformation(execution), this.getClass().getName(), execution.getVariables().entrySet().stream().map(entry -> entry.getKey() + "=" + jsonHelper.objectToJson(entry.getValue())) .collect(Collectors.joining(" "))); } }
/** * Loops through all process variables and logs them. * * @param execution the execution information */ protected void logInputParameters(DelegateExecution execution) { LOGGER.info("{} Input parameters for {}: {}", activitiHelper.getProcessIdentifyingInformation(execution), this.getClass().getName(), execution.getVariables().entrySet().stream().map(entry -> entry.getKey() + "=" + jsonHelper.objectToJson(entry.getValue())) .collect(Collectors.joining(" "))); } }
/** * Modify a list of tags * * @param tagEntityList the tag entities to modify * @param modificationType the type of modification */ public void modifyTagsInSearchIndex(List<TagEntity> tagEntityList, String modificationType) { List<Integer> tagIds = new ArrayList<>(); tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId())); processMessage(jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, modificationType))); }
/** * Modify a list of tags * * @param tagEntityList the tag entities to modify * @param modificationType the type of modification */ public void modifyTagsInSearchIndex(List<TagEntity> tagEntityList, String modificationType) { List<Integer> tagIds = new ArrayList<>(); tagEntityList.forEach(tagEntity -> tagIds.add(tagEntity.getId())); processMessage(jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, modificationType))); }
/** * Modify a tag * * @param tagEntity the tag entity to modify * @param modificationType the type of modification */ public void modifyTagInSearchIndex(TagEntity tagEntity, String modificationType) { List<Integer> tagIds = new ArrayList<>(); tagIds.add(tagEntity.getId()); processMessage(jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, modificationType))); }
/** * Modify a list of business object definitions * * @param businessObjectDefinitionEntityList the business object definition entities to modify * @param modificationType the type of modification */ public void modifyBusinessObjectDefinitionsInSearchIndex(List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityList, String modificationType) { List<Integer> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionEntityList.forEach(businessObjectDefinitionEntity -> businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId())); processMessage( jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, modificationType))); }
@Override public String createEmrCluster(String clusterName, EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParams) { RunJobFlowRequest runJobFlowRequest = getRunJobFlowRequest(clusterName, emrClusterDefinition); LOGGER.info("runJobFlowRequest={}", jsonHelper.objectToJson(runJobFlowRequest)); String clusterId = emrOperations.runEmrJobFlow(getEmrClient(awsParams), runJobFlowRequest); LOGGER.info("EMR cluster started. emrClusterId=\"{}\"", clusterId); return clusterId; }
@Override public String createEmrCluster(String clusterName, EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParams) { RunJobFlowRequest runJobFlowRequest = getRunJobFlowRequest(clusterName, emrClusterDefinition); LOGGER.info("runJobFlowRequest={}", jsonHelper.objectToJson(runJobFlowRequest)); String clusterId = emrOperations.runEmrJobFlow(getEmrClient(awsParams), runJobFlowRequest); LOGGER.info("EMR cluster started. emrClusterId=\"{}\"", clusterId); return clusterId; }
/** * Modify a tag * * @param tagEntity the tag entity to modify * @param modificationType the type of modification */ public void modifyTagInSearchIndex(TagEntity tagEntity, String modificationType) { List<Integer> tagIds = new ArrayList<>(); tagIds.add(tagEntity.getId()); processMessage(jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_TAG_UPDATE, tagIds, modificationType))); }
/** * Modify a business object definition * * @param businessObjectDefinitionEntity the business object definition entity to modify * @param modificationType the type of modification */ public void modifyBusinessObjectDefinitionInSearchIndex(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String modificationType) { List<Integer> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId()); processMessage( jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, modificationType))); }
/** * Modify a business object definition * * @param businessObjectDefinitionEntity the business object definition entity to modify * @param modificationType the type of modification */ public void modifyBusinessObjectDefinitionInSearchIndex(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String modificationType) { List<Integer> businessObjectDefinitionIds = new ArrayList<>(); businessObjectDefinitionIds.add(businessObjectDefinitionEntity.getId()); processMessage( jsonHelper.objectToJson(new SearchIndexUpdateDto(MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, businessObjectDefinitionIds, modificationType))); }
@Test public void testObjectToJson() { assertEquals(String.format("\"%s\"", STRING_VALUE), jsonHelper.objectToJson(STRING_VALUE)); }
@Test public void testCreateClusterContentTypeNullOverrideNotNull() throws Exception { String clusterName = "testCluster" + Math.random(); String override = jsonHelper.objectToJson(new EmrClusterDefinition()); executeWithoutLogging(ActivitiRuntimeHelper.class, () -> { Map<String, Object> variables = createJob(clusterName, "false", null, override); assertEquals("taskStatus", "ERROR", variables.get("createClusterServiceTask_taskStatus")); }); }
@Test public void testCreateClusterContentTypeInvalid() throws Exception { String clusterName = "testCluster" + Math.random(); String override = jsonHelper.objectToJson(new EmrClusterDefinition()); executeWithoutLogging(ActivitiRuntimeHelper.class, () -> { Map<String, Object> variables = createJob(clusterName, "false", "invalid", override); assertEquals("taskStatus", "ERROR", variables.get("createClusterServiceTask_taskStatus")); }); }
@Test public void testCreateClusterOverrideJson() throws Exception { String clusterName = "testCluster" + Math.random(); String override = jsonHelper.objectToJson(new EmrClusterDefinition()); Map<String, Object> variables = createJob(clusterName, "false", "json", override); assertEquals("taskStatus", "SUCCESS", variables.get("createClusterServiceTask_taskStatus")); assertNotNull("emrClusterId", variables.get("createClusterServiceTask_emrClusterId")); assertNotNull("emrClusterStatus", variables.get("createClusterServiceTask_emrClusterStatus")); assertNotNull("emrClusterCreated", variables.get("createClusterServiceTask_emrClusterCreated")); assertNotNull("emrClusterDefinition", variables.get("createClusterServiceTask_emrClusterDefinition")); terminateCluster(TEST_ACTIVITI_NAMESPACE_CD, EMR_CLUSTER_DEFINITION_NAME, clusterName); }
@Test public void testUpdateStoragePolicyTransitionFailedAttemptsIgnoreExceptionImplNoBusinessObjectDataKey() { // Create a storage policy transition parameters DTO that does not have business object data key specified. StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto = new StoragePolicyTransitionParamsDto(); storagePolicyTransitionParamsDto.setStorageName(STORAGE_NAME); // Call the method under test. storagePolicyProcessorHelperServiceImpl.updateStoragePolicyTransitionFailedAttemptsIgnoreException(storagePolicyTransitionParamsDto); // Verify the external calls. verify(jsonHelper).objectToJson(storagePolicyTransitionParamsDto); verifyNoMoreInteractionsHelper(); }
@Test public void testS3MessageNoKey() throws Exception { S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity("key_does_not_exist", 0L, null, null), null); List<S3EventNotificationRecord> records = new ArrayList<>(); records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null)); S3EventNotification s3EventNotification = new S3EventNotification(records); setLogLevel(UploadDownloadServiceImpl.class, LogLevel.OFF); setLogLevel(HerdJmsMessageListener.class, LogLevel.OFF); herdJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null); }