Source:
<code>public void shouldIncludePaResponseIn3dsSecondOrder() throws Exception { ChargeEntity mockChargeEntity = mock(ChargeEntity.class); when(mockChargeEntity.getGatewayAccount()).thenReturn(mockGatewayAccountEntity); when(mockChargeEntity.getExternalId()).thenReturn("uniqueSessionId"); when(mockChargeEntity.getGatewayTransactionId()).thenReturn("MyUniqueTransactionId!"); Map<String, String> credentialsMap = ImmutableMap.of("merchant_id", "MERCHANTCODE"); when(mockGatewayAccountEntity.getCredentials()).thenReturn(credentialsMap); <START> when(mockGatewayClient.postRequestFor(isNull(), any(GatewayAccountEntity.class), any(GatewayOrder.class), any(List.class))) <END> .thenThrow(new GatewayConnectionErrorException("Unexpected HTTP status code 401 from gateway")); GatewayClientFactory gatewayClientFactory = mock(GatewayClientFactory.class); when(gatewayClientFactory.createGatewayClient(any(PaymentGatewayName.class), any(GatewayOperation.class), any(Map.class), any())).thenReturn(mockGatewayClient); WorldpayPaymentProvider worldpayPaymentProvider = new WorldpayPaymentProvider(configuration, gatewayClientFactory, environment); worldpayPaymentProvider.authorise3dsResponse(get3dsResponseGatewayRequest(mockChargeEntity)); ArgumentCaptor<GatewayOrder> gatewayOrderArgumentCaptor = ArgumentCaptor.forClass(GatewayOrder.class); ArgumentCaptor<List> cookies = ArgumentCaptor.forClass(List.class); verify(mockGatewayClient).postRequestFor( eq(null), eq(mockGatewayAccountEntity), gatewayOrderArgumentCaptor.capture(), cookies.capture()); assertXMLEqual(TestTemplateResourceLoader.load(WORLDPAY_VALID_3DS_RESPONSE_AUTH_WORLDPAY_REQUEST), gatewayOrderArgumentCaptor.getValue().getPayload()); }</code><technical_language>I anyList() is generics</technical_language>

Target:
public void shouldIncludePaResponseIn3dsSecondOrder() throws Exception { ChargeEntity mockChargeEntity = mock(ChargeEntity.class); when(mockChargeEntity.getGatewayAccount()).thenReturn(mockGatewayAccountEntity); when(mockChargeEntity.getExternalId()).thenReturn("uniqueSessionId"); when(mockChargeEntity.getGatewayTransactionId()).thenReturn("MyUniqueTransactionId!"); Map<String, String> credentialsMap = ImmutableMap.of("merchant_id", "MERCHANTCODE"); when(mockGatewayAccountEntity.getCredentials()).thenReturn(credentialsMap); when(mockGatewayClient.postRequestFor(isNull(), any(GatewayAccountEntity.class), any(GatewayOrder.class), anyList())) .thenThrow(new GatewayConnectionErrorException("Unexpected HTTP status code 401 from gateway")); GatewayClientFactory gatewayClientFactory = mock(GatewayClientFactory.class); when(gatewayClientFactory.createGatewayClient(any(PaymentGatewayName.class), any(GatewayOperation.class), any(Map.class), any())).thenReturn(mockGatewayClient); WorldpayPaymentProvider worldpayPaymentProvider = new WorldpayPaymentProvider(configuration, gatewayClientFactory, environment); worldpayPaymentProvider.authorise3dsResponse(get3dsResponseGatewayRequest(mockChargeEntity)); ArgumentCaptor<GatewayOrder> gatewayOrderArgumentCaptor = ArgumentCaptor.forClass(GatewayOrder.class); ArgumentCaptor<List> cookies = ArgumentCaptor.forClass(List.class); verify(mockGatewayClient).postRequestFor( eq(null), eq(mockGatewayAccountEntity), gatewayOrderArgumentCaptor.capture(), cookies.capture()); assertXMLEqual(TestTemplateResourceLoader.load(WORLDPAY_VALID_3DS_RESPONSE_AUTH_WORLDPAY_REQUEST), gatewayOrderArgumentCaptor.getValue().getPayload()); }