Search in sources :

Example 11 with IProperty

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

the class MetadataTests method testGetEntry.

@Test
public void testGetEntry() {
    String key = "some_key", value = "some_value";
    assertNull(metadata.getEntry("something"));
    IProperty property = metadata.addEntry(key, value);
    assertEquals(property, metadata.getEntry(key));
}
Also used : IProperty(com.archimatetool.model.IProperty) Test(org.junit.Test)

Example 12 with IProperty

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

the class MetadataTests method testAddEntry.

@Test
public void testAddEntry() {
    String key = "some_key", value = "some_value";
    IProperty property = metadata.addEntry(key, value);
    assertNotNull(property);
    assertEquals(key, property.getKey());
    assertEquals(value, property.getValue());
    // Check entry is correct
    EList<IProperty> entries = metadata.getEntries();
    assertEquals(1, entries.size());
    assertEquals(property, entries.get(0));
}
Also used : IProperty(com.archimatetool.model.IProperty) Test(org.junit.Test)

Example 13 with IProperty

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

the class MetadataTests method testEntryCreated.

@Test
public void testEntryCreated() throws Exception {
    String key = "some_key", value = "some_value";
    // Add a metadata entry as a property key/value pair
    IProperty property = IArchimateFactory.eINSTANCE.createProperty();
    property.setKey(key);
    property.setValue(value);
    metadata.getEntries().add(property);
    // Check entry is correct
    EList<IProperty> entries = metadata.getEntries();
    assertEquals(1, entries.size());
    IProperty testProperty = entries.get(0);
    assertEquals(property, testProperty);
    assertEquals(testProperty.getKey(), key);
    assertEquals(testProperty.getValue(), value);
    // Save to file
    File file = TestSupport.saveModel(model);
    assertTrue(file.exists());
    // Load it in again
    IArchimateModel testModel = TestSupport.loadModel(file);
    // Check it persisted
    @SuppressWarnings("deprecation") EList<IProperty> testEntries = testModel.getMetadata().getEntries();
    assertEquals(1, testEntries.size());
    testProperty = testEntries.get(0);
    assertEquals(testProperty.getKey(), key);
    assertEquals(testProperty.getValue(), value);
}
Also used : IProperty(com.archimatetool.model.IProperty) File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 14 with IProperty

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

the class MetadataTests method testAddEntryExists.

@Test
public void testAddEntryExists() {
    String key = "some_key", value = "some_value", new_value = "another_value";
    IProperty property = metadata.addEntry(key, value);
    IProperty property2 = metadata.addEntry(key, new_value);
    assertEquals(property, property2);
    assertEquals(new_value, property2.getValue());
}
Also used : IProperty(com.archimatetool.model.IProperty) Test(org.junit.Test)

Example 15 with IProperty

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

the class Metadata method addEntry.

@Override
public IProperty addEntry(String key, String value) {
    if (key == null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("key cannot be null");
    }
    // If we already have an entry with this key set the value and return that property
    IProperty property = getEntry(key);
    if (property != null) {
        property.setValue(value);
        return property;
    }
    property = IArchimateFactory.eINSTANCE.createProperty();
    property.setKey(key);
    property.setValue(value);
    getEntries().add(property);
    return property;
}
Also used : IProperty(com.archimatetool.model.IProperty)

Aggregations

IProperty (com.archimatetool.model.IProperty)32 EObject (org.eclipse.emf.ecore.EObject)10 Test (org.junit.Test)9 IArchimateElement (com.archimatetool.model.IArchimateElement)5 IProperties (com.archimatetool.model.IProperties)5 IArchimateModel (com.archimatetool.model.IArchimateModel)4 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)4 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)4 Point (org.eclipse.swt.graphics.Point)4 HashSet (java.util.HashSet)3 Matcher (java.util.regex.Matcher)3 EObjectNonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.EObjectNonNotifyingCompoundCommand)2 IArchimateConcept (com.archimatetool.model.IArchimateConcept)2 Command (org.eclipse.gef.commands.Command)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Element (org.jdom2.Element)2 CSVParseException (com.archimatetool.csv.CSVParseException)1 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)1 IPreferenceConstants (com.archimatetool.editor.preferences.IPreferenceConstants)1