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