public List<Document> findByType(Type documentType) { List<Document> result = new ArrayList<Document>(); for (Document doc : listAll()) { if (doc.getType().getName().equals(documentType.getName())) result.add(doc); } return result; }
@Test public void testWithGroovyAll() { engine = context.getBean(SearchEngine.class); webType = context.getBean("webType", Type.class); List<Document> documents = engine.findByType(webType); assertNotNull(documents); assertTrue(documents.size() == 1); assertEquals(webType.getName(), documents.get(0).getType().getName()); assertEquals(webType.getDesc(), documents.get(0).getType().getDesc()); assertEquals(webType.getExtension(), documents.get(0).getType().getExtension()); engine = context.getBean(SearchEngine.class); documents = engine.listAll(); assertNotNull(documents); assertTrue(documents.size() == 4); }