Example usage for org.apache.commons.collections4 IterableUtils toString

List of usage examples for org.apache.commons.collections4 IterableUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.collections4 IterableUtils toString.

Prototype

public static <E> String toString(final Iterable<E> iterable,
        final Transformer<? super E, String> transformer) 

Source Link

Document

Returns a string representation of the elements of the specified iterable.

Usage

From source file:it.infn.ct.futuregateway.apiserver.v1.TaskServiceIT.java

/**
 * Tests the details retrieval.//from  w w w .  ja v a2  s .  co m
 */
@Test
public final void testTaskDetails() {
    Task newTask = TestData.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();
}