Search in sources :

Example 26 with ArchimateTestModel

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());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) DuplicateCommandHandler(com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler) Test(org.junit.Test)

Example 27 with ArchimateTestModel

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();
}
Also used : ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Before(org.junit.Before)

Example 28 with ArchimateTestModel

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());
}
Also used : ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 29 with ArchimateTestModel

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());
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 30 with ArchimateTestModel

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();
}
Also used : ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) BeforeClass(org.junit.BeforeClass)

Aggregations

ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)33 Test (org.junit.Test)14 IArchimateModel (com.archimatetool.model.IArchimateModel)13 BeforeClass (org.junit.BeforeClass)11 IArchimateElement (com.archimatetool.model.IArchimateElement)8 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 Before (org.junit.Before)6 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)5 File (java.io.File)4 IDiagramModel (com.archimatetool.model.IDiagramModel)3 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)3 ArchimateTestEditor (com.archimatetool.testingtools.ArchimateTestEditor)3 ArrayList (java.util.ArrayList)3 IIssue (com.archimatetool.hammer.validation.issues.IIssue)2 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)2 IAssignmentRelationship (com.archimatetool.model.IAssignmentRelationship)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 DuplicateCommandHandler (com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler)1 NewMapViewCommand (com.archimatetool.help.cheatsheets.CreateMapViewCheatSheetAction.NewMapViewCommand)1