use of com.netflix.conductor.common.validation.ValidationError in project conductor by Netflix.
the class AbstractHttpEndToEndTest method testUpdateWorkflowDefNameNull.
@Test(expected = ConductorClientException.class)
public void testUpdateWorkflowDefNameNull() {
WorkflowDef workflowDef = new WorkflowDef();
List<WorkflowDef> list = new ArrayList<>();
list.add(workflowDef);
try {
metadataClient.updateWorkflowDefs(list);
} catch (ConductorClientException e) {
assertEquals(3, e.getValidationErrors().size());
assertEquals(400, e.getStatus());
assertEquals("Validation failed, check below errors for detail.", e.getMessage());
assertFalse(e.isRetryable());
List<ValidationError> errors = e.getValidationErrors();
List<String> errorMessages = errors.stream().map(ValidationError::getMessage).collect(Collectors.toList());
assertTrue(errorMessages.contains("WorkflowDef name cannot be null or empty"));
assertTrue(errorMessages.contains("WorkflowTask list cannot be empty"));
assertTrue(errorMessages.contains("ownerEmail cannot be empty"));
throw e;
}
}
use of com.netflix.conductor.common.validation.ValidationError in project conductor by Netflix.
the class AbstractHttpEndToEndTest method testEmptyCreateWorkflowDef.
@Test(expected = ConductorClientException.class)
public void testEmptyCreateWorkflowDef() {
try {
WorkflowDef workflowDef = new WorkflowDef();
metadataClient.registerWorkflowDef(workflowDef);
} catch (ConductorClientException e) {
assertEquals(400, e.getStatus());
assertEquals("Validation failed, check below errors for detail.", e.getMessage());
assertFalse(e.isRetryable());
List<ValidationError> errors = e.getValidationErrors();
List<String> errorMessages = errors.stream().map(ValidationError::getMessage).collect(Collectors.toList());
assertTrue(errorMessages.contains("WorkflowDef name cannot be null or empty"));
assertTrue(errorMessages.contains("WorkflowTask list cannot be empty"));
throw e;
}
}
use of com.netflix.conductor.common.validation.ValidationError in project conductor by Netflix.
the class AbstractHttpEndToEndTest method testCreateInvalidWorkflowDef.
@Test(expected = ConductorClientException.class)
public void testCreateInvalidWorkflowDef() {
try {
WorkflowDef workflowDef = new WorkflowDef();
List<WorkflowDef> workflowDefList = new ArrayList<>();
workflowDefList.add(workflowDef);
metadataClient.registerWorkflowDef(workflowDef);
} catch (ConductorClientException e) {
assertEquals(3, e.getValidationErrors().size());
assertEquals(400, e.getStatus());
assertEquals("Validation failed, check below errors for detail.", e.getMessage());
assertFalse(e.isRetryable());
List<ValidationError> errors = e.getValidationErrors();
List<String> errorMessages = errors.stream().map(ValidationError::getMessage).collect(Collectors.toList());
assertTrue(errorMessages.contains("WorkflowDef name cannot be null or empty"));
assertTrue(errorMessages.contains("WorkflowTask list cannot be empty"));
assertTrue(errorMessages.contains("ownerEmail cannot be empty"));
throw e;
}
}
use of com.netflix.conductor.common.validation.ValidationError in project conductor by Netflix.
the class AbstractHttpEndToEndTest method testUpdateWorkflowDef.
@Test(expected = ConductorClientException.class)
public void testUpdateWorkflowDef() {
try {
WorkflowDef workflowDef = new WorkflowDef();
List<WorkflowDef> workflowDefList = new ArrayList<>();
workflowDefList.add(workflowDef);
metadataClient.updateWorkflowDefs(workflowDefList);
} catch (ConductorClientException e) {
assertEquals(400, e.getStatus());
assertEquals("Validation failed, check below errors for detail.", e.getMessage());
assertFalse(e.isRetryable());
List<ValidationError> errors = e.getValidationErrors();
List<String> errorMessages = errors.stream().map(ValidationError::getMessage).collect(Collectors.toList());
assertEquals(3, errors.size());
assertTrue(errorMessages.contains("WorkflowTask list cannot be empty"));
assertTrue(errorMessages.contains("WorkflowDef name cannot be null or empty"));
assertTrue(errorMessages.contains("ownerEmail cannot be empty"));
throw e;
}
}
use of com.netflix.conductor.common.validation.ValidationError in project conductor by Netflix.
the class ValidationExceptionMapper method constraintViolationExceptionToErrorResponse.
private static ErrorResponse constraintViolationExceptionToErrorResponse(ConstraintViolationException exception) {
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setStatus(Response.Status.BAD_REQUEST.getStatusCode());
errorResponse.setMessage("Validation failed, check below errors for detail.");
List<ValidationError> validationErrors = new ArrayList<>();
exception.getConstraintViolations().forEach(e -> validationErrors.add(new ValidationError(getViolationPath(e), e.getMessage(), getViolationInvalidValue(e.getInvalidValue()))));
errorResponse.setValidationErrors(validationErrors);
return errorResponse;
}
Aggregations