import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
public class RestconfStreamsSubscriptionServiceImplTest {
- private static final String uri = "/restconf/18/data/ietf-restconf-monitoring:restconf-state/streams/stream/"
+ private static final String URI = "/restconf/18/data/ietf-restconf-monitoring:restconf-state/streams/stream/"
+ "toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE";
private static Field listenersByStreamName;
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
final DOMDataReadWriteTransaction rwTx = Mockito.mock(DOMDataReadWriteTransaction.class);
- final CheckedFuture checkedFuture = Futures.immediateCheckedFuture(true);
+ final CheckedFuture<Boolean, ReadFailedException> checkedFuture = Futures.immediateCheckedFuture(Boolean.TRUE);
Mockito.when(rwTx.exists(Mockito.any(), Mockito.any())).thenReturn(checkedFuture);
- final CheckedFuture checkedFutureEmpty = Futures.immediateCheckedFuture("");
+ final CheckedFuture<Void, TransactionCommitFailedException> checkedFutureEmpty =
+ Futures.immediateCheckedFuture(null);
Mockito.when(rwTx.submit()).thenReturn(checkedFutureEmpty);
Mockito.when(domTx.newReadWriteTransaction()).thenReturn(rwTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
- final Object valueObj = null;
- Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ Mockito.when(checked.checkedGet()).thenReturn(null);
this.schemaHandler = new SchemaContextHandler(txHandler);
final DOMDataBroker dataBroker = mock(DOMDataBroker.class);
@Test
public void testSubscribeToStream() throws Exception {
- final UriBuilder uriBuilder = UriBuilder.fromUri(uri);
+ final UriBuilder uriBuilder = UriBuilder.fromUri(URI);
final ListenerAdapter createListener = Notificator.createListener(
IdentifierCodec.deserialize("toaster:toaster/toasterStatus", this.schemaHandler.get()),
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
this.uriInfo);
assertEquals(
- "ws://:8181/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
- response.getNewHeaders().get("Location").toString());
+ "ws://:8181/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
+ response.getNewHeaders().get("Location").toString());
}
@Test(expected = RestconfDocumentedException.class)
public void testSubscribeToStreamMissingDatastoreInPath() {
- final UriBuilder uriBuilder = UriBuilder.fromUri(uri);
+ final UriBuilder uriBuilder = UriBuilder.fromUri(URI);
doReturn(uriBuilder).when(this.uriInfo).getAbsolutePathBuilder();
final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
new RestconfStreamsSubscriptionServiceImpl(this.dataBrokerHandler, this.notificationServiceHandler,
@Test(expected = RestconfDocumentedException.class)
public void testSubscribeToStreamMissingScopeInPath() {
- final UriBuilder uriBuilder = UriBuilder.fromUri(uri);
+ final UriBuilder uriBuilder = UriBuilder.fromUri(URI);
doReturn(uriBuilder).when(this.uriInfo).getAbsolutePathBuilder();
final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
new RestconfStreamsSubscriptionServiceImpl(this.dataBrokerHandler, this.notificationServiceHandler,