Search in sources :

Example 6 with IArchimateModel

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

the class HTMLReportExporterTests method testCreateReport.

@Test
public void testCreateReport() throws Exception {
    // Create test model
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    IArchimateModel model = tm.loadModel();
    // Create Exporter and output folder
    HTMLReportExporter exporter = new HTMLReportExporter(model);
    File targetFolder = TestUtils.createTempFolder("archi-html-report");
    File outputFile = exporter.createReport(targetFolder, "index.html");
    // Check main file and folders exist
    assertTrue(outputFile.exists());
    File modelFolder = new File(targetFolder, model.getId());
    assertTrue(modelFolder.exists());
    File elementsFolder = new File(modelFolder, "elements");
    assertTrue(elementsFolder.exists());
    File imagesFolder = new File(modelFolder, "images");
    assertTrue(imagesFolder.exists());
    File viewsFolder = new File(modelFolder, "views");
    assertTrue(viewsFolder.exists());
    assertTrue(new File(targetFolder, "css").exists());
    assertTrue(new File(targetFolder, "elements").exists());
    assertTrue(new File(targetFolder, "hints").exists());
    assertTrue(new File(targetFolder, "js").exists());
    assertTrue(new File(targetFolder, "lib").exists());
    // Check element and view files created
    assertTrue(new File(elementsFolder, "model.html").exists());
    for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        // Concepts
        if (eObject instanceof IArchimateConcept) {
            assertTrue(new File(elementsFolder, ((IArchimateConcept) eObject).getId() + ".html").exists());
        }
        // Views & Images
        if (eObject instanceof IArchimateDiagramModel) {
            assertTrue(new File(imagesFolder, ((IArchimateDiagramModel) eObject).getId() + ".png").exists());
            assertTrue(new File(viewsFolder, ((IArchimateDiagramModel) eObject).getId() + ".html").exists());
        }
    }
    // Clean up
    FileUtils.deleteFolder(TestUtils.TMP_FOLDER);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateModel(com.archimatetool.model.IArchimateModel) File(java.io.File) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 7 with IArchimateModel

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

the class CreateMapViewCheatSheetActionTests method testNewMapViewCommand.

@Test
public void testNewMapViewCommand() throws IOException {
    // Load ArchiMate model
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    IArchimateModel model = tm.loadModel();
    // Has 17 diagrams
    assertEquals(17, model.getDiagramModels().size());
    NewMapViewCommand cmd = new NewMapViewCommand(model);
    cmd.execute();
    assertNotNull(cmd.diagramModel);
    assertNotNull(cmd.diagramModel.eContainer());
    // Model now has 18 diagrams
    assertEquals(18, model.getDiagramModels().size());
    // New diagram has 17 children...
    assertEquals(17, cmd.diagramModel.getChildren().size());
    // ...all of which are IDiagramModelReference types with IDs
    for (IDiagramModelObject dmo : cmd.diagramModel.getChildren()) {
        assertTrue(dmo instanceof IDiagramModelReference);
        assertNotNull(dmo.getId());
    }
    // Undo
    cmd.undo();
    assertEquals(17, model.getDiagramModels().size());
    assertNull(cmd.diagramModel.eContainer());
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) NewMapViewCommand(com.archimatetool.help.cheatsheets.CreateMapViewCheatSheetAction.NewMapViewCommand) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 8 with IArchimateModel

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

the class FieldDataFactoryTests method testGetFieldValue_Purpose.

@Test
public void testGetFieldValue_Purpose() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setPurpose("Purpose");
    Object o = FieldDataFactory.getFieldValue(model, "purpose");
    assertEquals("Purpose", o);
}
Also used : IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 9 with IArchimateModel

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

the class FieldDataFactoryTests method testGetFieldValue_Name.

@Test
public void testGetFieldValue_Name() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setName("Pogo");
    Object o = FieldDataFactory.getFieldValue(model, "name");
    assertEquals("Pogo", o);
}
Also used : IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 10 with IArchimateModel

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

the class DiagramModelConnectionTests method testGetID.

@Test
public void testGetID() {
    assertNull(component.getId());
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    IDiagramModelGroup dmo = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    dm.getChildren().add(dmo);
    connection.connect(dmo, dmo);
    assertNotNull(connection.getId());
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IArchimateModel(com.archimatetool.model.IArchimateModel) 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