Search in sources :

Example 31 with IProfile

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

the class ModelCheckerTests method checkProfiles.

@Test
public void checkProfiles() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getFolder(FolderType.BUSINESS).getElements().add(element);
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    profile.setName("Specialization");
    profile.setConceptType(element.eClass().getName());
    model.getProfiles().add(profile);
    element.getProfiles().add(profile);
    List<String> messages = modelChecker.checkProfiles(element);
    assertEquals(0, messages.size());
    // Remove from model
    model.getProfiles().remove(profile);
    messages = modelChecker.checkProfiles(element);
    assertEquals(1, messages.size());
    assertTrue(messages.get(0).startsWith("Profile reference is orphaned"));
    // Wrong concept type
    profile.setConceptType(IArchimatePackage.eINSTANCE.getArtifact().getName());
    messages = modelChecker.checkProfiles(element);
    assertEquals(2, messages.size());
    assertTrue(messages.get(1).startsWith("Profile has wrong concept type"));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IProfile(com.archimatetool.model.IProfile) Test(org.junit.Test)

Example 32 with IProfile

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

the class ArchimateModelUtilsTests method findProfileUsage.

@Test
public void findProfileUsage() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    model.getProfiles().add(profile);
    assertEquals(0, ArchimateModelUtils.findProfileUsage(profile).size());
    IArchimateElement element = IArchimateFactory.eINSTANCE.createApplicationFunction();
    model.getDefaultFolderForObject(element).getElements().add(element);
    element.getProfiles().add(profile);
    element = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element).getElements().add(element);
    element.getProfiles().add(profile);
    assertEquals(2, ArchimateModelUtils.findProfileUsage(profile).size());
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IProfile(com.archimatetool.model.IProfile) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 33 with IProfile

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

the class ArchimateModelUtilsTests method findProfilesUsage.

@Test
public void findProfilesUsage() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    model.getProfiles().add(profile);
    assertEquals(0, ArchimateModelUtils.findProfilesUsage(model).size());
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createApplicationFunction();
    model.getDefaultFolderForObject(element1).getElements().add(element1);
    element1.getProfiles().add(profile);
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element2).getElements().add(element2);
    element2.getProfiles().add(profile);
    Map<IProfile, List<IProfiles>> map = ArchimateModelUtils.findProfilesUsage(model);
    assertEquals(1, map.size());
    assertEquals(2, map.get(profile).size());
    assertTrue(map.get(profile).contains(element1));
    assertTrue(map.get(profile).contains(element2));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) List(java.util.List) IProfile(com.archimatetool.model.IProfile) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 34 with IProfile

use of com.archimatetool.model.IProfile in project archi-modelrepository-plugin by archi-contribs.

the class GraficoModelImporter method loadElement.

/**
 * Create an eObject from an XML file. Basically load a resource.
 *
 * @param file
 * @return
 * @throws IOException
 */
private EObject loadElement(File file) throws IOException {
    IIdentifier eObject = GraficoResourceLoader.loadEObject(file);
    // Update an ID -> Object mapping table (used as a cache to resolve proxies)
    fIDLookup.put(eObject.getId(), eObject);
    if (eObject instanceof IArchimateModel) {
        for (IProfile profile : ((IArchimateModel) eObject).getProfiles()) {
            fIDLookup.put(profile.getId(), profile);
        }
    }
    return eObject;
}
Also used : IIdentifier(com.archimatetool.model.IIdentifier) IProfile(com.archimatetool.model.IProfile) IArchimateModel(com.archimatetool.model.IArchimateModel)

Aggregations

IProfile (com.archimatetool.model.IProfile)34 Test (org.junit.Test)11 IArchimateModel (com.archimatetool.model.IArchimateModel)7 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 IArchimateElement (com.archimatetool.model.IArchimateElement)6 IDiagramModel (com.archimatetool.model.IDiagramModel)4 EObject (org.eclipse.emf.ecore.EObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)3 IProfiles (com.archimatetool.model.IProfiles)3 List (java.util.List)3 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IFolder (com.archimatetool.model.IFolder)2 ArrayList (java.util.ArrayList)2 CommandStack (org.eclipse.gef.commands.CommandStack)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2