Search in sources :

Example 1 with DataExistsReply

use of org.opendaylight.controller.cluster.datastore.messages.DataExistsReply in project controller by opendaylight.

the class ShardTransactionTest method testOnReceiveDataExistsPositive.

@Test
public void testOnReceiveDataExistsPositive() throws Exception {
    new TestKit(getSystem()) {

        {
            testOnReceiveDataExistsPositive(newTransactionActor(RO, readOnlyTransaction(), "testDataExistsPositiveRO"));
            testOnReceiveDataExistsPositive(newTransactionActor(RW, readWriteTransaction(), "testDataExistsPositiveRW"));
        }

        private void testOnReceiveDataExistsPositive(final ActorRef transaction) {
            transaction.tell(new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), getRef());
            DataExistsReply reply = expectMsgClass(duration("5 seconds"), DataExistsReply.class);
            assertTrue(reply.exists());
        }
    };
}
Also used : ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) DataExists(org.opendaylight.controller.cluster.datastore.messages.DataExists) DataExistsReply(org.opendaylight.controller.cluster.datastore.messages.DataExistsReply) TestKit(akka.testkit.javadsl.TestKit) Test(org.junit.Test)

Example 2 with DataExistsReply

use of org.opendaylight.controller.cluster.datastore.messages.DataExistsReply in project controller by opendaylight.

the class ShardTransaction method dataExists.

protected void dataExists(final AbstractShardDataTreeTransaction<?> transaction, final DataExists message) {
    if (checkClosed(transaction)) {
        return;
    }
    final YangInstanceIdentifier path = message.getPath();
    boolean exists = transaction.getSnapshot().readNode(path).isPresent();
    getSender().tell(new DataExistsReply(exists, message.getVersion()).toSerializable(), getSelf());
}
Also used : DataExistsReply(org.opendaylight.controller.cluster.datastore.messages.DataExistsReply) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 3 with DataExistsReply

use of org.opendaylight.controller.cluster.datastore.messages.DataExistsReply in project controller by opendaylight.

the class ShardTransactionTest method testOnReceiveDataExistsNegative.

@Test
public void testOnReceiveDataExistsNegative() throws Exception {
    new TestKit(getSystem()) {

        {
            testOnReceiveDataExistsNegative(newTransactionActor(RO, readOnlyTransaction(), "testDataExistsNegativeRO"));
            testOnReceiveDataExistsNegative(newTransactionActor(RW, readWriteTransaction(), "testDataExistsNegativeRW"));
        }

        private void testOnReceiveDataExistsNegative(final ActorRef transaction) {
            transaction.tell(new DataExists(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION), getRef());
            DataExistsReply reply = expectMsgClass(duration("5 seconds"), DataExistsReply.class);
            assertFalse(reply.exists());
        }
    };
}
Also used : ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) DataExists(org.opendaylight.controller.cluster.datastore.messages.DataExists) DataExistsReply(org.opendaylight.controller.cluster.datastore.messages.DataExistsReply) TestKit(akka.testkit.javadsl.TestKit) Test(org.junit.Test)

Aggregations

DataExistsReply (org.opendaylight.controller.cluster.datastore.messages.DataExistsReply)3 ActorRef (akka.actor.ActorRef)2 TestActorRef (akka.testkit.TestActorRef)2 TestKit (akka.testkit.javadsl.TestKit)2 Test (org.junit.Test)2 DataExists (org.opendaylight.controller.cluster.datastore.messages.DataExists)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1