SizePipe extends FixedForwardPipe { @Override public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException { try { int size = -1; Object input = message.asObject(); if (input instanceof String) { size = ((String)input).length(); } else if (input instanceof byte[]) { size = ((byte[])input).length; } return new PipeRunResult(getForward(), "" + size); } catch(Exception e) { throw new PipeRunException(this, "Error while transforming input", e); } }  @Override PipeRunResult doPipe(Message message, IPipeLineSession session);  }
@Test public void testDoPipeSuccess() throws Exception { PipeRunResult res = doPipe(pipe, "abcsd", session); assertEquals( "5", res.getResult().asString()); }
@Test public void testDoPipeFail() throws Exception { ArrayList<String> arr = new ArrayList<>(); PipeRunResult res = doPipe(pipe, arr, session); assertEquals("-1", res.getResult().asString()); }