X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FSimpleShardDataTreeCohortTest.java;h=7a4cb9b5efecc3233826c92f6ac7331bce478e4a;hb=9905bf0575ff196a531eb114e89b1bdb7226bc6c;hp=4550894fed33c07f30d8e7ba6b2a133df387297a;hpb=f81bccec7ac422dbcfdfba70dcfa22f9824b8e4c;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java index 4550894fed..7a4cb9b5ef 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertSame; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -53,24 +53,24 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { private SimpleShardDataTreeCohort cohort; @Before - public void setup() throws Exception { + public void setup() { MockitoAnnotations.initMocks(this); doReturn(Optional.empty()).when(mockUserCohorts).commit(); doReturn(Optional.empty()).when(mockUserCohorts).abort(); cohort = new SimpleShardDataTreeCohort(mockShardDataTree, mockModification, nextTransactionId(), - mockUserCohorts); + mockUserCohorts, Optional.empty()); } @Test - public void testCanCommitSuccess() throws Exception { + public void testCanCommitSuccess() { canCommitSuccess(); } private void canCommitSuccess() { doAnswer(invocation -> { - invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).successfulCanCommit(); + invocation.getArgument(0).successfulCanCommit(); return null; }).when(mockShardDataTree).startCanCommit(cohort); @@ -82,9 +82,9 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { verifyNoMoreInteractions(callback); } - private void testValidatationPropagates(final Exception cause) throws DataValidationFailedException { + private void testValidatationPropagates(final Exception cause) { doAnswer(invocation -> { - invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).failedCanCommit(cause); + invocation.getArgument(0).failedCanCommit(cause); return null; }).when(mockShardDataTree).startCanCommit(cohort); @@ -97,24 +97,24 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { } @Test - public void testCanCommitWithConflictingModEx() throws DataValidationFailedException { + public void testCanCommitWithConflictingModEx() { testValidatationPropagates(new ConflictingModificationAppliedException(YangInstanceIdentifier.EMPTY, "mock")); } @Test - public void testCanCommitWithDataValidationEx() throws DataValidationFailedException { + public void testCanCommitWithDataValidationEx() { testValidatationPropagates(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "mock")); } @Test - public void testCanCommitWithIllegalArgumentEx() throws DataValidationFailedException { + public void testCanCommitWithIllegalArgumentEx() { testValidatationPropagates(new IllegalArgumentException("mock")); } private DataTreeCandidateTip preCommitSuccess() { final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class); doAnswer(invocation -> { - invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).successfulPreCommit(mockCandidate); + invocation.getArgument(0).successfulPreCommit(mockCandidate); return null; }).when(mockShardDataTree).startPreCommit(cohort); @@ -131,13 +131,12 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { } @Test - public void testPreCommitAndCommitSuccess() throws Exception { + public void testPreCommitAndCommitSuccess() { canCommitSuccess(); final DataTreeCandidateTip candidate = preCommitSuccess(); doAnswer(invocation -> { - invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).successfulCommit(UnsignedLong.valueOf(0), - () -> { }); + invocation.getArgument(0).successfulCommit(UnsignedLong.valueOf(0), () -> { }); return null; }).when(mockShardDataTree).startCommit(cohort, candidate); @@ -152,12 +151,12 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { } @Test - public void testPreCommitWithIllegalArgumentEx() throws Exception { + public void testPreCommitWithIllegalArgumentEx() { canCommitSuccess(); final Exception cause = new IllegalArgumentException("mock"); doAnswer(invocation -> { - invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).failedPreCommit(cause); + invocation.getArgument(0).failedPreCommit(cause); return null; }).when(mockShardDataTree).startPreCommit(cohort); @@ -172,7 +171,7 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { } @Test - public void testPreCommitWithReportedFailure() throws Exception { + public void testPreCommitWithReportedFailure() { canCommitSuccess(); final Exception cause = new IllegalArgumentException("mock"); @@ -195,7 +194,7 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { final Exception cause = new IllegalArgumentException("mock"); doAnswer(invocation -> { - invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).failedCommit(cause); + invocation.getArgument(0).failedCommit(cause); return null; }).when(mockShardDataTree).startCommit(cohort, candidate);