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);
}
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());
}
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());
}
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());
}
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;
}
Aggregations