Search in sources :

Example 1 with ArchimateTestModel

use of com.archimatetool.testingtools.ArchimateTestModel 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 2 with ArchimateTestModel

use of com.archimatetool.testingtools.ArchimateTestModel 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 3 with ArchimateTestModel

use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.

the class JasperReportsExporterTests method runOnceBeforeAllTests.

@BeforeClass
public static void runOnceBeforeAllTests() throws JRException, IOException {
    // Load ArchiMate model
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    model = tm.loadModel();
    // Setup some folders
    exportFolder = TestUtils.createTempFolder("export");
    tmpFolder = new File(exportFolder, "tmp");
    tmpFolder.mkdirs();
    // Create exporter
    exporter = new JasperReportsExporter(model, exportFolder, exportFileName, mainTemplateFile, reportTitle, null, 0);
    // Set up diagrams and Jasper Print once (expensive operation)
    exporter.writeDiagrams(tmpFolder);
    jasperPrint = exporter.createJasperPrint(null, tmpFolder);
}
Also used : File(java.io.File) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) BeforeClass(org.junit.BeforeClass)

Example 4 with ArchimateTestModel

use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.

the class ElementsDataSourceTests 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)

Example 5 with ArchimateTestModel

use of com.archimatetool.testingtools.ArchimateTestModel in project archi by archimatetool.

the class ValidatorTests method runOnceBeforeAllTests.

@BeforeClass
public static void runOnceBeforeAllTests() throws IOException {
    // Need to do this if running only these tests
    TestUtils.ensureDefaultDisplay();
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    model = tm.loadModel();
    validator = new Validator(model);
}
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