@Test public void onlyLatestGetAssetCountCallbackIsInvocable() throws Exception { final boolean[] observed = { false, false }; assetQueryService.getNumberOfAssets(query).call(ignore -> { throw new AssertionError("First callback should not be invoked."); }, (msg, error) -> { throw new AssertionError("First error callback should not be invoked."); }); assetQueryService.getNumberOfAssets(query).call(ignore -> observed[0] = true, (msg, error) -> observed[1] = true); RemoteCallback<?> firstCallback = remoteCallbacks.get(0); ErrorCallback<Message> firstErrorCallback = errorCallbacks.get(0); RemoteCallback<?> secondCallback = remoteCallbacks.get(1); ErrorCallback<Message> secondErrorCallback = errorCallbacks.get(1); firstCallback.callback(null); firstErrorCallback.error(null, null); secondCallback.callback(null); assertTrue("Latest callback not invoked.", observed[0]); secondErrorCallback.error(null, null); assertTrue("Latest error callback not invoked.", observed[1]); }
public Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query) { return new Invoker<>(libraryService -> libraryService.getNumberOfAssets(query), () -> tokenForGetNumberOfAssets, newToken -> tokenForGetNumberOfAssets = newToken); }
AssetQueryService { public Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query) { return new Invoker<>(libraryService -> libraryService.getNumberOfAssets(query), () -> tokenForGetNumberOfAssets, newToken -> tokenForGetNumberOfAssets = newToken); } }
AssetQueryService { public Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query) { return new Invoker<>(libraryService -> libraryService.getNumberOfAssets(query), () -> tokenForGetNumberOfAssets, newToken -> tokenForGetNumberOfAssets = newToken); } @Inject  AssetQueryService(final Caller<LibraryService> libraryServiceCaller); }
AssetQueryService { public Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query) { return new Invoker<>(libraryService -> libraryService.getNumberOfAssets(query), () -> tokenForGetNumberOfAssets, newToken -> tokenForGetNumberOfAssets = newToken); } @Inject  AssetQueryService(final Caller<LibraryService> libraryServiceCaller); Invoker<AssetQueryResult> getAssets(ProjectAssetsQuery query); Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query); }
AssetQueryService { public Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query) { return new Invoker<>(libraryService -> libraryService.getNumberOfAssets(query), () -> tokenForGetNumberOfAssets, newToken -> tokenForGetNumberOfAssets = newToken); } @Inject  AssetQueryService(final Caller<LibraryService> libraryServiceCaller); Invoker<AssetQueryResult> getAssets(ProjectAssetsQuery query); Invoker<Integer> getNumberOfAssets(ProjectAssetsQuery query);  }