use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project genius by opendaylight.
the class DataTreeEventCallbackRegistrarTest method testExceptionInCallbackMustBeLogged.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testExceptionInCallbackMustBeLogged() throws TransactionCommitFailedException, InterruptedException {
logCaptureRule.expectLastErrorMessageContains("Error invoking worker");
DataBroker spiedDataBroker = spy(db);
final DataTreeChangeListener mockListener = mock(DataTreeChangeListener.class, "TestListener");
doAnswer(invocation -> db.registerDataTreeChangeListener(invocation.getArgument(0), mockListener)).when(spiedDataBroker).registerDataTreeChangeListener(any(), any());
AtomicBoolean added = new AtomicBoolean(false);
DataTreeEventCallbackRegistrar dataTreeEventCallbackRegistrar = new DataTreeEventCallbackRegistrarImpl(spiedDataBroker);
dataTreeEventCallbackRegistrar.onAdd(OPERATIONAL, FOO_PATH, (Function<TopLevelList, NextAction>) topLevelList -> {
added.set(true);
throw new IllegalStateException("TEST");
});
ArgumentCaptor<DataTreeChangeListener> realListener = ArgumentCaptor.forClass(DataTreeChangeListener.class);
verify(spiedDataBroker).registerDataTreeChangeListener(any(), realListener.capture());
AtomicBoolean onDataTreeChangeDone = new AtomicBoolean(false);
doAnswer(invocation -> {
try {
realListener.getValue().onDataTreeChanged(invocation.getArgument(0));
} finally {
onDataTreeChangeDone.set(true);
}
return null;
}).when(mockListener).onDataTreeChanged(anyCollection());
db1.syncWrite(OPERATIONAL, FOO_PATH, FOO_DATA);
await().untilTrue(added);
await().untilTrue(onDataTreeChangeDone);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewTypedWriteOnlyTransactionAndSubmitPutSuccessfully.
@Test
public void testCallWithNewTypedWriteOnlyTransactionAndSubmitPutSuccessfully() throws Exception {
TopLevelList data = newTestDataObject();
managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> writeTx.put(TEST_PATH, data)).get();
assertEquals(data, singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewTypedReadWriteTransactionAndSubmitPutSuccessfully.
@Test
public void testCallWithNewTypedReadWriteTransactionAndSubmitPutSuccessfully() throws Exception {
TopLevelList data = newTestDataObject();
managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> tx.put(TEST_PATH, data)).get();
assertEquals(data, singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewReadWriteTransactionAndSubmitPutSuccessfully.
@Test
public void testCallWithNewReadWriteTransactionAndSubmitPutSuccessfully() throws Exception {
TopLevelList data = newTestDataObject();
managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, data)).get();
assertEquals(data, singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewWriteOnlyTransactionAndSubmitPutSuccessfully.
@Test
public void testCallWithNewWriteOnlyTransactionAndSubmitPutSuccessfully() throws Exception {
TopLevelList data = newTestDataObject();
managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTx -> writeTx.put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, data)).get();
assertEquals(data, singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Aggregations