### Question:
ProcessConnectorDependencyDatastore extends CommonDatastore<ProcessConnectorDependencyItem, ConnectorImplementationDescriptor> implements
        DatastoreHasSearch<ProcessConnectorDependencyItem> { @Override @SuppressWarnings("unchecked") public ItemSearchResult<ProcessConnectorDependencyItem> search(final int page, final int resultsByPage, final String search, final String orders, final Map<String, String> filters) { try { final Long processId = MapUtil.getValueAsLong(filters, ATTRIBUTE_PROCESS_ID); final String connectorName = filters.get(ATTRIBUTE_CONNECTOR_NAME); final String connectorVersion = filters.get(ATTRIBUTE_CONNECTOR_VERSION); final ConnectorImplementationDescriptor connectorImplementation = getProcessAPI().getConnectorImplementation(processId, connectorName, connectorVersion); if (connectorImplementation == null) { return new ItemSearchResult<ProcessConnectorDependencyItem>(page, 0, 0, new ArrayList<ProcessConnectorDependencyItem>()); } final List<String> jarDependencies = connectorImplementation.getJarDependencies(); final List<String> dependencies = (List<String>) ListUtil.paginate(jarDependencies, page, resultsByPage); final List<ProcessConnectorDependencyItem> results = convertEngineToConsoleItems(processId, connectorName, connectorVersion, dependencies); return new ItemSearchResult<ProcessConnectorDependencyItem>(page, results.size(), jarDependencies.size(), results); } catch (final Exception e) { throw new APIException(e); } } ProcessConnectorDependencyDatastore(final APISession engineSession); @Override @SuppressWarnings("unchecked") ItemSearchResult<ProcessConnectorDependencyItem> search(final int page, final int resultsByPage, 
            final String search, final String orders, final Map<String, String> filters);  }### Answer:
@Test public void searchReturnAnEmptyResultIfNoConnectorImplementationIsFound() throws Exception { when(this.processAPI.getConnectorImplementation(anyLong(), anyString(), anyString())).thenReturn(null); final Map<String, String> filters = buildFilters(1L, "aConnectorName", "1"); final ItemSearchResult<ProcessConnectorDependencyItem> searchResult = this.datastore.search(0, 10, null, null, filters); assertTrue(searchResult.getResults().isEmpty()); assertEquals(0L, searchResult.getTotal()); }
@Test(expected = APIException.class) @SuppressWarnings("unchecked") public void searchThrowExceptionIfProcessIdIsUnknown() throws Exception { when(this.processAPI.getConnectorImplementation(anyLong(), anyString(), anyString())).thenThrow( new ConnectorNotFoundException(new NullPointerException())); final Map<String, String> filters = buildFilters(1L, "aConnectorName", "1"); this.datastore.search(0, 10, null, null, filters); }
@Test public void searchCanBePaginated() throws Exception { final ConnectorImplementationDescriptor connectorWith3Dependencies = new ConnectorImplementationDescriptor( "implementationClassName", "connectorId", "connectorVersion", "1", "definitionVersion", asList("dependency1", "dependency2", "dependency3")); when(this.processAPI.getConnectorImplementation(1L, "connectorId", "connectorVersion")).thenReturn(connectorWith3Dependencies); final Map<String, String> filters = buildFilters(1L, "connectorId", "connectorVersion"); final ItemSearchResult<ProcessConnectorDependencyItem> searchResult = this.datastore.search(0, 2, null, null, filters); assertEquals(2L, searchResult.getResults().size()); assertEquals(3L, searchResult.getTotal()); assertEquals(searchResult.getResults().get(0).getFilename(), "dependency1"); assertEquals(searchResult.getResults().get(1).getFilename(), "dependency2"); }