### Question:
KogitoResourceContentService { public void getFilteredItems(final String pattern, final RemoteCallback<List<String>> callback, final ErrorCallback<Object> errorCallback) { resourceContentService.list(pattern).then(fileList -> { callback.callback(Arrays.asList(fileList)); return promises.resolve(); }) .catch_(error -> { errorCallback.error("Error " + error, new Throwable("Failed to retrieve files with pattern " + pattern)); return null; }); } private  KogitoResourceContentService(); @Inject  KogitoResourceContentService(final ResourceContentService resourceContentService,
                                        final Promises promises); void loadFile(final String fileUri,
                         final RemoteCallback<String> callback,
                         final ErrorCallback<Object> errorCallback); void getAllItems(final RemoteCallback<List<String>> callback,
                            final ErrorCallback<Object> errorCallback); void getFilteredItems(final String pattern,
                                 final RemoteCallback<List<String>> callback,
                                 final ErrorCallback<Object> errorCallback); Promise<String[]> getFilteredItems(final String pattern,
                                              final ResourceListOptions options); Promise<String> loadFile(final String fileUri);  }### Answer:
@Test public void getFilteredItemsNoException() { RemoteCallback<List<String>> testingCallbackSpy = spy(new RemoteCallback<List<String>>() { @Override public void callback(List<String> response) { assertEquals(dmnFiles.length, response.size()); response.forEach(fileName -> assertEquals("dmn", fileName.substring(fileName.lastIndexOf('.') + 1))); } }); kogitoResourceContentService.getFilteredItems(DMN_PATTERN, testingCallbackSpy, mock(ErrorCallback.class)); verify(resourceContentServiceMock, times(1)).list(eq(DMN_PATTERN)); verify(testingCallbackSpy, times(1)).callback(isA(List.class)); }
@Test public void getFilteredItemsException() { ErrorCallback<Object> testingCallbackSpy = spy(new ErrorCallback<Object>() { @Override public boolean error(Object message, Throwable throwable) { assertEquals("Error " + REJECT_OBJECT, message); assertEquals("Failed to retrieve files with pattern "+ NULL_PATTERN, throwable.getMessage()); return false; } }); kogitoResourceContentService.getFilteredItems(NULL_PATTERN, mock(RemoteCallback.class), testingCallbackSpy); verify(resourceContentServiceMock, times(1)).list(eq(NULL_PATTERN)); verify(testingCallbackSpy, times(1)).error(isA(String.class), isA(Throwable.class)); }