@Test public void loadFileException() { ErrorCallback<Object> testingCallbackSpy = spy(new ErrorCallback<Object>() { @Override public boolean error(Object message, Throwable throwable) { assertEquals("Error " + REJECT_OBJECT, message); assertEquals("Failed to load file "+ UNKNOWN_FILE, throwable.getMessage()); return false; } }); kogitoResourceContentService.loadFile(UNKNOWN_FILE, mock(RemoteCallback.class), testingCallbackSpy); verify(resourceContentServiceMock, times(1)).get(eq(UNKNOWN_FILE)); verify(testingCallbackSpy, times(1)).error(isA(String.class), isA(Throwable.class)); }
public void loadFile(final String fileUri, final RemoteCallback<String> callback, final ErrorCallback<Object> errorCallback) { resourceContentService.get(fileUri).then((IThenable.ThenOnFulfilledCallbackFn<String, Void>) fileContent -> { callback.callback(fileContent); return promises.resolve(); }) .catch_(error -> { errorCallback.error("Error " + error, new Throwable("Failed to load file " + fileUri)); return null; }) ; }
KogitoResourceContentService { public void loadFile(final String fileUri, final RemoteCallback<String> callback, final ErrorCallback<Object> errorCallback) { resourceContentService.get(fileUri).then((IThenable.ThenOnFulfilledCallbackFn<String, Void>) fileContent -> { callback.callback(fileContent); return promises.resolve(); }) .catch_(error -> { errorCallback.error("Error " + error, new Throwable("Failed to load file " + fileUri)); return null; }) ; } }
KogitoResourceContentService { public void loadFile(final String fileUri, final RemoteCallback<String> callback, final ErrorCallback<Object> errorCallback) { resourceContentService.get(fileUri).then((IThenable.ThenOnFulfilledCallbackFn<String, Void>) fileContent -> { callback.callback(fileContent); return promises.resolve(); }) .catch_(error -> { errorCallback.error("Error " + error, new Throwable("Failed to load file " + fileUri)); return null; }) ; } private  KogitoResourceContentService(); @Inject  KogitoResourceContentService(final ResourceContentService resourceContentService,
                                        final Promises promises); }
KogitoResourceContentService { public void loadFile(final String fileUri, final RemoteCallback<String> callback, final ErrorCallback<Object> errorCallback) { resourceContentService.get(fileUri).then((IThenable.ThenOnFulfilledCallbackFn<String, Void>) fileContent -> { callback.callback(fileContent); return promises.resolve(); }) .catch_(error -> { errorCallback.error("Error " + error, new Throwable("Failed to load file " + fileUri)); 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); }
KogitoResourceContentService { public void loadFile(final String fileUri, final RemoteCallback<String> callback, final ErrorCallback<Object> errorCallback) { resourceContentService.get(fileUri).then((IThenable.ThenOnFulfilledCallbackFn<String, Void>) fileContent -> { callback.callback(fileContent); return promises.resolve(); }) .catch_(error -> { errorCallback.error("Error " + error, new Throwable("Failed to load file " + fileUri)); 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);  }