### Question:
WorkItemDefinitionVFSLookupService implements WorkItemDefinitionService<Metadata> { @Override public Collection<WorkItemDefinition> execute(final Metadata metadata) { return search(metadata); } protected  WorkItemDefinitionVFSLookupService(); @Inject  WorkItemDefinitionVFSLookupService(final VFSService vfsService,
                                              final WorkItemDefinitionResources resources); @Override Collection<WorkItemDefinition> execute(final Metadata metadata); Collection<WorkItemDefinition> search(final Metadata metadata); Collection<WorkItemDefinition> search(final Metadata metadata,
                                                 final Path root); Collection<WorkItemDefinition> get(final Metadata metadata,
                                              final Path resource);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testFilter() { Collection<WorkItemDefinition> result = tested.execute(metadata); ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class); verify(vfsService, times(1)) .newDirectoryStream(eq(path), filterCaptor.capture()); DirectoryStream.Filter<Path> filter = filterCaptor.getValue(); Path path1 = mock(Path.class); when(path1.getFileName()).thenReturn("someFile.wid"); assertTrue(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.bpmn"); assertFalse(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.WID"); assertTrue(filter.accept(path1)); when(path1.getFileName()).thenReturn("someFile.WiD"); assertTrue(filter.accept(path1)); }
@Test @SuppressWarnings("unchecked") public void testExecute() { Collection<WorkItemDefinition> result = tested.execute(metadata); ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class); verify(vfsService, times(1)) .newDirectoryStream(eq(path), any(DirectoryStream.Filter.class)); assertFalse(result.isEmpty()); assertEquals(1, result.size()); WorkItemDefinition wid = result.iterator().next(); assertEquals("Email", wid.getName()); }