@Test
  public void testGetWorkflowShouldReturnLatestSavedWorkflowRevision() throws IOException {
    WorkflowMetadata secondWorkflowRevision =
        workflowRevisionService.createWorkflowRevision(
            workflow.bucketId,
            Optional.of(workflow.id),
            IntegrationTestUtil.getWorkflowAsByteArray("workflow.xml"),
            Optional.empty());

    given()
        .pathParam("bucketId", workflow.bucketId)
        .pathParam("workflowId", workflow.id)
        .when()
        .get(WORKFLOW_RESOURCE)
        .then()
        .assertThat()
        .statusCode(HttpStatus.SC_OK)
        .body("bucket_id", is(secondWorkflowRevision.bucketId.intValue()))
        .body("id", is(secondWorkflowRevision.id.intValue()))
        .body("name", is(secondWorkflowRevision.name))
        .body("project_name", is(secondWorkflowRevision.projectName))
        .body("revision_id", is(secondWorkflowRevision.revisionId.intValue()))
        .body("generic_information", hasSize(secondWorkflowRevision.genericInformation.size()))
        .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(secondWorkflowRevision.variables.size()))
        .body("variables[0].key", is("var1"))
        .body("variables[0].value", is("var1Value"))
        .body("variables[1].key", is("var2"))
        .body("variables[1].value", is("var2Value"));
  }
 @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 testCreateWorkflowShouldReturnNotFoundIfNonExistingBucketId() {
   given()
       .pathParam("bucketId", 42)
       .multiPart(IntegrationTestUtil.getWorkflowFile("workflow.xml"))
       .when()
       .post(WORKFLOWS_RESOURCE)
       .then()
       .assertThat()
       .statusCode(HttpStatus.SC_NOT_FOUND);
 }