use of org.pentaho.metaverse.api.MetaverseLogicalIdGenerator in project pentaho-metaverse by pentaho.
the class MetaverseNodeTest method testGetLogicalId.
@Test
public void testGetLogicalId() throws Exception {
MetaverseNode node = new MetaverseNode(v);
when(v.getProperty("name")).thenReturn("testName");
when(v.getProperty("zzz")).thenReturn("last");
when(v.getProperty("type")).thenReturn("testType");
MetaverseNode spyNode = spy(node);
when(spyNode.getPropertyKeys()).thenReturn(new HashSet<String>() {
{
add("name");
add("type");
add("zzz");
}
});
// should be using the default logical id generator initially
assertEquals("{\"name\":\"testName\",\"namespace\":\"\",\"type\":\"testType\"}", spyNode.getLogicalId());
ILogicalIdGenerator idGenerator = new MetaverseLogicalIdGenerator("type", "zzz", "name");
spyNode.setLogicalIdGenerator(idGenerator);
assertNotNull(spyNode.logicalIdGenerator);
// logical id should be sorted based on key
assertEquals("{\"name\":\"testName\",\"type\":\"testType\",\"zzz\":\"last\"}", spyNode.getLogicalId());
}
use of org.pentaho.metaverse.api.MetaverseLogicalIdGenerator in project pentaho-metaverse by pentaho.
the class MetaverseTransientNodeTest method testGetLogicalId.
@Test
public void testGetLogicalId() throws Exception {
MetaverseTransientNode myNode = new MetaverseTransientNode();
myNode.setName("testName");
myNode.setType("testType");
myNode.setProperty("zzz", "last");
myNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, "");
myNode.setStringID("myId");
// should be using the default logical id generator initially
assertEquals("{\"name\":\"testName\",\"namespace\":\"\",\"type\":\"testType\"}", myNode.getLogicalId());
ILogicalIdGenerator idGenerator = new MetaverseLogicalIdGenerator("type", "zzz", "name");
myNode.setLogicalIdGenerator(idGenerator);
assertNotNull(myNode.logicalIdGenerator);
// logical id should be sorted based on key
assertEquals("{\"name\":\"testName\",\"type\":\"testType\",\"zzz\":\"last\"}", myNode.getLogicalId());
}
Aggregations