use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class CommitTransactionPayloadTest method testLeafSetEntryNodeCandidate.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testLeafSetEntryNodeCandidate() throws Exception {
YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
YangInstanceIdentifier leafSetEntryPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).node(entryPathArg).build();
NormalizedNode<?, ?> leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg).withValue("one").build();
candidate = DataTreeCandidates.fromNormalizedNode(leafSetEntryPath, leafSetEntryNode);
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate().getValue());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class CommitTransactionPayloadTest method testOrderedLeafSetNodeCandidate.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testOrderedLeafSetNodeCandidate() throws Exception {
YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg).withValue("one").build();
NormalizedNode<?, ?> leafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build();
candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode);
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate().getValue());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class CommitTransactionPayloadTest method setUp.
@Before
public void setUp() {
setUpStatic();
final YangInstanceIdentifier writePath = TestModel.TEST_PATH;
final NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
candidate = DataTreeCandidates.fromNormalizedNode(writePath, writeData);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class AbstractDOMRpcRoutingTableEntry method add.
/**
* Adds an entry to the DOM RPC routing table.
*
* @param implementation RPC implementation
* @param newRpcs List of new RPCs, must be mutable
*/
final AbstractDOMRpcRoutingTableEntry add(final DOMRpcImplementation implementation, final List<YangInstanceIdentifier> newRpcs) {
final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : implementations.entrySet()) {
if (newRpcs.remove(ve.getKey())) {
final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue().size() + 1);
i.addAll(ve.getValue());
i.add(implementation);
// New implementation is at the end, this will move it to be the last among implementations
// with equal cost -- relying on sort() being stable.
i.sort(Comparator.comparingLong(DOMRpcImplementation::invocationCost));
vb.put(ve.getKey(), i);
} else {
vb.put(ve);
}
}
for (final YangInstanceIdentifier ii : newRpcs) {
final List<DOMRpcImplementation> impl = new ArrayList<>(1);
impl.add(implementation);
vb.put(ii, impl);
}
return newInstance(vb.build());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class DeleteModificationTest method testSerialization.
@Test
public void testSerialization() {
YangInstanceIdentifier path = TestModel.TEST_PATH;
DeleteModification expected = new DeleteModification(path);
DeleteModification clone = (DeleteModification) SerializationUtils.clone(expected);
assertEquals("getPath", expected.getPath(), clone.getPath());
}
Aggregations