FixMessage { public String toFixString() { final char tagSeparator = '\u0001'; return buildString(tagSeparator); } FixMessage(final Multimap<Integer, String> multimap); Collection<String> getValues(int tagId); String getFirstValue(int tagId); boolean hasValue(int tagId); void replace(int tagId, String value); String toFixString(); String toHumanString(); @Override String toString();  }
@Test public void shouldReturnFixMessage() throws Exception { final Multimap<Integer, String> multimap = ArrayListMultimap.create(); multimap.put(1, "firstKey"); multimap.put(2, "secondKey"); multimap.put(3, "thirdKey"); final FixMessage fixMessage = new FixMessage(multimap); final String expectedString = "1=firstKey" + SOH_CHAR + "2=secondKey" + SOH_CHAR + "3=thirdKey" + SOH_CHAR; Assert.assertThat(fixMessage.toFixString(), is(expectedString)); }
@Test public void shouldReturnFixMessageWithDuplicateKeys() throws Exception { final Multimap<Integer, String> multimap = ArrayListMultimap.create(); multimap.put(1, "firstKey"); multimap.put(2, "secondKey"); multimap.put(2, "anotherSecondKey"); multimap.put(3, "thirdKey"); final FixMessage fixMessage = new FixMessage(multimap); final String expectedString = "1=firstKey" + SOH_CHAR + "2=secondKey" + SOH_CHAR + "2=anotherSecondKey" + SOH_CHAR + "3=thirdKey" + SOH_CHAR; Assert.assertThat(fixMessage.toFixString(), is(expectedString)); }