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


Java ArgumentCaptor.getValue方法代码示例

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


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

示例1: saveUdaDefinitions_Create

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void saveUdaDefinitions_Create() throws Exception {
    ArgumentCaptor<UdaDefinition> ac = ArgumentCaptor
            .forClass(UdaDefinition.class);
    // when
    uda.saveUdaDefinitions(Arrays.asList(voDef), supplier);

    // then
    verifyZeroInteractions(ctx);
    verify(ds, times(1)).persist(ac.capture());

    UdaDefinition persisted = ac.getValue();
    assertEquals(voDef.getConfigurationType(),
            persisted.getConfigurationType());
    assertEquals(voDef.getDefaultValue(), persisted.getDefaultValue());
    assertEquals(voDef.getTargetType(), persisted.getTargetType().name());
    assertEquals(voDef.getUdaId(), persisted.getUdaId());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:UdaDefinitionAccessTest.java

示例2: statusShouldSendNoMatchResponseToTransaction_whenNoMatchResponseSentFromMatchingServiceCycle3Match

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void statusShouldSendNoMatchResponseToTransaction_whenNoMatchResponseSentFromMatchingServiceCycle3Match() throws Exception {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller =
            new Cycle3MatchRequestSentStateController(state, eventSinkHubEventLogger, stateTransitionAction, policyConfiguration,
                    null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<NoMatchState> argumentCaptor = ArgumentCaptor.forClass(NoMatchState.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);

    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);

    verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
    NoMatchStateController noMatchStateController = new NoMatchStateController(argumentCaptor.getValue(), responseFromHubFactory);
    ResponseProcessingDetails responseProcessingDetails = noMatchStateController.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_NO_MATCH_RESPONSE_TO_TRANSACTION);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:Cycle3MatchRequestSentStateControllerTest.java

示例3: verifyIdpStateControllerIsCalledWithRightDataOnSuccess

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
private void verifyIdpStateControllerIsCalledWithRightDataOnSuccess(InboundResponseFromIdpDto successResponseFromIdp) {
    ArgumentCaptor<SuccessFromIdp> captor = ArgumentCaptor.forClass(SuccessFromIdp.class);

    PersistentId persistentId = PersistentIdBuilder.aPersistentId().withNameId(successResponseFromIdp.getPersistentId().get()).build();
    SuccessFromIdp expectedSuccessFromIdp = SuccessFromIdpBuilder.aSuccessFromIdp()
            .withIssuerId(successResponseFromIdp.getIssuer())
            .withEncryptedMatchingDatasetAssertion(successResponseFromIdp.getEncryptedMatchingDatasetAssertion().get())
            .withAuthnStatementAssertion(successResponseFromIdp.getAuthnStatementAssertionBlob().get())
            .withPersistentId(persistentId)
            .withLevelOfAssurance(successResponseFromIdp.getLevelOfAssurance().get())
            .withPrincipalIpAddressAsSeenByHub(samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub())
            .withPrincipalIpAddressSeenByIdp(successResponseFromIdp.getPrincipalIpAddressAsSeenByIdp().get())
            .build();
    verify(idpSelectedStateController).handleSuccessResponseFromIdp(captor.capture());
    SuccessFromIdp actualSuccessFromIdp = captor.getValue();
    assertThat(actualSuccessFromIdp).isEqualToIgnoringGivenFields(expectedSuccessFromIdp, "persistentId");
    assertThat(actualSuccessFromIdp.getPersistentId().getNameId()).isEqualTo(persistentId.getNameId());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:AuthnResponseFromIdpServiceTest.java

示例4: testDataTreeChangeListener

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataTreeChangeListener() throws Exception {
    DataBroker dataBroker = getDataBroker();

    DataTreeChangeListener<ListItem> listener = mock(DataTreeChangeListener.class);
    InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class)
            .child(ListItem.class).build();
    ListenerRegistration<DataTreeChangeListener<ListItem>> reg = dataBroker.registerDataTreeChangeListener(
            new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, wildCard), listener);

    final ListItem item = writeListItem();

    ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);

    verify(listener, timeout(100)).onDataTreeChanged(captor.capture());

    Collection<DataTreeModification<ListItem>> mods = captor.getValue();
    assertEquals("ListItem", item, mods.iterator().next().getRootNode().getDataAfter());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:Bug4513Test.java

示例5: usingPodYamlConfigurations_shouldCreateKubernetesPodWithPodLabels

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void usingPodYamlConfigurations_shouldCreateKubernetesPodWithPodLabels() throws Exception {
    createAgentRequest = CreateAgentRequestMother.createAgentRequestUsingPodYaml();

    ArgumentCaptor<Pod> argumentCaptor = ArgumentCaptor.forClass(Pod.class);
    kubernetesAgentInstances.create(createAgentRequest, settings, mockedPluginRequest);
    verify(pods).create(argumentCaptor.capture());
    Pod elasticAgentPod = argumentCaptor.getValue();

    assertNotNull(elasticAgentPod.getMetadata());

    HashMap<String, String> labels = new HashMap<>();
    labels.put(Constants.CREATED_BY_LABEL_KEY, Constants.PLUGIN_ID);
    labels.put(Constants.JOB_ID_LABEL_KEY, createAgentRequest.jobIdentifier().getJobId().toString());
    labels.put(Constants.KUBERNETES_POD_KIND_LABEL_KEY, Constants.KUBERNETES_POD_KIND_LABEL_VALUE);
    labels.put(Constants.ENVIRONMENT_LABEL_KEY, createAgentRequest.environment());

    labels.put("app", "gocd-agent");

    assertThat(elasticAgentPod.getMetadata().getLabels(), is(labels));
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:22,代码来源:KubernetesAgentInstancesIntegrationTest.java

示例6: verifyListenerOnWriteSuccessAndGetResourceId

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

  CacheEvent cacheEvent = cacheEventCaptor.getValue();
  CacheEventAssert.assertThat(cacheEvent)
      .isNotNull()
      .hasCacheKey(key)
      .hasItemSize(itemSize)
      .hasResourceIdSet();

  return cacheEvent.getResourceId();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DiskStorageCacheTest.java

示例7: captureAfterTransmissionArg

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
private Context.AfterTransmission captureAfterTransmissionArg(ExecutionInterceptor interceptor) {
    ArgumentCaptor<Context.AfterTransmission> afterTransmissionArg = ArgumentCaptor.forClass(Context.AfterTransmission.class);

    InOrder inOrder = Mockito.inOrder(interceptor);
    inOrder.verify(interceptor).beforeExecution(any(), any());
    inOrder.verify(interceptor).modifyRequest(any(), any());
    inOrder.verify(interceptor).beforeMarshalling(any(), any());
    inOrder.verify(interceptor).afterMarshalling(any(), any());
    inOrder.verify(interceptor).modifyHttpRequest(any(), any());
    inOrder.verify(interceptor).beforeTransmission(any(), any());
    inOrder.verify(interceptor).afterTransmission(afterTransmissionArg.capture(), any());
    inOrder.verify(interceptor).modifyHttpResponse(any(), any());
    inOrder.verify(interceptor).beforeUnmarshalling(any(), any());
    inOrder.verify(interceptor).afterUnmarshalling(any(), any());
    inOrder.verify(interceptor).modifyResponse(any(), any());
    inOrder.verify(interceptor).afterExecution(any(), any());
    verifyNoMoreInteractions(interceptor);
    return afterTransmissionArg.getValue();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:20,代码来源:ExecutionInterceptorTest.java

示例8: doBreakAsEmmeraldStoneSilkTouchtest

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void doBreakAsEmmeraldStoneSilkTouchtest() {

    doReturn(Material.STONE).when(block).getType(); 

    Map < String, Boolean > enchants = new HashMap < String, Boolean > (); 
    enchants.put(Pick.UNBREAKING, false); 
    enchants.put(Pick.FORTUNE, false); 
    enchants.put(Pick.SILK_TOUCH, true); 

    //test normal picks
    pick.doBreak(block, enchants, player, Material.EMERALD_ORE);

    ArgumentCaptor<ItemStack> argumentCaptor = ArgumentCaptor.forClass(ItemStack.class);
    verify(inventory, times(1)).addItem(argumentCaptor.capture());
    ItemStack capturedArgument = argumentCaptor.getValue();
    assertTrue(capturedArgument.getType().equals(Material.EMERALD_ORE));
}
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:19,代码来源:PickTest.java

示例9: shouldProcessSingleTextAction

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

    initializeWithActions(actions);
    initializeModuleHierarchyWithTextProcessor();

    // when
    processor.processActions(source);

    // then
    ArgumentCaptor<FeedbackAction> argument = ArgumentCaptor.forClass(FeedbackAction.class);
    verify(textProcessor).processSingleAction(argument.capture(), eq(FeedbackMark.OK));
    FeedbackAction processedAction = argument.getValue();

    assertThat(argument.getAllValues().size(), is(equalTo(1)));
    assertThat(processedAction, is(instanceOf(ShowTextAction.class)));
    assertThat(((ShowTextAction) processedAction).getContent().toString(), is(equalTo("Good")));
    assertThat(collector.getActions().size(), is(equalTo(0)));

    verify(mathJaxNative).renderMath(Mockito.isA(JavaScriptObject.class));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:27,代码来源:TextActionProcessingJUnitTest.java

示例10: shouldCreateKubernetesPodWithGoCDElasticAgentContainerContainingEnvironmentVariables

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void shouldCreateKubernetesPodWithGoCDElasticAgentContainerContainingEnvironmentVariables() throws Exception {
    ArgumentCaptor<Pod> argumentCaptor = ArgumentCaptor.forClass(Pod.class);
    KubernetesInstance instance = kubernetesAgentInstances.create(createAgentRequest, settings, mockedPluginRequest);
    verify(pods).create(argumentCaptor.capture());
    Pod elasticAgentPod = argumentCaptor.getValue();

    ArrayList<EnvVar> expectedEnvVars = new ArrayList<>();
    expectedEnvVars.add(new EnvVar("GO_EA_SERVER_URL", settings.getGoServerUrl(), null));

    expectedEnvVars.add(new EnvVar("ENV1", "VALUE1", null));
    expectedEnvVars.add(new EnvVar("ENV2", "VALUE2", null));

    expectedEnvVars.add(new EnvVar("GO_EA_AUTO_REGISTER_KEY", createAgentRequest.autoRegisterKey(), null));
    expectedEnvVars.add(new EnvVar("GO_EA_AUTO_REGISTER_ENVIRONMENT", createAgentRequest.environment(), null));
    expectedEnvVars.add(new EnvVar("GO_EA_AUTO_REGISTER_ELASTIC_AGENT_ID", instance.name(), null));
    expectedEnvVars.add(new EnvVar("GO_EA_AUTO_REGISTER_ELASTIC_PLUGIN_ID", Constants.PLUGIN_ID, null));

    List<Container> containers = elasticAgentPod.getSpec().getContainers();
    assertThat(containers.size(), is(1));

    assertThat(containers.get(0).getEnv(), is(expectedEnvVars));
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:24,代码来源:KubernetesAgentInstancesIntegrationTest.java

示例11: testNewTransaction

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testNewTransaction() throws Exception {
    FactTransactionJson factTransactionJson = objectMapper.readValue(this.getClass()
            .getResourceAsStream("TransactionJson.json"), FactTransactionJson.class);
    uut.newTransaction(factTransactionJson);
    ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
    verify(factStore).publish(captor.capture());

    List<Fact> facts = captor.getValue();
    Fact fact = facts.get(0);
    FactJson sentFact = factTransactionJson.facts().get(0);
    assertEquals(sentFact.header().ns(), fact.ns());
    assertEquals(sentFact.header().aggIds(), fact.aggIds());
    assertEquals(sentFact.header().type(), fact.type());
    assertEquals(sentFact.header().id(), fact.id());
    assertEquals(objectMapper.writeValueAsString(sentFact.header()), fact.jsonHeader());
    assertEquals(sentFact.payload().toString(), fact.jsonPayload());
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:20,代码来源:FactsTransactionsResource0Test.java

示例12: testSubsegmentWithChildEmittedTogetherInLambdaContext

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testSubsegmentWithChildEmittedTogetherInLambdaContext() {
    TraceHeader header = TraceHeader.fromString(TRACE_HEADER);

    PowerMockito.stub(PowerMockito.method(LambdaSegmentContext.class, "getTraceHeaderFromEnvironment")).toReturn(header);
    PowerMockito.stub(PowerMockito.method(LambdaSegmentContextResolver.class, "getLambdaTaskRoot")).toReturn("/var/task");

    Emitter mockEmitter = Mockito.mock(UDPEmitter.class);
    AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withEmitter(mockEmitter).build();

    recorder.createSubsegment("testTogether", () -> {
        recorder.createSubsegment("testTogether2", () -> {
        });
    });

    ArgumentCaptor<Subsegment> emittedSubsegment = ArgumentCaptor.forClass(Subsegment.class);
    Mockito.verify(mockEmitter, Mockito.times(1)).sendSubsegment(emittedSubsegment.capture());

    Subsegment captured = emittedSubsegment.getValue();

    Assert.assertEquals(1, captured.getSubsegments().size());
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:23,代码来源:AWSXRayRecorderTest.java

示例13: verifyEmailAddressValid

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void verifyEmailAddressValid() throws Exception {
    String urlId = "url_id";
    String emailChange = "[email protected]";

    User user = mock(User.class);
    HttpServletResponse httpRes = mock(HttpServletResponse.class);
    AuthenticationLink validationLink = mock(AuthenticationLink.class);

    when(dao.getUserByEmailVerificationLink(urlId)).thenReturn(user);
    when(user.getValidateEmailLink()).thenReturn(validationLink);
    when(user.getEmailChange()).thenReturn(emailChange);
    when(validationLink.hasExpired()).thenReturn(false);

    String response = sut.verifyEmailAddress(httpRes, urlId);

    ArgumentCaptor<AuthenticationLink> captor = ArgumentCaptor.forClass(AuthenticationLink.class);
    verify(user, times(1)).setValidateEmailLink(captor.capture());
    AuthenticationLink recoverPassLink = captor.getValue();
    assertEquals("", recoverPassLink.getUrl());
    assertEquals(0, recoverPassLink.getTimestamp());
    verify(user, times(1)).setEmail(emailChange);
    verify(user, times(1)).setEmailChange("");
    verify(dao, times(1)).update(user);
    verify(httpRes, times(1)).sendRedirect("/");
    assertEquals("", response);
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:28,代码来源:VisitorControllerTest.java

示例14: testReadFromSuccessfulMuxedFile

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void testReadFromSuccessfulMuxedFile()
		throws Exception {
	// Given
	FileHandleFiller filler = mock(FileHandleFiller.class);
	ArgumentCaptor<Integer> handleCaptor = ArgumentCaptor.forClass(Integer.class);
	doNothing().when(filler).setFileHandle(handleCaptor.capture());
	Path mkv = mockPath("file1.mkv");
	Path srt = mockPath("file1.eng.srt", 2893756L);
	mockShuffledDirectoryStream(mirrorRoot, mkv, srt);
	mockAttributes(mkv, 1);
	Muxer muxer = mock(Muxer.class);
	when(muxerFactory.from(mkv, srt, tempDir)).thenReturn(muxer);
	Path muxedFile = mockPath(tempDir, "file1-muxed.mkv");
	when(muxer.getOutput()).thenReturn(Optional.of(muxedFile));
	FileChannel fileChannel = mock(FileChannel.class);
	when(fileSystem.provider().newFileChannel(eq(muxedFile), eq(set(StandardOpenOption.READ)))).thenReturn(fileChannel);
	fs.open("file1.mkv", filler);
	Integer fileHandle = handleCaptor.getValue();
	ArgumentCaptor<ByteBuffer> bufferCaptor = ArgumentCaptor.forClass(ByteBuffer.class);
	when(fileChannel.read(bufferCaptor.capture(), eq(64L))).thenReturn(128);
	when(muxer.state()).thenReturn(State.SUCCESSFUL);
	// When
	int bytesRead = fs.read("file1.mkv", (data) -> assertThat(data).hasSize(128), 128, 64, fileHandle);
	// Then
	assertThat(bytesRead).isEqualTo(128);
	verify(muxerFactory).from(mkv, srt, tempDir);
	verifyNoMoreInteractions(muxerFactory);
	verify(muxer).start();
	verify(muxer).waitForOutput();
	verify(muxer).getOutput();
	verify(muxer).state();
	verifyNoMoreInteractions(muxer);
	verify(filler).setFileHandle(gt(1));
	verify(fileSystem.provider()).newFileChannel(eq(muxedFile), eq(set(StandardOpenOption.READ)));
}
 
开发者ID:tfiskgul,项目名称:mux2fs,代码行数:37,代码来源:MuxFsTest.java

示例15: onActivityResumed

import org.mockito.ArgumentCaptor; //导入方法依赖的package包/类
@Test
public void onActivityResumed() throws Exception {
    ScreenListener listener = mock(ScreenListener.class);
    screenTracker.addListener(listener);

    Activity activity = mock(Activity.class);
    screenTracker.onActivityResumed(activity);

    ArgumentCaptor<Screen> screenCaptor = ArgumentCaptor.forClass(Screen.class);
    verify(listener).onScreenChanged(screenCaptor.capture());

    Screen screen = screenCaptor.getValue();
    assertEquals(activity, screen.getActivity());
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:15,代码来源:ScreenTrackerTest.java


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