當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。