@Test
public void testInputFlow() throws IOException {
final Pipe pipeFromDisco = Pipe.open();
final DiscoWorker discoWorker = new DiscoWorker(pipeFromDisco.source(), new NullByteChannel());
final SinkChannel disco = pipeFromDisco.sink();
// Put messages in the input pipeline (from the disco master)
final String okStr = "OK 4 \"ok\"\n";
disco.write(ByteBuffer.wrap(okStr.getBytes()));
final String taskStr = "TASK 327 {\"taskid\":0,\"master\":\"http://lhoersten-66113:8989\",\"disco_port\":8989,\"put_port\":8990,\"ddfs_data\":\"/srv/disco/ddfs\",\"disco_data\":\"/srv/disco/data\",\"mode\":\"map\",\"jobfile\":\"/srv/disco/data/localhost/5a/lhoersten-FunshineSimulator@524:7310e:1cb44/jobfile\",\"jobname\":\"lhoersten-FunshineSimulator@524:7310e:1cb44\",\"host\":\"localhost\"}\n";
disco.write(ByteBuffer.wrap(taskStr.getBytes()));
final String inputStr = "INPUT 110 [\"done\",[[0,\"ok\",[[0,\"raw://eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVD\"]]]]]\n";
disco.write(ByteBuffer.wrap(inputStr.getBytes()));
discoWorker.requestTask();
final ReadableByteChannel mapInput = discoWorker.getMapInput();
final String input = DiscoUtils.channelLineToString(mapInput);
assertEquals("eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVD", input);
}