use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class TreeModelViewerDragDropHandlerTests method moveTreeObjects_DropChildElementsOntoDifferentParent.
/**
* Drag and dropping child elements onto different parent
*/
@Test
public void moveTreeObjects_DropChildElementsOntoDifferentParent() {
// Add child elements to a folder
IFolder sourceParentFolder = model.getFolder(FolderType.BUSINESS);
IArchimateElement childElement1 = IArchimateFactory.eINSTANCE.createBusinessActor();
sourceParentFolder.getElements().add(childElement1);
IArchimateElement childElement2 = IArchimateFactory.eINSTANCE.createBusinessActor();
sourceParentFolder.getElements().add(childElement2);
// Check all is well
assertEquals(2, sourceParentFolder.getElements().size());
assertEquals(childElement1, sourceParentFolder.getElements().get(0));
assertEquals(childElement2, sourceParentFolder.getElements().get(1));
// New target parent folder and all is well
IFolder targetParentFolder = model.getFolder(FolderType.APPLICATION);
assertTrue(targetParentFolder.getFolders().isEmpty());
assertTrue(targetParentFolder.getElements().isEmpty());
// Move child element to the different target parent folder
dragHandler.moveTreeObjects(targetParentFolder, new Object[] { childElement1, childElement2 });
// Source should be empty
assertTrue(sourceParentFolder.getElements().isEmpty());
// Shouldn't affect folders
assertEquals(2, targetParentFolder.getElements().size());
// Target should be populated
assertEquals(childElement1, targetParentFolder.getElements().get(0));
assertEquals(childElement2, targetParentFolder.getElements().get(1));
assertTrue(targetParentFolder.getFolders().isEmpty());
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class DeleteCommandHandlerTests method testDelete_Folder_Deleted_SubElements.
@Test
public void testDelete_Folder_Deleted_SubElements() {
// Sub-folder with elements
Object[] folder = new Object[] { ArchimateModelUtils.getObjectByID(model, "0bd99416") };
assertTrue(folder[0] instanceof IFolder);
// sub-Elements that should be zapped
String[] elementIDs = new String[] { // element
"e836c6be", // element
"b5742e18", // element
"d1247cf1" };
List<IArchimateElement> elements = new ArrayList<IArchimateElement>();
for (String id : elementIDs) {
elements.add((IArchimateElement) ArchimateModelUtils.getObjectByID(model, id));
}
// Delete top folder
DeleteCommandHandler commandHandler = new DeleteCommandHandler(treeModelViewer, folder);
commandHandler.delete();
// Is top folder deleted?
assertNull(ArchimateModelUtils.getObjectByID(model, "0bd99416"));
// Is sub folder deleted?
assertNull(ArchimateModelUtils.getObjectByID(model, "02460ff1"));
// Are elements deleted?
for (IArchimateElement element : elements) {
assertNull(ArchimateModelUtils.getObjectByID(model, element.getId()));
assertFalse(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
}
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class DuplicateCommandHandlerTests method testDuplicateArchimateElements.
@Test
public void testDuplicateArchimateElements() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IFolder folder = model.getFolder(FolderType.BUSINESS);
IArchimateElement element1 = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
element1.setName("Actor 1");
element1.setDocumentation("Doc 1");
assertEquals(1, folder.getElements().size());
assertSame(element1, folder.getElements().get(0));
IArchimateElement element2 = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
element2.setName("Actor 2");
element2.setDocumentation("Doc 2");
assertEquals(2, folder.getElements().size());
assertSame(element2, folder.getElements().get(1));
IArchimateRelationship relation = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getAssociationRelationship());
relation.connect(element1, element2);
assertTrue(element1.getSourceRelationships().contains(relation));
assertTrue(element2.getTargetRelationships().contains(relation));
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { element1, element2 });
handler.duplicate();
assertEquals(4, folder.getElements().size());
assertSame(element1, folder.getElements().get(0));
assertSame(element2, folder.getElements().get(1));
IArchimateElement copy1 = (IArchimateElement) folder.getElements().get(2);
assertNotSame(element1, copy1);
assertNotEquals(element1.getId(), copy1.getId());
assertEquals(element1.getName() + " (copy)", copy1.getName());
assertEquals(element1.getDocumentation(), copy1.getDocumentation());
IArchimateElement copy2 = (IArchimateElement) folder.getElements().get(3);
assertNotSame(element2, copy2);
assertNotEquals(element2.getId(), copy2.getId());
assertEquals(element2.getName() + " (copy)", copy2.getName());
assertEquals(element2.getDocumentation(), copy2.getDocumentation());
assertTrue(copy1.getSourceRelationships().isEmpty());
assertTrue(copy1.getTargetRelationships().isEmpty());
assertTrue(copy2.getSourceRelationships().isEmpty());
assertTrue(copy2.getTargetRelationships().isEmpty());
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class CommandsTests method testDeleteFolderCommand.
@Test
public void testDeleteFolderCommand() {
IFolder folder = (IFolder) tm.getObjectByID("403e5717");
assertNotNull(folder);
IFolder parent = (IFolder) folder.eContainer();
DeleteFolderCommand cmd = new DeleteFolderCommand(folder);
cmd.execute();
assertNull(folder.eContainer());
assertFalse(parent.getFolders().contains(folder));
cmd.undo();
assertEquals(1, parent.getFolders().indexOf(folder));
}
use of com.archimatetool.model.IFolder in project archi by archimatetool.
the class ArchimateModelTests method testGetDefaultFolderForWrongElement.
@Test
public void testGetDefaultFolderForWrongElement() {
// Null
IFolder folder = model.getDefaultFolderForObject(null);
assertNull(folder);
// Folder
EObject element = IArchimateFactory.eINSTANCE.createFolder();
folder = model.getDefaultFolderForObject(element);
assertNull(folder);
element = IArchimateFactory.eINSTANCE.createSketchModelActor();
folder = model.getDefaultFolderForObject(element);
assertNull(folder);
element = IArchimateFactory.eINSTANCE.createSketchModelSticky();
folder = model.getDefaultFolderForObject(element);
assertNull(folder);
}
Aggregations