@Test public void testUpdateComponent() { component.setName(COMPONENT_NAME); component.setCategories(Collections.singleton("Antenna")); SW360Component updatedComponent = new SW360Component(); updatedComponent.setName(COMPONENT_NAME + "_updated"); when(componentClient.patchComponent(component)) .thenReturn(CompletableFuture.completedFuture(updatedComponent)); SW360Component result = block(componentClientAdapter.updateComponent(component)); assertThat(result).isEqualTo(updatedComponent); }
@Override public CompletableFuture<SW360Component> updateComponent(SW360Component component) { return FutureUtils.wrapInFuture(() -> SW360ComponentAdapterUtils.validateComponent(component), "Cannot update invalid component for " + component.getName()) .thenCompose(getComponentClient()::patchComponent); }
SW360ComponentClientAdapterAsyncImpl implements SW360ComponentClientAdapterAsync { @Override public CompletableFuture<SW360Component> updateComponent(SW360Component component) { return FutureUtils.wrapInFuture(() -> SW360ComponentAdapterUtils.validateComponent(component), "Cannot update invalid component for " + component.getName()) .thenCompose(getComponentClient()::patchComponent); } }
SW360ComponentClientAdapterAsyncImpl implements SW360ComponentClientAdapterAsync { @Override public CompletableFuture<SW360Component> updateComponent(SW360Component component) { return FutureUtils.wrapInFuture(() -> SW360ComponentAdapterUtils.validateComponent(component), "Cannot update invalid component for " + component.getName()) .thenCompose(getComponentClient()::patchComponent); } SW360ComponentClientAdapterAsyncImpl(SW360ComponentClient client); }
SW360ComponentClientAdapterAsyncImpl implements SW360ComponentClientAdapterAsync { @Override public CompletableFuture<SW360Component> updateComponent(SW360Component component) { return FutureUtils.wrapInFuture(() -> SW360ComponentAdapterUtils.validateComponent(component), "Cannot update invalid component for " + component.getName()) .thenCompose(getComponentClient()::patchComponent); } SW360ComponentClientAdapterAsyncImpl(SW360ComponentClient client); @Override SW360ComponentClient getComponentClient(); @Override CompletableFuture<SW360Component> createComponent(SW360Component component); @Override CompletableFuture<Optional<SW360Component>> getComponentById(String componentId); @Override CompletableFuture<Optional<SW360Component>> getComponentByName(String componentName); @Override CompletableFuture<List<SW360SparseComponent>> search(ComponentSearchParams searchParams); @Override CompletableFuture<PagingResult<SW360SparseComponent>> searchWithPaging(ComponentSearchParams searchParams); @Override CompletableFuture<SW360Component> updateComponent(SW360Component component); @Override CompletableFuture<MultiStatusResponse> deleteComponents(Collection<String> idsToDelete); @Override CompletableFuture<Void> deleteComponent(String componentId); }
SW360ComponentClientAdapterAsyncImpl implements SW360ComponentClientAdapterAsync { @Override public CompletableFuture<SW360Component> updateComponent(SW360Component component) { return FutureUtils.wrapInFuture(() -> SW360ComponentAdapterUtils.validateComponent(component), "Cannot update invalid component for " + component.getName()) .thenCompose(getComponentClient()::patchComponent); } SW360ComponentClientAdapterAsyncImpl(SW360ComponentClient client); @Override SW360ComponentClient getComponentClient(); @Override CompletableFuture<SW360Component> createComponent(SW360Component component); @Override CompletableFuture<Optional<SW360Component>> getComponentById(String componentId); @Override CompletableFuture<Optional<SW360Component>> getComponentByName(String componentName); @Override CompletableFuture<List<SW360SparseComponent>> search(ComponentSearchParams searchParams); @Override CompletableFuture<PagingResult<SW360SparseComponent>> searchWithPaging(ComponentSearchParams searchParams); @Override CompletableFuture<SW360Component> updateComponent(SW360Component component); @Override CompletableFuture<MultiStatusResponse> deleteComponents(Collection<String> idsToDelete); @Override CompletableFuture<Void> deleteComponent(String componentId);  }