@Test public void testExecuteWithDupes() { List<String> htContents = new ArrayList<String>(); htContents.add("hi"); htContents.add("#hi"); htContents.add("HI"); htContents.add("HI"); htContents.add("There"); Collection<HashTag> results = sut.execute(htContents); assertEquals(2, results.size()); boolean hiFound = false; boolean thereFound = false; for (HashTag ht : results) { hiFound = hiFound || ht.getContent().equals("#hi"); thereFound = thereFound || ht.getContent().equals("#there"); } assertTrue(hiFound && thereFound); }
@Override public List<HashTag> execute(final List<String> inHashTags) { Set<String> hashTagContents = new HashSet<String>(); for (String htContent : inHashTags) { if (!htContent.startsWith("#")) { hashTagContents.add("#" + htContent.toLowerCase()); } else { hashTagContents.add(htContent.toLowerCase()); } } List<HashTag> results = new ArrayList<HashTag>(); for (String htContent : hashTagContents) { results.add(new HashTag(htContent)); } return results; }
HashTagBuilderMapper implements DomainMapper<List<String>, List<HashTag>> { @Override public List<HashTag> execute(final List<String> inHashTags) { Set<String> hashTagContents = new HashSet<String>(); for (String htContent : inHashTags) { if (!htContent.startsWith("#")) { hashTagContents.add("#" + htContent.toLowerCase()); } else { hashTagContents.add(htContent.toLowerCase()); } } List<HashTag> results = new ArrayList<HashTag>(); for (String htContent : hashTagContents) { results.add(new HashTag(htContent)); } return results; } }
HashTagBuilderMapper implements DomainMapper<List<String>, List<HashTag>> { @Override public List<HashTag> execute(final List<String> inHashTags) { Set<String> hashTagContents = new HashSet<String>(); for (String htContent : inHashTags) { if (!htContent.startsWith("#")) { hashTagContents.add("#" + htContent.toLowerCase()); } else { hashTagContents.add(htContent.toLowerCase()); } } List<HashTag> results = new ArrayList<HashTag>(); for (String htContent : hashTagContents) { results.add(new HashTag(htContent)); } return results; }  }
HashTagBuilderMapper implements DomainMapper<List<String>, List<HashTag>> { @Override public List<HashTag> execute(final List<String> inHashTags) { Set<String> hashTagContents = new HashSet<String>(); for (String htContent : inHashTags) { if (!htContent.startsWith("#")) { hashTagContents.add("#" + htContent.toLowerCase()); } else { hashTagContents.add(htContent.toLowerCase()); } } List<HashTag> results = new ArrayList<HashTag>(); for (String htContent : hashTagContents) { results.add(new HashTag(htContent)); } return results; }  @Override List<HashTag> execute(final List<String> inHashTags); }
HashTagBuilderMapper implements DomainMapper<List<String>, List<HashTag>> { @Override public List<HashTag> execute(final List<String> inHashTags) { Set<String> hashTagContents = new HashSet<String>(); for (String htContent : inHashTags) { if (!htContent.startsWith("#")) { hashTagContents.add("#" + htContent.toLowerCase()); } else { hashTagContents.add(htContent.toLowerCase()); } } List<HashTag> results = new ArrayList<HashTag>(); for (String htContent : hashTagContents) { results.add(new HashTag(htContent)); } return results; }  @Override List<HashTag> execute(final List<String> inHashTags);  }