- system = ActorSystem.apply();
- probe = TestProbe.apply(system);
- actorRef = TestActorRef.create(system, ReadTransactionActor.props(deviceReadTx), "testA");
- }
-
- @After
- public void tearDown() throws Exception {
- JavaTestKit.shutdownActorSystem(system, null, true);
- }
-
- @Test
- public void testRead() throws Exception {
- final ContainerNode node = Builders.containerBuilder()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
- .build();
- when(deviceReadTx.read(STORE, PATH)).thenReturn(Futures.immediateCheckedFuture(Optional.of(node)));
- actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
- verify(deviceReadTx).read(STORE, PATH);
- probe.expectMsgClass(NormalizedNodeMessage.class);
- }
-
- @Test
- public void testReadEmpty() throws Exception {
- when(deviceReadTx.read(STORE, PATH)).thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
- actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
- verify(deviceReadTx).read(STORE, PATH);
- probe.expectMsgClass(EmptyReadResponse.class);
- }
-
- @Test
- public void testReadFailure() throws Exception {
- final ReadFailedException cause = new ReadFailedException("fail");
- when(deviceReadTx.read(STORE, PATH)).thenReturn(Futures.immediateFailedCheckedFuture(cause));
- actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
- verify(deviceReadTx).read(STORE, PATH);
- probe.expectMsg(cause);
- }
-
- @Test
- public void testExists() throws Exception {
- when(deviceReadTx.exists(STORE, PATH)).thenReturn(Futures.immediateCheckedFuture(true));
- actorRef.tell(new ExistsRequest(STORE, PATH), probe.ref());
- verify(deviceReadTx).exists(STORE, PATH);
- probe.expectMsg(true);