### Question:
ClouderaManagerModificationService implements ClusterModificationService { @Override public void removeUnusedParcels(Set<ClusterComponent> usedParcelComponents) throws CloudbreakException { ParcelsResourceApi parcelsResourceApi = clouderaManagerApiFactory.getParcelsResourceApi(apiClient); ParcelResourceApi parcelResourceApi = clouderaManagerApiFactory.getParcelResourceApi(apiClient); Map<String, ClouderaManagerProduct> cmProducts = new HashMap<>(); for (ClusterComponent clusterComponent : usedParcelComponents) { ClouderaManagerProduct product = clusterComponent.getAttributes().getSilent(ClouderaManagerProduct.class); cmProducts.put(product.getName(), product); } clouderaManagerParcelService.deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, stack.getName(), cmProducts); clouderaManagerParcelService.undistributeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, cmProducts); clouderaManagerParcelService.removeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, cmProducts); } ClouderaManagerModificationService(Stack stack, HttpClientConfig clientConfig); @PostConstruct void initApiClient(); @Override List<String> upscaleCluster(HostGroup hostGroup, Collection<InstanceMetaData> instanceMetaDatas); @Override void cleanupCluster(Telemetry telemetry); @Override void upgradeClusterRuntime(Set<ClusterComponent> components, boolean patchUpgrade); void restartStaleServices(MgmtServiceResourceApi mgmtServiceResourceApi, ClustersResourceApi clustersResourceApi); @Override void stopCluster(boolean disableKnoxAutorestart); @Override int startCluster(Set<InstanceMetaData> hostsInCluster); @Override Map<String, String> getComponentsByCategory(String blueprintName, String hostGroupName); @Override String getStackRepositoryJson(StackRepoDetails repoDetails, String stackRepoId); @Override Map<String, String> gatherInstalledParcels(String stackName); @Override void removeUnusedParcels(Set<ClusterComponent> usedParcelComponents); @Override void restartAll();  }### Answer:
@Test public void removeUnusedParcels() throws CloudbreakException { ClouderaManagerProduct cmProduct1 = createClouderaManagerProduct("product1", "version1"); ClouderaManagerProduct cmProduct2 = createClouderaManagerProduct("product2", "version2"); Set<ClusterComponent> usedComponents = Set.of(createClusterComponent(cmProduct1), createClusterComponent(cmProduct2)); Map<String, ClouderaManagerProduct> productMap = Map.of(cmProduct1.getName(), cmProduct1, cmProduct2.getName(), cmProduct2); when(clouderaManagerApiFactory.getParcelsResourceApi(apiClientMock)).thenReturn(parcelsResourceApi); when(clouderaManagerApiFactory.getParcelResourceApi(apiClientMock)).thenReturn(parcelResourceApi); underTest.removeUnusedParcels(usedComponents); verify(clouderaManagerParcelService, times(1)).deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, stack.getName(), productMap); verify(clouderaManagerParcelService, times(1)).undistributeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, productMap); verify(clouderaManagerParcelService, times(1)).removeUnusedParcels(apiClientMock, parcelsResourceApi, parcelResourceApi, stack, productMap); }