Search in sources :

Example 1 with MetaverseLogicalIdGenerator

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());
}
Also used : ILogicalIdGenerator(org.pentaho.metaverse.api.ILogicalIdGenerator) MetaverseLogicalIdGenerator(org.pentaho.metaverse.api.MetaverseLogicalIdGenerator) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with MetaverseLogicalIdGenerator

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());
}
Also used : ILogicalIdGenerator(org.pentaho.metaverse.api.ILogicalIdGenerator) MetaverseLogicalIdGenerator(org.pentaho.metaverse.api.MetaverseLogicalIdGenerator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ILogicalIdGenerator (org.pentaho.metaverse.api.ILogicalIdGenerator)2 MetaverseLogicalIdGenerator (org.pentaho.metaverse.api.MetaverseLogicalIdGenerator)2 Matchers.anyString (org.mockito.Matchers.anyString)1