@Test public void test_findAbstractionWithoutDecoupling() throws Exception { Assume.assumeTrue(cache.ensuresReferentialIntegrity()); String AWD = "motif awd\n" + "select client, service, service_impl\n" + "where \"client.getProperty('artifacttype')=='type'\" and \"service.getProperty('artifacttype')=='type'\" and \"service_impl.getProperty('artifacttype')=='type'\"\n" + "and \"!client.getProperty('abstract')\" and \"service.getProperty('abstract')\" and \"!service_impl.getProperty('abstract')\"\n" + "connected by inherits(service_impl>service) and service_invocation(client>service)[1,1] and implementation_dependency(client>service_impl)\n" + "where \"inherits.getProperty('type')=='extends' || inherits.getProperty('type')=='implements'\" and \"service_invocation.getProperty('type')=='uses'\" and \"implementation_dependency.getProperty('type')=='uses'\"\n" + "group by \"client\" and \"service\""; List<MotifInstance<Vertex, Edge>> results = Utilities.query(getBlueprintsAdapter(), AWD); System.out.println(" ################ RESULT: ############"); System.out.println(" SIZE: " + results.size()); for (MotifInstance<Vertex, Edge> motifInstance : results) { System.out.println(" * INSTANCE: " + motifInstance); Vertex client = motifInstance.getVertex("client"); System.out.println(" client : " + client); System.out.println(" service: " + motifInstance.getVertex("service")); System.out.println(" service_impl: " + motifInstance.getVertex("service_impl")); dumpPath(motifInstance, "inherits"); dumpPath(motifInstance, "service_invocation"); dumpPath(motifInstance, "implementation_dependency"); } assertEquals(1, results.size()); }
private void dumpPath(MotifInstance<Vertex, Edge> motifInstance, String pathName) { Path<Vertex, Edge> path = motifInstance.getPath(pathName); System.out.println(" path : '" + pathName + "': " + path); Vertex start = path.getStart(); Vertex end = path.getEnd(); System.out.println(" Start: " + start + " (" + start.getProperty("qname") + ")"); System.out.println(" End : " + end + " (" + end.getProperty("qname") + ")"); Collection<Vertex> vertices = path.getVertices(); if (vertices != null) { for (Vertex vertex : vertices) { System.out.println( " Vertex : " + vertex + " (" + vertex.getProperty("qname") + ")"); } } else { System.out.println(" No vertices"); } }