### Question:
ServiceComponentSupport { public Set<String> unsupportedServices(Cluster cluster, String stackName, String stackVersion) { return cluster.getServices().keySet().stream() .filter(serviceName -> !isServiceSupported(serviceName, stackName, stackVersion)) .collect(toSet()); } @Inject  ServiceComponentSupport(Provider<AmbariMetaInfo> metaInfo); Set<String> unsupportedServices(Cluster cluster, String stackName, String stackVersion); boolean isServiceSupported(String serviceName, String stackName, String stackVersion); Set<ServiceComponent> unsupportedComponents(Cluster cluster, String stackName, String stackVersion); Collection<String> allUnsupported(Cluster cluster, String stackName, String stackVersion);  }### Answer:
@Test public void testNoUnsupportedIfAllExistsInTargetStack() throws Exception { targetStackWith("SERVICE1", "SERVICE2"); Set<String> unsupported = unsupportedServices(clusterWith("SERVICE1", "SERVICE2")); assertThat(unsupported, hasSize(0)); verifyAll(); }
@Test public void testUnsupportedIfDoesntExistInTargetStack() throws Exception { targetStackWith("SERVICE1"); Set<String> unsupported = unsupportedServices(clusterWith("SERVICE1", "SERVICE2")); assertThat(unsupported, hasOnlyItems(is("SERVICE2"))); verifyAll(); }
@Test public void testUnsupportedIfDeletedFromTargetStack() throws Exception { targetStackWith("SERVICE1", "SERVICE2"); markAsDeleted("SERVICE2"); Set<String> unsupported = unsupportedServices(clusterWith("SERVICE1", "SERVICE2")); assertThat(unsupported, hasOnlyItems(is("SERVICE2"))); verifyAll(); }