TradeReferenceLine { public void parse( String referenceLine ) { String[] mainTokens = referenceLine.split("\\*"); String[] tokens = mainTokens[0].split(":"); strategy = tokens[0]; correlationId = tokens[1]; side = parseSide(tokens[2]); direction = parseDirection(tokens[3]); if(mainTokens.length > 1 ) { additionalInfo = mainTokens[1]; } }  static TradeReferenceLine create( String strategy, Direction direction, Side side ); static TradeReferenceLine createEntryLine( String strategy, Direction direction ); static TradeReferenceLine createExitLine( String strategy, Direction direction, String correlationId); static TradeReferenceLine createEntryLine( String strategy, Direction direction, String additionalInfo ); static TradeReferenceLine create( String strategy, Direction direction, Side side, String additionalInfo ); static TradeReferenceLine parseLine( String referenceLine ); void parse( String referenceLine ); String getStrategy(); TradeReferenceLine setStrategy(String strategy); String getCorrelationId(); TradeReferenceLine setCorrelationId(String correlationId); Direction getDirection(); TradeReferenceLine setDirection(Direction direction); Side getSide(); TradeReferenceLine setSide(Side side); String getAdditionalInfo(); void setAdditionalInfo(String additionalInfo); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final long serialVersionUID; }
@Test public void testParse() { String e = "EOD-Pair-Strategy:123:Exit:Long*MyAdditionalInfo"; TradeReferenceLine expected = new TradeReferenceLine(); expected.correlationId = "123"; expected.strategy = "EOD-Pair-Strategy"; expected.side = EXIT; expected.direction = LONG; expected.additionalInfo = "MyAdditionalInfo"; doReturn(LONG).when(testLine).parseDirection("Long"); doReturn(EXIT).when(testLine).parseSide("Exit"); testLine.parse(e); assertEquals(expected.toString(),testLine.toString()); }