本文整理汇总了Java中org.mockito.AdditionalMatchers类的典型用法代码示例。如果您正苦于以下问题:Java AdditionalMatchers类的具体用法?Java AdditionalMatchers怎么用?Java AdditionalMatchers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AdditionalMatchers类属于org.mockito包,在下文中一共展示了AdditionalMatchers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetAllModules_multi
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testGetAllModules_multi() {
Mockito.when(server.getModules()).thenReturn(new IModule[] {module1});
Mockito.when(server.getChildModules(any(IModule[].class), any(IProgressMonitor.class)))
.thenReturn(new IModule[0]);
Mockito.when(server.getChildModules(AdditionalMatchers.aryEq(new IModule[] {module1}),
any(IProgressMonitor.class))).thenReturn(new IModule[] {module2a, module2b});
Mockito.when(server.getChildModules(AdditionalMatchers.aryEq(new IModule[] {module1, module2b}),
any(IProgressMonitor.class))).thenReturn(new IModule[] {module3});
IModule[] result = ModuleUtils.getAllModules(server);
Assert.assertNotNull(result);
Assert.assertEquals(4, result.length);
Assert.assertThat(result,
IsArrayContainingInOrder.arrayContaining(module1, module2a, module2b, module3));
}
示例2: decorate_should_saveExpectedMeasureTotal_when_usingAnyMetric
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
@Parameters
public void decorate_should_saveExpectedMeasureTotal_when_usingAnyMetric(final Metric<Integer> metric, final Collection<Measure> measures) {
Mockito.when(this.context.getComponent())
.thenReturn(this.component);
Mockito.when(this.component.getType())
.thenReturn(Type.PROJECT);
Mockito.when(this.context.getChildrenMeasures(Matchers.eq(metric.getKey())))
.thenReturn(measures);
Mockito.when(this.context.getChildrenMeasures(AdditionalMatchers.not(Matchers.eq(metric.getKey()))))
.thenReturn(null);
final AbstractSmellMeasureComputer sut = sut();
sut.compute(this.context);
Mockito.verify(this.context, Mockito.times(1))
.getComponent();
Mockito.verify(this.context, Mockito.times(1))
.getChildrenMeasures(Matchers.eq(metric.getKey()));
Mockito.verify(this.context, Mockito.times(1))
.addMeasure(Matchers.eq(metric.getKey()), Matchers.eq(3));
Mockito.verify(this.context, Mockito.times(sut.getInputMetricsKeys()
.size() - 1))
.addMeasure(AdditionalMatchers.not(Matchers.eq(metric.getKey())), Matchers.eq(0));
}
开发者ID:QualInsight,项目名称:qualinsight-plugins-sonarqube-smell,代码行数:24,代码来源:SmellCountByTypeMeasuresComputerTest.java
示例3: testNoRollOverNeeded
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testNoRollOverNeeded() throws IOException{
final long startTime = 10000L;
when(mockCurrentTimeProvider.getCurrentTimeMillis()).thenReturn(startTime);
filesManager = new TestEventsFilesManager(RuntimeEnvironment.application, transform,
mockCurrentTimeProvider, mockEventStorage,
"testNoRollOverNeeded", EventsFilesManager.MAX_FILES_TO_KEEP);
when(mockEventStorage.canWorkingFileStore(anyInt(), anyInt()))
.thenReturn(true);
filesManager.writeEvent(testEvent);
verify(mockEventStorage).add(AdditionalMatchers.aryEq(transform.toBytes(testEvent)));
verify(mockEventStorage).canWorkingFileStore(anyInt(), anyInt());
verify(mockCurrentTimeProvider, times(1)).getCurrentTimeMillis();
assertEquals("roll over time should NOT have been updated",
startTime, filesManager.getLastRollOverTime());
}
示例4: testDeliverGCRefresh
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testDeliverGCRefresh() throws Exception {
// setup
GCIdSet idSet = mock(GCIdSet.class);
when(idSet.numElements()).thenReturn(1);
GCId id = mock(GCId.class);
when(idSet.asArray()).thenReturn(new GCId[] { id });
message = new GCRefreshMessage(0, idSet, null, null);
// act
koalaGCPastImpl.deliver(null, message);
// assert
verify(continuation).receiveResult(AdditionalMatchers.aryEq(new Boolean[] { Boolean.TRUE }));
verify(storageManager, never()).exists((Id) anyObject());
}
示例5: testDelSelectionsJob
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testDelSelectionsJob() {
JobMeta jobMeta = mock( JobMeta.class );
Spoon spoon = mock( Spoon.class );
JobEntryCopy selected1 = mock( JobEntryCopy.class );
JobEntryCopy selected2 = mock( JobEntryCopy.class );
when( jobMeta.getSelectedEntries() ).thenReturn( Arrays.asList( selected1, selected2 ) );
JobGraph jobGraph = mock( JobGraph.class );
doCallRealMethod().when( jobGraph ).setJobMeta( any( JobMeta.class ) );
doCallRealMethod().when( jobGraph ).setSpoon( any( Spoon.class ) );
doCallRealMethod().when( jobGraph ).delSelected( any( JobEntryCopy.class ) );
jobGraph.setJobMeta( jobMeta );
jobGraph.setSpoon( spoon );
jobGraph.delSelected( null );
verify( spoon ).deleteJobEntryCopies( eq( jobMeta ),
AdditionalMatchers.aryEq( new JobEntryCopy[] { selected1, selected2 } ) );
}
示例6: setUp
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
userDAO = Mockito.mock(UserDAO.class);
groupDAO = Mockito.mock(GroupDAO.class);
rolesDAO = Mockito.mock(RolesDAO.class);
permissionsDAO = Mockito.mock(PermissionDAO.class);
userProfileController = Mockito.mock(UserProfileController.class);
List<User> validUsers = new ArrayList<>();
validUsers.add(new User());
Group validGroup = new Group(VALID_GROUP_NAME);
validGroup.setId(1);
Mockito.when(rolesDAO.find(
AdditionalMatchers.not(Matchers.eq(INVALID_ROLE_ID)))).
thenReturn(Optional.fromNullable(new Role(ROLE_NAME)));
Mockito.when(permissionsDAO.find(
AdditionalMatchers.not(Matchers.eq(INVALID_Permission_ID)))).
thenReturn(Optional.fromNullable(new Permission(PERMISSION_NAME)));
Mockito.when(permissionsDAO.find(INVALID_Permission_ID)).thenReturn(Optional.absent());
Mockito.when(rolesDAO.find(INVALID_ROLE_ID)).thenReturn(Optional.absent());
Mockito.when(groupDAO.findByName(DUPLICATE_NAME)).thenReturn(new Group());
Mockito.when(groupDAO.save(Matchers.any())).thenReturn(validGroup);
Mockito.when(userDAO.findUsersWithRole(Matchers.anyInt())).thenReturn(validUsers);
Mockito.when(userDAO.findUsersWithPermissionLevel(Matchers.anyInt())).thenReturn(validUsers);
Mockito.when(groupDAO.findByName(VALID_GROUP_NAME)).thenReturn(null);
controller = new GroupController(groupDAO,userDAO,rolesDAO,permissionsDAO, userProfileController);
}
示例7: setUp
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
filterDAO = Mockito.mock(FilterDAO.class);
rolesDAO = Mockito.mock(RolesDAO.class);
permissionsDAO = Mockito.mock(PermissionDAO.class);
Filter validFilter = new Filter(VALID_FILTER_NAME);
validFilter.setId(1);
Mockito.when(rolesDAO.find(
AdditionalMatchers.not(Matchers.eq(INVALID_ROLE_ID)))).
thenReturn(Optional.fromNullable(new Role(ROLE_NAME)));
Mockito.when(permissionsDAO.find(
AdditionalMatchers.not(Matchers.eq(INVALID_Permission_ID)))).
thenReturn(Optional.fromNullable(new Permission(PERMISSION_NAME)));
Mockito.when(permissionsDAO.find(INVALID_Permission_ID)).thenReturn(Optional.absent());
Mockito.when(rolesDAO.find(INVALID_ROLE_ID)).thenReturn(Optional.absent());
Mockito.when(filterDAO.findByName(DUPLICATE_NAME)).thenReturn(new Filter());
Mockito.when(filterDAO.save(Matchers.any())).thenReturn(validFilter);
Mockito.when(filterDAO.findByName(VALID_FILTER_NAME)).thenReturn(null);
controller = new FilterController(filterDAO,rolesDAO,permissionsDAO);
}
示例8: testCommitAnalysisWithNewIssues
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewIssues() {
settings.setProperty(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_FILE, false);
DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
PostJobIssue newIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg1");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");
Mockito.when(commitFacade.getRuleLink("repo:rule")).thenReturn("http://myserver/coding_rules#rule_key=repo%3Arule");
PostJobIssue lineNotVisible = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 2)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L2");
DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/Foo2.php");
PostJobIssue fileNotInPR = Utils.newMockedIssue("foo:src/Foo2.php", inputFile2, 1, Severity.BLOCKER, true, "msg3");
PostJobIssue notNewIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, false, "msg");
PostJobIssue issueOnDir = Utils.newMockedIssue("foo:src", Severity.BLOCKER, true, "msg4");
PostJobIssue issueOnProject = Utils.newMockedIssue("foo", Severity.BLOCKER, true, "msg");
PostJobIssue globalIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, null, Severity.BLOCKER, true, "msg5");
Mockito.when(context.issues()).thenReturn(Arrays.asList(newIssue, globalIssue, issueOnProject, issueOnDir, fileNotInPR, lineNotVisible, notNewIssue));
Mockito.when(commitFacade.hasFile(inputFile1)).thenReturn(true);
Mockito.when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn("abc123");
commitIssuePostJob.execute(context);
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("SonarQube analysis reported 6 issues"));
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("* :no_entry: 6 blocker"));
Mockito.verify(commitFacade).addGlobalComment(AdditionalMatchers.not(Mockito.contains("1. [Project")));
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("1. :no_entry: [msg2](http://gitlab/blob/abc123/src/Foo.php#L2) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)"));
Mockito.verify(commitFacade).createOrUpdateSonarQubeStatus("failed", "SonarQube reported 6 issues, with 6 blocker (fail)");
}
示例9: testCommitAnalysisWithNewIssuesOnly
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewIssuesOnly() {
settings.setProperty(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_FILE, true);
DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
PostJobIssue newIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg1");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");
Mockito.when(commitFacade.getRuleLink("repo:rule")).thenReturn("http://myserver/coding_rules#rule_key=repo%3Arule");
PostJobIssue lineNotVisible = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 2)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L2");
DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/Foo2.php");
PostJobIssue fileNotInPR = Utils.newMockedIssue("foo:src/Foo2.php", inputFile2, 1, Severity.BLOCKER, true, "msg3");
PostJobIssue notNewIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, false, "msg");
PostJobIssue issueOnDir = Utils.newMockedIssue("foo:src", Severity.BLOCKER, true, "msg4");
PostJobIssue issueOnProject = Utils.newMockedIssue("foo", Severity.BLOCKER, true, "msg");
PostJobIssue globalIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, null, Severity.BLOCKER, true, "msg5");
Mockito.when(context.issues()).thenReturn(Arrays.asList(newIssue, globalIssue, issueOnProject, issueOnDir, fileNotInPR, lineNotVisible, notNewIssue));
Mockito.when(commitFacade.hasFile(inputFile1)).thenReturn(true);
Mockito.when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn("abc123");
commitIssuePostJob.execute(context);
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("SonarQube analysis reported 5 issues"));
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("* :no_entry: 5 blocker"));
Mockito.verify(commitFacade).addGlobalComment(AdditionalMatchers.not(Mockito.contains("1. [Project")));
Mockito.verify(commitFacade)
.addGlobalComment(Mockito.contains("1. :no_entry: [msg2](http://gitlab/blob/abc123/src/Foo.php#L2) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)"));
Mockito.verify(commitFacade).createOrUpdateReviewComment("abc123", inputFile1, 1, ":no_entry: msg1 [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)");
Mockito.verify(commitFacade).createOrUpdateSonarQubeStatus("failed", "SonarQube reported 5 issues, with 5 blocker (fail)");
}
示例10: testCommitAnalysisWithNewIssuesOnlyLine
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewIssuesOnlyLine() {
settings.setProperty(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_LINE, true);
DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
PostJobIssue newIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg1");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");
Mockito.when(commitFacade.getRuleLink("repo:rule")).thenReturn("http://myserver/coding_rules#rule_key=repo%3Arule");
PostJobIssue lineNotVisible = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 2)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L2");
DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/Foo2.php");
PostJobIssue fileNotInPR = Utils.newMockedIssue("foo:src/Foo2.php", inputFile2, 1, Severity.BLOCKER, true, "msg3");
PostJobIssue notNewIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, false, "msg");
PostJobIssue issueOnDir = Utils.newMockedIssue("foo:src", Severity.BLOCKER, true, "msg4");
PostJobIssue issueOnProject = Utils.newMockedIssue("foo", Severity.BLOCKER, true, "msg");
PostJobIssue globalIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, null, Severity.BLOCKER, true, "msg5");
Mockito.when(context.issues()).thenReturn(Arrays.asList(newIssue, globalIssue, issueOnProject, issueOnDir, fileNotInPR, lineNotVisible, notNewIssue));
Mockito.when(commitFacade.hasFile(inputFile1)).thenReturn(true);
Mockito.when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn("abc123");
commitIssuePostJob.execute(context);
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("SonarQube analysis reported 1 issue"));
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("* :no_entry: 1 blocker"));
Mockito.verify(commitFacade).addGlobalComment(AdditionalMatchers.not(Mockito.contains("1. [Project")));
Mockito.verify(commitFacade)
.addGlobalComment(AdditionalMatchers.not(Mockito.contains("1. :no_entry: [msg2](http://gitlab/blob/abc123/src/Foo.php#L2) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)")));
Mockito.verify(commitFacade).createOrUpdateReviewComment("abc123", inputFile1, 1, ":no_entry: msg1 [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)");
Mockito.verify(commitFacade).createOrUpdateSonarQubeStatus("failed", "SonarQube reported 1 issue, with 1 blocker (fail)");
}
示例11: testCommitAnalysisWithNewIssuesAllIssues
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewIssuesAllIssues() {
settings.setProperty(GitLabPlugin.GITLAB_ALL_ISSUES, true);
DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
PostJobIssue newIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg1");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");
Mockito.when(commitFacade.getRuleLink("repo:rule")).thenReturn("http://myserver/coding_rules#rule_key=repo%3Arule");
PostJobIssue lineNotVisible = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 2)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L2");
DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/Foo2.php");
PostJobIssue fileNotInPR = Utils.newMockedIssue("foo:src/Foo2.php", inputFile2, 1, Severity.BLOCKER, true, "msg3");
PostJobIssue notNewIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, false, "msg");
PostJobIssue issueOnDir = Utils.newMockedIssue("foo:src", Severity.BLOCKER, true, "msg4");
PostJobIssue issueOnProject = Utils.newMockedIssue("foo", Severity.BLOCKER, true, "msg");
PostJobIssue globalIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, null, Severity.BLOCKER, true, "msg5");
Mockito.when(context.issues()).thenReturn(Arrays.asList(newIssue, globalIssue, issueOnProject, issueOnDir, fileNotInPR, lineNotVisible, notNewIssue));
Mockito.when(commitFacade.hasFile(inputFile1)).thenReturn(true);
Mockito.when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn("abc123");
commitIssuePostJob.execute(context);
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("SonarQube analysis reported 7 issues"));
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("* :no_entry: 7 blocker"));
Mockito.verify(commitFacade).addGlobalComment(AdditionalMatchers.not(Mockito.contains("1. [Project")));
Mockito.verify(commitFacade).addGlobalComment(Mockito.contains("1. :no_entry: [msg2](http://gitlab/blob/abc123/src/Foo.php#L2) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)"));
Mockito.verify(commitFacade).createOrUpdateSonarQubeStatus("failed", "SonarQube reported 7 issues, with 7 blocker (fail)");
}
示例12: testProperCharsetUsed
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testProperCharsetUsed() throws IOException {
when(mockAmqpBrokerConfig.getCharset()).thenReturn(Charset.forName("UTF-32"));
String message = "ö";
byte[] expectedEncodedMessage = new byte[] { 0, 0, 0, -10 }; // In UTF-32 ö is mapped to 000000f6
AmqpProducerAdapter producerAdapter = new AmqpProducerAdapter("myTopic", ExchangeType.FANOUT, mockAmqpBrokerConfig, mockAmqpConnectionManager);
producerAdapter.publish(message);
verify(mockChannel).basicPublish(anyString(), anyString(), any(AMQP.BasicProperties.class), AdditionalMatchers.aryEq(expectedEncodedMessage));
}
示例13: testSizeTriggeredRollOver
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testSizeTriggeredRollOver() throws IOException{
final long startTime = 10000L;
final long newMostRecentRollOverTime = 11500L;
when(mockCurrentTimeProvider.getCurrentTimeMillis())
.thenReturn(startTime)
.thenReturn(newMostRecentRollOverTime);
filesManager = new TestEventsFilesManager(RuntimeEnvironment.application, transform,
mockCurrentTimeProvider, mockEventStorage,
"testSizeTriggeredRollOver", EventsFilesManager.MAX_FILES_TO_KEEP);
when(mockEventStorage.canWorkingFileStore(anyInt(), anyInt()))
.thenReturn(false);
// Called during log message
when(mockEventStorage.getWorkingFileUsedSizeInBytes()).thenReturn(10000);
when(mockEventStorage.isWorkingFileEmpty()).thenReturn(false);
filesManager.writeEvent(testEvent);
verify(mockEventStorage).add(AdditionalMatchers.aryEq(transform.toBytes(testEvent)));
verify(mockEventStorage).canWorkingFileStore(anyInt(), anyInt());
verify(mockEventStorage).getWorkingFileUsedSizeInBytes();
verify(mockEventStorage).isWorkingFileEmpty();
verify(mockEventStorage).rollOver(any(String.class));
verify(mockCurrentTimeProvider, times(2)).getCurrentTimeMillis();
assertEquals("roll over time should have been updated", newMostRecentRollOverTime,
filesManager.getLastRollOverTime());
}
示例14: testRampSampling
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void testRampSampling() throws Exception {
handler.handleMessage(null);
MParticleApiClientImpl apiClient = Mockito.mock(MParticleApiClientImpl.class);
MParticleApiClientImpl.MPRampException rampException = new MParticleApiClientImpl.MPRampException();
Mockito.when(apiClient.sendMessageBatch(Mockito.anyString())).thenThrow(rampException);
handler.setApiClient(apiClient);
handler.uploadMessage(522, "");
String[] params = {"522"};
Mockito.verify(mockDatabase, Mockito.times(1)).delete(Mockito.anyString(), Mockito.anyString(), AdditionalMatchers.aryEq(params));
}
示例15: visitCOSName
import org.mockito.AdditionalMatchers; //导入依赖的package包/类
@Test
public void visitCOSName() throws Exception
{
COSName name = COSName.getPDFName("a()7");
InOrder inOrder = Mockito.inOrder(writer);
victim.visit(name);
inOrder.verify(writer).write((byte) 0x2F);
inOrder.verify(writer).write((byte) 0x61);
inOrder.verify(writer).write((byte) 0x23);
inOrder.verify(writer).write(AdditionalMatchers.aryEq(new byte[] { 0x32, 0x38 }));
inOrder.verify(writer).write((byte) 0x23);
inOrder.verify(writer).write(AdditionalMatchers.aryEq(new byte[] { 0x32, 0x39 }));
inOrder.verify(writer).write((byte) 0x37);
}