import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
askAndAwait(cohortActor, new Commit(txId2));
}
- @SuppressWarnings("unchecked")
@Test
public void testAsyncCohort() throws Exception {
ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
doReturn(executeWithDelay(executor, mockPostCanCommit))
- .when(mockCohort).canCommit(any(Object.class), any(SchemaContext.class), any(Collection.class));
+ .when(mockCohort).canCommit(any(Object.class), any(SchemaContext.class), anyCollection());
doReturn(executor.submit(() -> mockPostPreCommit)).when(mockPostCanCommit).preCommit();
executor.shutdownNow();
}
- @SuppressWarnings("unchecked")
@Test
public void testFailureOnCanCommit() throws Exception {
DataValidationFailedException failure = new DataValidationFailedException(YangInstanceIdentifier.empty(),
"mock");
doReturn(FluentFutures.immediateFailedFluentFuture(failure)).when(mockCohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
ActorRef cohortActor = newCohortActor("testFailureOnCanCommit");
return actorFactory.createActor(DataTreeCohortActor.props(mockCohort, YangInstanceIdentifier.empty()), name);
}
- @SuppressWarnings("unchecked")
private void resetMockCohort() {
reset(mockCohort);
doReturn(ThreePhaseCommitStep.NOOP_ABORT_FUTURE).when(mockPostCanCommit).abort();
doReturn(Futures.immediateFuture(mockPostPreCommit)).when(mockPostCanCommit).preCommit();
doReturn(FluentFutures.immediateFluentFuture(mockPostCanCommit)).when(mockCohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
doReturn(ThreePhaseCommitStep.NOOP_ABORT_FUTURE).when(mockPostPreCommit).abort();
doReturn(Futures.immediateFuture(null)).when(mockPostPreCommit).commit();
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
public void testSuccessfulCanCommitWithNoopPostStep() throws Exception {
final DOMDataTreeCommitCohort cohort = mock(DOMDataTreeCommitCohort.class);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
ArgumentCaptor<Collection> candidateCapt = ArgumentCaptor.forClass(Collection.class);
IntegrationTestKit kit = new IntegrationTestKit(getSystem(), datastoreContextBuilder);
reset(cohort);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
kit.testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH,
ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
.withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 42))
.build());
- verify(cohort).canCommit(any(Object.class), any(SchemaContext.class), any(Collection.class));
+ verify(cohort).canCommit(any(Object.class), any(SchemaContext.class), anyCollection());
cohortReg.close();
}
}
- @SuppressWarnings("unchecked")
@Test
public void testFailedCanCommit() throws Exception {
final DOMDataTreeCommitCohort failedCohort = mock(DOMDataTreeCommitCohort.class);
doReturn(FAILED_CAN_COMMIT_FUTURE).when(failedCohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
IntegrationTestKit kit = new IntegrationTestKit(getSystem(), datastoreContextBuilder);
try (AbstractDataStore dataStore = kit.setupAbstractDataStore(
public void testCanCommitWithListEntries() throws Exception {
final DOMDataTreeCommitCohort cohort = mock(DOMDataTreeCommitCohort.class);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
IntegrationTestKit kit = new IntegrationTestKit(getSystem(), datastoreContextBuilder);
try (AbstractDataStore dataStore = kit.setupAbstractDataStore(
reset(cohort);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
writeTx = dataStore.newWriteOnlyTransaction();
final YangInstanceIdentifier sportagePath = CarsModel.newCarPath("sportage");
reset(cohort);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
writeTx = dataStore.newWriteOnlyTransaction();
writeTx.delete(CarsModel.BASE_PATH);
* DataTreeCandidate) and since currently preCommit is a noop in the Shard backend (it is combined with commit),
* we can't actually test abort after canCommit.
*/
- @SuppressWarnings("unchecked")
@Test
@Ignore
public void testAbortAfterCanCommit() throws Exception {
doReturn(ThreePhaseCommitStep.NOOP_ABORT_FUTURE).when(stepToAbort).abort();
doReturn(PostPreCommitStep.NOOP_FUTURE).when(stepToAbort).preCommit();
doReturn(FluentFutures.immediateFluentFuture(stepToAbort)).when(cohortToAbort).canCommit(any(Object.class),
- any(SchemaContext.class), any(Collection.class));
+ any(SchemaContext.class), anyCollection());
IntegrationTestKit kit = new IntegrationTestKit(getSystem(), datastoreContextBuilder);
try (AbstractDataStore dataStore = kit.setupAbstractDataStore(