TeamTagMap { public TeamTagMap addTagToTeam(String tag, int team) throws DecodingException { return addTagToTeam(new TagId(tag), team); } TeamTagMap(); private  TeamTagMap(ImmutableMap<TagId,Integer> tagToTeam); TeamTagMap addTagToTeam(String tag, int team); TeamTagMap addTagToTeam(TagId tag, int team); TeamTagMap removeTag(String tag); TeamTagMap removeTag(TagId tag); Optional<Integer> tagToTeam(String tag); Optional<Integer> tagToTeam(TagId tag); Map<TagId, Integer> getTagToTeam();  }
@Test public void testAddTagToTeam() throws Exception { TeamTagMap ttm = new TeamTagMap(); TeamTagMap ttmAfter = ttm.addTagToTeam("ABCDEFF012", 0); assertThat(ttm.tagToTeam("ABCDEFF012"), equalTo(Optional.empty())); assertThat(ttmAfter.getTagToTeam(), hasEntry(new TagId("ABCDEFF012"), 0)); assertThat(ttmAfter.tagToTeam("ABCDEFF012"), equalTo(Optional.of(0))); }
@Test public void testWriteToJson() throws Exception { TeamTagMap ttm = new TeamTagMap(); ttm = ttm.addTagToTeam("abcd", 4); ttm = ttm.addTagToTeam("deff", 5); ttm = ttm.addTagToTeam("adcb", 4); String result = Serialization.getJsonMapper().writeValueAsString(ttm); assertThat(result, equalTo("{\"4\":[\"abcd\",\"adcb\"],\"5\":[\"deff\"]}")); }