+ @Test
+ public void testEntityRetrievalWithYiid() throws Exception {
+ final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME),
+ new NodeIdentifier(Topology.QNAME),
+ NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"),
+ new NodeIdentifier(Node.QNAME),
+ NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
+
+ final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
+
+ final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
+
+ verifyEntityOwnershipCandidateRegistration(entity, reg);
+ verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
+
+ RpcResult<GetEntityOutput> getEntityResult = service.getEntity(new GetEntityInputBuilder()
+ .setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)))
+ .setType(new EntityType(ENTITY_TYPE))
+ .build())
+ .get();
+
+ assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
+ assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
+
+ // we should not be able to retrieve the entity when using string
+ final String entityPathEncoded =
+ "/network-topology:network-topology/topology[topology-id='test']/node[node-id='test://test-node']";
+
+ getEntityResult = service.getEntity(new GetEntityInputBuilder()
+ .setName(new EntityName(entityPathEncoded))
+ .setType(new EntityType(ENTITY_TYPE))
+ .build())
+ .get();
+
+ assertNull(getEntityResult.getResult().getOwnerNode());
+ assertTrue(getEntityResult.getResult().getCandidateNodes().isEmpty());
+ }
+