use of org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest in project netconf by opendaylight.
the class ReadTransactionActorTestAdapter method testRead.
@Test
public void testRead() {
doReturn(immediateFluentFuture(Optional.of(NODE))).when(mockReadTx).read(STORE, PATH);
actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
verify(mockReadTx).read(STORE, PATH);
final NormalizedNodeMessage response = probe.expectMsgClass(NormalizedNodeMessage.class);
assertEquals(NODE, response.getNode());
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest in project netconf by opendaylight.
the class ProxyReadWriteTransactionTest method testRead.
@Test
public void testRead() throws Exception {
ProxyReadWriteTransaction tx = newSuccessfulProxyTx();
final ListenableFuture<Optional<NormalizedNode>> read = tx.read(STORE, PATH);
final ReadRequest readRequest = masterActor.expectMsgClass(ReadRequest.class);
assertEquals(STORE, readRequest.getStore());
assertEquals(PATH, readRequest.getPath());
masterActor.reply(new NormalizedNodeMessage(PATH, node));
final Optional<NormalizedNode> result = read.get(5, TimeUnit.SECONDS);
assertTrue(result.isPresent());
assertEquals(node, result.get());
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest in project netconf by opendaylight.
the class ReadTransactionActorTestAdapter method testReadEmpty.
@Test
public void testReadEmpty() {
doReturn(immediateFluentFuture(Optional.empty())).when(mockReadTx).read(STORE, PATH);
actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
verify(mockReadTx).read(STORE, PATH);
probe.expectMsgClass(EmptyReadResponse.class);
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest in project netconf by opendaylight.
the class ReadTransactionActorTestAdapter method testReadFailure.
@Test
public void testReadFailure() {
final ReadFailedException cause = new ReadFailedException("fail");
doReturn(immediateFailedFluentFuture(cause)).when(mockReadTx).read(STORE, PATH);
actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
verify(mockReadTx).read(STORE, PATH);
final Failure response = probe.expectMsgClass(Failure.class);
assertEquals(cause, response.cause());
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest in project netconf by opendaylight.
the class ActorProxyTransactionFacade method read.
@Override
public FluentFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
LOG.debug("{}: Read {} {} via actor {}", id, store, path, masterTxActor);
final Future<Object> future = Patterns.ask(masterTxActor, new ReadRequest(store, path), askTimeout);
final SettableFuture<Optional<NormalizedNode>> settableFuture = SettableFuture.create();
future.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable failure, final Object response) {
if (failure != null) {
LOG.debug("{}: Read {} {} failed", id, store, path, failure);
final Throwable processedFailure = processFailure(failure);
if (processedFailure instanceof ReadFailedException) {
settableFuture.setException(processedFailure);
} else {
settableFuture.setException(new ReadFailedException("Read of store " + store + " path " + path + " failed", processedFailure));
}
return;
}
LOG.debug("{}: Read {} {} succeeded: {}", id, store, path, response);
if (response instanceof EmptyReadResponse) {
settableFuture.set(Optional.empty());
return;
}
if (response instanceof NormalizedNodeMessage) {
final NormalizedNodeMessage data = (NormalizedNodeMessage) response;
settableFuture.set(Optional.of(data.getNode()));
}
}
}, executionContext);
return FluentFuture.from(settableFuture);
}
Aggregations