Search in sources :

Example 6 with IArchimateDiagramModel

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

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

the class EmptyViewsCheckerTests method testGetIssues.

@Test
public void testGetIssues() {
    List<IArchimateDiagramModel> views = new ArrayList<IArchimateDiagramModel>();
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    dm.setName("view");
    views.add(dm);
    EmptyViewsChecker checker = new EmptyViewsChecker(views);
    // Should be warning
    List<IIssue> issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertTrue(issues.get(0) instanceof AdviceType);
    assertSame(dm, issues.get(0).getObject());
    // Add something to view for no issues
    dm.getChildren().add(IArchimateFactory.eINSTANCE.createDiagramModelGroup());
    issues = checker.getIssues();
    assertEquals(0, issues.size());
}
Also used : AdviceType(com.archimatetool.hammer.validation.issues.AdviceType) ArrayList(java.util.ArrayList) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 8 with IArchimateDiagramModel

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

the class NestedElementsCheckerTests method testGetIssues.

@Test
public void testGetIssues() {
    List<IArchimateDiagramModel> views = new ArrayList<IArchimateDiagramModel>();
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    dm.setName("view");
    views.add(dm);
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createGrouping());
    dm.getChildren().add(dmo1);
    IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createLocation());
    dmo1.getChildren().add(dmo2);
    NestedElementsChecker checker = new NestedElementsChecker(views);
    // Should not be ok
    List<IIssue> issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertSame(dmo2, issues.get(0).getObject());
    // With this relationship should also not be OK
    IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    relation.connect(dmo1.getArchimateElement(), dmo2.getArchimateElement());
    conn.setArchimateRelationship(relation);
    conn.connect(dmo1, dmo2);
    issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertSame(dmo2, issues.get(0).getObject());
    // With a valid relationship should be OK
    relation = IArchimateFactory.eINSTANCE.createCompositionRelationship();
    relation.connect(dmo1.getArchimateElement(), dmo2.getArchimateElement());
    conn.setArchimateRelationship(relation);
    issues = checker.getIssues();
    assertEquals(0, issues.size());
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 9 with IArchimateDiagramModel

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

the class ViewpointCheckerTests method testGetIssues.

@Test
public void testGetIssues() {
    List<IArchimateDiagramModel> views = new ArrayList<IArchimateDiagramModel>();
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    dm.setName("view");
    views.add(dm);
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createNode());
    dm.getChildren().add(dmo1);
    ViewpointChecker checker = new ViewpointChecker(views);
    // Should be ok
    List<IIssue> issues = checker.getIssues();
    assertEquals(0, issues.size());
    // Set viewpoint
    dm.setViewpoint("organization");
    issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertSame(dmo1, issues.get(0).getObject());
}
Also used : ArrayList(java.util.ArrayList) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 10 with IArchimateDiagramModel

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

the class ViewModelDataSource method getViewpointName.

public String getViewpointName() {
    if (fCurrentView instanceof IArchimateDiagramModel) {
        String id = ((IArchimateDiagramModel) fCurrentView).getViewpoint();
        IViewpoint vp = ViewpointManager.INSTANCE.getViewpoint(id);
        if (vp == ViewpointManager.NONE_VIEWPOINT) {
            return Messages.ViewModelDataSource_1;
        }
        String name = vp.getName();
        // $NON-NLS-1$
        return name == null ? "" : NLS.bind(Messages.ViewModelDataSource_0, name);
    }
    return null;
}
Also used : IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Aggregations

IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)29 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)8 IIssue (com.archimatetool.hammer.validation.issues.IIssue)6 IArchimateModel (com.archimatetool.model.IArchimateModel)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IViewpoint (com.archimatetool.model.viewpoints.IViewpoint)5 EObject (org.eclipse.emf.ecore.EObject)5 AdviceType (com.archimatetool.hammer.validation.issues.AdviceType)4 ISketchModel (com.archimatetool.model.ISketchModel)4 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)3 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)3 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)2 ArchimateDiagramEditPartFactory (com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory)2 IFolder (com.archimatetool.model.IFolder)2 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)2 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2