InMemoryPreparationRepository extends ObjectPreparationRepository { @Override public void add(Identifiable object) { store.put(object.id(), object); }  @Override void add(Identifiable object); @Override @SuppressWarnings("unchecked") Stream<T> source(Class<T> clazz); @Override @SuppressWarnings("unchecked") T get(String id, Class<T> clazz); @Override void clear(); @Override void remove(Identifiable object);  }
@Test public void getByDataSetTest() { repository.add(getStep("s1")); repository.add(getStep("s2")); repository.add(getStep("s3")); repository.add(getStep("s4")); repository.add(getStep("s5")); repository.add(getPreparation("p1")); repository.add(getPreparation("p2")); repository.add(getPreparation("p3")); repository.add(getPreparation("p4")); repository.add(getPreparation("p5")); String dataSetId = "wantedId"; Collection<Preparation> expected = Arrays.asList(getPreparation(dataSetId, "10"), getPreparation(dataSetId, "11"), getPreparation(dataSetId, "12")); for (Preparation preparation : expected) { repository.add(preparation); } Collection<Preparation> actual = getRepository().list(Preparation.class, eq("dataSetId", dataSetId)).collect(Collectors.toList()); Assert.assertEquals(3, actual.size()); for (Preparation preparation : expected) { Assert.assertTrue(actual.contains(preparation)); } }