SpecificationTransformerTypeBased implements Transformer<T, S> { @Override public S transform(T typeBasedSpec) { Architecture<Resource, Link> architecture = generateArchitecture(typeBasedSpec.getResourceTypes(), typeBasedSpec.getLinkTypes()); Mappings<Task, Resource> archMappings = generateMappings(typeBasedSpec.getMappings(), architecture); return (S) new Specification(typeBasedSpec.getApplication(), architecture, archMappings); }  @Override S transform(T typeBasedSpec);  }
@Test public void transformTest() { Resource r1 = new Resource("type1"); Resource r2 = new Resource("type2"); ResourceTypes<Resource> types = new ResourceTypes<Resource>(); types.put("r1", r1); types.put("r2", r2); Link l1 = new Link("linkType1"); LinkTypes<Link> linkTypes = new LinkTypes<Link>(); linkTypes.put("l1", l1); Task t1 = new Task("t1"); Task t2 = new Task("t2"); Application<Task, Dependency> app = new Application<Task, Dependency>(); app.addVertex(t1); app.addVertex(t2); app.addEdge(new Dependency("dep"), t1, t2); Mappings<Task, Resource> typeMappings = new Mappings<Task, Resource>(); Mapping<Task, Resource> m1 = new Mapping<Task, Resource>("m1", t1, r1); Mapping<Task, Resource> m2 = new Mapping<Task, Resource>("m2", t1, r2); Mapping<Task, Resource> m3 = new Mapping<Task, Resource>("m3", t2, r1); m3.setAttribute("M1", 0); typeMappings.add(m1); typeMappings.add(m2); typeMappings.add(m3); SpecificationTypeBased specTB = new SpecificationTypeBased(app, types, typeMappings, linkTypes); SpecificationTransformerTypeBased<SpecificationTypeBased, Specification> transformer = new SpecificationTransformerTypeBased<SpecificationTypeBased, Specification>(); Specification spec = transformer.transform(specTB); Assert.assertNotNull(spec.getApplication()); Assert.assertNotNull(spec.getArchitecture()); Assert.assertNotNull(spec.getMappings()); }