package archmapper.main.test;
import org.junit.Before;
import org.junit.Test;
import archmapper.main.model.architecture.Component;
import archmapper.main.model.architecture.Connector;
import archmapper.main.model.architecture.Port;
import archmapper.main.model.architecture.Role;
import archmapper.main.model.architecture.Role.RoleDirection;
import archmapper.main.model.archmapping.ComponentMapping;
import static org.junit.Assert.*;
public class ArchitectureXMLReaderTest extends MappingTestBase {
@Before
public void loadFiles() {
super.loadFiles();
}
@Test
public void testComponentsPresent() {
Component comp1 = architecture.getComponentByName("Comp1");
Component comp2 = architecture.getComponentByName("Comp2");
assertNotNull(comp1);
assertNotNull(comp2);
Port p = comp1.getPortByName("p");
assertNotNull(p);
assertEquals(p.getParent(), comp1);
Role role = p.getRoles().get(0);
assertNotNull(role);
assertEquals(role.getParent(), p);
assertEquals("CallerRole", role.getStyleType());
assertEquals("caller1", role.getName());
assertEquals(RoleDirection.out, role.getDirection());
Role role2 = p.getRoles().get(1);
assertNotNull(role2);
assertEquals("caller2", role2.getName());
assertEquals(RoleDirection.in, role2.getDirection());
Connector conn = architecture.getConnectorByName("Connector1");
assertNotNull(conn);
assertEquals(2, conn.getRoles().size());
assertEquals(role.getConnector(), conn);
}
@Test
public void testArchitectureMappingOk() {
ComponentMapping comp1Mapping = archMapping.getComponentMapping("Comp1");
ComponentMapping comp2Mapping = archMapping.getComponentMapping("Comp2");
assertNotNull(comp1Mapping);
assertNotNull(comp2Mapping);
assertTrue(comp2Mapping.getClassNamePattern().size() > 0);
}
}