Package archmapper.main.model.archmapping

Examples of archmapper.main.model.archmapping.ComponentMapping


  @Test
  public void testNoExceptionsWithOnlyArchitectureMapping() {
    // create an architecture mapping and nothing else
    createArchitectureMapping();
   
    ComponentMapping comp1Mapping = archMapping.getComponentMapping("Comp1");
   
    ClassDefinition classDef = (ClassDefinition) mappingHelper.getImplementationArtifactDefinitionByClassname(comp1Mapping,
        "de.superpackage.ClassName1");

    assertNotNull(classDef);
   
    assertEquals("de.superpackage",
        mappingHelper.getDefaultPackage(comp1Mapping));
   
    assertNull(mappingHelper.getComponentTypeOf(comp1Mapping));
    assertNull(mappingHelper.getConnectorTypeOf(archMapping.getConnectorMapping("Connector1")));
   
    FileDefinition fileDef = comp1Mapping.getFileDefinition().get(0);
   
    assertEquals("file1", mappingHelper.getFilename(fileDef));
    assertNull(mappingHelper.getFileTypeForFileDefinition(fileDef));
   
    assertEquals("de.superpackage", mappingHelper.getPackageOfImplementationArtifact(classDef));
View Full Code Here


  @Test
  public void testNoExceptionsWithoutStyleMapping() {
    createArchitecture();
    createArchitectureMapping();
   
    ComponentMapping comp1Mapping = archMapping.getComponentMapping("Comp1");
    ComponentMapping comp2Mapping = archMapping.getComponentMapping("Comp2");
    ConnectorMapping conn1Mapping = archMapping.getConnectorMapping("Connector1");
   
    assertNull(mappingHelper.getComponentTypeMapping("Comp1"));
    assertEquals("CompType1", mappingHelper.getComponentTypeOf(comp1Mapping));
    assertEquals("ConnType", mappingHelper.getConnectorTypeOf(conn1Mapping));
   
    ClassDefinition class1Def = comp1Mapping.getClassDefinition().get(0);
   
    Port p = architecture.getComponentByName("Comp1").getPortByName("p");
    assertTrue(mappingHelper.isClassUsingPort(class1Def,     
        p, comp1Mapping.getPortMapping("p")));
    assertTrue(mappingHelper.isClassExposedByPort(class1Def,
        p, comp1Mapping.getPortMapping("p")));
   
    assertEquals("com.testpackage.Class2", mappingHelper.getQualifiedName(comp2Mapping.getClassDefinition().get(0)));
   
    assertFalse(mappingHelper.isExternalComponent("Comp1"));
   
    assertFalse(mappingHelper.mayClassReferenceOtherClass("de.superpackage.ClassName1", "Comp1",
        "com.testpackage.Class2", "Comp2"));
View Full Code Here

 
  @Test
  public void testCommunicationIntegrityTests() {
    loadFiles();
   
    ComponentMapping comp1Mapping = archMapping.getComponentMapping("Comp1");
    PortMapping pMapping = comp1Mapping.getPortMapping("p");
    Component comp1 = architecture.getComponentByName("Comp1");
    Port p = comp1.getPortByName("p");
   
    assertTrue(mappingHelper.isClassExposedByPort(comp1Mapping.getInterfaceDefinition().get(0),
        p, pMapping));
    assertFalse(mappingHelper.isClassExposedByPort(comp1Mapping.getClassDefinition().get(0),
        p, pMapping));
   
    assertTrue(mappingHelper.isClassUsingPort(comp1Mapping.getClassDefinition().get(0),
        p, pMapping));
    assertFalse(mappingHelper.isClassUsingPort(comp1Mapping.getInterfaceDefinition().get(0),
        p, pMapping));
   
    assertTrue(mappingHelper.isClassExposedByPort(comp1Mapping.getInterfaceDefinition().get(1),
        p, pMapping));
    assertFalse(mappingHelper.isClassUsingPort(comp1Mapping.getInterfaceDefinition().get(1),
        p, pMapping));
   
    assertTrue(mappingHelper.mayClassReferenceOtherClass
        ("Comp1Interface3", "Comp1", "Comp2If1", "Comp2"));
   
    Component comp2 = architecture.getComponentByName("Comp2");
    ComponentMapping comp2Mapping = archMapping.getComponentMapping("Comp2");
    Port p2 = comp2.getPortByName("p2");
   
    assertFalse(mappingHelper.isClassUsingPort(comp2Mapping.getClassDefinition().get(0), p2, null));
    assertTrue(mappingHelper.isClassExposedByPort(comp2Mapping.getClassDefinition().get(0), p2, null));
   
    // every class is exposed by the port, so we can also test with null
    // (which will be the case for classes defined by classNamePattern)
    assertTrue(mappingHelper.isClassExposedByPort(null, p2, null));
   
    assertTrue(mappingHelper.isClassUsingPort(comp2Mapping.getInterfaceDefinition().get(0),
        p2, null));
   
   
    // Test with implemented Connector
   
    Component comp3 = architecture.getComponentByName("Comp3");
    ComponentMapping comp3Mapping = archMapping.getComponentMapping("Comp3");
    ClassDefinition classComp3Def = comp3Mapping.getClassDefinition().get(0);
    ClassDefinition class2Comp3Def = comp3Mapping.getClassDefinition().get(1);
   
    Connector connWithImpl = architecture.getConnectorByName("ConnWithImpl");
    ConnectorMapping connWithImplMapping = archMapping.getConnectorMapping("ConnWithImpl");
    ClassDefinition connClassDef = connWithImplMapping.getClassDefinition().get(0);
   
View Full Code Here

        javaProject);
   
    // Add attributes, getters and setters to this class
    if (created && archElem instanceof Component) {
      Component comp = (Component) archElem;
      ComponentMapping compMapping = (ComponentMapping) archElemMapping;
     
      for (Port port : comp.getPorts()) {
        if (mappingHelper.isClassUsingPort(classDef, port, compMapping.getPortMapping(port.getName()))) {
          List<ComponentToComponentConnection> connections = comp.getConnectionsOverPort(RoleDirection.out, port);
         
          for (ComponentToComponentConnection connection : connections) {
            ComponentMapping remoteComp = archMapping.getComponentMapping(connection.getTargetComponent().getName());
            if (remoteComp != null) {
              PortMapping remotePortMapping = remoteComp.getPortMapping(connection.getTargetPort().getName());
             
              for (ClassDefinition remoteClass : remoteComp.getClassDefinition()) {
                if (mappingHelper.isClassExposedByPort(classDef, connection.getTargetPort(), remotePortMapping) &&
                    mappingHelper.isClassSingleton(remoteClass)) {
                  // we could need an attribute for this class...
                  CodeGenerationHelper.generateAttributeForClass(classDef, remoteClass,
                      javaProject, mappingHelper);
View Full Code Here

TOP

Related Classes of archmapper.main.model.archmapping.ComponentMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.