use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.
the class DiagramModelUtilsTests method testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram.
// =================================================================================================
@Test
public void testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IDiagramModel dm = model.getDefaultDiagramModel();
IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
dm.getChildren().add(dmo1);
IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
dm.getChildren().add(dmo2);
IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
dmc1.connect(dmo1, dmo2);
List<?> list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
assertEquals(1, list.size());
list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
assertEquals(1, list.size());
list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
assertEquals(1, list.size());
// Duplicate
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
handler.duplicate();
list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
assertEquals(2, list.size());
list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
assertEquals(2, list.size());
list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
assertEquals(2, list.size());
}
use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.
the class CommandsTests method runBeforeEachTest.
// ---------------------------------------------------------------------------------------------
// BEFORE AND AFTER METHODS GO HERE
// ---------------------------------------------------------------------------------------------
@Before
public void runBeforeEachTest() throws IOException {
tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
model = tm.loadModel();
}
use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.
the class UnusedElementsCheckerTests method testGetIssues.
@Test
public void testGetIssues() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
List<IArchimateElement> elements = new ArrayList<IArchimateElement>();
IArchimateElement element = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
elements.add(element);
UnusedElementsChecker checker = new UnusedElementsChecker(elements);
// Should not be OK
List<IIssue> issues = checker.getIssues();
assertEquals(1, issues.size());
assertSame(element, issues.get(0).getObject());
// Add it to a diagram
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setArchimateElement(element);
model.getDefaultDiagramModel().getChildren().add(dmo);
// Should be OK
issues = checker.getIssues();
assertEquals(0, issues.size());
}
use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.
the class UnusedRelationsCheckerTests method testGetIssues.
@Test
public void testGetIssues() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
List<IArchimateRelationship> relations = new ArrayList<IArchimateRelationship>();
IArchimateRelationship relation = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getAssociationRelationship());
relations.add(relation);
IArchimateElement e1 = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
IArchimateElement e2 = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
relation.connect(e1, e2);
UnusedRelationsChecker checker = new UnusedRelationsChecker(relations);
// Should not be OK
List<IIssue> issues = checker.getIssues();
assertEquals(1, issues.size());
assertSame(relation, issues.get(0).getObject());
// Add it to a diagram
IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo1.setArchimateElement(e1);
model.getDefaultDiagramModel().getChildren().add(dmo1);
IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo2.setArchimateElement(e2);
model.getDefaultDiagramModel().getChildren().add(dmo2);
IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
conn.setArchimateRelationship(relation);
conn.connect(dmo1, dmo2);
// Should be OK
issues = checker.getIssues();
assertEquals(0, issues.size());
}
use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.
the class ArchimateModelDataSourceTests method runOnceBeforeAllTests.
@BeforeClass
public static void runOnceBeforeAllTests() throws IOException {
// Load ArchiMate model
ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
model = tm.loadModel();
}
Aggregations