ServiceDependencyBuilder { public static java.util.Set<ServiceDefinition> getInitialServices(java.util.Collection<ServiceDefinition> sds) { java.util.Set<ServiceDefinition> ret= new java.util.HashSet<ServiceDefinition>(); for (ServiceDefinition sd : sds) { java.util.Set<ServiceDefinition> clients= getServiceClients(sd, sds); if (clients.size() == 0) { ret.add(sd); } } return (ret); } private  ServiceDependencyBuilder(); static java.util.Set<ServiceDefinition> getInitialServices(java.util.Collection<ServiceDefinition> sds); static java.util.Set<ServiceDefinition> getServiceClients(ServiceDefinition mainsd,
                        java.util.Collection<ServiceDefinition> sds); static ServiceGraph buildGraph(java.util.Set<ServiceDefinition> sds,
                        java.util.List<Situation> sits, String focusServiceType); static ServiceGraph buildGraph(java.util.Set<ServiceDefinition> sds,
                        java.util.List<Situation> sits); static InvocationMetric getMergedMetrics(java.util.List<InvocationDefinition> invocations);  }
@Test public void testInitialServices() { ServiceDefinition sd1=new ServiceDefinition(); sd1.setServiceType(SERVICE_TYPE1); InterfaceDefinition idef1=new InterfaceDefinition(); sd1.getInterfaces().add(idef1); idef1.setInterface(INTERFACE1); OperationDefinition op1=new OperationDefinition(); idef1.getOperations().add(op1); RequestResponseDefinition rrd1=new RequestResponseDefinition(); op1.setRequestResponse(rrd1); InvocationDefinition id1=new InvocationDefinition(); id1.setInterface(INTERFACE3); rrd1.getInvocations().add(id1); ServiceDefinition sd2=new ServiceDefinition(); sd2.setServiceType(SERVICE_TYPE2); InterfaceDefinition idef2=new InterfaceDefinition(); sd2.getInterfaces().add(idef2); idef2.setInterface(INTERFACE2); OperationDefinition op2=new OperationDefinition(); idef2.getOperations().add(op2); RequestResponseDefinition rrd2=new RequestResponseDefinition(); op2.setRequestResponse(rrd2); InvocationDefinition id2=new InvocationDefinition(); id2.setInterface(INTERFACE3); rrd2.getInvocations().add(id2); ServiceDefinition sd3=new ServiceDefinition(); sd3.setServiceType(SERVICE_TYPE3); InterfaceDefinition idef3=new InterfaceDefinition(); sd3.getInterfaces().add(idef3); idef3.setInterface(INTERFACE3); java.util.Set<ServiceDefinition> sds=new java.util.HashSet<ServiceDefinition>(); sds.add(sd1); sds.add(sd2); sds.add(sd3); java.util.Set<ServiceDefinition> results= ServiceDependencyBuilder.getInitialServices(sds); if (results == null) { fail("Results null"); } if (results.size() != 2) { fail("Should be 2 results: "+results.size()); } if (!results.contains(sd1)) { fail("SD1 not in results"); } if (!results.contains(sd2)) { fail("SD2 not in results"); } }