use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class DeploymentRestServiceInteractionTest method testRedeployThrowsNotValidException.
@Test
public void testRedeployThrowsNotValidException() {
String message = "not valid";
doThrow(new NotValidException(message)).when(mockDeploymentBuilder).deployWithResult();
String expected = "Cannot redeploy deployment '" + MockProvider.EXAMPLE_DEPLOYMENT_ID + "': " + message;
given().pathParam("id", MockProvider.EXAMPLE_DEPLOYMENT_ID).contentType(POST_JSON_CONTENT_TYPE).expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", is(InvalidRequestException.class.getSimpleName())).body("message", is(expected)).when().post(REDEPLOY_DEPLOYMENT_URL);
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class CaseInstanceRestServiceInteractionTest method testUnsuccessfulComplete.
@Test
public void testUnsuccessfulComplete() {
doThrow(new NotValidException("expected exception")).when(caseExecutionCommandBuilderMock).complete();
given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", containsString("Cannot complete case instance " + MockProvider.EXAMPLE_CASE_INSTANCE_ID + ": expected exception")).when().post(CASE_INSTANCE_COMPLETE_URL);
verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID);
verify(caseExecutionCommandBuilderMock).complete();
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class CaseInstanceRestServiceInteractionTest method testUnsuccessfulTerminate.
@Test
public void testUnsuccessfulTerminate() {
doThrow(new NotValidException("expected exception")).when(caseExecutionCommandBuilderMock).terminate();
given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", containsString("Cannot terminate case instance " + MockProvider.EXAMPLE_CASE_INSTANCE_ID + ": expected exception")).when().post(CASE_INSTANCE_TERMINATE_URL);
verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID);
verify(caseExecutionCommandBuilderMock).terminate();
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class CaseExecutionRestServiceInteractionTest method testUnsuccessfulDisable.
@Test
public void testUnsuccessfulDisable() {
doThrow(new NotValidException("expected exception")).when(caseExecutionCommandBuilderMock).disable();
given().pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID).contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", containsString("Cannot disable case execution " + MockProvider.EXAMPLE_CASE_EXECUTION_ID + ": expected exception")).when().post(CASE_EXECUTION_DISABLE_URL);
verify(caseServiceMock).withCaseExecution(MockProvider.EXAMPLE_CASE_EXECUTION_ID);
verify(caseExecutionCommandBuilderMock).disable();
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class DeployCmd method addResources.
protected void addResources(List<ResourceEntity> resources, DeploymentBuilderImpl deploymentBuilder) {
DeploymentEntity deployment = deploymentBuilder.getDeployment();
Map<String, ResourceEntity> existingResources = deployment.getResources();
for (ResourceEntity resource : resources) {
String resourceName = resource.getName();
if (existingResources != null && existingResources.containsKey(resourceName)) {
String message = String.format("Cannot add resource with id '%s' and name '%s' from " + "deployment with id '%s' to new deployment because the new deployment contains " + "already a resource with same name.", resource.getId(), resourceName, resource.getDeploymentId());
throw new NotValidException(message);
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(resource.getBytes());
deploymentBuilder.addInputStream(resourceName, inputStream);
}
}
Aggregations