import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import org.junit.Assert;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public class ReadWriteTxTest {
@Mock
verify(delegateWriteTx).merge(LogicalDatastoreType.CONFIGURATION, id2, leafNode);
tx.delete(LogicalDatastoreType.CONFIGURATION, id2);
verify(delegateWriteTx).delete(LogicalDatastoreType.CONFIGURATION, id2);
- tx.submit();
- verify(delegateWriteTx).submit();
- }
-
- @Test
- public void commit() throws Exception {
tx.commit();
verify(delegateWriteTx).commit();
}
@Test
public void exists() throws Exception {
final YangInstanceIdentifier id = TxTestUtils.getContainerId();
- final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> resultFuture =
- Futures.immediateCheckedFuture(Optional.of(TxTestUtils.getContainerNode()));
- when(delegateReadTx.read(LogicalDatastoreType.CONFIGURATION, id)).thenReturn(resultFuture);
+ final CheckedFuture<Boolean, ReadFailedException> resultFuture =
+ Futures.immediateCheckedFuture(true);
+ when(delegateReadTx.exists(LogicalDatastoreType.CONFIGURATION, id)).thenReturn(resultFuture);
final CheckedFuture<Boolean, ReadFailedException> exists = tx.exists(LogicalDatastoreType.CONFIGURATION, id);
Assert.assertTrue(exists.get());
}
Assert.assertNotEquals(tx.getIdentifier(), tx2.getIdentifier());
}
-}
\ No newline at end of file
+}