@Test public void testExecuteNoResults() { PartialHashTagDbMapper sut = new PartialHashTagDbMapper(); sut.setEntityManager(getEntityManager()); List<String> hashTags = new ArrayList<String>(); hashTags.add("#heynow"); hashTags.add("#foobar"); PartialMapperResponse<List<String>, List<HashTag>> results = sut.execute(hashTags); assertEquals(0, results.getResponse().size()); assertEquals(2, results.getUnhandledRequest().size()); assertTrue(results.getUnhandledRequest().contains("#heynow")); assertTrue(results.getUnhandledRequest().contains("#foobar")); }
@Override public PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents) { Set<String> contents = new HashSet<String>(); for (String content : inHashTagContents) { String hashTag = content.toLowerCase(); if (!hashTag.startsWith("#")) { contents.add("#" + hashTag); } else { contents.add(hashTag); } } Criteria criteria = getHibernateSession().createCriteria(HashTag.class); criteria.add(Restrictions.in("this.content", contents)); List<HashTag> results = criteria.list(); List<String> hashtagsNotFound = new ArrayList<String>(); hashtagsNotFound.addAll(contents); for (HashTag ht : results) { String lowerCasedContent = ht.getContent().toLowerCase(); if (hashtagsNotFound.contains(lowerCasedContent)) { hashtagsNotFound.remove(lowerCasedContent); } } if (hashtagsNotFound.size() > 0) { return new PartialMapperResponse<List<String>, List<HashTag>>(results, hashtagsNotFound); } else { return new PartialMapperResponse<List<String>, List<HashTag>>(results); } }
PartialHashTagDbMapper extends
        ReadMapper<List<String>, PartialMapperResponse<List<String>, List<HashTag>>> { @Override public PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents) { Set<String> contents = new HashSet<String>(); for (String content : inHashTagContents) { String hashTag = content.toLowerCase(); if (!hashTag.startsWith("#")) { contents.add("#" + hashTag); } else { contents.add(hashTag); } } Criteria criteria = getHibernateSession().createCriteria(HashTag.class); criteria.add(Restrictions.in("this.content", contents)); List<HashTag> results = criteria.list(); List<String> hashtagsNotFound = new ArrayList<String>(); hashtagsNotFound.addAll(contents); for (HashTag ht : results) { String lowerCasedContent = ht.getContent().toLowerCase(); if (hashtagsNotFound.contains(lowerCasedContent)) { hashtagsNotFound.remove(lowerCasedContent); } } if (hashtagsNotFound.size() > 0) { return new PartialMapperResponse<List<String>, List<HashTag>>(results, hashtagsNotFound); } else { return new PartialMapperResponse<List<String>, List<HashTag>>(results); } } }
PartialHashTagDbMapper extends
        ReadMapper<List<String>, PartialMapperResponse<List<String>, List<HashTag>>> { @Override public PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents) { Set<String> contents = new HashSet<String>(); for (String content : inHashTagContents) { String hashTag = content.toLowerCase(); if (!hashTag.startsWith("#")) { contents.add("#" + hashTag); } else { contents.add(hashTag); } } Criteria criteria = getHibernateSession().createCriteria(HashTag.class); criteria.add(Restrictions.in("this.content", contents)); List<HashTag> results = criteria.list(); List<String> hashtagsNotFound = new ArrayList<String>(); hashtagsNotFound.addAll(contents); for (HashTag ht : results) { String lowerCasedContent = ht.getContent().toLowerCase(); if (hashtagsNotFound.contains(lowerCasedContent)) { hashtagsNotFound.remove(lowerCasedContent); } } if (hashtagsNotFound.size() > 0) { return new PartialMapperResponse<List<String>, List<HashTag>>(results, hashtagsNotFound); } else { return new PartialMapperResponse<List<String>, List<HashTag>>(results); } }  }
PartialHashTagDbMapper extends
        ReadMapper<List<String>, PartialMapperResponse<List<String>, List<HashTag>>> { @Override public PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents) { Set<String> contents = new HashSet<String>(); for (String content : inHashTagContents) { String hashTag = content.toLowerCase(); if (!hashTag.startsWith("#")) { contents.add("#" + hashTag); } else { contents.add(hashTag); } } Criteria criteria = getHibernateSession().createCriteria(HashTag.class); criteria.add(Restrictions.in("this.content", contents)); List<HashTag> results = criteria.list(); List<String> hashtagsNotFound = new ArrayList<String>(); hashtagsNotFound.addAll(contents); for (HashTag ht : results) { String lowerCasedContent = ht.getContent().toLowerCase(); if (hashtagsNotFound.contains(lowerCasedContent)) { hashtagsNotFound.remove(lowerCasedContent); } } if (hashtagsNotFound.size() > 0) { return new PartialMapperResponse<List<String>, List<HashTag>>(results, hashtagsNotFound); } else { return new PartialMapperResponse<List<String>, List<HashTag>>(results); } }  @Override PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents); }
PartialHashTagDbMapper extends
        ReadMapper<List<String>, PartialMapperResponse<List<String>, List<HashTag>>> { @Override public PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents) { Set<String> contents = new HashSet<String>(); for (String content : inHashTagContents) { String hashTag = content.toLowerCase(); if (!hashTag.startsWith("#")) { contents.add("#" + hashTag); } else { contents.add(hashTag); } } Criteria criteria = getHibernateSession().createCriteria(HashTag.class); criteria.add(Restrictions.in("this.content", contents)); List<HashTag> results = criteria.list(); List<String> hashtagsNotFound = new ArrayList<String>(); hashtagsNotFound.addAll(contents); for (HashTag ht : results) { String lowerCasedContent = ht.getContent().toLowerCase(); if (hashtagsNotFound.contains(lowerCasedContent)) { hashtagsNotFound.remove(lowerCasedContent); } } if (hashtagsNotFound.size() > 0) { return new PartialMapperResponse<List<String>, List<HashTag>>(results, hashtagsNotFound); } else { return new PartialMapperResponse<List<String>, List<HashTag>>(results); } }  @Override PartialMapperResponse<List<String>, List<HashTag>> execute(final List<String> inHashTagContents);  }