@Test
public void writesListOfAsynchronousProcessAsPlainText() throws Exception {

    List<AsynchronousProcess> processes = newArrayList(new AsynchronousProcess("andrew", 1L, "/a", "running"),
                                                       new AsynchronousProcess("user", 2L, "/b", "done"));
    List<List<String>> expectedProcessesTable = newArrayList(newArrayList("USER", "ID", "STAT", "PATH"),
                                                             newArrayList("andrew", "1", "running", "/a"),
                                                             newArrayList("user", "2", "done", "/b"));
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    processListWriter.writeTo(processes, List.class,
                              newParameterizedType(List.class, AsynchronousProcess.class),
                              new Annotation[0],
                              MediaType.TEXT_PLAIN_TYPE,
                              new MultivaluedHashMap<>(),
                              bout);
    List<String> lines = CharStreams.readLines(new StringReader(bout.toString()));
    assertEquals(3, lines.size());
    Pattern pattern = Pattern.compile("(\\w+)\\s+(\\w+)\\s+(\\w+)\\s+(/?\\w+)");
    List<List<String>> processesTable = newArrayList();
    for (String line : lines) {
        Matcher matcher = pattern.matcher(line);
        assertTrue(String.format("String '%s' is not matched to pattern", line), matcher.matches());
        processesTable.add(getAllGroups(matcher));
    }
    assertEquals(expectedProcessesTable, processesTable);
}