use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip in project controller by opendaylight.
the class SimpleShardDataTreeCohortTest method preCommitSuccess.
private DataTreeCandidateTip preCommitSuccess() {
final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class);
doAnswer(invocation -> {
invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).successfulPreCommit(mockCandidate);
return null;
}).when(mockShardDataTree).startPreCommit(cohort);
@SuppressWarnings("unchecked") final FutureCallback<DataTreeCandidate> callback = mock(FutureCallback.class);
cohort.preCommit(callback);
verify(callback).onSuccess(mockCandidate);
verifyNoMoreInteractions(callback);
assertSame("getCandidate", mockCandidate, cohort.getCandidate());
return mockCandidate;
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip in project controller by opendaylight.
the class SimpleShardDataTreeCohortTest method testCommitWithIllegalArgumentEx.
@Test
public void testCommitWithIllegalArgumentEx() {
canCommitSuccess();
final DataTreeCandidateTip candidate = preCommitSuccess();
final Exception cause = new IllegalArgumentException("mock");
doAnswer(invocation -> {
invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).failedCommit(cause);
return null;
}).when(mockShardDataTree).startCommit(cohort, candidate);
@SuppressWarnings("unchecked") final FutureCallback<UnsignedLong> callback = mock(FutureCallback.class);
cohort.commit(callback);
verify(callback).onFailure(cause);
verifyNoMoreInteractions(callback);
verify(mockUserCohorts).abort();
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip in project controller by opendaylight.
the class SimpleShardDataTreeCohortTest method testPreCommitAndCommitSuccess.
@Test
public void testPreCommitAndCommitSuccess() throws Exception {
canCommitSuccess();
final DataTreeCandidateTip candidate = preCommitSuccess();
doAnswer(invocation -> {
invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).successfulCommit(UnsignedLong.valueOf(0), () -> {
});
return null;
}).when(mockShardDataTree).startCommit(cohort, candidate);
@SuppressWarnings("unchecked") final FutureCallback<UnsignedLong> mockCommitCallback = mock(FutureCallback.class);
cohort.commit(mockCommitCallback);
verify(mockCommitCallback).onSuccess(any(UnsignedLong.class));
verifyNoMoreInteractions(mockCommitCallback);
verify(mockUserCohorts).commit();
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip in project controller by opendaylight.
the class AbstractShardTest method mockUnmodifiedCandidate.
static DataTreeCandidateTip mockUnmodifiedCandidate(final String name) {
final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
doReturn(ModificationType.UNMODIFIED).when(mockCandidateNode).getModificationType();
doReturn(YangInstanceIdentifier.EMPTY).when(mockCandidate).getRootPath();
doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
return mockCandidate;
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip in project controller by opendaylight.
the class AbstractShardTest method mockCandidate.
public static DataTreeCandidateTip mockCandidate(final String name) {
final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
doReturn(ModificationType.WRITE).when(mockCandidateNode).getModificationType();
doReturn(Optional.of(ImmutableNodes.containerNode(CarsModel.CARS_QNAME))).when(mockCandidateNode).getDataAfter();
doReturn(CarsModel.BASE_PATH).when(mockCandidate).getRootPath();
doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
return mockCandidate;
}
Aggregations