public class BindingDOMRpcProviderServiceAdapter extends AbstractBindingAdapter<DOMRpcProviderService>
implements RpcProviderService {
- private static final ImmutableSet<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.EMPTY);
+ private static final ImmutableSet<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.empty());
public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry,
final BindingToNormalizedNodeCodec codec) {
final BindingNormalizedNodeCodecRegistry registry = mock(BindingNormalizedNodeCodecRegistry.class);
final BindingToNormalizedNodeCodec codec =
new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry);
- final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY;
+ final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.empty();
doReturn(yangInstanceIdentifier).when(registry).toYangInstanceIdentifier(any());
doReturn(mock(DOMDataTreeWriteCursor.class)).when(delegate).createCursor(any());
final DOMDataTreeCandidate domDataTreeCandidate = mock(DOMDataTreeCandidate.class);
final DOMDataTreeIdentifier domDataTreeIdentifier =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
doReturn(InstanceIdentifier.create(DataObject.class)).when(registry).fromYangInstanceIdentifier(any());
final BindingCodecTree bindingCodecTree = mock(BindingCodecTree.class);
final BindingDataObjectCodecTreeNode<?> bindingCodecTreeNode = mock(BindingDataObjectCodecTreeNode.class);
doNothing().when(delegate).write(any(), any());
doNothing().when(delegate).merge(any(), any());
doNothing().when(delegate).delete(any());
- doReturn(YangInstanceIdentifier.EMPTY).when(registry).toYangInstanceIdentifier(any());
+ doReturn(YangInstanceIdentifier.empty()).when(registry).toYangInstanceIdentifier(any());
doNothing().when(delegate).close();
final NormalizedNode<?, ?> normalizedNode = mock(NormalizedNode.class);
- doReturn(new SimpleEntry<YangInstanceIdentifier,NormalizedNode<?,?>>(YangInstanceIdentifier.EMPTY,
+ doReturn(new SimpleEntry<YangInstanceIdentifier,NormalizedNode<?,?>>(YangInstanceIdentifier.empty(),
normalizedNode)).when(registry).toNormalizedNode(any(), any());
adapter.write(pathArgument, data);
verify(delegate).write(any(), any());
@Test
public void onMountPointCreatedWithExceptionTest() throws Exception {
reset(listener);
- bindingDOMMountPointListenerAdapter.onMountPointCreated(YangInstanceIdentifier.EMPTY);
+ bindingDOMMountPointListenerAdapter.onMountPointCreated(YangInstanceIdentifier.empty());
verifyZeroInteractions(listener);
}
@Test
public void onMountPointRemovedWithExceptionTest() throws Exception {
reset(listener);
- bindingDOMMountPointListenerAdapter.onMountPointRemoved(YangInstanceIdentifier.EMPTY);
+ bindingDOMMountPointListenerAdapter.onMountPointRemoved(YangInstanceIdentifier.empty());
verifyZeroInteractions(listener);
}
}
\ No newline at end of file
final BindingNormalizedNodeCodecRegistry registry = mock(BindingNormalizedNodeCodecRegistry.class);
final BindingToNormalizedNodeCodec codec =
new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry);
- doReturn(YangInstanceIdentifier.EMPTY).when(registry).toYangInstanceIdentifier(any());
+ doReturn(YangInstanceIdentifier.empty()).when(registry).toYangInstanceIdentifier(any());
final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
final BindingDOMMountPointServiceAdapter adapter =
new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry);
final DOMDataTreeCandidate domDataTreeCandidate = mock(DOMDataTreeCandidate.class);
final DOMDataTreeIdentifier domDataTreeIdentifier =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
doReturn(InstanceIdentifier.create(DataObject.class)).when(registry).fromYangInstanceIdentifier(any());
final BindingCodecTree bindingCodecTree = mock(BindingCodecTree.class);
final BindingDataObjectCodecTreeNode<?> bindingCodecTreeNode = mock(BindingDataObjectCodecTreeNode.class);
@Override
public YangInstanceIdentifier getContextReference() {
- return YangInstanceIdentifier.EMPTY;
+ return YangInstanceIdentifier.empty();
}
}
// Find a DOMRpcImplementation for a wild card. Usually remote-rpc-connector would register an
// implementation this way
final List<DOMRpcImplementation> mayBeRemoteImpls =
- entry.getImplementations(YangInstanceIdentifier.EMPTY);
+ entry.getImplementations(YangInstanceIdentifier.empty());
if (mayBeRemoteImpls != null) {
return mayBeRemoteImpls.get(0)
private static ListenableFuture<DOMRpcResult> invokeGlobalRpc(final GlobalDOMRpcRoutingTableEntry entry,
final NormalizedNode<?, ?> input) {
- return entry.getImplementations(YangInstanceIdentifier.EMPTY).get(0).invokeRpc(entry.getRpcId(), input);
+ return entry.getImplementations(YangInstanceIdentifier.empty()).get(0).invokeRpc(entry.getRpcId(), input);
}
}
}
final DOMDataTreeChangeListener listener = mock(DOMDataTreeChangeListener.class);
doNothing().when(listener).onInitialData();
- domStore.registerTreeChangeListener(YangInstanceIdentifier.EMPTY, listener);
+ domStore.registerTreeChangeListener(YangInstanceIdentifier.empty(), listener);
verify(listener, timeout(1000)).onInitialData();
}
private static final DOMDataTreeIdentifier ROOT_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
- YangInstanceIdentifier.EMPTY);
+ YangInstanceIdentifier.empty());
private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
TestModel.TEST_PATH);
private static final DOMDataTreeIdentifier ROOT_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
- YangInstanceIdentifier.EMPTY);
+ YangInstanceIdentifier.empty());
private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
TestModel.TEST_PATH);
private static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
private static final DOMDataTreeIdentifier ROOT_ID =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
private static final DOMDataTreeIdentifier TEST_ID =
new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH);
private static final DOMDataTreeIdentifier ROOT_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
- YangInstanceIdentifier.EMPTY);
+ YangInstanceIdentifier.empty());
private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
TestModel.TEST_PATH);
private static final DOMDataTreeIdentifier ROOT_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
- YangInstanceIdentifier.EMPTY);
+ YangInstanceIdentifier.empty());
private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
TestModel.TEST_PATH);
private static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
private static final DOMDataTreeIdentifier ROOT_ID =
- new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
private static final DOMDataTreeIdentifier TEST_ID =
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
doNothing().when(listener).onDataTreeChanged(any(), any());
dataTreeService.registerListener(listener,
Collections.singletonList(
- new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)),
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())),
false, Collections.emptyList());
verify(listener, times(2)).onDataTreeChanged(any(), any());
private static final Map<YangInstanceIdentifier, List<NormalizedNode<?, ?>>> TEST_MAP = new HashMap<>();
private static final DOMDataTreeIdentifier ROOT_ID =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
@Mock
private WriteableDOMDataTreeShard rootShard;
cursor.close();
try {
transaction.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
- YangInstanceIdentifier.EMPTY));
+ YangInstanceIdentifier.empty()));
fail("Should have failed, config ds not available to this tx");
} catch (final IllegalArgumentException e) {
assertTrue(e.getMessage().contains("not accessible"));
doReturn(FluentFutures.immediateNullFluentFuture()).when(readTransaction).read(any(), any());
assertNotNull(transactionChainReadTransaction.exists(
- LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY));
- transactionChainReadTransaction.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
- verify(readTransaction, atLeastOnce()).read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty()));
+ transactionChainReadTransaction.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
+ verify(readTransaction, atLeastOnce()).read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
doReturn(FluentFutures.immediateFailedFluentFuture(
new NullPointerException())).when(readTransaction).read(any(), any());
doNothing().when(chainAdapter).transactionFailed(any(), any());
assertNotNull(transactionChainReadTransaction.read(
- LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY));
+ LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty()));
previousWriteTxFuture = FluentFutures.immediateFailedFluentFuture(new NullPointerException());
transactionChainReadTransaction =
new TransactionChainReadTransaction(identifier, readTransaction, previousWriteTxFuture, chainAdapter);
assertNotNull(transactionChainReadTransaction.read(
- LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY));
+ LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty()));
}
}
final UnknownDOMRpcRoutingTableEntry test = new UnknownDOMRpcRoutingTableEntry(SchemaPath.ROOT, emptyImpls);
TEST_LIST.add(testClass);
- emptyImpls.put(YangInstanceIdentifier.EMPTY, TEST_LIST);
+ emptyImpls.put(YangInstanceIdentifier.empty(), TEST_LIST);
assertNotNull(test);
assertNotNull(test.newInstance(emptyImpls));
assertNotNull(OperationInvocation.invoke(test, TEST_CONTAINER));
assertNotNull(test.getImplementations());
- assertEquals(test.getImplementations(YangInstanceIdentifier.EMPTY), TEST_LIST);
- assertTrue(test.containsContext(YangInstanceIdentifier.EMPTY));
- assertTrue(test.registeredIdentifiers().contains(YangInstanceIdentifier.EMPTY));
+ assertEquals(test.getImplementations(YangInstanceIdentifier.empty()), TEST_LIST);
+ assertTrue(test.containsContext(YangInstanceIdentifier.empty()));
+ assertTrue(test.registeredIdentifiers().contains(YangInstanceIdentifier.empty()));
- addList1.add(YangInstanceIdentifier.EMPTY);
+ addList1.add(YangInstanceIdentifier.empty());
addList1.add(YangInstanceIdentifier.of(TestModel.TEST_QNAME));
addList2.add(YangInstanceIdentifier.of(TestModel.TEST2_QNAME));
<L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
final AbstractDOMDataTreeChangeListenerRegistration<L> reg = registerTreeChangeListener(treeId, listener);
- final Optional<NormalizedNode<?, ?>> preExistingData = snapshot.readNode(YangInstanceIdentifier.EMPTY);
+ final Optional<NormalizedNode<?, ?>> preExistingData = snapshot.readNode(YangInstanceIdentifier.empty());
if (!preExistingData.isPresent()) {
listener.onInitialData();
return reg;
}
}
- final DataTreeCandidate candidate = DataTreeCandidates.fromNormalizedNode(YangInstanceIdentifier.EMPTY, data);
+ final DataTreeCandidate candidate = DataTreeCandidates.fromNormalizedNode(YangInstanceIdentifier.empty(), data);
final InMemoryDOMStoreTreeChangePublisher publisher = new InMemoryDOMStoreTreeChangePublisher(
notificationManager);
publisher.registerTreeChangeListener(treeId, listener);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.mdsal.dom.store.inmemory;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import java.util.ArrayList;
void delete(final YangInstanceIdentifier path) {
final YangInstanceIdentifier relativePath = toRelative(path);
- Preconditions.checkArgument(!YangInstanceIdentifier.EMPTY.equals(relativePath),
- "Deletion of shard root is not allowed");
+ checkArgument(!relativePath.isEmpty(), "Deletion of shard root is not allowed");
SimpleCursorOperation.DELETE.apply(getCursor(), relativePath, null);
}
private YangInstanceIdentifier toRelative(final YangInstanceIdentifier path) {
final Optional<YangInstanceIdentifier> relative =
path.relativeTo(modification.getPrefix().getRootIdentifier());
- Preconditions.checkArgument(relative.isPresent());
+ checkArgument(relative.isPresent());
return relative.get();
}
@Override
public void close() {
- Preconditions.checkState(!finished, "Attempting to close an already finished transaction.");
+ checkState(!finished, "Attempting to close an already finished transaction.");
modification.closeTransactions();
if (cursor != null) {
cursor.close();
@Override
public void ready() {
- Preconditions.checkState(!finished, "Attempting to ready an already finished transaction.");
- Preconditions.checkState(cursor == null, "Attempting to ready a transaction that has an open cursor.");
+ checkState(!finished, "Attempting to ready an already finished transaction.");
+ checkState(cursor == null, "Attempting to ready a transaction that has an open cursor.");
requireNonNull(modification, "Attempting to ready an empty transaction.");
LOG.debug("Readying open transaction on shard {}", modification.getPrefix());
LOG.debug("Submitting open transaction on shard {}", modification.getPrefix());
requireNonNull(cohorts);
- Preconditions.checkState(!cohorts.isEmpty(), "Transaction was not readied yet.");
+ checkState(!cohorts.isEmpty(), "Transaction was not readied yet.");
return executor.submit(new ShardSubmitCoordinationTask(modification.getPrefix(), cohorts, this));
}
@Override
public DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
- Preconditions.checkState(!finished, "Transaction is finished/closed already.");
- Preconditions.checkState(cursor == null, "Previous cursor wasn't closed");
+ checkState(!finished, "Transaction is finished/closed already.");
+ checkState(cursor == null, "Previous cursor wasn't closed");
final YangInstanceIdentifier relativePath = toRelative(prefix.getRootIdentifier());
final DOMDataTreeWriteCursor ret = getCursor();
ret.enter(relativePath.getPathArguments());
}
// FIXME: Should there be non-root path?
- DataTreeModificationCursor dataTreeCursor = modification.openCursor(YangInstanceIdentifier.EMPTY).get();
+ DataTreeModificationCursor dataTreeCursor = modification.openCursor(YangInstanceIdentifier.empty()).get();
cursor = DataTreeModificationCursorAdaptor.of(dataTreeCursor);
}
return cursor;
doReturn(listenerRegistration)
.when(READABLE_WRITEABLE_DOM_DATA_TREE_SHARD).registerTreeChangeListener(any(), any());
final DOMDataTreeIdentifier domDataTreeIdentifier =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
final ChildShardContext childShardContext =
new ChildShardContext(domDataTreeIdentifier, READABLE_WRITEABLE_DOM_DATA_TREE_SHARD);
final Map<DOMDataTreeIdentifier, ChildShardContext> childShardContextMap =
doNothing().when(domDataTreeChangeListener).onDataTreeChanged(any());
doNothing().when(domDataTreeChangeListener).onInitialData();
inMemoryDOMDataStore.onGlobalContextUpdated(TestModel.createTestContext());
- inMemoryDOMDataStore.registerTreeChangeListener(YangInstanceIdentifier.EMPTY, domDataTreeChangeListener);
+ inMemoryDOMDataStore.registerTreeChangeListener(YangInstanceIdentifier.empty(), domDataTreeChangeListener);
final AutoCloseable autoCloseable = mock(AutoCloseable.class);
doNothing().when(autoCloseable).close();
final ListenerRegistration<?> listenerRegistration = mock(ListenerRegistration.class);
doReturn(listenerRegistration).when(domDataTreeShard).registerTreeChangeListener(any(), any());
doNothing().when(domDataTreeChangeListener).onDataTreeChanged(any());
- inMemoryDOMDataTreeShard.registerTreeChangeListener(YangInstanceIdentifier.EMPTY, domDataTreeChangeListener);
+ inMemoryDOMDataTreeShard.registerTreeChangeListener(YangInstanceIdentifier.empty(), domDataTreeChangeListener);
verify(domDataTreeShard, atLeastOnce()).registerTreeChangeListener(any(), any());
inMemoryDOMDataTreeShard.onChildDetached(DOM_DATA_TREE_IDENTIFIER, domDataTreeShard);
@Test
public void createTransactionWithException() {
final DOMDataTreeIdentifier domDataTreeIdentifier =
- new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
final InMemoryDOMDataTreeShard inMemoryDOMDataTreeShard =
InMemoryDOMDataTreeShard.create(domDataTreeIdentifier,
@Before
public void setUp() throws Exception {
- doReturn(YangInstanceIdentifier.EMPTY).when(DATA_TREE_CANDIDATE).getRootPath();
+ doReturn(YangInstanceIdentifier.empty()).when(DATA_TREE_CANDIDATE).getRootPath();
doReturn("testDataTreeCandidate").when(DATA_TREE_CANDIDATE).toString();
doReturn(DATA_TREE_CANDIDATE_NODE).when(DATA_TREE_CANDIDATE).getRootNode();
doReturn(DATA_TREE_CANDIDATE).when(DATA_TREE).prepare(any());
@Test
public void canCommitWithDataValidationFailedExceptionTest() throws Exception {
- doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "testException"))
+ doThrow(new DataValidationFailedException(YangInstanceIdentifier.empty(), "testException"))
.when(DATA_TREE).validate(any());
try {
IN_MEMORY_DOM_DATA_TREE_SHARD_THREE_PHASE_COMMIT_COHORT.canCommit().get();
@SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = OptimisticLockFailedException.class)
public void canCommitTestWithOptimisticLockFailedException() throws Throwable {
- doThrow(new ConflictingModificationAppliedException(YangInstanceIdentifier.EMPTY, "testException"))
+ doThrow(new ConflictingModificationAppliedException(YangInstanceIdentifier.empty(), "testException"))
.when(IN_MEMORY_DOM_DATA_STORE).validate(any());
try {
inMemoryDOMStoreThreePhaseCommitCohort.canCommit().get();
@SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = TransactionCommitFailedException.class)
public void canCommitTestWithTransactionCommitFailedException() throws Throwable {
- doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "testException"))
+ doThrow(new DataValidationFailedException(YangInstanceIdentifier.empty(), "testException"))
.when(IN_MEMORY_DOM_DATA_STORE).validate(any());
try {
inMemoryDOMStoreThreePhaseCommitCohort.canCommit().get();
doReturn(cursorAwareDataTreeModification).when(cursorAwareDataTreeSnapshot).newModification();
doNothing().when(cursorAwareDataTreeModification).ready();
doReturn(Optional.of(dataTreeModificationCursor))
- .when(cursorAwareDataTreeModification).openCursor(YangInstanceIdentifier.EMPTY);
+ .when(cursorAwareDataTreeModification).openCursor(YangInstanceIdentifier.empty());
doNothing().when(dataTreeModificationCursor).close();
final ShardRootModificationContext shardRootModificationContext =
assertNotNull(dataTreeModificationCursorAdaptor);
assertTrue(shardRootModificationContext.isModified());
verify(cursorAwareDataTreeSnapshot).newModification();
- verify(cursorAwareDataTreeModification).openCursor(YangInstanceIdentifier.EMPTY);
+ verify(cursorAwareDataTreeModification).openCursor(YangInstanceIdentifier.empty());
shardRootModificationContext.ready();
verify(cursorAwareDataTreeModification).ready();
final class TestUtils {
static final DOMDataTreeIdentifier DOM_DATA_TREE_IDENTIFIER =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
static final PathArgument PATH_ARGUMENT = mock(PathArgument.class);
final class TestUtils {
static final DOMDataTreeIdentifier DOM_DATA_TREE_IDENTIFIER =
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
static final PathArgument PATH_ARGUMENT = mock(PathArgument.class);
final NormalizedNode<?, ?> testNode = mock(NormalizedNode.class);
final Optional<NormalizedNode<?, ?>> optional = Optional.of(testNode);
doReturn("testNode").when(testNode).toString();
- doReturn(Optional.of(testNode)).when(DATA_TREE_SNAPSHOT).readNode(YangInstanceIdentifier.EMPTY);
- assertTrue(snapshotBackedReadTransaction.exists(YangInstanceIdentifier.EMPTY).get());
+ doReturn(Optional.of(testNode)).when(DATA_TREE_SNAPSHOT).readNode(YangInstanceIdentifier.empty());
+ assertTrue(snapshotBackedReadTransaction.exists(YangInstanceIdentifier.empty()).get());
- assertEquals(optional, snapshotBackedReadTransaction.read(YangInstanceIdentifier.EMPTY).get());
+ assertEquals(optional, snapshotBackedReadTransaction.read(YangInstanceIdentifier.empty()).get());
final Field stableSnapshotField = SnapshotBackedReadTransaction.class.getDeclaredField("stableSnapshot");
stableSnapshotField.setAccessible(true);
public void readTestWithException() throws Throwable {
snapshotBackedReadTransaction.close();
try {
- snapshotBackedReadTransaction.read(YangInstanceIdentifier.EMPTY).get();
+ snapshotBackedReadTransaction.read(YangInstanceIdentifier.empty()).get();
fail("Expected ReadFailedException");
} catch (Exception e) {
throw e.getCause();
snapshotBackedReadTransaction = new SnapshotBackedReadTransaction<>(new Object(), false, DATA_TREE_SNAPSHOT,
null);
try {
- snapshotBackedReadTransaction.read(YangInstanceIdentifier.EMPTY).get();
+ snapshotBackedReadTransaction.read(YangInstanceIdentifier.empty()).get();
fail("Expected ReadFailedException");
} catch (Exception e) {
throw e.getCause();
doThrow(new NullPointerException("no Node")).when(DATA_TREE_SNAPSHOT).readNode(any());
try {
- snapshotBackedReadTransaction.exists(YangInstanceIdentifier.EMPTY).get();
+ snapshotBackedReadTransaction.exists(YangInstanceIdentifier.empty()).get();
fail("Expected ReadFailedException");
} catch (Exception e) {
throw e.getCause();
final NormalizedNode<?, ?> testNode = mock(NormalizedNode.class);
final Optional<NormalizedNode<?, ?>> optional = Optional.of(testNode);
doReturn("testNode").when(testNode).toString();
- doReturn(Optional.of(testNode)).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.EMPTY);
- assertTrue(snapshotBackedReadWriteTransaction.exists(YangInstanceIdentifier.EMPTY).get());
- assertEquals(optional, snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get());
+ doReturn(Optional.of(testNode)).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.empty());
+ assertTrue(snapshotBackedReadWriteTransaction.exists(YangInstanceIdentifier.empty()).get());
+ assertEquals(optional, snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.empty()).get());
}
@SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = ReadFailedException.class)
public void readTestWithNullException() throws Throwable {
- doReturn(null).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.EMPTY);
+ doReturn(null).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.empty());
try {
- snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get();
+ snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.empty()).get();
fail("Expected ReadFailedException");
} catch (ExecutionException e) {
throw e.getCause();
public void readNodeTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_MODIFICATION).readNode(any());
try {
- snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get();
+ snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.empty()).get();
fail("Expected ReadFailedException");
} catch (ExecutionException e) {
throw e.getCause();
public void existsTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_MODIFICATION).readNode(any());
try {
- snapshotBackedReadWriteTransaction.exists(YangInstanceIdentifier.EMPTY).get();
+ snapshotBackedReadWriteTransaction.exists(YangInstanceIdentifier.empty()).get();
fail("Expected ReadFailedException");
} catch (ExecutionException e) {
throw e.getCause();
doReturn(DOM_STORE_THREE_PHASE_COMMIT_COHORT)
.when(TRANSACTION_READY_PROTOTYPE)
.transactionReady(any(),any(), any());
- doReturn(NORMALIZED_NODE_OPTIONAL).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.EMPTY);
+ doReturn(NORMALIZED_NODE_OPTIONAL).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.empty());
snapshotBackedWriteTransaction = new SnapshotBackedWriteTransaction<>(new Object(), false, DATA_TREE_SNAPSHOT,
TRANSACTION_READY_PROTOTYPE);
}
@Test
public void basicTest() throws Exception {
- snapshotBackedWriteTransaction.write(YangInstanceIdentifier.EMPTY, NORMALIZED_NODE);
+ snapshotBackedWriteTransaction.write(YangInstanceIdentifier.empty(), NORMALIZED_NODE);
verify(DATA_TREE_MODIFICATION).write(any(), any());
- snapshotBackedWriteTransaction.merge(YangInstanceIdentifier.EMPTY, NORMALIZED_NODE);
+ snapshotBackedWriteTransaction.merge(YangInstanceIdentifier.empty(), NORMALIZED_NODE);
verify(DATA_TREE_MODIFICATION).merge(any(), any());
- snapshotBackedWriteTransaction.delete(YangInstanceIdentifier.EMPTY);
+ snapshotBackedWriteTransaction.delete(YangInstanceIdentifier.empty());
verify(DATA_TREE_MODIFICATION).delete(any());
assertEquals(NORMALIZED_NODE_OPTIONAL,
- snapshotBackedWriteTransaction.readSnapshotNode(YangInstanceIdentifier.EMPTY));
+ snapshotBackedWriteTransaction.readSnapshotNode(YangInstanceIdentifier.empty()));
verify(DATA_TREE_MODIFICATION).readNode(any());
assertTrue(snapshotBackedWriteTransaction.addToStringAttributes(
doAnswer(inv -> {
throw new TestException();
}).when(DATA_TREE_MODIFICATION).write(any(), any());
- snapshotBackedWriteTransaction.write(YangInstanceIdentifier.EMPTY, NORMALIZED_NODE);
+ snapshotBackedWriteTransaction.write(YangInstanceIdentifier.empty(), NORMALIZED_NODE);
}
@Test(expected = IllegalArgumentException.class)
doAnswer(inv -> {
throw new TestException();
}).when(DATA_TREE_MODIFICATION).merge(any(), any());
- snapshotBackedWriteTransaction.merge(YangInstanceIdentifier.EMPTY, NORMALIZED_NODE);
+ snapshotBackedWriteTransaction.merge(YangInstanceIdentifier.empty(), NORMALIZED_NODE);
}
@Test(expected = IllegalArgumentException.class)
doAnswer(inv -> {
throw new TestException();
}).when(DATA_TREE_MODIFICATION).delete(any());
- snapshotBackedWriteTransaction.delete(YangInstanceIdentifier.EMPTY);
+ snapshotBackedWriteTransaction.delete(YangInstanceIdentifier.empty());
}
private static final class TestException extends Exception {