当前位置: 首页>>代码示例>>Java>>正文


Java ArgumentCaptor.getAllValues方法代码示例

本文整理汇总了Java中org.mockito.ArgumentCaptor.getAllValues方法的典型用法代码示例。如果您正苦于以下问题:Java ArgumentCaptor.getAllValues方法的具体用法?Java ArgumentCaptor.getAllValues怎么用?Java ArgumentCaptor.getAllValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mockito.ArgumentCaptor的用法示例。


在下文中一共展示了ArgumentCaptor.getAllValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkSettings_withOkResponse_shouldPerformFormBasedAuthentication

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void checkSettings_withOkResponse_shouldPerformFormBasedAuthentication() throws Exception {
    WebDavStore webDavStore = createDefaultWebDavStore();
    ArgumentCaptor<HttpGeneric> requestCaptor = ArgumentCaptor.forClass(HttpGeneric.class);
    when(mockHttpClient.executeOverride(requestCaptor.capture(), any(HttpContext.class)))
            .thenReturn(OK_200_RESPONSE)
            .thenReturn(createOkResponseWithForm())
            .thenAnswer(createOkResponseWithCookie())
            .thenReturn(OK_200_RESPONSE);

    webDavStore.checkSettings();

    List<HttpGeneric> requests = requestCaptor.getAllValues();
    assertEquals(4, requests.size());
    assertEquals("GET", requests.get(0).getMethod()); // Checking auth type
    assertEquals("POST", requests.get(1).getMethod()); // Posting form data
    assertEquals("http://example.org:80/exchweb/bin/auth/owaauth.dll", requests.get(1).getURI().toString());
    assertEquals("POST", requests.get(2).getMethod()); // Confirming login
    assertEquals("http://example.org:80/exchweb/bin/auth/owaauth.dll", requests.get(2).getURI().toString());
    assertEquals("GET", requests.get(3).getMethod()); // Getting response
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:22,代码来源:WebDavStoreTest.java

示例2: testCreate

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testCreate() {
	Task task = new Task();
	task.setId(13L);
	task.setName("myTask");
	taskRepo.create(task);

	// check client call and link span
	ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
	Mockito.verify(clientReporter, Mockito.times(1)).report(clientSpanCaptor.capture());
	List<Span> clientSpans = clientSpanCaptor.getAllValues();
	Span callSpan = clientSpans.get(0);
	Assert.assertEquals("post", callSpan.name());
	Assert.assertEquals(Span.Kind.CLIENT, callSpan.kind());

	// check server local span
	ArgumentCaptor<Span> serverSpanCaptor = ArgumentCaptor.forClass(Span.class);
	Mockito.verify(serverReporter, Mockito.times(1)).report(serverSpanCaptor.capture());
	List<Span> serverSpans = serverSpanCaptor.getAllValues();
	Span repositorySpan = serverSpans.get(0);
	Assert.assertEquals("crnk:post:/tasks/13/", repositorySpan.name());
	Assert.assertTrue(repositorySpan.toString().contains("\"lc\""));

	assertTag(repositorySpan, "lc", "crnk");
	assertTag(repositorySpan, "crnk.query", "?");
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:27,代码来源:AbstractBraveModuleTest.java

示例3: willLogBeforeAndAfter

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
void willLogBeforeAndAfter() throws Exception {
  Method testMethod =
      WatcherExtensionTest.class.getMethod("canExecuteATestWithTheWatcherEngaged");

  givenExtensionContentWithMethod(testMethod);
  when(store.remove(eq(testMethod), eq(long.class))).thenReturn(System.currentTimeMillis());

  sut.beforeTestExecution(extensionContext);
  sut.afterTestExecution(extensionContext);

  ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
  verify(logger, times(2)).info(captor.capture());

  List<String> logEvents = captor.getAllValues();
  assertThat(logEvents.size(), is(2));
  assertThat(logEvents.get(0), is(String.format("Starting test [%s]", testMethod.getName())));
  assertThat(
      logEvents.get(1),
      startsWith(String.format("Completed test [%s] in ", testMethod.getName())));
}
 
开发者ID:glytching,项目名称:junit-extensions,代码行数:22,代码来源:WatcherExtensionMetaTest.java

示例4: shouldProcessManyImageActions

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void shouldProcessManyImageActions() {
    // given
    List<FeedbackAction> actions = ActionListBuilder.create().addUrlAction(ActionType.NARRATION, "good.mp3").addUrlAction(ActionType.IMAGE, "good.jpg")
                                                    .addUrlAction(ActionType.NARRATION, "allok.mp3").addUrlAction(ActionType.IMAGE, "bad.jpg").getList();

    initializeWithActions(actions);
    initializeModuleHierarchyWithImageProcessor();

    // when
    processor.processActions(source);

    // then
    ArgumentCaptor<FeedbackAction> argument = ArgumentCaptor.forClass(FeedbackAction.class);
    verify(imageProcessor, times(2)).processSingleAction(argument.capture(), eq(FeedbackMark.OK));
    assertThat(collector.getActions().size(), is(equalTo(0)));
    List<FeedbackAction> processedActions = argument.getAllValues();

    FeedbackAction processedAction1 = processedActions.get(0);
    assertThat(processedAction1, is(instanceOf(ShowUrlAction.class)));
    assertThat(((ShowUrlAction) processedAction1).getHref(), is(equalTo("good.jpg")));

    FeedbackAction processedAction2 = processedActions.get(1);
    assertThat(processedAction2, is(instanceOf(ShowUrlAction.class)));
    assertThat(((ShowUrlAction) processedAction2).getHref(), is(equalTo("bad.jpg")));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:27,代码来源:ImageActionProcessingJUnitTest.java

示例5: shareItem

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void shareItem() throws Exception {
   final long pathParam_itemId = ITEM_ID1;
   final Resource authenticatedResource = Resources.getInstance(22L);
   when(oacc.getSessionResource()).thenReturn(authenticatedResource);

   todoItemService.shareItem(oacc,
                             pathParam_itemId,
                             EMAIL);

   ArgumentCaptor<ResourcePermission> permissionCaptor = ArgumentCaptor.forClass(ResourcePermission.class);
   ArgumentCaptor<ResourcePermission> permissionVarargsCaptor = ArgumentCaptor.forClass(ResourcePermission.class);
   verify(oacc).grantResourcePermissions(eq(Resources.getInstance(EMAIL)),
                                         eq(Resources.getInstance(String.valueOf(pathParam_itemId))),
                                         permissionCaptor.capture(),
                                         permissionVarargsCaptor.capture());
   final List<ResourcePermission> permissions = permissionVarargsCaptor.getAllValues();
   permissions.add(permissionCaptor.getValue());
   assertThat(permissions).containsExactlyInAnyOrder(SecurityModel.PERM_MARK_COMPLETED, SecurityModel.PERM_VIEW);
   verify(oacc, never()).assertResourcePermissions(any(Resource.class),
                                                   any(Resource.class),
                                                   any());
   verifyZeroInteractions(todoItemDAO);
}
 
开发者ID:acciente,项目名称:oacc-example-securetodo,代码行数:25,代码来源:TodoItemServiceTest.java

示例6: captureStepOutput

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
private StepOutput captureStepOutput() {

        StepOutput actualOutput = new StepOutput();

        ArgumentCaptor<CloudServiceBrokerExtended> createArgumentCaptor = ArgumentCaptor.forClass(CloudServiceBrokerExtended.class);
        int expectedCreatedBrokersCnt = expectedOutput.createdServiceBrokers.size();
        Mockito.verify(serviceBrokerCreator, Mockito.times(expectedCreatedBrokersCnt)).createServiceBroker(Mockito.eq(client),
            createArgumentCaptor.capture());
        actualOutput.createdServiceBrokers = createArgumentCaptor.getAllValues();

        ArgumentCaptor<CloudServiceBrokerExtended> updateArgumentCaptor = ArgumentCaptor.forClass(CloudServiceBrokerExtended.class);
        int expectedUpdatedBrokersCnt = expectedOutput.updatedServiceBrokers.size();
        Mockito.verify(client, Mockito.times(expectedUpdatedBrokersCnt)).updateServiceBroker(updateArgumentCaptor.capture());
        actualOutput.updatedServiceBrokers = updateArgumentCaptor.getAllValues();

        return actualOutput;
    }
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:18,代码来源:CreateOrUpdateServiceBrokersStepTest.java

示例7: testError

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testError() {
	Task task = new Task();
	task.setId(13L);
	try {
		taskRepo.create(task);
	}
	catch (Exception e) {
		// ok
	}

	// check client call and link span
	ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
	Mockito.verify(clientReporter, Mockito.times(isOkHttp ? 2 : 1)).report(clientSpanCaptor.capture());
	List<Span> clientSpans = clientSpanCaptor.getAllValues();
	Span callSpan = clientSpans.get(0);
	Assert.assertEquals("post", callSpan.name);
	Assert.assertTrue(callSpan.toString().contains("\"cs\""));
	Assert.assertTrue(callSpan.toString().contains("\"cr\""));
	assertBinaryAnnotation(callSpan, "http.status_code", "500");
	if (isOkHttp) {
		Span linkSpan = clientSpans.get(1);
		Assert.assertEquals("post", linkSpan.name);
		Assert.assertTrue(linkSpan.toString().contains("\"lc\""));
	}

	// check server local span
	ArgumentCaptor<Span> serverSpanCaptor = ArgumentCaptor.forClass(Span.class);
	Mockito.verify(serverReporter, Mockito.times(1)).report(serverSpanCaptor.capture());
	List<Span> serverSpans = serverSpanCaptor.getAllValues();
	Span repositorySpan = serverSpans.get(0);
	Assert.assertEquals("crnk:post:/tasks/13", repositorySpan.name);
	Assert.assertTrue(repositorySpan.toString().contains("\"lc\""));

	assertBinaryAnnotation(repositorySpan, "lc", "crnk");
	assertBinaryAnnotation(repositorySpan, "crnk.query", "?");
	assertBinaryAnnotation(repositorySpan, "crnk.status", "EXCEPTION");
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:39,代码来源:AbstractBraveModuleTest.java

示例8: testError

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testError() {
	Task task = new Task();
	task.setId(13L);
	try {
		taskRepo.create(task);
	}
	catch (Exception e) {
		// ok
	}

	// check client call and link span
	ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
	List<Span> clientSpans = clientSpanCaptor.getAllValues();
	Span callSpan = clientSpans.get(0);
	Assert.assertEquals("post", callSpan.getName());
	Assert.assertTrue(callSpan.toString().contains("\"cs\""));
	Assert.assertTrue(callSpan.toString().contains("\"cr\""));
	assertBinaryAnnotation(callSpan, "http.status_code", "500");

	// check server local span
	Assert.assertEquals(1, reportedSpans.spans.size());
	Span repositorySpan = reportedSpans.spans.get(0);
	Assert.assertEquals("crnk:post:/tasks/13", repositorySpan.getName());
	Assert.assertTrue(repositorySpan.toString().contains("\"lc\""));

	assertBinaryAnnotation(repositorySpan, "lc", "crnk");
	assertBinaryAnnotation(repositorySpan, "crnk.query", "?");
	assertBinaryAnnotation(repositorySpan, "crnk.status", "EXCEPTION");
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:31,代码来源:SleuthModuleTest.java

示例9: verifyListenerOnHit

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
private void verifyListenerOnHit(CacheKey key, String resourceId) {
  ArgumentCaptor<CacheEvent> cacheEventCaptor = ArgumentCaptor.forClass(CacheEvent.class);
  mCacheEventListenerInOrder.verify(mCacheEventListener).onHit(cacheEventCaptor.capture());

  for (CacheEvent event : cacheEventCaptor.getAllValues()) {
    CacheEventAssert.assertThat(event)
        .isNotNull()
        .hasCacheKey(key)
        .hasResourceId(resourceId);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:DiskStorageCacheTest.java

示例10: on

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
public List<JavaClass> on(Class<?>... toCheck) {
    JavaClasses classes = importClassesWithContext(toCheck);
    ArchCondition<JavaClass> condition = spy(new ArchCondition<JavaClass>("ignored") {
        @Override
        public void check(JavaClass item, ConditionEvents events) {
        }
    });
    givenClasses.should(condition).check(classes);

    ArgumentCaptor<JavaClass> classesCaptor = ArgumentCaptor.forClass(JavaClass.class);
    verify(condition, atLeast(0)).check(classesCaptor.capture(), any(ConditionEvents.class));
    return classesCaptor.getAllValues();
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:14,代码来源:GivenClassesThatTest.java

示例11: testTodo

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testTodo() {
    MainScreen mainScreen = mock(MainScreen.class);
    mianPresenter.attachScreen(mainScreen);
    mianPresenter.getFavourites();

    ArgumentCaptor<String> todosCaptor = ArgumentCaptor.forClass(String.class);
    verify(mainScreen, times(2)).showMessage(todosCaptor.capture());

    List<String> capturedTodos = todosCaptor.getAllValues();
    assertEquals("todo one", capturedTodos.get(0));
    assertEquals("todo two", capturedTodos.get(1));
}
 
开发者ID:bpatrik,项目名称:mobsoft-lab,代码行数:14,代码来源:TodoTest.java

示例12: testFindTargets

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testFindTargets() {
	RelationshipRepositoryV2<Project, Serializable, Task, Serializable> relRepo = client
			.getRepositoryForType(Project.class, Task.class);
	relRepo.findManyTargets(123L, "tasks", new QuerySpec(Task.class));

	// check client call and link span
	ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
	Mockito.verify(clientReporter, Mockito.times(1)).report(clientSpanCaptor.capture());
	List<Span> clientSpans = clientSpanCaptor.getAllValues();
	Span callSpan = clientSpans.get(0);
	Assert.assertEquals("get", callSpan.name());
	Assert.assertEquals(Span.Kind.CLIENT, callSpan.kind());

	// check server local span
	ArgumentCaptor<Span> serverSpanCaptor = ArgumentCaptor.forClass(Span.class);
	Mockito.verify(serverReporter, Mockito.times(2)).report(serverSpanCaptor.capture());
	List<Span> serverSpans = serverSpanCaptor.getAllValues();

	Span repositorySpan0 = serverSpans.get(0);
	Assert.assertEquals("crnk:get:/tasks/", repositorySpan0.name());
	Assert.assertTrue(repositorySpan0.toString().contains("\"lc\""));

	assertTag(repositorySpan0, "lc", "crnk");
	assertTag(repositorySpan0, "crnk.results", "0");
	assertTag(repositorySpan0, "crnk.status", "OK");

	Span repositorySpan1 = serverSpans.get(1);
	Assert.assertEquals("crnk:get:/projects/123/tasks/", repositorySpan1.name());
	Assert.assertTrue(repositorySpan1.toString().contains("\"lc\""));

	assertTag(repositorySpan1, "lc", "crnk");
	assertTag(repositorySpan1, "crnk.query", "?");
	assertTag(repositorySpan1, "crnk.results", "0");
	assertTag(repositorySpan1, "crnk.status", "OK");
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:37,代码来源:AbstractBraveModuleTest.java

示例13: getCallArgumentsOfUpdateApplicationEnvMethod

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private List<CloudApplication> getCallArgumentsOfUpdateApplicationEnvMethod(CloudSpace space, CloudFoundryOperations client) {
    ArgumentCaptor<Map> appEnvCaptor = ArgumentCaptor.forClass(Map.class);
    ArgumentCaptor<String> appNameCaptor = ArgumentCaptor.forClass(String.class);
    verify(client, Mockito.atLeast(0)).updateApplicationEnv(appNameCaptor.capture(), appEnvCaptor.capture());

    List<Map> appEnvs = appEnvCaptor.getAllValues();
    List<String> appNames = appNameCaptor.getAllValues();
    List<CloudApplication> result = new ArrayList<>();
    for (int i = 0; i < appNames.size(); i++) {
        result.add(createApp(appNames.get(i), space, appEnvs.get(i)));
    }
    return result;
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:15,代码来源:UpdateSubscribersStepTest.java

示例14: captureStepOutput

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
private StepOutput captureStepOutput() throws Exception {
    ArgumentCaptor<ConfigurationSubscription> argumentCaptor;

    StepOutput output = new StepOutput();

    argumentCaptor = ArgumentCaptor.forClass(ConfigurationSubscription.class);
    Mockito.verify(dao, times(input.subscriptionsToUpdate.size())).update(eq(DUMMY_ID), argumentCaptor.capture());
    output.updatedSubscriptions = argumentCaptor.getAllValues();

    argumentCaptor = ArgumentCaptor.forClass(ConfigurationSubscription.class);
    Mockito.verify(dao, times(input.subscriptionsToCreate.size())).add(argumentCaptor.capture());
    output.createdSubscriptions = argumentCaptor.getAllValues();

    return output;
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:16,代码来源:CreateSubscriptionsStepTest.java

示例15: filterCaptured

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
protected <T> List<T> filterCaptured(final ArgumentCaptor<T> captor, final Class<T> type) {
    List<T> captured = new ArrayList<>();
    for (T c: captor.getAllValues()) {
        if (type.isInstance(c)) {
            captured.add(c);
        }
    }

    return captured;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:AbstractTransactionProxyTest.java


注:本文中的org.mockito.ArgumentCaptor.getAllValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。