/** Test task delete. */ @Test public final void testTaskDelete() { Response rs; rs = target("/v1.0/tasks/" + UUID.randomUUID()).request().delete(); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rs.getStatus()); Task testTask = TestDataIT.createTask(); testTask.setApplicationId(apps.get((int) (Math.random() * apps.size()))); rs = target("/v1.0/tasks") .request(Constants.INDIGOMIMETYPE) .post(Entity.entity(testTask, Constants.INDIGOMIMETYPE)); String id = rs.readEntity(Task.class).getId(); rs = target("/v1.0/tasks/" + id).request().delete(); Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), rs.getStatus()); rs = target("/v1.0/tasks/" + id).request().delete(); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rs.getStatus()); }
/** Tests the details retrieval. */ @Test public final void testTaskDetails() { Task newTask = TestDataIT.createTask(); newTask.setApplicationId(apps.get((int) (Math.random() * apps.size()))); Response rs; rs = target("/v1.0/tasks") .request(Constants.INDIGOMIMETYPE) .post(Entity.entity(newTask, Constants.INDIGOMIMETYPE)); rs = target("/v1.0/tasks/" + rs.readEntity(Application.class).getId()) .request(Constants.INDIGOMIMETYPE) .get(); Assert.assertEquals(Response.Status.OK.getStatusCode(), rs.getStatus()); Task task = rs.readEntity(Task.class); Assert.assertNotNull(task); Assert.assertNotNull(task.getId()); Assert.assertNotNull(task.getDateCreated()); Assert.assertNotNull(task.getLastChange()); Assert.assertEquals(newTask.getDescription(), task.getDescription()); Assert.assertEquals(newTask.getApplicationId(), task.getApplicationId()); Transformer<TaskFile, String> transformer = new Transformer<TaskFile, String>() { @Override public String transform(final TaskFile file) { return file.getName(); } }; if (newTask.getInputFiles() != null) { Assert.assertNotNull(task.getInputFiles()); Assert.assertEquals( IterableUtils.toString(newTask.getInputFiles(), transformer), IterableUtils.toString(task.getInputFiles(), transformer)); } if (newTask.getOutputFiles() != null) { Assert.assertNotNull(task.getOutputFiles()); Assert.assertEquals( IterableUtils.toString(newTask.getOutputFiles(), transformer), IterableUtils.toString(task.getOutputFiles(), transformer)); } target("/v1.0/tasks/" + task.getId()).request().delete(); }