@Test
 public void testCreateWorkflowShouldReturnSavedWorkflow() {
   given()
       .pathParam("bucketId", bucket.getId())
       .queryParam("layout", layoutMetadata)
       .multiPart(IntegrationTestUtil.getWorkflowFile("workflow.xml"))
       .when()
       .post(WORKFLOWS_RESOURCE)
       .then()
       .assertThat()
       .statusCode(HttpStatus.SC_CREATED)
       .body("bucket_id", is(bucket.getId().intValue()))
       .body("id", is(2))
       .body("name", is("Valid Workflow"))
       .body("project_name", is("Project Name"))
       .body("revision_id", is(1))
       .body("generic_information", hasSize(2))
       .body("generic_information[0].key", is("genericInfo1"))
       .body("generic_information[0].value", is("genericInfo1Value"))
       .body("generic_information[1].key", is("genericInfo2"))
       .body("generic_information[1].value", is("genericInfo2Value"))
       .body("variables", hasSize(2))
       .body("variables[0].key", is("var1"))
       .body("variables[0].value", is("var1Value"))
       .body("variables[1].key", is("var2"))
       .body("variables[1].value", is("var2Value"))
       .body("layout", is(layoutMetadata));
 }
 @Before
 public void setup() throws IOException {
   bucket = bucketRepository.save(new Bucket("myBucket", "BucketControllerIntegrationTestUser"));
   workflow =
       workflowService.createWorkflow(
           bucket.getId(),
           Optional.of(layoutMetadata),
           IntegrationTestUtil.getWorkflowAsByteArray("workflow.xml"));
 }
 @Test
 public void testListWorkflowsShouldReturnSavedWorkflows() {
   given()
       .pathParam("bucketId", bucket.getId())
       .when()
       .get(WORKFLOWS_RESOURCE)
       .then()
       .assertThat()
       .statusCode(HttpStatus.SC_OK);
 }
 @Test
 public void testCreateWorkflowShouldReturnUnsupportedMediaTypeWithoutBody() {
   given()
       .pathParam("bucketId", bucket.getId())
       .when()
       .post(WORKFLOWS_RESOURCE)
       .then()
       .assertThat()
       .statusCode(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE);
 }
 @Test
 public void testDeleteNonExistingWorkflow() {
   given()
       .pathParam("bucketId", bucket.getId())
       .pathParam("workflowId", 42)
       .when()
       .delete(WORKFLOW_RESOURCE)
       .then()
       .assertThat()
       .statusCode(HttpStatus.SC_NOT_FOUND);
 }
  @Test
  public void testDeleteExistingWorkflow() {
    given()
        .pathParam("bucketId", bucket.getId())
        .pathParam("workflowId", workflow.id)
        .when()
        .delete(WORKFLOW_RESOURCE)
        .then()
        .assertThat()
        .statusCode(HttpStatus.SC_OK)
        .body("name", is(workflow.name));

    // check that the workflow is really gone
    given()
        .pathParam("bucketId", bucket.getId())
        .pathParam("workflowId", workflow.id)
        .when()
        .get(WORKFLOW_RESOURCE)
        .then()
        .assertThat()
        .statusCode(HttpStatus.SC_NOT_FOUND);
  }