@Test public void generateArchitectureTest() { Resource r1 = new Resource("type1"); r1.setAttribute("A1", 5); r1.setAttribute("A2", 1); Resource r2 = new Resource("type2"); r2.setAttribute("A1", 0); ResourceTypes<Resource> types = new ResourceTypes<Resource>(); types.put("r1", r1); types.put("r2", r2); Link l1 = new Link("linkType1"); l1.setAttribute("B1", 2); LinkTypes<Link> linkTypes = new LinkTypes<Link>(); linkTypes.put("l1", l1); SpecificationTransformerTypeBased<SpecificationTypeBased, Specification> transformer = new SpecificationTransformerTypeBased<SpecificationTypeBased, Specification>(); Architecture<Resource, Link> arch = transformer.generateArchitecture(types, linkTypes); Assert.assertNotNull(arch); Assert.assertEquals(arch.getVertexCount(), 3); Assert.assertNotNull(arch.getVertex("r_type1")); Assert.assertNotNull(arch.getVertex("r_type2")); Assert.assertNotNull(arch.getVertex("bus")); Assert.assertNotNull(arch.getEdge("l_type1")); Assert.assertNotNull(arch.getEdge("l_type2")); Assert.assertEquals(arch.getVertex("r_type1").getAttribute("A1"), 5); Assert.assertEquals(arch.getVertex("r_type1").getAttribute("A2"), 1); Assert.assertEquals(arch.getVertex("r_type1").getType(), "type1"); Assert.assertEquals(arch.getEdge("l_type1").getAttribute("B1"), 2); Assert.assertNotEquals(arch.getVertex("r_type1"), types.get("type1")); }
protected Architecture<Resource, Link> generateArchitecture(ResourceTypes<Resource> resourceTypes, LinkTypes<?> linkTypes) { Architecture<Resource, Link> architecture = new Architecture<Resource, Link>(); Link linkType = linkTypes.values().iterator().next(); Resource bus = new Resource("bus"); for (Resource type : resourceTypes.values()) { Resource instance = new Resource("r" + CONNECTOR + type.getId()); Attributes attributes = type.getAttributes(); for (String key : attributes.keySet()) { instance.setAttribute(key, attributes.getAttribute(key)); } instance.setType(type.getId()); Link link = new Link("l" + CONNECTOR + type.getId()); Attributes linkAttributes = linkType.getAttributes(); for (String key : linkAttributes.keySet()) { link.setAttribute(key, linkAttributes.getAttribute(key)); } architecture.addVertex(instance); architecture.addEdge(link, instance, bus); } return architecture; }
SpecificationTransformerTypeBased implements Transformer<T, S> { protected Architecture<Resource, Link> generateArchitecture(ResourceTypes<Resource> resourceTypes, LinkTypes<?> linkTypes) { Architecture<Resource, Link> architecture = new Architecture<Resource, Link>(); Link linkType = linkTypes.values().iterator().next(); Resource bus = new Resource("bus"); for (Resource type : resourceTypes.values()) { Resource instance = new Resource("r" + CONNECTOR + type.getId()); Attributes attributes = type.getAttributes(); for (String key : attributes.keySet()) { instance.setAttribute(key, attributes.getAttribute(key)); } instance.setType(type.getId()); Link link = new Link("l" + CONNECTOR + type.getId()); Attributes linkAttributes = linkType.getAttributes(); for (String key : linkAttributes.keySet()) { link.setAttribute(key, linkAttributes.getAttribute(key)); } architecture.addVertex(instance); architecture.addEdge(link, instance, bus); } return architecture; } }
SpecificationTransformerTypeBased implements Transformer<T, S> { protected Architecture<Resource, Link> generateArchitecture(ResourceTypes<Resource> resourceTypes, LinkTypes<?> linkTypes) { Architecture<Resource, Link> architecture = new Architecture<Resource, Link>(); Link linkType = linkTypes.values().iterator().next(); Resource bus = new Resource("bus"); for (Resource type : resourceTypes.values()) { Resource instance = new Resource("r" + CONNECTOR + type.getId()); Attributes attributes = type.getAttributes(); for (String key : attributes.keySet()) { instance.setAttribute(key, attributes.getAttribute(key)); } instance.setType(type.getId()); Link link = new Link("l" + CONNECTOR + type.getId()); Attributes linkAttributes = linkType.getAttributes(); for (String key : linkAttributes.keySet()) { link.setAttribute(key, linkAttributes.getAttribute(key)); } architecture.addVertex(instance); architecture.addEdge(link, instance, bus); } return architecture; }  }
SpecificationTransformerTypeBased implements Transformer<T, S> { protected Architecture<Resource, Link> generateArchitecture(ResourceTypes<Resource> resourceTypes, LinkTypes<?> linkTypes) { Architecture<Resource, Link> architecture = new Architecture<Resource, Link>(); Link linkType = linkTypes.values().iterator().next(); Resource bus = new Resource("bus"); for (Resource type : resourceTypes.values()) { Resource instance = new Resource("r" + CONNECTOR + type.getId()); Attributes attributes = type.getAttributes(); for (String key : attributes.keySet()) { instance.setAttribute(key, attributes.getAttribute(key)); } instance.setType(type.getId()); Link link = new Link("l" + CONNECTOR + type.getId()); Attributes linkAttributes = linkType.getAttributes(); for (String key : linkAttributes.keySet()) { link.setAttribute(key, linkAttributes.getAttribute(key)); } architecture.addVertex(instance); architecture.addEdge(link, instance, bus); } return architecture; }  @Override S transform(T typeBasedSpec); }
SpecificationTransformerTypeBased implements Transformer<T, S> { protected Architecture<Resource, Link> generateArchitecture(ResourceTypes<Resource> resourceTypes, LinkTypes<?> linkTypes) { Architecture<Resource, Link> architecture = new Architecture<Resource, Link>(); Link linkType = linkTypes.values().iterator().next(); Resource bus = new Resource("bus"); for (Resource type : resourceTypes.values()) { Resource instance = new Resource("r" + CONNECTOR + type.getId()); Attributes attributes = type.getAttributes(); for (String key : attributes.keySet()) { instance.setAttribute(key, attributes.getAttribute(key)); } instance.setType(type.getId()); Link link = new Link("l" + CONNECTOR + type.getId()); Attributes linkAttributes = linkType.getAttributes(); for (String key : linkAttributes.keySet()) { link.setAttribute(key, linkAttributes.getAttribute(key)); } architecture.addVertex(instance); architecture.addEdge(link, instance, bus); } return architecture; }  @Override S transform(T typeBasedSpec);  }