Search in sources :

Example 86 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class EditorModelManagerTests method loadModel_File_Null.

@Test
public void loadModel_File_Null() {
    IArchimateModel model = editorModelManager.loadModel(null);
    assertNull(model);
}
Also used : IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 87 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class EditorModelManagerTests method createNewArchiveManager_Created.

@Test
public void createNewArchiveManager_Created() throws Exception {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    IArchiveManager archiveManager = (IArchiveManager) TestUtils.invokePrivateMethod(editorModelManager, "createNewArchiveManager", new Class[] { IArchimateModel.class }, new Object[] { model });
    assertNotNull(archiveManager);
    assertTrue(model.getAdapter(IArchiveManager.class) instanceof IArchiveManager);
}
Also used : IArchiveManager(com.archimatetool.editor.model.IArchiveManager) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 88 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class EditorModelManagerTests method saveModel.

@Test
public void saveModel() throws Exception {
    File file = TestData.TEST_MODEL_FILE_ARCHISURANCE;
    IArchimateModel model = editorModelManager.loadModel(file);
    assertNotNull(model);
    File tmpFile = TestUtils.createTempFile(".archimate");
    model.setFile(tmpFile);
    Preferences.STORE.setValue(IPreferenceConstants.BACKUP_ON_SAVE, false);
    boolean result = editorModelManager.saveModel(model);
    assertTrue(result);
}
Also used : File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 89 with IArchimateModel

use of com.archimatetool.model.IArchimateModel 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 90 with IArchimateModel

use of com.archimatetool.model.IArchimateModel 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)

Aggregations

IArchimateModel (com.archimatetool.model.IArchimateModel)124 Test (org.junit.Test)51 File (java.io.File)35 IOException (java.io.IOException)22 IArchimateElement (com.archimatetool.model.IArchimateElement)14 EObject (org.eclipse.emf.ecore.EObject)14 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)13 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)13 IDiagramModel (com.archimatetool.model.IDiagramModel)12 CommandStack (org.eclipse.gef.commands.CommandStack)11 IFolder (com.archimatetool.model.IFolder)10 ArrayList (java.util.ArrayList)10 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)9 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)9 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)7 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)6 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)6 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)5 IIdentifier (com.archimatetool.model.IIdentifier)5 GraficoModelLoader (org.archicontribs.modelrepository.grafico.GraficoModelLoader)5