MetadataCategorySpecs { public static Specification<MetadataCategory> hasCategoryNameIn(final Collection<String> names) { return new Specification<MetadataCategory>() { @Override public Predicate toPredicate(Root<MetadataCategory> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return root.get(MetadataCategory_.name).in(names); } }; }  static Specification<MetadataCategory> hasCategoryNameIn(final Collection<String> names);  }
@Test public void testHasCategoryNameIn() throws Exception { final MetadataCategory category = categoryRepository.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc)); final MetadataCategory category2 = categoryRepository.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc)); final MetadataCategory category3 = categoryRepository.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc)); final Specification<MetadataCategory> specification = MetadataCategorySpecs.hasCategoryNameIn(Arrays.asList (category.getName(), category3.getName())); final List<String> all = Lists.transform(categoryRepository.findAll(specification), new Function<MetadataCategory, String>() { @Nullable @Override public String apply(@Nullable MetadataCategory input) { return input.getName(); } }); assertEquals(2, all.size()); assertTrue(all.contains(category.getName())); assertFalse(all.contains(category2.getName())); assertTrue(all.contains(category3.getName())); }