### Question:
SoapSearchService extends AbstractService implements SearchService { @Override public WSDocument[] findByFilename(String sid, String filename) throws Exception { User user = validateSession(sid); DocumentDAO docDao = (DocumentDAO) Context.get().getBean(DocumentDAO.class); List<Document> docs = docDao.findByFileNameAndParentFolderId(null, filename, null, user.getTenantId(), null); WSDocument[] wsDocs = new WSDocument[docs.size()]; for (int i = 0; i < docs.size(); i++) { try { checkReadEnable(user, docs.get(i).getFolder().getId()); checkPublished(user, docs.get(i)); checkNotArchived(docs.get(i)); } catch (Exception e) { continue; } docDao.initialize(docs.get(i)); wsDocs[i] = WSUtil.toWSDocument(docs.get(i)); } return wsDocs; }  @Override WSSearchResult find(String sid, WSSearchOptions opt); @Override WSDocument[] findByFilename(String sid, String filename); @Override WSFolder[] findFolders(String sid, String name);  }### Answer:
@Test public void testFindByFilename() throws Exception { WSDocument[] documents = searchServiceImpl.findByFilename("", "pluto"); Assert.assertNotNull(documents); Assert.assertEquals(1, documents.length); List<WSDocument> docsList = Arrays.asList(documents); Assert.assertEquals(2, docsList.get(0).getId()); documents = searchServiceImpl.findByFilename("", "PLUTO"); Assert.assertNotNull(documents); Assert.assertEquals(1, documents.length); docsList = Arrays.asList(documents); Assert.assertEquals(2, docsList.get(0).getId()); documents = searchServiceImpl.findByFilename("", "paperino"); Assert.assertNotNull(documents); Assert.assertEquals(0, documents.length); Document doc = docDao.findById(1); Assert.assertNotNull(doc); Assert.assertEquals("pippo", doc.getFileName()); docDao.initialize(doc); doc.setFileName("paperina"); docDao.store(doc); Assert.assertEquals("paperina", doc.getFileName()); documents = searchServiceImpl.findByFilename("", "pluto"); Assert.assertNotNull(documents); Assert.assertEquals(1, documents.length); }