Search in sources :

Example 71 with YangInstanceIdentifier

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());
}
Also used : YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test) AbstractTest(org.opendaylight.controller.cluster.datastore.AbstractTest)

Example 72 with YangInstanceIdentifier

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());
}
Also used : LeafSetEntryNode(org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test) AbstractTest(org.opendaylight.controller.cluster.datastore.AbstractTest)

Example 73 with YangInstanceIdentifier

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);
}
Also used : YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Before(org.junit.Before)

Example 74 with YangInstanceIdentifier

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());
}
Also used : DOMRpcImplementation(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 75 with YangInstanceIdentifier

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());
}
Also used : YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Aggregations

YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)187 Test (org.junit.Test)111 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)34 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)21 ActorRef (akka.actor.ActorRef)19 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)19 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)15 TestActorRef (akka.testkit.TestActorRef)14 TestKit (akka.testkit.javadsl.TestKit)13 WriteModification (org.opendaylight.controller.cluster.datastore.modification.WriteModification)12 ArrayList (java.util.ArrayList)11 RegisterDataTreeNotificationListenerReply (org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply)10 DeleteModification (org.opendaylight.controller.cluster.datastore.modification.DeleteModification)10 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)10 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)10 AbstractTest (org.opendaylight.controller.cluster.datastore.AbstractTest)9 RegisterChangeListener (org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener)9 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)9 DOMStoreWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction)9 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)9