file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
TestVerlagServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/test/java/de/adorsys/xs2a/adapter/verlag/TestVerlagServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import java.util.AbstractMap;
import java.util.Collections;
/**
* The purpose of this test class is to substitute apiKeyEntry map with a mocked one for WireMock testing.
*/
public class TestVerlagServiceProvider extends VerlagServiceProvider {
private final AbstractMap.SimpleImmutableEntry<String, String> apiKeyEntry
= new AbstractMap.SimpleImmutableEntry<>("foo", "boo");
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new VerlagAccountInformationService(aspsp,
apiKeyEntry,
httpClientFactory,
Collections.emptyList(),
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new VerlagPaymentInitiationService(aspsp,
apiKeyEntry,
httpClientFactory,
Collections.emptyList(),
linksRewriter);
}
}
| 2,500 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagPaymentInitiationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/test/java/de/adorsys/xs2a/adapter/verlag/VerlagPaymentInitiationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.AbstractMap;
import java.util.Map;
import static com.google.common.collect.Maps.immutableEntry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class VerlagPaymentInitiationServiceTest {
private static final String API_KEY = "apiKey";
private static final String API_VALUE = "apiValue";
private VerlagPaymentInitiationService paymentInitiationService;
@Mock
private HttpClient httpClient;
@Mock
private HttpClientFactory httpClientFactory;
@Mock
private HttpClientConfig httpClientConfig;
@Mock
private LinksRewriter linksRewriter;
private final Aspsp aspsp = new Aspsp();
private final AbstractMap.SimpleImmutableEntry<String, String> apiKeyEntry
= new AbstractMap.SimpleImmutableEntry<>(API_KEY, API_VALUE);
private Map<String, String> headers;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClient(any(), any(), any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
paymentInitiationService = new VerlagPaymentInitiationService(aspsp, apiKeyEntry, httpClientFactory, null, linksRewriter);
headers = RequestHeaders.empty().toMap();
}
@Test
void populatePostHeaders() {
Map<String, String> actualHeaders = paymentInitiationService.populatePostHeaders(headers);
assertHeaders(actualHeaders);
}
private void assertHeaders(Map<String, String> actualHeaders) {
assertThat(actualHeaders)
.hasSize(1)
.contains(immutableEntry(API_KEY, API_VALUE));
}
@Test
void populatePutHeaders() {
Map<String, String> actualHeaders = paymentInitiationService.populatePutHeaders(headers);
assertHeaders(actualHeaders);
}
@Test
void populateGetHeaders() {
Map<String, String> actualHeaders = paymentInitiationService.populateGetHeaders(headers);
assertHeaders(actualHeaders);
}
}
| 3,519 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/test/java/de/adorsys/xs2a/adapter/verlag/VerlagServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.DownloadService;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BaseDownloadService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class VerlagServiceProviderTest {
private VerlagServiceProvider serviceProvider;
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final Aspsp aspsp = new Aspsp();
@BeforeEach
void setUp() {
serviceProvider = new VerlagServiceProvider();
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
}
@Test
void getAccountInformationService() {
AccountInformationService actualService
= serviceProvider.getAccountInformationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(VerlagAccountInformationService.class);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService actualService
= serviceProvider.getPaymentInitiationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(VerlagPaymentInitiationService.class);
}
@Test
void getDownloadService() {
DownloadService actualService
= serviceProvider.getDownloadService("", httpClientFactory);
assertThat(actualService)
.isExactlyInstanceOf(BaseDownloadService.class);
}
}
| 2,835 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagAccountInformationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/test/java/de/adorsys/xs2a/adapter/verlag/VerlagAccountInformationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(TestVerlagServiceProvider.class)
class VerlagAccountInformationServiceWireMockTest {
private static final String CONSENT_ID = "cWpVQSW1X4peDA49LYWH3BnqXgDPkAdbTUf4flwrBcBGfRJPXJzpBFL-ZNGkNtYmeTllIL2aPmJr5erBhdvaj_SdMWF3876hAweK_n7HJlg=_=_psGLvQpt9Q";
private static final String AUTHORISATION_ID = "356e6d7d-9242-4264-8cb5-892e0758d69c";
private static final String ACCOUNT_ID = "3a4c851658957bc30d767425679769fc380120315d6da67faa52f016723ec9a2";
private final AccountInformationService service;
VerlagAccountInformationServiceWireMockTest(AccountInformationService service) {
this.service = service;
}
@Test
void createConsent() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/create-consent.json");
Response<ConsentsResponse201> response = service.createConsent(requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(Consents.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ConsentsResponse201.class));
}
@Test
void authenticatePsu() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/authenticate-psu.json");
Response<StartScaprocessResponse> response = service.startConsentAuthorisation(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(UpdatePsuAuthentication.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(StartScaprocessResponse.class));
}
@Test
void selectScaMethod() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/select-sca-method.json");
Response<SelectPsuAuthenticationMethodResponse> response = service.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(SelectPsuAuthenticationMethod.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(SelectPsuAuthenticationMethodResponse.class));
}
@Test
void authoriseTransaction() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/authorise-transaction.json");
Response<ScaStatusResponse> response = service.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(TransactionAuthorisation.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@Test
void getAccounts() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/get-accounts.json");
Response<AccountList> response = service.getAccountList(requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(AccountList.class));
}
@Test
void getTransactions() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/get-transactions.json");
Response<String> response = service.getTransactionListAsString(ACCOUNT_ID,
requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody());
}
@Test
void getBalances() throws IOException {
TestRequestResponse requestResponse = new TestRequestResponse("ais/get-balances.json");
Response<ReadAccountBalanceResponse200> response = service.getBalances(ACCOUNT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ReadAccountBalanceResponse200.class));
}
@Test
void getConsentStatus() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/get-consent-status.json");
Response<ConsentStatusResponse200> response = service.getConsentStatus(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ConsentStatusResponse200.class));
}
@Test
void deleteConsent() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/delete-consent.json");
Response<Void> response = service.deleteConsent(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getStatusCode()).isEqualTo(204);
}
}
| 6,222 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/VerlagMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.verlag.model.VerlagOK200TransactionDetails;
import de.adorsys.xs2a.adapter.verlag.model.VerlagTransactionDetails;
import de.adorsys.xs2a.adapter.verlag.model.VerlagTransactionResponse200Json;
import org.mapstruct.Mapper;
@Mapper
public interface VerlagMapper {
TransactionsResponse200Json toTransactionsResponse200Json(VerlagTransactionResponse200Json value);
OK200TransactionDetails toOK200TransactionDetails(VerlagOK200TransactionDetails value);
Transactions toTransactions(VerlagTransactionDetails value);
default String map(RemittanceInformationStructured value) {
return value == null ? null : value.getReference();
}
}
| 1,601 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
PsuIdTypeHeaderInterceptor.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/PsuIdTypeHeaderInterceptor.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.http.Interceptor;
import de.adorsys.xs2a.adapter.api.http.Request;
import org.apache.commons.lang3.StringUtils;
import static de.adorsys.xs2a.adapter.api.RequestHeaders.PSU_ID_TYPE;
public class PsuIdTypeHeaderInterceptor implements Interceptor {
@Override
public Request.Builder preHandle(Request.Builder builder) {
return handlePsuIdTypeHeader(builder);
}
private Request.Builder handlePsuIdTypeHeader(Request.Builder builder) {
if (builder.headers().containsKey(PSU_ID_TYPE)) {
String psuIdType = builder.headers().get(PSU_ID_TYPE);
if (StringUtils.isBlank(psuIdType)) {
builder.headers().remove(PSU_ID_TYPE);
}
}
return builder;
}
}
| 1,652 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagPaymentInitiationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/VerlagPaymentInitiationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.Interceptor;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
public class VerlagPaymentInitiationService extends BasePaymentInitiationService {
private final AbstractMap.SimpleImmutableEntry<String, String> apiKey;
public VerlagPaymentInitiationService(Aspsp aspsp,
AbstractMap.SimpleImmutableEntry<String, String> apiKey,
HttpClientFactory httpClientFactory,
List<Interceptor> interceptors,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId(), null, VerlagServiceProvider.SUPPORTED_CIPHER_SUITES),
interceptors,
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
this.apiKey = apiKey;
}
@Override
protected Map<String, String> populatePostHeaders(Map<String, String> map) {
return addApiKey(map);
}
@Override
protected Map<String, String> populatePutHeaders(Map<String, String> headers) {
return addApiKey(headers);
}
@Override
protected Map<String, String> populateGetHeaders(Map<String, String> headers) {
return addApiKey(headers);
}
private Map<String, String> addApiKey(Map<String, String> headers) {
headers.put(apiKey.getKey(), apiKey.getValue());
return headers;
}
}
| 2,647 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/VerlagAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.*;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import de.adorsys.xs2a.adapter.verlag.model.VerlagOK200TransactionDetails;
import de.adorsys.xs2a.adapter.verlag.model.VerlagTransactionResponse200Json;
import org.mapstruct.factory.Mappers;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static de.adorsys.xs2a.adapter.api.http.ContentType.APPLICATION_JSON;
public class VerlagAccountInformationService extends BaseAccountInformationService {
private final VerlagMapper verlagMapper = Mappers.getMapper(VerlagMapper.class);
private AbstractMap.SimpleImmutableEntry<String, String> apiKey;
public VerlagAccountInformationService(Aspsp aspsp,
AbstractMap.SimpleImmutableEntry<String, String> apiKey,
HttpClientFactory httpClientFactory,
List<Interceptor> interceptors,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId(), null, VerlagServiceProvider.SUPPORTED_CIPHER_SUITES),
interceptors,
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
this.apiKey = apiKey;
}
@Override
public Response<String> getTransactionListAsString(String accountId, RequestHeaders requestHeaders, RequestParams requestParams) {
return super.getTransactionListAsString(accountId, modifyAcceptHeader(requestHeaders), requestParams);
}
// Needed to deal with the behaviour of ASPSP, that responds with 406 on any value except 'application/json'
// for Accept header in production
// ASPSP Sandbox supports 'text/plain' only which is also concerned
private RequestHeaders modifyAcceptHeader(RequestHeaders requestHeaders) {
if (isTextPlain(requestHeaders)) {
return requestHeaders;
}
return setAcceptJson(requestHeaders);
}
private boolean isTextPlain(RequestHeaders requestHeaders) {
Optional<String> acceptHeaderOptional = requestHeaders.get(RequestHeaders.ACCEPT);
return acceptHeaderOptional.isPresent() && ContentType.TEXT_PLAIN.equalsIgnoreCase(acceptHeaderOptional.get());
}
@Override
public Response<TransactionsResponse200Json> getTransactionList(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionList(accountId,
requestHeaders,
requestParams,
VerlagTransactionResponse200Json.class,
verlagMapper::toTransactionsResponse200Json);
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
VerlagOK200TransactionDetails.class,
verlagMapper::toOK200TransactionDetails);
}
private RequestHeaders setAcceptJson(RequestHeaders requestHeaders) {
Map<String, String> headersMap = requestHeaders.toMap();
headersMap.put(RequestHeaders.ACCEPT, APPLICATION_JSON);
return RequestHeaders.fromMap(headersMap);
}
@Override
protected Map<String, String> populatePostHeaders(Map<String, String> headers) {
return addApiKey(headers);
}
@Override
protected Map<String, String> populatePutHeaders(Map<String, String> headers) {
return addApiKey(headers);
}
@Override
protected Map<String, String> populateGetHeaders(Map<String, String> headers) {
return addApiKey(headers);
}
@Override
protected Map<String, String> populateDeleteHeaders(Map<String, String> headers) {
return addApiKey(headers);
}
private Map<String, String> addApiKey(Map<String, String> headers) {
headers.put(apiKey.getKey(), apiKey.getValue());
return headers;
}
}
| 6,071 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/VerlagServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.config.AdapterConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
import de.adorsys.xs2a.adapter.impl.BaseDownloadService;
import java.util.AbstractMap;
public class VerlagServiceProvider extends AbstractAdapterServiceProvider implements DownloadServiceProvider {
private static final String VERLAG_API_KEY_NAME = "verlag.apikey.name";
private static final String VERLAG_API_KEY_VALUE = "verlag.apikey.value";
static final String[] SUPPORTED_CIPHER_SUITES =
{"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"};
private static final AbstractMap.SimpleImmutableEntry<String, String> apiKeyEntry;
private final PsuIdTypeHeaderInterceptor psuIdTypeHeaderInterceptor = new PsuIdTypeHeaderInterceptor();
static {
String apiKeyName = AdapterConfig.readProperty(VERLAG_API_KEY_NAME, "");
String apiKeyValue = AdapterConfig.readProperty(VERLAG_API_KEY_VALUE, "");
apiKeyEntry = new AbstractMap.SimpleImmutableEntry<>(apiKeyName, apiKeyValue);
}
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new VerlagAccountInformationService(aspsp,
apiKeyEntry,
httpClientFactory,
getInterceptors(aspsp, psuIdTypeHeaderInterceptor),
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new VerlagPaymentInitiationService(aspsp,
apiKeyEntry,
httpClientFactory,
getInterceptors(aspsp, psuIdTypeHeaderInterceptor),
linksRewriter);
}
@Override
public DownloadService getDownloadService(String baseUrl,
HttpClientFactory httpClientFactory) {
return new BaseDownloadService(baseUrl,
httpClientFactory.getHttpClient(getAdapterId(), null, SUPPORTED_CIPHER_SUITES),
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public String getAdapterId() {
return "verlag-adapter";
}
}
| 3,946 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagTransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/model/VerlagTransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.*;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class VerlagTransactionDetails {
private String transactionId;
private String entryReference;
private String endToEndId;
private String mandateId;
private String checkId;
private String creditorId;
private LocalDate bookingDate;
private LocalDate valueDate;
private Amount transactionAmount;
private List<ReportExchangeRate> currencyExchange;
private String creditorName;
private AccountReference creditorAccount;
private String creditorAgent;
private String ultimateCreditor;
private String debtorName;
private AccountReference debtorAccount;
private String debtorAgent;
private String ultimateDebtor;
private String remittanceInformationUnstructured;
private List<String> remittanceInformationUnstructuredArray;
private RemittanceInformationStructured remittanceInformationStructured;
private List<RemittanceInformationStructured> remittanceInformationStructuredArray;
private String additionalInformation;
private AdditionalInformationStructured additionalInformationStructured;
private PurposeCode purposeCode;
private String bankTransactionCode;
private String proprietaryBankTransactionCode;
private Balance balanceAfterTransaction;
@JsonProperty("_links")
private Map<String, HrefType> links;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getEntryReference() {
return entryReference;
}
public void setEntryReference(String entryReference) {
this.entryReference = entryReference;
}
public String getEndToEndId() {
return endToEndId;
}
public void setEndToEndId(String endToEndId) {
this.endToEndId = endToEndId;
}
public String getMandateId() {
return mandateId;
}
public void setMandateId(String mandateId) {
this.mandateId = mandateId;
}
public String getCheckId() {
return checkId;
}
public void setCheckId(String checkId) {
this.checkId = checkId;
}
public String getCreditorId() {
return creditorId;
}
public void setCreditorId(String creditorId) {
this.creditorId = creditorId;
}
public LocalDate getBookingDate() {
return bookingDate;
}
public void setBookingDate(LocalDate bookingDate) {
this.bookingDate = bookingDate;
}
public LocalDate getValueDate() {
return valueDate;
}
public void setValueDate(LocalDate valueDate) {
this.valueDate = valueDate;
}
public Amount getTransactionAmount() {
return transactionAmount;
}
public void setTransactionAmount(Amount transactionAmount) {
this.transactionAmount = transactionAmount;
}
public List<ReportExchangeRate> getCurrencyExchange() {
return currencyExchange;
}
public void setCurrencyExchange(List<ReportExchangeRate> currencyExchange) {
this.currencyExchange = currencyExchange;
}
public String getCreditorName() {
return creditorName;
}
public void setCreditorName(String creditorName) {
this.creditorName = creditorName;
}
public AccountReference getCreditorAccount() {
return creditorAccount;
}
public void setCreditorAccount(AccountReference creditorAccount) {
this.creditorAccount = creditorAccount;
}
public String getCreditorAgent() {
return creditorAgent;
}
public void setCreditorAgent(String creditorAgent) {
this.creditorAgent = creditorAgent;
}
public String getUltimateCreditor() {
return ultimateCreditor;
}
public void setUltimateCreditor(String ultimateCreditor) {
this.ultimateCreditor = ultimateCreditor;
}
public String getDebtorName() {
return debtorName;
}
public void setDebtorName(String debtorName) {
this.debtorName = debtorName;
}
public AccountReference getDebtorAccount() {
return debtorAccount;
}
public void setDebtorAccount(AccountReference debtorAccount) {
this.debtorAccount = debtorAccount;
}
public String getDebtorAgent() {
return debtorAgent;
}
public void setDebtorAgent(String debtorAgent) {
this.debtorAgent = debtorAgent;
}
public String getUltimateDebtor() {
return ultimateDebtor;
}
public void setUltimateDebtor(String ultimateDebtor) {
this.ultimateDebtor = ultimateDebtor;
}
public String getRemittanceInformationUnstructured() {
return remittanceInformationUnstructured;
}
public void setRemittanceInformationUnstructured(String remittanceInformationUnstructured) {
this.remittanceInformationUnstructured = remittanceInformationUnstructured;
}
public List<String> getRemittanceInformationUnstructuredArray() {
return remittanceInformationUnstructuredArray;
}
public void setRemittanceInformationUnstructuredArray(
List<String> remittanceInformationUnstructuredArray) {
this.remittanceInformationUnstructuredArray = remittanceInformationUnstructuredArray;
}
public RemittanceInformationStructured getRemittanceInformationStructured() {
return remittanceInformationStructured;
}
public void setRemittanceInformationStructured(RemittanceInformationStructured remittanceInformationStructured) {
this.remittanceInformationStructured = remittanceInformationStructured;
}
public List<RemittanceInformationStructured> getRemittanceInformationStructuredArray() {
return remittanceInformationStructuredArray;
}
public void setRemittanceInformationStructuredArray(
List<RemittanceInformationStructured> remittanceInformationStructuredArray) {
this.remittanceInformationStructuredArray = remittanceInformationStructuredArray;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public AdditionalInformationStructured getAdditionalInformationStructured() {
return additionalInformationStructured;
}
public void setAdditionalInformationStructured(
AdditionalInformationStructured additionalInformationStructured) {
this.additionalInformationStructured = additionalInformationStructured;
}
public PurposeCode getPurposeCode() {
return purposeCode;
}
public void setPurposeCode(PurposeCode purposeCode) {
this.purposeCode = purposeCode;
}
public String getBankTransactionCode() {
return bankTransactionCode;
}
public void setBankTransactionCode(String bankTransactionCode) {
this.bankTransactionCode = bankTransactionCode;
}
public String getProprietaryBankTransactionCode() {
return proprietaryBankTransactionCode;
}
public void setProprietaryBankTransactionCode(String proprietaryBankTransactionCode) {
this.proprietaryBankTransactionCode = proprietaryBankTransactionCode;
}
public Balance getBalanceAfterTransaction() {
return balanceAfterTransaction;
}
public void setBalanceAfterTransaction(Balance balanceAfterTransaction) {
this.balanceAfterTransaction = balanceAfterTransaction;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VerlagTransactionDetails that = (VerlagTransactionDetails) o;
return Objects.equals(transactionId, that.transactionId) &&
Objects.equals(entryReference, that.entryReference) &&
Objects.equals(endToEndId, that.endToEndId) &&
Objects.equals(mandateId, that.mandateId) &&
Objects.equals(checkId, that.checkId) &&
Objects.equals(creditorId, that.creditorId) &&
Objects.equals(bookingDate, that.bookingDate) &&
Objects.equals(valueDate, that.valueDate) &&
Objects.equals(transactionAmount, that.transactionAmount) &&
Objects.equals(currencyExchange, that.currencyExchange) &&
Objects.equals(creditorName, that.creditorName) &&
Objects.equals(creditorAccount, that.creditorAccount) &&
Objects.equals(creditorAgent, that.creditorAgent) &&
Objects.equals(ultimateCreditor, that.ultimateCreditor) &&
Objects.equals(debtorName, that.debtorName) &&
Objects.equals(debtorAccount, that.debtorAccount) &&
Objects.equals(debtorAgent, that.debtorAgent) &&
Objects.equals(ultimateDebtor, that.ultimateDebtor) &&
Objects.equals(remittanceInformationUnstructured, that.remittanceInformationUnstructured) &&
Objects.equals(remittanceInformationUnstructuredArray, that.remittanceInformationUnstructuredArray) &&
Objects.equals(remittanceInformationStructured, that.remittanceInformationStructured) &&
Objects.equals(remittanceInformationStructuredArray, that.remittanceInformationStructuredArray) &&
Objects.equals(additionalInformation, that.additionalInformation) &&
Objects.equals(additionalInformationStructured, that.additionalInformationStructured) &&
Objects.equals(purposeCode, that.purposeCode) &&
Objects.equals(bankTransactionCode, that.bankTransactionCode) &&
Objects.equals(proprietaryBankTransactionCode, that.proprietaryBankTransactionCode) &&
Objects.equals(balanceAfterTransaction, that.balanceAfterTransaction) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(transactionId,
entryReference,
endToEndId,
mandateId,
checkId,
creditorId,
bookingDate,
valueDate,
transactionAmount,
currencyExchange,
creditorName,
creditorAccount,
creditorAgent,
ultimateCreditor,
debtorName,
debtorAccount,
debtorAgent,
ultimateDebtor,
remittanceInformationUnstructured,
remittanceInformationUnstructuredArray,
remittanceInformationStructured,
remittanceInformationStructuredArray,
additionalInformation,
additionalInformationStructured,
purposeCode,
bankTransactionCode,
proprietaryBankTransactionCode,
balanceAfterTransaction,
links);
}
}
| 12,128 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagOK200TransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/model/VerlagOK200TransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag.model;
import java.util.Objects;
public class VerlagOK200TransactionDetails {
private VerlagTransactionDetails transactionsDetails;
public VerlagTransactionDetails getTransactionsDetails() {
return transactionsDetails;
}
public void setTransactionsDetails(VerlagTransactionDetails transactionsDetails) {
this.transactionsDetails = transactionsDetails;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VerlagOK200TransactionDetails that = (VerlagOK200TransactionDetails) o;
return Objects.equals(transactionsDetails, that.transactionsDetails);
}
@Override
public int hashCode() {
return Objects.hash(transactionsDetails);
}
}
| 1,684 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagAccountReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/model/VerlagAccountReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class VerlagAccountReport {
private List<VerlagTransactionDetails> booked;
private List<VerlagTransactionDetails> pending;
@JsonProperty("_links")
private Map<String, HrefType> links;
public List<VerlagTransactionDetails> getBooked() {
return booked;
}
public void setBooked(List<VerlagTransactionDetails> booked) {
this.booked = booked;
}
public List<VerlagTransactionDetails> getPending() {
return pending;
}
public void setPending(List<VerlagTransactionDetails> pending) {
this.pending = pending;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VerlagAccountReport that = (VerlagAccountReport) o;
return Objects.equals(booked, that.booked) &&
Objects.equals(pending, that.pending) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(booked,
pending,
links);
}
}
| 2,318 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
VerlagTransactionResponse200Json.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/verlag-adapter/src/main/java/de/adorsys/xs2a/adapter/verlag/model/VerlagTransactionResponse200Json.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.verlag.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.AccountReference;
import de.adorsys.xs2a.adapter.api.model.Balance;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class VerlagTransactionResponse200Json {
private AccountReference account;
private VerlagAccountReport transactions;
private List<Balance> balances;
@JsonProperty("_links")
private Map<String, HrefType> links;
public AccountReference getAccount() {
return account;
}
public void setAccount(AccountReference account) {
this.account = account;
}
public VerlagAccountReport getTransactions() {
return transactions;
}
public void setTransactions(VerlagAccountReport transactions) {
this.transactions = transactions;
}
public List<Balance> getBalances() {
return balances;
}
public void setBalances(List<Balance> balances) {
this.balances = balances;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VerlagTransactionResponse200Json that = (VerlagTransactionResponse200Json) o;
return Objects.equals(account, that.account) &&
Objects.equals(transactions, that.transactions) &&
Objects.equals(balances, that.balances) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(account,
transactions,
balances,
links);
}
}
| 2,733 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditHeadersTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/test/java/de/adorsys/xs2a/adapter/unicredit/UnicreditHeadersTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static de.adorsys.xs2a.adapter.unicredit.UnicreditHeaders.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
class UnicreditHeadersTest {
@Test
void addPsuIdTypeHeaderDefault() {
Map<String, String> header = addPsuIdTypeHeader(new HashMap<>());
assertThat(header).hasSize(1)
.containsValues(DEFAULT_PSU_ID_TYPE);
}
@Test
void addPsuIdTypeHeaderNotSupported() {
HashMap<String, String> headers = new HashMap<>();
headers.put(RequestHeaders.PSU_ID_TYPE, "UNSUPPORTED_PSU_ID_TYPE");
Map<String, String> header = addPsuIdTypeHeader(headers);
assertThat(header).hasSize(1)
.containsValues(DEFAULT_PSU_ID_TYPE);
}
@Test
void addPsuIdTypeHeaderGlobal() {
HashMap<String, String> headers = new HashMap<>();
headers.put(RequestHeaders.PSU_ID_TYPE, UCE_BANKING_GLOBAL);
Map<String, String> header = addPsuIdTypeHeader(headers);
assertThat(header).hasSize(1)
.containsValues(UCE_BANKING_GLOBAL);
}
@Test
void addPossibleValues() {
assertThrows(UnsupportedOperationException.class, () -> POSSIBLE_PSU_ID_TYPE_VALUES.add("new-item"));
}
}
| 2,297 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditPaymentInitiationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/test/java/de/adorsys/xs2a/adapter/unicredit/UnicreditPaymentInitiationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.exception.ErrorResponseException;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import static de.adorsys.xs2a.adapter.api.model.PaymentProduct.SEPA_CREDIT_TRANSFERS;
import static de.adorsys.xs2a.adapter.api.model.PaymentService.PAYMENTS;
import static de.adorsys.xs2a.adapter.api.model.PaymentService.PERIODIC_PAYMENTS;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.InstanceOfAssertFactories.optional;
import static org.assertj.core.api.InstanceOfAssertFactories.type;
import static org.junit.jupiter.params.provider.Arguments.arguments;
@ServiceWireMockTest(UnicreditServiceProvider.class)
class UnicreditPaymentInitiationServiceWireMockTest {
private static final String PAYMENTS_PAYMENT_ID = "PDEA630971";
private static final String PAYMENTS_AUTHORISATION_ID = "PDEA630971";
private static final String PERIODIC_PAYMENT_ID = "PDEA744022";
private static final String PERIODIC_AUTHORISATION_ID = "PDEA744022";
private final Map<PaymentService, Pair<String, String>> ids;
private final PaymentInitiationService paymentInitiationService;
UnicreditPaymentInitiationServiceWireMockTest(PaymentInitiationService paymentInitiationService) {
this.paymentInitiationService = paymentInitiationService;
this.ids = initiateMap();
}
private Map<PaymentService, Pair<String, String>> initiateMap() {
Map<PaymentService, Pair<String, String>> map = new HashMap<>();
map.put(PaymentService.PAYMENTS, Pair.of(PAYMENTS_PAYMENT_ID, PAYMENTS_AUTHORISATION_ID));
map.put(PaymentService.PERIODIC_PAYMENTS, Pair.of(PERIODIC_PAYMENT_ID, PERIODIC_AUTHORISATION_ID));
return map;
}
@ParameterizedTest
@MethodSource("paymentTypes")
void initiatePayment(PaymentService paymentService, PaymentProduct paymentProduct) throws IOException {
var requestResponse = new TestRequestResponse(format("pis/%s/%s/initiate-payment.json", paymentService, paymentProduct));
var response = paymentInitiationService.initiatePayment(paymentService,
paymentProduct,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(getPaymentClass(paymentService)));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(PaymentInitationRequestResponse201.class));
}
private Class<?> getPaymentClass(PaymentService paymentService) {
if (PAYMENTS == paymentService) {
return PaymentInitiationJson.class;
}
return PeriodicPaymentInitiationJson.class;
}
@ParameterizedTest
@MethodSource("paymentTypes")
void getPaymentStatus(PaymentService paymentService, PaymentProduct paymentProduct) throws IOException {
var requestResponse = new TestRequestResponse(format("pis/%s/%s/get-payment-status.json", paymentService, paymentProduct));
var response = paymentInitiationService.getPaymentInitiationStatus(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(PaymentInitiationStatusResponse200Json.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void getScaStatus(PaymentService paymentService, PaymentProduct paymentProduct) throws IOException {
var requestResponse = new TestRequestResponse(format("pis/%s/%s/get-sca-status.json", paymentService, paymentProduct));
if (PAYMENTS == paymentService) {
var response = paymentInitiationService.getPaymentInitiationScaStatus(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
} else { // get SCA Status is not implemented for periodic-payments
var requestHeaders = requestResponse.requestHeaders();
var params = RequestParams.empty();
assertThatThrownBy(() -> paymentInitiationService.getPaymentInitiationScaStatus(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestHeaders,
params))
.asInstanceOf(type(ErrorResponseException.class))
.matches(er -> 404 == er.getStatusCode())
.extracting(ErrorResponseException::getErrorResponse, optional(ErrorResponse.class))
.contains(requestResponse.responseBody(ErrorResponse.class));
}
}
@ParameterizedTest
@MethodSource("paymentTypes")
void authorizeTransaction(PaymentService paymentService, PaymentProduct paymentProduct) throws IOException {
var requestResponse = new TestRequestResponse(format("pis/%s/%s/authorise-transaction.json", paymentService, paymentProduct));
var response = paymentInitiationService.updatePaymentPsuData(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
requestResponse.requestParams(),
requestResponse.requestBody(TransactionAuthorisation.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void authenticatePsu(PaymentService paymentService, PaymentProduct paymentProduct) throws IOException {
var requestResponse = new TestRequestResponse(format("pis/%s/%s/authenticate-psu.json", paymentService, paymentProduct));
var response = paymentInitiationService.startPaymentAuthorisation(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(StartScaprocessResponse.class));
}
@Disabled("Sandbox and Production environments have different UpdatePsuAuthentication models, thus can't run this test for" +
"avoiding MismatchedInputException")
@ParameterizedTest
@MethodSource("paymentTypes")
void updatePsuAuthentication(PaymentService paymentService, PaymentProduct paymentProduct) throws IOException {
var requestResponse = new TestRequestResponse(format("pis/%s/%s/update-psu-authentication.json", paymentService, paymentProduct));
var response = paymentInitiationService.updatePaymentPsuData(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
requestResponse.requestParams(),
requestResponse.requestBody(UpdatePsuAuthentication.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(UpdatePsuAuthenticationResponse.class));
}
private static Stream<Arguments> paymentTypes() {
return Stream.of(arguments(PAYMENTS, SEPA_CREDIT_TRANSFERS),
arguments(PERIODIC_PAYMENTS, SEPA_CREDIT_TRANSFERS));
}
}
| 9,188 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditPaymentInitiationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/test/java/de/adorsys/xs2a/adapter/unicredit/UnicreditPaymentInitiationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.Request;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditUpdatePsuAuthenticationResponse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static de.adorsys.xs2a.adapter.unicredit.UnicreditHeaders.DEFAULT_PSU_ID_TYPE;
import static de.adorsys.xs2a.adapter.unicredit.UnicreditHeaders.UCE_BANKING_GLOBAL;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
class UnicreditPaymentInitiationServiceTest {
private static final String BASE_URL = "https://simulator-xs2a.db.com/p9is/DE/SB-DB";
private static final Aspsp ASPSP = buildAspspWithUrl();
private static final String INITIATE_PAYMENT_URL = BASE_URL + "/v1/payments/sepa-credit-transfers";
private static final String INITIATE_PERIODIC_PAYMENT_URL = BASE_URL + "/v1/periodic-payments/sepa-credit-transfers";
private static final String PAYMENT_ID = "payment-id";
private static final String PAYMENT_ID_URL = INITIATE_PAYMENT_URL + "/" + PAYMENT_ID;
private static final String WRONG_PSU_ID_TYPE = "PSU_ID_TYPE";
private static final String AUTHORISATION_ID = "authorisation-id";
private static final String AUTHORISATION_URL = PAYMENT_ID_URL + "?authenticationCurrentNumber=" + AUTHORISATION_ID;
private static final String TPP_REDIRECT_URI = "http://example.com";
private static final String POST_METHOD = "POST";
private static final String DEFAULT_COUNTRY_CODE = "DE";
private static final Map<String, String> defaultHeaders = getHeadersMap(DEFAULT_PSU_ID_TYPE);
private HttpClient httpClient;
private LinksRewriter linksRewriter;
private UnicreditPaymentInitiationService paymentInitiationService;
@BeforeEach
void setUp() {
httpClient = mock(HttpClient.class);
linksRewriter = mock(LinksRewriter.class);
HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
paymentInitiationService = new UnicreditPaymentInitiationService(ASPSP, httpClientFactory, linksRewriter);
}
@Test
void initiatePayment_wrongPsuIdTypeValue() {
Map<String, String> headersMap = getHeadersMap(WRONG_PSU_ID_TYPE);
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, POST_METHOD, INITIATE_PAYMENT_URL);
when(httpClient.post(eq(INITIATE_PAYMENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new PaymentInitationRequestResponse201(), ResponseHeaders.fromMap(headersMap)));
paymentInitiationService.initiatePayment(PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
RequestHeaders.fromMap(headersMap),
RequestParams.empty(),
new PaymentInitiationJson());
verify(httpClient, times(1)).post(eq(INITIATE_PAYMENT_URL));
assertThat(requestBuilder.headers()).containsEntry(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
@Test
void initiatePayment_defaultPsuIdTypeValue() {
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, POST_METHOD, INITIATE_PAYMENT_URL);
when(httpClient.post(eq(INITIATE_PAYMENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new PaymentInitationRequestResponse201(), ResponseHeaders.fromMap(defaultHeaders)));
paymentInitiationService.initiatePayment(PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
RequestHeaders.fromMap(defaultHeaders),
RequestParams.empty(),
new PaymentInitiationJson());
verify(httpClient, times(1)).post(eq(INITIATE_PAYMENT_URL));
assertThat(requestBuilder.headers()).containsEntry(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
@Test
void initiatePayment_alternativeAcceptedPsuIdTypeValue() {
Map<String, String> headersMap = getHeadersMap(UCE_BANKING_GLOBAL);
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, POST_METHOD, INITIATE_PAYMENT_URL);
when(httpClient.post(eq(INITIATE_PAYMENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new PaymentInitationRequestResponse201(), ResponseHeaders.fromMap(headersMap)));
paymentInitiationService.initiatePayment(PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
RequestHeaders.fromMap(headersMap),
RequestParams.empty(),
new PaymentInitiationJson());
verify(httpClient, times(1)).post(eq(INITIATE_PAYMENT_URL));
assertThat(requestBuilder.headers()).containsEntry(RequestHeaders.PSU_ID_TYPE, UnicreditHeaders.UCE_BANKING_GLOBAL);
}
@Test
void updatePaymentPsuData() {
Request.Builder requestBuilder = spy(new RequestBuilderImpl(httpClient, "PUT", AUTHORISATION_URL));
ScaStatusResponse statusResponse = new ScaStatusResponse();
when(httpClient.put(anyString())).thenReturn(requestBuilder);
doReturn(new Response<>(200,
statusResponse,
ResponseHeaders.fromMap(Collections.emptyMap()))).when(requestBuilder).send(any(), eq(Collections.emptyList()));
paymentInitiationService.updatePaymentPsuData(PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
AUTHORISATION_ID,
RequestHeaders.fromMap(Collections.emptyMap()),
RequestParams.empty(),
new TransactionAuthorisation());
assertThat(requestBuilder.headers()).containsEntry(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
@Test
void updatePaymentPsuData_responseMapping() {
Request.Builder requestBuilder = spy(new RequestBuilderImpl(httpClient, "PUT", AUTHORISATION_URL));
UnicreditUpdatePsuAuthenticationResponse unicreditResponse = new UnicreditUpdatePsuAuthenticationResponse();
Map<String, HrefType> links = new HashMap<>();
HrefType hrefAuthoriseTransaction = new HrefType();
hrefAuthoriseTransaction.setHref("https://api.unicredit.de/hydrogen/v1/payments/****");
links.put("authoriseTransaction", hrefAuthoriseTransaction);
unicreditResponse.setLinks(Collections.singletonList(links));
when(httpClient.put(anyString())).thenReturn(requestBuilder);
doReturn(new Response<>(200,
unicreditResponse,
ResponseHeaders.fromMap(Collections.emptyMap()))).when(requestBuilder).send(any(), eq(Collections.emptyList()));
when(linksRewriter.rewrite(any())).thenAnswer(i -> i.getArguments()[0]);
Response<UpdatePsuAuthenticationResponse> response = paymentInitiationService.updatePaymentPsuData(
PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
AUTHORISATION_ID,
RequestHeaders.fromMap(Collections.emptyMap()),
RequestParams.empty(),
new UpdatePsuAuthentication());
assertThat(response.getBody().getLinks()).containsExactlyEntriesOf(links);
}
@Test
void initiatePayment_payments_json_noCreditorAddressInitially() {
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, POST_METHOD, INITIATE_PAYMENT_URL);
when(httpClient.post(eq(INITIATE_PAYMENT_URL))).thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new PaymentInitationRequestResponse201(), ResponseHeaders.emptyResponseHeaders()));
paymentInitiationService.initiatePayment(PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
RequestHeaders.fromMap(defaultHeaders),
RequestParams.empty(),
new PaymentInitiationJson());
verify(httpClient, times(1)).post(eq(INITIATE_PAYMENT_URL));
PaymentInitiationJson actualBody = null;
try {
actualBody = deserializeString(requestBuilder.body(), PaymentInitiationJson.class);
} catch (JsonProcessingException e) {
fail("failed to deserialize body string");
}
assertThat(actualBody)
.extracting((body) -> Optional.ofNullable(body)
.map(PaymentInitiationJson::getCreditorAddress)
.map(Address::getCountry)
.orElse(null))
.isNotNull()
.isEqualTo(DEFAULT_COUNTRY_CODE);
}
@Test
void initiatePayment_payments_json_withCreditorAddress() {
String countryCode = "UK";
Address address = new Address();
address.setCountry(countryCode);
PaymentInitiationJson requestBody = new PaymentInitiationJson();
requestBody.setCreditorAddress(address);
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, POST_METHOD, INITIATE_PAYMENT_URL);
when(httpClient.post(eq(INITIATE_PAYMENT_URL))).thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new PaymentInitationRequestResponse201(), ResponseHeaders.emptyResponseHeaders()));
paymentInitiationService.initiatePayment(PaymentService.PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
RequestHeaders.fromMap(defaultHeaders),
RequestParams.empty(),
requestBody);
verify(httpClient, times(1)).post(eq(INITIATE_PAYMENT_URL));
PaymentInitiationJson actualBody = null;
try {
actualBody = deserializeString(requestBuilder.body(), PaymentInitiationJson.class);
} catch (JsonProcessingException e) {
fail("failed to deserialize body string");
}
assertThat(actualBody)
.extracting((body) -> Optional.ofNullable(body)
.map(PaymentInitiationJson::getCreditorAddress)
.map(Address::getCountry)
.orElse(null))
.isNotNull()
.isEqualTo(countryCode);
}
@Test
void initiatePayment_periodic_json_noCreditorAddressInitially() {
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, POST_METHOD, INITIATE_PAYMENT_URL);
when(httpClient.post(eq(INITIATE_PERIODIC_PAYMENT_URL))).thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new PaymentInitationRequestResponse201(), ResponseHeaders.emptyResponseHeaders()));
paymentInitiationService.initiatePayment(PaymentService.PERIODIC_PAYMENTS,
PaymentProduct.SEPA_CREDIT_TRANSFERS,
RequestHeaders.fromMap(defaultHeaders),
RequestParams.empty(),
new PeriodicPaymentInitiationJson());
verify(httpClient, times(1)).post(eq(INITIATE_PERIODIC_PAYMENT_URL));
PeriodicPaymentInitiationJson actualBody = null;
try {
actualBody = deserializeString(requestBuilder.body(), PeriodicPaymentInitiationJson.class);
} catch (JsonProcessingException e) {
fail("failed to deserialize body string");
}
assertThat(actualBody)
.extracting((body) -> Optional.ofNullable(body)
.map(PeriodicPaymentInitiationJson::getCreditorAddress)
.map(Address::getCountry)
.orElse(null))
.isNotNull()
.isEqualTo(DEFAULT_COUNTRY_CODE);
}
private static Map<String, String> getHeadersMap(String uceBankingGlobal) {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(RequestHeaders.PSU_ID_TYPE, uceBankingGlobal);
headersMap.put(RequestHeaders.TPP_REDIRECT_URI, TPP_REDIRECT_URI);
return headersMap;
}
private static Aspsp buildAspspWithUrl() {
Aspsp aspsp = new Aspsp();
aspsp.setUrl(BASE_URL);
return aspsp;
}
private <T> T deserializeString(String value, Class<T> tClass) throws JsonProcessingException {
return new ObjectMapper().readValue(value, tClass);
}
}
| 14,998 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditAccountInformationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/test/java/de/adorsys/xs2a/adapter/unicredit/UnicreditAccountInformationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.exception.ErrorResponseException;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.InstanceOfAssertFactories.optional;
import static org.assertj.core.api.InstanceOfAssertFactories.type;
@ServiceWireMockTest(UnicreditServiceProvider.class)
class UnicreditAccountInformationServiceWireMockTest {
private static final String CONSENT_ID = "12f6ed9d-fd09-4aea-97bc-aeb61052cf3e";
private static final String ACCOUNT_ID = "3dc3d5b37023";
private static final String AUTHORISATION_ID = "3dc3d5b37023";
private final AccountInformationService accountInformationService;
UnicreditAccountInformationServiceWireMockTest(AccountInformationService accountInformationService) {
this.accountInformationService = accountInformationService;
}
@Test
void createConsent() throws Exception {
var requestResponse = new TestRequestResponse("ais/create-consent.json");
var response = accountInformationService.createConsent(requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(Consents.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ConsentsResponse201.class));
}
@Test
void deleteConsent() throws Exception {
var requestResponse = new TestRequestResponse("ais/delete-consent.json");
var response = accountInformationService.deleteConsent(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getStatusCode()).isEqualTo(204);
}
@Test
void getAccounts() throws Exception {
var requestResponse = new TestRequestResponse("ais/get-accounts.json");
var response = accountInformationService.getAccountList(requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(AccountList.class));
}
@Test
void getBalances() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-balances.json");
var response = accountInformationService.getBalances(ACCOUNT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ReadAccountBalanceResponse200.class));
}
@Test
void getConsentStatus() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-consent-status.json");
var response = accountInformationService.getConsentStatus(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ConsentStatusResponse200.class));
}
@Test
void getScaStatus() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-sca-status.json");
var requestHeaders = requestResponse.requestHeaders();
var params = RequestParams.empty();
assertThatThrownBy(() -> accountInformationService.getConsentScaStatus(CONSENT_ID,
AUTHORISATION_ID,
requestHeaders,
params))
.asInstanceOf(type(ErrorResponseException.class))
.matches(er -> 404 == er.getStatusCode())
.extracting(ErrorResponseException::getErrorResponse, optional(ErrorResponse.class))
.contains(requestResponse.responseBody(ErrorResponse.class));
}
@Test
void getTransactions() throws Exception {
var requestResponse = new TestRequestResponse("ais/get-transactions.json");
var response = accountInformationService.getTransactionList(ACCOUNT_ID,
requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(TransactionsResponse200Json.class));
}
@Test
void authoriseTransaction() throws Exception {
var requestResponse = new TestRequestResponse("ais/authorise-transaction.json");
var response = accountInformationService.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
requestResponse.requestParams(),
requestResponse.requestBody(TransactionAuthorisation.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@Test
void authenticatePsu() throws Exception {
var requestResponse = new TestRequestResponse("ais/authenticate-psu.json");
var response = accountInformationService.startConsentAuthorisation(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(StartScaprocessResponse.class));
}
@Test
void updatePsuAuthentication() throws IOException {
var requestResponse = new TestRequestResponse("ais/update-psu-authentication.json");
var response = accountInformationService.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
requestResponse.requestParams(),
requestResponse.requestBody(UpdatePsuAuthentication.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(UpdatePsuAuthenticationResponse.class));
}
}
| 6,880 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/test/java/de/adorsys/xs2a/adapter/unicredit/UnicreditServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class UnicreditServiceProviderTest {
private UnicreditServiceProvider serviceProvider;
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final Aspsp aspsp = new Aspsp();
@BeforeEach
void setUp() {
serviceProvider = new UnicreditServiceProvider();
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
}
@Test
void getAccountInformationService() {
AccountInformationService actualService
= serviceProvider.getAccountInformationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(UnicreditAccountInformationService.class);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService actualService
= serviceProvider.getPaymentInitiationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(UnicreditPaymentInitiationService.class);
}
}
| 2,488 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditAccountInformationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/test/java/de/adorsys/xs2a/adapter/unicredit/UnicreditAccountInformationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.Request;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
class UnicreditAccountInformationServiceTest {
private static final String BASE_URL = "https://simulator-xs2a.db.com/ais/DE/SB-DB";
private static final Aspsp ASPSP = buildAspspWithUrl();
private static final String CONSENT_URL = BASE_URL + "/v1/consents";
public static final String CONSENT_ID = "consent-id";
private static final String CONSENT_ID_URL = CONSENT_URL + "/" + CONSENT_ID;
private static final String WRONG_PSU_ID_TYPE = "PSU_ID_TYPE";
private static final String DEFAULT_PSU_ID_TYPE = "HVB_ONLINEBANKING";
private static final String ALTERNATIVE_PSU_ID_TYPE = "UCEBANKINGGLOBAL";
public static final String AUTHORISATION_ID = "authorisation-id";
public static final String AUTHORISATION_URL = CONSENT_ID_URL + "?authenticationCurrentNumber=" + AUTHORISATION_ID;
private static final String TPP_REDIRECT_URI = "http://example.com";
private static final String ACCOUNT_ID = "accountId";
private static final String REMITTANCE_INFORMATION_STRUCTURED = "remittanceInformationStructuredStringValue";
private final HttpClient httpClient = mock(HttpClient.class);
private final LinksRewriter linksRewriter = mock(LinksRewriter.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private UnicreditAccountInformationService accountInformationService;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
accountInformationService = new UnicreditAccountInformationService(ASPSP, httpClientFactory, linksRewriter);
}
@Test
void createConsent_wrongPsuIdTypeValue() {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(RequestHeaders.PSU_ID_TYPE, WRONG_PSU_ID_TYPE);
headersMap.put(RequestHeaders.TPP_REDIRECT_URI, TPP_REDIRECT_URI);
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, "POST", CONSENT_URL);
when(httpClient.post(eq(CONSENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new ConsentsResponse201(), ResponseHeaders.fromMap(headersMap)));
accountInformationService.createConsent(RequestHeaders.fromMap(headersMap),
RequestParams.empty(),
new Consents());
verify(httpClient, times(1)).post(eq(CONSENT_URL));
Map<String, String> headers = requestBuilder.headers();
assertThat(headers).containsEntry(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
@Test
void createConsent_defaultPsuIdTypeValue() {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
headersMap.put(RequestHeaders.TPP_REDIRECT_URI, TPP_REDIRECT_URI);
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, "POST", CONSENT_URL);
when(httpClient.post(eq(CONSENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new ConsentsResponse201(), ResponseHeaders.fromMap(headersMap)));
accountInformationService.createConsent(RequestHeaders.fromMap(headersMap),
RequestParams.empty(),
new Consents());
verify(httpClient, times(1)).post(eq(CONSENT_URL));
Map<String, String> headers = requestBuilder.headers();
assertThat(headers).containsEntry(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
@Test
void createConsent_alternativeAcceptedPsuIdTypeValue() {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(RequestHeaders.PSU_ID_TYPE, ALTERNATIVE_PSU_ID_TYPE);
headersMap.put(RequestHeaders.TPP_REDIRECT_URI, TPP_REDIRECT_URI);
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, "POST", CONSENT_URL);
when(httpClient.post(eq(CONSENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new ConsentsResponse201(), ResponseHeaders.fromMap(headersMap)));
accountInformationService.createConsent(RequestHeaders.fromMap(headersMap),
RequestParams.empty(),
new Consents());
verify(httpClient, times(1)).post(eq(CONSENT_URL));
Map<String, String> headers = requestBuilder.headers();
assertThat(headers).containsEntry(RequestHeaders.PSU_ID_TYPE, ALTERNATIVE_PSU_ID_TYPE);
}
@Test
void updateConsentsPsuData() {
Request.Builder requestBuilder = spy(new RequestBuilderImpl(httpClient, "PUT", AUTHORISATION_URL));
ScaStatusResponse statusResponse = new ScaStatusResponse();
when(httpClient.put(anyString())).thenReturn(requestBuilder);
doReturn(new Response<>(200,
statusResponse,
ResponseHeaders.fromMap(Collections.emptyMap()))).when(requestBuilder).send(any(), eq(Collections.emptyList()));
accountInformationService.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
RequestHeaders.fromMap(Collections.emptyMap()),
RequestParams.empty(),
new TransactionAuthorisation());
Map<String, String> headers = requestBuilder.headers();
assertThat(headers).containsEntry(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
@Test
void getTransactionList() {
String rawResponse = "{\n" +
" \"transactions\": {\n" +
" \"booked\": [\n" +
" {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", BASE_URL));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionList(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(TransactionsResponse200Json.class))
.matches(body ->
body.getTransactions()
.getBooked()
.get(0)
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
@Test
void getTransactionDetails() {
String rawResponse = "{\n" +
" \"transactionsDetails\": {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", BASE_URL));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionDetails(ACCOUNT_ID, "transactionId", RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(OK200TransactionDetails.class))
.matches(body ->
body.getTransactionsDetails()
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
private static Aspsp buildAspspWithUrl() {
Aspsp aspsp = new Aspsp();
aspsp.setUrl(BASE_URL);
return aspsp;
}
}
| 11,497 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditPaymentInitiationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/UnicreditPaymentInitiationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.ContentType;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.api.validation.ValidationError;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditUpdatePsuAuthenticationResponse;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
public class UnicreditPaymentInitiationService extends BasePaymentInitiationService {
private static final String DEFAULT_COUNTRY_CODE = "DE";
private final UnicreditMapper unicreditMapper = Mappers.getMapper(UnicreditMapper.class);
public UnicreditPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public Response<PaymentInitationRequestResponse201> initiatePayment(PaymentService paymentService,
PaymentProduct paymentProduct,
RequestHeaders requestHeaders,
RequestParams requestParams,
Object body) {
Object requestBody = null;
if (!isXml(paymentProduct)) {
Class<?> paymentBodyClass = getPaymentInitiationBodyClass(paymentService);
requestBody = jsonMapper.convertValue(body, paymentBodyClass);
addCreditorAddress(requestBody);
}
return super.initiatePayment(paymentService, paymentProduct, requestHeaders, requestParams, requestBody == null ? body : requestBody);
}
@Override
public Response<UpdatePsuAuthenticationResponse> updatePaymentPsuData(PaymentService paymentService,
PaymentProduct paymentProduct,
String paymentId,
String authorisationId,
RequestHeaders requestHeaders,
RequestParams requestParams,
UpdatePsuAuthentication updatePsuAuthentication) {
return updatePaymentPsuData(paymentService,
paymentProduct,
paymentId,
authorisationId,
requestHeaders,
requestParams,
updatePsuAuthentication,
UnicreditUpdatePsuAuthenticationResponse.class,
unicreditMapper::toUpdatePsuAuthenticationResponse);
}
private void addCreditorAddress(Object body) {
if (body instanceof PaymentInitiationJson) {
PaymentInitiationJson paymentsJson = (PaymentInitiationJson) body;
if (paymentsJson.getCreditorAddress() == null) {
paymentsJson.setCreditorAddress(buildDefaultAddress());
}
} else if (body instanceof PeriodicPaymentInitiationJson) {
PeriodicPaymentInitiationJson periodicJson = (PeriodicPaymentInitiationJson) body;
if (periodicJson.getCreditorAddress() == null) {
periodicJson.setCreditorAddress(buildDefaultAddress());
}
}
}
private Address buildDefaultAddress() {
Address address = new Address();
address.setCountry(DEFAULT_COUNTRY_CODE);
return address;
}
@Override
protected Map<String, String> populatePostHeaders(Map<String, String> map) {
Map<String, String> headers = super.populatePostHeaders(map);
headers.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return headers;
}
@Override
protected Map<String, String> populatePutHeaders(Map<String, String> headers) {
headers.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return headers;
}
@Override
protected Map<String, String> addPsuIdTypeHeader(Map<String, String> headers) {
return UnicreditHeaders.addPsuIdTypeHeader(headers);
}
@Override
public List<ValidationError> validateInitiatePayment(PaymentService paymentService,
PaymentProduct paymentProduct,
RequestHeaders requestHeaders,
RequestParams requestParams,
Object body) {
return UnicreditValidators.requireTppRedirectUri(requestHeaders);
}
@Override
public List<ValidationError> validateStartPaymentAuthorisation(PaymentService paymentService,
PaymentProduct paymentProduct,
String paymentId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return UnicreditValidators.requireTppRedirectUri(requestHeaders);
}
@Override
public List<ValidationError> validateStartPaymentAuthorisation(PaymentService paymentService,
PaymentProduct paymentProduct,
String paymentId,
RequestHeaders requestHeaders,
RequestParams requestParams,
UpdatePsuAuthentication updatePsuAuthentication) {
return UnicreditValidators.requireTppRedirectUri(requestHeaders);
}
}
| 7,495 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/UnicreditMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditOK200TransactionDetails;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditTransactionDetails;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditTransactionResponse200Json;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditUpdatePsuAuthenticationResponse;
import org.mapstruct.Mapper;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@Mapper
public interface UnicreditMapper {
TransactionsResponse200Json toTransactionsResponse200Json(UnicreditTransactionResponse200Json value);
OK200TransactionDetails toOK200TransactionDetails(UnicreditOK200TransactionDetails value);
Transactions toTransactions(UnicreditTransactionDetails value);
UpdatePsuAuthenticationResponse toUpdatePsuAuthenticationResponse(UnicreditUpdatePsuAuthenticationResponse value);
default String map(RemittanceInformationStructured value) {
return value == null ? null : value.getReference();
}
default Map<String, HrefType> map(Collection<Map<String, HrefType>> value) {
return value == null ? null : value.stream().findFirst().orElse(new HashMap<>());
}
}
| 2,098 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditValidators.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/UnicreditValidators.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.validation.ValidationError;
import java.util.Collections;
import java.util.List;
class UnicreditValidators {
private UnicreditValidators() {
}
static List<ValidationError> requireTppRedirectUri(RequestHeaders requestHeaders) {
if (!requestHeaders.get(RequestHeaders.TPP_REDIRECT_URI).isPresent()) {
return Collections.singletonList(new ValidationError(ValidationError.Code.REQUIRED,
RequestHeaders.TPP_REDIRECT_URI,
"TPP-Redirect-URI header is missing. It must be provided for this request"));
}
return Collections.emptyList();
}
}
| 1,579 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/UnicreditServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
public class UnicreditServiceProvider extends AbstractAdapterServiceProvider {
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new UnicreditAccountInformationService(aspsp,
httpClientFactory,
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new UnicreditPaymentInitiationService(aspsp,
httpClientFactory,
linksRewriter);
}
@Override
public String getAdapterId() {
return "unicredit-adapter";
}
}
| 2,149 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/UnicreditAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.ContentType;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.api.validation.ValidationError;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditOK200TransactionDetails;
import de.adorsys.xs2a.adapter.unicredit.model.UnicreditTransactionResponse200Json;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
public class UnicreditAccountInformationService extends BaseAccountInformationService {
private final UnicreditMapper unicreditMapper = Mappers.getMapper(UnicreditMapper.class);
public UnicreditAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public Response<TransactionsResponse200Json> getTransactionList(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionList(accountId,
requestHeaders,
requestParams,
UnicreditTransactionResponse200Json.class,
unicreditMapper::toTransactionsResponse200Json);
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
UnicreditOK200TransactionDetails.class,
unicreditMapper::toOK200TransactionDetails);
}
@Override
public Response<AccountList> getAccountList(RequestHeaders requestHeaders, RequestParams requestParams) {
return super.getAccountList(requestHeaders, RequestParams.builder().build());
}
@Override
protected Map<String, String> populatePostHeaders(Map<String, String> map) {
map.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return map;
}
@Override
protected Map<String, String> populatePutHeaders(Map<String, String> headers) {
headers.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return headers;
}
@Override
protected Map<String, String> addPsuIdTypeHeader(Map<String, String> headers) {
return UnicreditHeaders.addPsuIdTypeHeader(headers);
}
@Override
public List<ValidationError> validateCreateConsent(RequestHeaders requestHeaders,
RequestParams requestParams,
Consents body) {
return UnicreditValidators.requireTppRedirectUri(requestHeaders);
}
@Override
public List<ValidationError> validateStartConsentAuthorisation(String consentId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return UnicreditValidators.requireTppRedirectUri(requestHeaders);
}
@Override
public List<ValidationError> validateStartConsentAuthorisation(String consentId,
RequestHeaders requestHeaders,
RequestParams requestParams,
UpdatePsuAuthentication updatePsuAuthentication) {
return UnicreditValidators.requireTppRedirectUri(requestHeaders);
}
}
| 5,638 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditHeaders.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/UnicreditHeaders.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import java.util.*;
public class UnicreditHeaders {
public static final String HVB_ONLINE_BANKING = "HVB_ONLINEBANKING";
public static final String UCE_BANKING_GLOBAL = "UCEBANKINGGLOBAL";
public static final String DEFAULT_PSU_ID_TYPE = HVB_ONLINE_BANKING;
protected static final Set<String> POSSIBLE_PSU_ID_TYPE_VALUES
= Collections.unmodifiableSet(new HashSet<>(Arrays.asList(HVB_ONLINE_BANKING, UCE_BANKING_GLOBAL)));
private UnicreditHeaders() {
}
public static Map<String, String> addPsuIdTypeHeader(Map<String, String> headers) {
if (!POSSIBLE_PSU_ID_TYPE_VALUES.contains(headers.get(RequestHeaders.PSU_ID_TYPE))) {
headers.put(RequestHeaders.PSU_ID_TYPE, DEFAULT_PSU_ID_TYPE);
}
return headers;
}
}
| 1,714 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditTransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/model/UnicreditTransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.*;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class UnicreditTransactionDetails {
private String transactionId;
private String entryReference;
private String endToEndId;
private String mandateId;
private String checkId;
private String creditorId;
private LocalDate bookingDate;
private LocalDate valueDate;
private Amount transactionAmount;
private List<ReportExchangeRate> currencyExchange;
private String creditorName;
private AccountReference creditorAccount;
private String creditorAgent;
private String ultimateCreditor;
private String debtorName;
private AccountReference debtorAccount;
private String debtorAgent;
private String ultimateDebtor;
private String remittanceInformationUnstructured;
private List<String> remittanceInformationUnstructuredArray;
private RemittanceInformationStructured remittanceInformationStructured;
private List<RemittanceInformationStructured> remittanceInformationStructuredArray;
private String additionalInformation;
private AdditionalInformationStructured additionalInformationStructured;
private PurposeCode purposeCode;
private String bankTransactionCode;
private String proprietaryBankTransactionCode;
private Balance balanceAfterTransaction;
@JsonProperty("_links")
private Map<String, HrefType> links;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getEntryReference() {
return entryReference;
}
public void setEntryReference(String entryReference) {
this.entryReference = entryReference;
}
public String getEndToEndId() {
return endToEndId;
}
public void setEndToEndId(String endToEndId) {
this.endToEndId = endToEndId;
}
public String getMandateId() {
return mandateId;
}
public void setMandateId(String mandateId) {
this.mandateId = mandateId;
}
public String getCheckId() {
return checkId;
}
public void setCheckId(String checkId) {
this.checkId = checkId;
}
public String getCreditorId() {
return creditorId;
}
public void setCreditorId(String creditorId) {
this.creditorId = creditorId;
}
public LocalDate getBookingDate() {
return bookingDate;
}
public void setBookingDate(LocalDate bookingDate) {
this.bookingDate = bookingDate;
}
public LocalDate getValueDate() {
return valueDate;
}
public void setValueDate(LocalDate valueDate) {
this.valueDate = valueDate;
}
public Amount getTransactionAmount() {
return transactionAmount;
}
public void setTransactionAmount(Amount transactionAmount) {
this.transactionAmount = transactionAmount;
}
public List<ReportExchangeRate> getCurrencyExchange() {
return currencyExchange;
}
public void setCurrencyExchange(List<ReportExchangeRate> currencyExchange) {
this.currencyExchange = currencyExchange;
}
public String getCreditorName() {
return creditorName;
}
public void setCreditorName(String creditorName) {
this.creditorName = creditorName;
}
public AccountReference getCreditorAccount() {
return creditorAccount;
}
public void setCreditorAccount(AccountReference creditorAccount) {
this.creditorAccount = creditorAccount;
}
public String getCreditorAgent() {
return creditorAgent;
}
public void setCreditorAgent(String creditorAgent) {
this.creditorAgent = creditorAgent;
}
public String getUltimateCreditor() {
return ultimateCreditor;
}
public void setUltimateCreditor(String ultimateCreditor) {
this.ultimateCreditor = ultimateCreditor;
}
public String getDebtorName() {
return debtorName;
}
public void setDebtorName(String debtorName) {
this.debtorName = debtorName;
}
public AccountReference getDebtorAccount() {
return debtorAccount;
}
public void setDebtorAccount(AccountReference debtorAccount) {
this.debtorAccount = debtorAccount;
}
public String getDebtorAgent() {
return debtorAgent;
}
public void setDebtorAgent(String debtorAgent) {
this.debtorAgent = debtorAgent;
}
public String getUltimateDebtor() {
return ultimateDebtor;
}
public void setUltimateDebtor(String ultimateDebtor) {
this.ultimateDebtor = ultimateDebtor;
}
public String getRemittanceInformationUnstructured() {
return remittanceInformationUnstructured;
}
public void setRemittanceInformationUnstructured(String remittanceInformationUnstructured) {
this.remittanceInformationUnstructured = remittanceInformationUnstructured;
}
public List<String> getRemittanceInformationUnstructuredArray() {
return remittanceInformationUnstructuredArray;
}
public void setRemittanceInformationUnstructuredArray(
List<String> remittanceInformationUnstructuredArray) {
this.remittanceInformationUnstructuredArray = remittanceInformationUnstructuredArray;
}
public RemittanceInformationStructured getRemittanceInformationStructured() {
return remittanceInformationStructured;
}
public void setRemittanceInformationStructured(RemittanceInformationStructured remittanceInformationStructured) {
this.remittanceInformationStructured = remittanceInformationStructured;
}
public List<RemittanceInformationStructured> getRemittanceInformationStructuredArray() {
return remittanceInformationStructuredArray;
}
public void setRemittanceInformationStructuredArray(
List<RemittanceInformationStructured> remittanceInformationStructuredArray) {
this.remittanceInformationStructuredArray = remittanceInformationStructuredArray;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public AdditionalInformationStructured getAdditionalInformationStructured() {
return additionalInformationStructured;
}
public void setAdditionalInformationStructured(
AdditionalInformationStructured additionalInformationStructured) {
this.additionalInformationStructured = additionalInformationStructured;
}
public PurposeCode getPurposeCode() {
return purposeCode;
}
public void setPurposeCode(PurposeCode purposeCode) {
this.purposeCode = purposeCode;
}
public String getBankTransactionCode() {
return bankTransactionCode;
}
public void setBankTransactionCode(String bankTransactionCode) {
this.bankTransactionCode = bankTransactionCode;
}
public String getProprietaryBankTransactionCode() {
return proprietaryBankTransactionCode;
}
public void setProprietaryBankTransactionCode(String proprietaryBankTransactionCode) {
this.proprietaryBankTransactionCode = proprietaryBankTransactionCode;
}
public Balance getBalanceAfterTransaction() {
return balanceAfterTransaction;
}
public void setBalanceAfterTransaction(Balance balanceAfterTransaction) {
this.balanceAfterTransaction = balanceAfterTransaction;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnicreditTransactionDetails that = (UnicreditTransactionDetails) o;
return Objects.equals(transactionId, that.transactionId) &&
Objects.equals(entryReference, that.entryReference) &&
Objects.equals(endToEndId, that.endToEndId) &&
Objects.equals(mandateId, that.mandateId) &&
Objects.equals(checkId, that.checkId) &&
Objects.equals(creditorId, that.creditorId) &&
Objects.equals(bookingDate, that.bookingDate) &&
Objects.equals(valueDate, that.valueDate) &&
Objects.equals(transactionAmount, that.transactionAmount) &&
Objects.equals(currencyExchange, that.currencyExchange) &&
Objects.equals(creditorName, that.creditorName) &&
Objects.equals(creditorAccount, that.creditorAccount) &&
Objects.equals(creditorAgent, that.creditorAgent) &&
Objects.equals(ultimateCreditor, that.ultimateCreditor) &&
Objects.equals(debtorName, that.debtorName) &&
Objects.equals(debtorAccount, that.debtorAccount) &&
Objects.equals(debtorAgent, that.debtorAgent) &&
Objects.equals(ultimateDebtor, that.ultimateDebtor) &&
Objects.equals(remittanceInformationUnstructured, that.remittanceInformationUnstructured) &&
Objects.equals(remittanceInformationUnstructuredArray, that.remittanceInformationUnstructuredArray) &&
Objects.equals(remittanceInformationStructured, that.remittanceInformationStructured) &&
Objects.equals(remittanceInformationStructuredArray, that.remittanceInformationStructuredArray) &&
Objects.equals(additionalInformation, that.additionalInformation) &&
Objects.equals(additionalInformationStructured, that.additionalInformationStructured) &&
Objects.equals(purposeCode, that.purposeCode) &&
Objects.equals(bankTransactionCode, that.bankTransactionCode) &&
Objects.equals(proprietaryBankTransactionCode, that.proprietaryBankTransactionCode) &&
Objects.equals(balanceAfterTransaction, that.balanceAfterTransaction) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(transactionId,
entryReference,
endToEndId,
mandateId,
checkId,
creditorId,
bookingDate,
valueDate,
transactionAmount,
currencyExchange,
creditorName,
creditorAccount,
creditorAgent,
ultimateCreditor,
debtorName,
debtorAccount,
debtorAgent,
ultimateDebtor,
remittanceInformationUnstructured,
remittanceInformationUnstructuredArray,
remittanceInformationStructured,
remittanceInformationStructuredArray,
additionalInformation,
additionalInformationStructured,
purposeCode,
bankTransactionCode,
proprietaryBankTransactionCode,
balanceAfterTransaction,
links);
}
}
| 12,140 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditTransactionResponse200Json.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/model/UnicreditTransactionResponse200Json.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.AccountReference;
import de.adorsys.xs2a.adapter.api.model.Balance;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class UnicreditTransactionResponse200Json {
private AccountReference account;
private UnicreditAccountReport transactions;
private List<Balance> balances;
@JsonProperty("_links")
private Map<String, HrefType> links;
public AccountReference getAccount() {
return account;
}
public void setAccount(AccountReference account) {
this.account = account;
}
public UnicreditAccountReport getTransactions() {
return transactions;
}
public void setTransactions(UnicreditAccountReport transactions) {
this.transactions = transactions;
}
public List<Balance> getBalances() {
return balances;
}
public void setBalances(List<Balance> balances) {
this.balances = balances;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnicreditTransactionResponse200Json that = (UnicreditTransactionResponse200Json) o;
return Objects.equals(account, that.account) &&
Objects.equals(transactions, that.transactions) &&
Objects.equals(balances, that.balances) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(account,
transactions,
balances,
links);
}
}
| 2,754 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditUpdatePsuAuthenticationResponse.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/model/UnicreditUpdatePsuAuthenticationResponse.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class UnicreditUpdatePsuAuthenticationResponse {
private Amount transactionFees;
private Amount currencyConversionFees;
private Amount estimatedTotalAmount;
private Amount estimatedInterbankSettlementAmount;
private AuthenticationObject chosenScaMethod;
private ChallengeData challengeData;
private List<AuthenticationObject> scaMethods;
@JsonProperty("_links")
private Collection<Map<String, HrefType>> links;
private ScaStatus scaStatus;
private String psuMessage;
private String authorisationId;
public Amount getTransactionFees() {
return transactionFees;
}
public void setTransactionFees(Amount transactionFees) {
this.transactionFees = transactionFees;
}
public Amount getCurrencyConversionFees() {
return currencyConversionFees;
}
public void setCurrencyConversionFees(Amount currencyConversionFees) {
this.currencyConversionFees = currencyConversionFees;
}
public Amount getEstimatedTotalAmount() {
return estimatedTotalAmount;
}
public void setEstimatedTotalAmount(Amount estimatedTotalAmount) {
this.estimatedTotalAmount = estimatedTotalAmount;
}
public Amount getEstimatedInterbankSettlementAmount() {
return estimatedInterbankSettlementAmount;
}
public void setEstimatedInterbankSettlementAmount(Amount estimatedInterbankSettlementAmount) {
this.estimatedInterbankSettlementAmount = estimatedInterbankSettlementAmount;
}
public AuthenticationObject getChosenScaMethod() {
return chosenScaMethod;
}
public void setChosenScaMethod(AuthenticationObject chosenScaMethod) {
this.chosenScaMethod = chosenScaMethod;
}
public ChallengeData getChallengeData() {
return challengeData;
}
public void setChallengeData(ChallengeData challengeData) {
this.challengeData = challengeData;
}
public List<AuthenticationObject> getScaMethods() {
return scaMethods;
}
public void setScaMethods(List<AuthenticationObject> scaMethods) {
this.scaMethods = scaMethods;
}
public Collection<Map<String, HrefType>> getLinks() {
return links;
}
public void setLinks(Collection<Map<String, HrefType>> links) {
this.links = links;
}
public ScaStatus getScaStatus() {
return scaStatus;
}
public void setScaStatus(ScaStatus scaStatus) {
this.scaStatus = scaStatus;
}
public String getPsuMessage() {
return psuMessage;
}
public void setPsuMessage(String psuMessage) {
this.psuMessage = psuMessage;
}
public String getAuthorisationId() {
return authorisationId;
}
public void setAuthorisationId(String authorisationId) {
this.authorisationId = authorisationId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnicreditUpdatePsuAuthenticationResponse that = (UnicreditUpdatePsuAuthenticationResponse) o;
return Objects.equals(transactionFees, that.transactionFees) &&
Objects.equals(currencyConversionFees, that.currencyConversionFees) &&
Objects.equals(estimatedTotalAmount, that.estimatedTotalAmount) &&
Objects.equals(estimatedInterbankSettlementAmount, that.estimatedInterbankSettlementAmount) &&
Objects.equals(chosenScaMethod, that.chosenScaMethod) &&
Objects.equals(challengeData, that.challengeData) &&
Objects.equals(scaMethods, that.scaMethods) &&
Objects.equals(links, that.links) &&
Objects.equals(scaStatus, that.scaStatus) &&
Objects.equals(psuMessage, that.psuMessage) &&
Objects.equals(authorisationId, that.authorisationId);
}
@Override
public int hashCode() {
return Objects.hash(transactionFees,
currencyConversionFees,
estimatedTotalAmount,
estimatedInterbankSettlementAmount,
chosenScaMethod,
challengeData,
scaMethods,
links,
scaStatus,
psuMessage,
authorisationId);
}
}
| 5,380 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditOK200TransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/model/UnicreditOK200TransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit.model;
import java.util.Objects;
public class UnicreditOK200TransactionDetails {
private UnicreditTransactionDetails transactionsDetails;
public UnicreditTransactionDetails getTransactionsDetails() {
return transactionsDetails;
}
public void setTransactionsDetails(UnicreditTransactionDetails transactionsDetails) {
this.transactionsDetails = transactionsDetails;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnicreditOK200TransactionDetails that = (UnicreditOK200TransactionDetails) o;
return Objects.equals(transactionsDetails, that.transactionsDetails);
}
@Override
public int hashCode() {
return Objects.hash(transactionsDetails);
}
}
| 1,705 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
UnicreditAccountReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/unicredit-adapter/src/main/java/de/adorsys/xs2a/adapter/unicredit/model/UnicreditAccountReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.unicredit.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class UnicreditAccountReport {
private List<UnicreditTransactionDetails> booked;
private List<UnicreditTransactionDetails> pending;
@JsonProperty("_links")
private Map<String, HrefType> links;
public List<UnicreditTransactionDetails> getBooked() {
return booked;
}
public void setBooked(List<UnicreditTransactionDetails> booked) {
this.booked = booked;
}
public List<UnicreditTransactionDetails> getPending() {
return pending;
}
public void setPending(List<UnicreditTransactionDetails> pending) {
this.pending = pending;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnicreditAccountReport that = (UnicreditAccountReport) o;
return Objects.equals(booked, that.booked) &&
Objects.equals(pending, that.pending) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(booked,
pending,
links);
}
}
| 2,348 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DabAccountInformationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/dab-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/dab/DabAccountInformationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.dab;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.HttpLogSanitizer;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import de.adorsys.xs2a.adapter.impl.link.identity.IdentityLinksRewriter;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
class DabAccountInformationServiceTest {
private final HttpClient httpClient = mock(HttpClient.class);
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private AccountInformationService service;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientConfig.getLogSanitizer()).thenReturn(mock(HttpLogSanitizer.class));
service = new DabServiceProvider()
.getAccountInformationService(new Aspsp(), httpClientFactory, new IdentityLinksRewriter());
}
@Test
void getTransactionDetails() {
String rawResponse = "{\n" +
" \"transactionsDetails\": {\n" +
" \"transactionId\": \"test\"\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", "https://uri.com"));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= service.getTransactionDetails("accountId", "transactionId", RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(OK200TransactionDetails.class))
.matches(body ->
body.getTransactionsDetails()
.getTransactionId()
.equals("test"));
}
}
| 4,021 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DabServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/dab-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/dab/DabServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.dab;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class DabServiceProviderTest {
private final HttpClientFactory factory = mock(HttpClientFactory.class);
private final HttpClientConfig config = mock(HttpClientConfig.class);
private final DabServiceProvider provider = new DabServiceProvider();
@BeforeEach
void setUp() {
when(factory.getHttpClientConfig()).thenReturn(config);
}
@Test
void getAccountInformationService() {
AccountInformationService actualService
= provider.getAccountInformationService(new Aspsp(), factory, null);
assertThat(actualService)
.isExactlyInstanceOf(DabAccountInformationService.class);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService actualService
= provider.getPaymentInitiationService(null, factory, null);
assertThat(actualService)
.isExactlyInstanceOf(BasePaymentInitiationService.class);
}
}
| 2,379 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DabAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/dab-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/dab/DabAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.dab;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.dab.model.DabOK200TransactionDetails;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import org.mapstruct.factory.Mappers;
public class DabAccountInformationService extends BaseAccountInformationService {
private final DabMapper mapper = Mappers.getMapper(DabMapper.class);
public DabAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
DabOK200TransactionDetails.class,
mapper::toOK200TransactionDetails);
}
}
| 2,591 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DabServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/dab-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/dab/DabServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.dab;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
public class DabServiceProvider extends AbstractAdapterServiceProvider {
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new DabAccountInformationService(aspsp,
httpClientFactory,
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new BasePaymentInitiationService(aspsp,
httpClientFactory.getHttpClient(getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public String getAdapterId() {
return "dab-bank-adapter";
}
}
| 2,292 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DabMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/dab-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/dab/DabMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.dab;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.dab.model.DabOK200TransactionDetails;
import org.mapstruct.Mapper;
@Mapper
public interface DabMapper {
OK200TransactionDetails toOK200TransactionDetails(DabOK200TransactionDetails value);
}
| 1,162 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DabOK200TransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/dab-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/dab/model/DabOK200TransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.dab.model;
import de.adorsys.xs2a.adapter.api.model.Transactions;
import java.util.Objects;
public class DabOK200TransactionDetails {
private Transactions transactionsDetails;
public Transactions getTransactionsDetails() {
return transactionsDetails;
}
public void setTransactionsDetails(Transactions transactionsDetails) {
this.transactionsDetails = transactionsDetails;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DabOK200TransactionDetails that = (DabOK200TransactionDetails) o;
return Objects.equals(transactionsDetails, that.transactionsDetails);
}
@Override
public int hashCode() {
return Objects.hash(transactionsDetails);
}
}
| 1,692 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbAccountInformationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/test/java/de/adorsys/xs2a/adapter/olb/OlbAccountInformationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.ByteArrayInputStream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class OlbAccountInformationServiceTest {
private static final String URI = "https://foo.boo";
private static final String ACCOUNT_ID = "accountId";
private static final String REMITTANCE_INFORMATION_STRUCTURED = "remittanceInformationStructuredStringValue";
private OlbAccountInformationService accountInformationService;
@Mock
private HttpClient httpClient;
@Mock
private Aspsp aspsp;
@Mock
private LinksRewriter linksRewriter;
@Mock
private HttpClientFactory httpClientFactory;
@Mock
private HttpClientConfig httpClientConfig;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
accountInformationService = new OlbAccountInformationService(aspsp, httpClientFactory, linksRewriter);
}
@Test
void getTransactionList() {
String rawResponse = "{\n" +
" \"transactions\": {\n" +
" \"booked\": [\n" +
" {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionList(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(TransactionsResponse200Json.class))
.matches(body ->
body.getTransactions()
.getBooked()
.get(0)
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
@Test
void getTransactionDetails() {
String rawResponse = "{\n" +
" \"transactionsDetails\": {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionDetails(ACCOUNT_ID, "transactionId", RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(OK200TransactionDetails.class))
.matches(body ->
body.getTransactionsDetails()
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
}
| 6,402 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/test/java/de/adorsys/xs2a/adapter/olb/OlbServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class OlbServiceProviderTest {
private OlbServiceProvider serviceProvider;
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final Aspsp aspsp = new Aspsp();
@BeforeEach
void setUp() {
serviceProvider = new OlbServiceProvider();
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
}
@Test
void getAccountInformationService() {
AccountInformationService actualService
= serviceProvider.getAccountInformationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(OlbAccountInformationService.class);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService actualService
= serviceProvider.getPaymentInitiationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(BasePaymentInitiationService.class);
}
}
| 2,519 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/OlbAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import de.adorsys.xs2a.adapter.olb.model.OlbOK200TransactionDetails;
import de.adorsys.xs2a.adapter.olb.model.OlbTransactionResponse200Json;
import org.mapstruct.factory.Mappers;
public class OlbAccountInformationService extends BaseAccountInformationService {
private final OlbMapper olbMapper = Mappers.getMapper(OlbMapper.class);
public OlbAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public Response<TransactionsResponse200Json> getTransactionList(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionList(accountId,
requestHeaders,
requestParams,
OlbTransactionResponse200Json.class,
olbMapper::toTransactionsResponse200Json);
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
OlbOK200TransactionDetails.class,
olbMapper::toOK200TransactionDetails);
}
}
| 3,523 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/OlbMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.olb.model.OlbOK200TransactionDetails;
import de.adorsys.xs2a.adapter.olb.model.OlbTransactionDetails;
import de.adorsys.xs2a.adapter.olb.model.OlbTransactionResponse200Json;
import org.mapstruct.Mapper;
@Mapper
public interface OlbMapper {
TransactionsResponse200Json toTransactionsResponse200Json(OlbTransactionResponse200Json value);
OK200TransactionDetails toOK200TransactionDetails(OlbOK200TransactionDetails value);
Transactions toTransactions(OlbTransactionDetails value);
default String map(RemittanceInformationStructured value) {
return value == null ? null : value.getReference();
}
}
| 1,568 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/OlbServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
public class OlbServiceProvider extends AbstractAdapterServiceProvider {
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new OlbAccountInformationService(aspsp,
httpClientFactory,
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new BasePaymentInitiationService(aspsp,
httpClientFactory.getHttpClient(getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public String getAdapterId() {
return "olb-adapter";
}
}
| 2,287 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbOK200TransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/model/OlbOK200TransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb.model;
import java.util.Objects;
public class OlbOK200TransactionDetails {
private OlbTransactionDetails transactionsDetails;
public OlbTransactionDetails getTransactionsDetails() {
return transactionsDetails;
}
public void setTransactionsDetails(OlbTransactionDetails transactionsDetails) {
this.transactionsDetails = transactionsDetails;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OlbOK200TransactionDetails that = (OlbOK200TransactionDetails) o;
return Objects.equals(transactionsDetails, that.transactionsDetails);
}
@Override
public int hashCode() {
return Objects.hash(transactionsDetails);
}
}
| 1,663 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbAccountReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/model/OlbAccountReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class OlbAccountReport {
private List<OlbTransactionDetails> booked;
private List<OlbTransactionDetails> pending;
@JsonProperty("_links")
private Map<String, HrefType> links;
public List<OlbTransactionDetails> getBooked() {
return booked;
}
public void setBooked(List<OlbTransactionDetails> booked) {
this.booked = booked;
}
public List<OlbTransactionDetails> getPending() {
return pending;
}
public void setPending(List<OlbTransactionDetails> pending) {
this.pending = pending;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OlbAccountReport that = (OlbAccountReport) o;
return Objects.equals(booked, that.booked) &&
Objects.equals(pending, that.pending) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(booked,
pending,
links);
}
}
| 2,288 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbTransactionResponse200Json.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/model/OlbTransactionResponse200Json.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.AccountReference;
import de.adorsys.xs2a.adapter.api.model.Balance;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class OlbTransactionResponse200Json {
private AccountReference account;
private OlbAccountReport transactions;
private List<Balance> balances;
@JsonProperty("_links")
private Map<String, HrefType> links;
public AccountReference getAccount() {
return account;
}
public void setAccount(AccountReference account) {
this.account = account;
}
public OlbAccountReport getTransactions() {
return transactions;
}
public void setTransactions(OlbAccountReport transactions) {
this.transactions = transactions;
}
public List<Balance> getBalances() {
return balances;
}
public void setBalances(List<Balance> balances) {
this.balances = balances;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OlbTransactionResponse200Json that = (OlbTransactionResponse200Json) o;
return Objects.equals(account, that.account) &&
Objects.equals(transactions, that.transactions) &&
Objects.equals(balances, that.balances) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(account,
transactions,
balances,
links);
}
}
| 2,712 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OlbTransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/olb-adapter/src/main/java/de/adorsys/xs2a/adapter/olb/model/OlbTransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.olb.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.*;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class OlbTransactionDetails {
private String transactionId;
private String entryReference;
private String endToEndId;
private String mandateId;
private String checkId;
private String creditorId;
private LocalDate bookingDate;
private LocalDate valueDate;
private Amount transactionAmount;
private List<ReportExchangeRate> currencyExchange;
private String creditorName;
private AccountReference creditorAccount;
private String creditorAgent;
private String ultimateCreditor;
private String debtorName;
private AccountReference debtorAccount;
private String debtorAgent;
private String ultimateDebtor;
private String remittanceInformationUnstructured;
private List<String> remittanceInformationUnstructuredArray;
private RemittanceInformationStructured remittanceInformationStructured;
private List<RemittanceInformationStructured> remittanceInformationStructuredArray;
private String additionalInformation;
private AdditionalInformationStructured additionalInformationStructured;
private PurposeCode purposeCode;
private String bankTransactionCode;
private String proprietaryBankTransactionCode;
private Balance balanceAfterTransaction;
@JsonProperty("_links")
private Map<String, HrefType> links;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getEntryReference() {
return entryReference;
}
public void setEntryReference(String entryReference) {
this.entryReference = entryReference;
}
public String getEndToEndId() {
return endToEndId;
}
public void setEndToEndId(String endToEndId) {
this.endToEndId = endToEndId;
}
public String getMandateId() {
return mandateId;
}
public void setMandateId(String mandateId) {
this.mandateId = mandateId;
}
public String getCheckId() {
return checkId;
}
public void setCheckId(String checkId) {
this.checkId = checkId;
}
public String getCreditorId() {
return creditorId;
}
public void setCreditorId(String creditorId) {
this.creditorId = creditorId;
}
public LocalDate getBookingDate() {
return bookingDate;
}
public void setBookingDate(LocalDate bookingDate) {
this.bookingDate = bookingDate;
}
public LocalDate getValueDate() {
return valueDate;
}
public void setValueDate(LocalDate valueDate) {
this.valueDate = valueDate;
}
public Amount getTransactionAmount() {
return transactionAmount;
}
public void setTransactionAmount(Amount transactionAmount) {
this.transactionAmount = transactionAmount;
}
public List<ReportExchangeRate> getCurrencyExchange() {
return currencyExchange;
}
public void setCurrencyExchange(List<ReportExchangeRate> currencyExchange) {
this.currencyExchange = currencyExchange;
}
public String getCreditorName() {
return creditorName;
}
public void setCreditorName(String creditorName) {
this.creditorName = creditorName;
}
public AccountReference getCreditorAccount() {
return creditorAccount;
}
public void setCreditorAccount(AccountReference creditorAccount) {
this.creditorAccount = creditorAccount;
}
public String getCreditorAgent() {
return creditorAgent;
}
public void setCreditorAgent(String creditorAgent) {
this.creditorAgent = creditorAgent;
}
public String getUltimateCreditor() {
return ultimateCreditor;
}
public void setUltimateCreditor(String ultimateCreditor) {
this.ultimateCreditor = ultimateCreditor;
}
public String getDebtorName() {
return debtorName;
}
public void setDebtorName(String debtorName) {
this.debtorName = debtorName;
}
public AccountReference getDebtorAccount() {
return debtorAccount;
}
public void setDebtorAccount(AccountReference debtorAccount) {
this.debtorAccount = debtorAccount;
}
public String getDebtorAgent() {
return debtorAgent;
}
public void setDebtorAgent(String debtorAgent) {
this.debtorAgent = debtorAgent;
}
public String getUltimateDebtor() {
return ultimateDebtor;
}
public void setUltimateDebtor(String ultimateDebtor) {
this.ultimateDebtor = ultimateDebtor;
}
public String getRemittanceInformationUnstructured() {
return remittanceInformationUnstructured;
}
public void setRemittanceInformationUnstructured(String remittanceInformationUnstructured) {
this.remittanceInformationUnstructured = remittanceInformationUnstructured;
}
public List<String> getRemittanceInformationUnstructuredArray() {
return remittanceInformationUnstructuredArray;
}
public void setRemittanceInformationUnstructuredArray(
List<String> remittanceInformationUnstructuredArray) {
this.remittanceInformationUnstructuredArray = remittanceInformationUnstructuredArray;
}
public RemittanceInformationStructured getRemittanceInformationStructured() {
return remittanceInformationStructured;
}
public void setRemittanceInformationStructured(RemittanceInformationStructured remittanceInformationStructured) {
this.remittanceInformationStructured = remittanceInformationStructured;
}
public List<RemittanceInformationStructured> getRemittanceInformationStructuredArray() {
return remittanceInformationStructuredArray;
}
public void setRemittanceInformationStructuredArray(
List<RemittanceInformationStructured> remittanceInformationStructuredArray) {
this.remittanceInformationStructuredArray = remittanceInformationStructuredArray;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public AdditionalInformationStructured getAdditionalInformationStructured() {
return additionalInformationStructured;
}
public void setAdditionalInformationStructured(
AdditionalInformationStructured additionalInformationStructured) {
this.additionalInformationStructured = additionalInformationStructured;
}
public PurposeCode getPurposeCode() {
return purposeCode;
}
public void setPurposeCode(PurposeCode purposeCode) {
this.purposeCode = purposeCode;
}
public String getBankTransactionCode() {
return bankTransactionCode;
}
public void setBankTransactionCode(String bankTransactionCode) {
this.bankTransactionCode = bankTransactionCode;
}
public String getProprietaryBankTransactionCode() {
return proprietaryBankTransactionCode;
}
public void setProprietaryBankTransactionCode(String proprietaryBankTransactionCode) {
this.proprietaryBankTransactionCode = proprietaryBankTransactionCode;
}
public Balance getBalanceAfterTransaction() {
return balanceAfterTransaction;
}
public void setBalanceAfterTransaction(Balance balanceAfterTransaction) {
this.balanceAfterTransaction = balanceAfterTransaction;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OlbTransactionDetails that = (OlbTransactionDetails) o;
return Objects.equals(transactionId, that.transactionId) &&
Objects.equals(entryReference, that.entryReference) &&
Objects.equals(endToEndId, that.endToEndId) &&
Objects.equals(mandateId, that.mandateId) &&
Objects.equals(checkId, that.checkId) &&
Objects.equals(creditorId, that.creditorId) &&
Objects.equals(bookingDate, that.bookingDate) &&
Objects.equals(valueDate, that.valueDate) &&
Objects.equals(transactionAmount, that.transactionAmount) &&
Objects.equals(currencyExchange, that.currencyExchange) &&
Objects.equals(creditorName, that.creditorName) &&
Objects.equals(creditorAccount, that.creditorAccount) &&
Objects.equals(creditorAgent, that.creditorAgent) &&
Objects.equals(ultimateCreditor, that.ultimateCreditor) &&
Objects.equals(debtorName, that.debtorName) &&
Objects.equals(debtorAccount, that.debtorAccount) &&
Objects.equals(debtorAgent, that.debtorAgent) &&
Objects.equals(ultimateDebtor, that.ultimateDebtor) &&
Objects.equals(remittanceInformationUnstructured, that.remittanceInformationUnstructured) &&
Objects.equals(remittanceInformationUnstructuredArray, that.remittanceInformationUnstructuredArray) &&
Objects.equals(remittanceInformationStructured, that.remittanceInformationStructured) &&
Objects.equals(remittanceInformationStructuredArray, that.remittanceInformationStructuredArray) &&
Objects.equals(additionalInformation, that.additionalInformation) &&
Objects.equals(additionalInformationStructured, that.additionalInformationStructured) &&
Objects.equals(purposeCode, that.purposeCode) &&
Objects.equals(bankTransactionCode, that.bankTransactionCode) &&
Objects.equals(proprietaryBankTransactionCode, that.proprietaryBankTransactionCode) &&
Objects.equals(balanceAfterTransaction, that.balanceAfterTransaction) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(transactionId,
entryReference,
endToEndId,
mandateId,
checkId,
creditorId,
bookingDate,
valueDate,
transactionAmount,
currencyExchange,
creditorName,
creditorAccount,
creditorAgent,
ultimateCreditor,
debtorName,
debtorAccount,
debtorAgent,
ultimateDebtor,
remittanceInformationUnstructured,
remittanceInformationUnstructuredArray,
remittanceInformationStructured,
remittanceInformationStructuredArray,
additionalInformation,
additionalInformationStructured,
purposeCode,
bankTransactionCode,
proprietaryBankTransactionCode,
balanceAfterTransaction,
links);
}
}
| 12,116 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankPaymentInitiationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankPaymentInitiationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static de.adorsys.xs2a.adapter.api.model.PaymentProduct.SEPA_CREDIT_TRANSFERS;
import static de.adorsys.xs2a.adapter.api.model.PaymentService.PAYMENTS;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(CommerzbankServiceProvider.class)
class CommerzbankPaymentInitiationServiceWireMockTest {
private static final String PAYMENT_ID = "PAYMENT_ID_RCVD_SCT";
private static final String AUTHORISATION_ID = "22222222-2222-2222-2222-222222222222";
private final PaymentInitiationService paymentInitiationService;
CommerzbankPaymentInitiationServiceWireMockTest(PaymentInitiationService paymentInitiationService) {
this.paymentInitiationService = paymentInitiationService;
}
@Test
void initiatePayment() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/initiate-payment.json");
var response = paymentInitiationService.initiatePayment(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(PaymentInitiationJson.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(PaymentInitationRequestResponse201.class));
}
@Test
void getPaymentStatus() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/get-payment-status.json");
var response = paymentInitiationService.getPaymentInitiationStatus(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(PaymentInitiationStatusResponse200Json.class));
}
@Test
void getPaymentAuthorisations() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/get-payment-authorisations.json");
var response = paymentInitiationService.getPaymentInitiationAuthorisation(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(Authorisations.class));
}
@Test
void getScaStatus() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/get-sca-status.json");
var response = paymentInitiationService.getPaymentInitiationScaStatus(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
}
| 4,180 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankAccountInformationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankAccountInformationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.ReadAccountBalanceResponse200;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankBalanceReport;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.ByteArrayInputStream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class CommerzbankAccountInformationServiceTest {
private static final String URI = "https://foo.boo";
private static final String ACCOUNT_ID = "accountId";
private static final String REMITTANCE_INFORMATION_STRUCTURED = "remittanceInformationStructuredStringValue";
private CommerzbankAccountInformationService accountInformationService;
@Mock
private HttpClient httpClient;
@Mock
private HttpClientFactory httpClientFactory;
@Mock
private HttpClientConfig httpClientConfig;
@Mock
private Aspsp aspsp;
@Mock
private LinksRewriter linksRewriter;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
accountInformationService = new CommerzbankAccountInformationService(aspsp, httpClientFactory, linksRewriter);
}
@Test
void getTransactionList() {
String rawResponse = "{\n" +
" \"transactions\": {\n" +
" \"booked\": [\n" +
" {\n" +
" \"remittanceInformationStructured\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionList(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(TransactionsResponse200Json.class))
.matches(body ->
body.getTransactions()
.getBooked()
.get(0)
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
@Test
void getBalances() {
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(-1, new CommerzbankBalanceReport(), ResponseHeaders.emptyResponseHeaders()));
Response<?> actualResponse
= accountInformationService.getBalances(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.isInstanceOf(ReadAccountBalanceResponse200.class);
}
@Test
void getTransactionDetails() {
String rawResponse = "{\n" +
" \"transactionsDetails\": {\n" +
" \"remittanceInformationStructured\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionDetails(ACCOUNT_ID, "transactionId", RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(OK200TransactionDetails.class))
.matches(body ->
body.getTransactionsDetails()
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
}
| 7,168 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankAccountInformationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankAccountInformationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(CommerzbankServiceProvider.class)
class CommerzbankAccountInformationServiceWireMockTest {
private static final String CONSENT_ID = "VALID_CONSENT_ID";
private static final String ACCOUNT_ID = "ACCOUNT_ID";
private static final String AUTHORISATION_ID = "11111111-1111-1111-1111-111111111111";
private final AccountInformationService accountInformationService;
CommerzbankAccountInformationServiceWireMockTest(AccountInformationService accountInformationService) {
this.accountInformationService = accountInformationService;
}
@Test
void createConsent() throws IOException {
var requestResponse = new TestRequestResponse("ais/create-consent.json");
var response = accountInformationService.createConsent(requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(Consents.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ConsentsResponse201.class));
}
@Test
void deleteConsent() throws IOException {
var requestResponse = new TestRequestResponse("ais/delete-consent.json");
var response = accountInformationService.deleteConsent(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getStatusCode())
.isEqualTo(204);
}
@Test
void getAccounts() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-accounts.json");
var response = accountInformationService.getAccountList(requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(AccountList.class));
}
@Test
void getBalances() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-balances.json");
var response = accountInformationService.getBalances(ACCOUNT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ReadAccountBalanceResponse200.class));
}
@Test
void getConsentAuthorisation() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-consent-authorisations.json");
var response = accountInformationService.getConsentAuthorisation(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(Authorisations.class));
}
@Test
void getConsentStatus() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-consent-status.json");
var response = accountInformationService.getConsentStatus(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ConsentStatusResponse200.class));
}
@Test
void getScaStatus() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-sca-status.json");
var response = accountInformationService.getConsentScaStatus(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@Test
void getTransactions() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-transactions.json");
var response = accountInformationService.getTransactionList(ACCOUNT_ID,
requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(TransactionsResponse200Json.class));
}
}
| 5,315 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class CommerzbankServiceProviderTest {
private CommerzbankServiceProvider serviceProvider;
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final Aspsp aspsp = new Aspsp();
@BeforeEach
void setUp() {
serviceProvider = new CommerzbankServiceProvider();
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
}
@Test
void getAccountInformationService() {
AccountInformationService actualService
= serviceProvider.getAccountInformationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(CommerzbankAccountInformationService.class);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService actualService
= serviceProvider.getPaymentInitiationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(BasePaymentInitiationService.class);
}
@Test
void getOauth2Service() {
Oauth2Service actualService
= serviceProvider.getOauth2Service(aspsp, httpClientFactory);
assertThat(actualService)
.isExactlyInstanceOf(CommerzbankOauth2Service.class);
}
}
| 2,867 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankOauth2ServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankOauth2ServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.model.TokenResponse;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.LinkedHashMap;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(CommerzbankServiceProvider.class)
class CommerzbankOauth2ServiceWireMockTest {
private final Oauth2Service oauth2Service;
CommerzbankOauth2ServiceWireMockTest(Oauth2Service oauth2Service) {
this.oauth2Service = oauth2Service;
}
@Test
void getAccessToken() throws IOException {
var requestResponse = new TestRequestResponse("oauth2/get-access-token.json");
var modifiableParams = new LinkedHashMap<>(requestResponse.requestParams().toMap());
var actualToken = oauth2Service.getToken(requestResponse.requestHeaders().toMap(),
new Oauth2Service.Parameters(modifiableParams));
assertThat(actualToken)
.isNotNull()
.isEqualTo(requestResponse.responseBody(TokenResponse.class));
}
}
| 2,056 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankOauth2ServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankOauth2ServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.Oauth2Service.Parameters;
import de.adorsys.xs2a.adapter.api.Pkcs12KeyStore;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.TokenResponse;
import de.adorsys.xs2a.adapter.impl.http.ApacheHttpClient;
import de.adorsys.xs2a.adapter.impl.oauth2.api.model.AuthorisationServerMetaData;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.*;
class CommerzbankOauth2ServiceTest {
private static final String ORG_ID = "PSDDE-BAFIN-999999";
private static final String BASE_URL = "https://psd2.api-sandbox.commerzbank.com/berlingroup";
private static final String CONSENT_ID = "consent-id";
private static final String STATE = "test";
private static final String REDIRECT_URI = "https://example.com/cb";
private static final String SCA_OAUTH_LINK = "https://psd2.api.commerzbank.com/berlingroup/.well-known";
private static final String AUTHORIZATION_ENDPOINT =
"https://psd2.redirect.commerzbank.com/public/berlingroup/authorize/authorisation-id";
private static final String TOKEN_ENDPOINT = BASE_URL + "/v1/token";
private static final String AUTHORIZATION_CODE = "authorization-code";
private HttpClient httpClient;
private CommerzbankOauth2Service oauth2Service;
@BeforeEach
void setUp() throws Exception {
Aspsp aspsp = new Aspsp();
aspsp.setUrl(BASE_URL);
httpClient = spy(new ApacheHttpClient(null, null));
doReturn(authorizationServerMetadata())
.when(httpClient).send(argThat(req -> req.uri().equals(SCA_OAUTH_LINK)), any());
doReturn(new Response<>(200, new TokenResponse(), ResponseHeaders.emptyResponseHeaders()))
.when(httpClient).send(argThat(req -> req.uri().equals(TOKEN_ENDPOINT)), any());
Pkcs12KeyStore keyStore = mock(Pkcs12KeyStore.class);
when(keyStore.getOrganizationIdentifier())
.thenReturn(ORG_ID);
HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
when(httpClientConfig.getKeyStore()).thenReturn(keyStore);
oauth2Service = CommerzbankOauth2Service.create(aspsp, httpClientFactory);
}
private Response<AuthorisationServerMetaData> authorizationServerMetadata() {
AuthorisationServerMetaData metadata = new AuthorisationServerMetaData();
metadata.setAuthorisationEndpoint(AUTHORIZATION_ENDPOINT);
metadata.setTokenEndpoint(TOKEN_ENDPOINT);
return new Response<>(200, metadata, ResponseHeaders.emptyResponseHeaders());
}
@Test
void getAuthorizationRequestUri() throws IOException {
Parameters parameters = new Parameters();
parameters.setScaOAuthLink(SCA_OAUTH_LINK);
parameters.setState(STATE);
parameters.setRedirectUri(REDIRECT_URI);
parameters.setConsentId(CONSENT_ID);
URI uri = oauth2Service.getAuthorizationRequestUri(null, parameters);
assertEquals(AUTHORIZATION_ENDPOINT + "?" +
"response_type=code&" +
"state=" + STATE + "&" +
"redirect_uri=" + URLEncoder.encode(REDIRECT_URI, StandardCharsets.UTF_8.name()) + "&" +
"client_id=" + ORG_ID + "&" +
"code_challenge_method=S256&" +
"code_challenge=" + oauth2Service.codeChallenge() + "&" +
"scope=AIS%3A" + CONSENT_ID, uri.toString());
}
@Test
void getAuthorizationRequestUriForPayment() throws IOException {
Parameters parameters = new Parameters();
parameters.setScaOAuthLink(SCA_OAUTH_LINK);
parameters.setState(STATE);
parameters.setRedirectUri(REDIRECT_URI);
parameters.setPaymentId("payment-id");
URI uri = oauth2Service.getAuthorizationRequestUri(null, parameters);
assertEquals(AUTHORIZATION_ENDPOINT + "?" +
"response_type=code&" +
"state=" + STATE + "&" +
"redirect_uri=" + URLEncoder.encode(REDIRECT_URI, StandardCharsets.UTF_8.name()) + "&" +
"client_id=" + ORG_ID + "&" +
"code_challenge_method=S256&" +
"code_challenge=" + oauth2Service.codeChallenge() + "&" +
"scope=PIS%3Apayment-id", uri.toString());
}
@Test
void getToken() throws IOException {
Parameters parameters = new Parameters();
parameters.setGrantType(Oauth2Service.GrantType.AUTHORIZATION_CODE.toString());
parameters.setAuthorizationCode(AUTHORIZATION_CODE);
parameters.setRedirectUri(REDIRECT_URI);
oauth2Service.getToken(null, parameters);
Map<String, String> expectedBody = new HashMap<>();
expectedBody.put(Parameters.GRANT_TYPE, Oauth2Service.GrantType.AUTHORIZATION_CODE.toString());
expectedBody.put(Parameters.CODE, AUTHORIZATION_CODE);
expectedBody.put(Parameters.CLIENT_ID, ORG_ID);
expectedBody.put(Parameters.REDIRECT_URI, REDIRECT_URI);
expectedBody.put(Parameters.CODE_VERIFIER, oauth2Service.codeVerifier());
Mockito.verify(httpClient, Mockito.times(1)).send(argThat(req -> {
boolean tokenExchange = req.uri().equals(TOKEN_ENDPOINT);
if (tokenExchange) {
assertEquals(expectedBody, req.urlEncodedBody());
}
return tokenExchange;
}), any());
}
}
| 7,171 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
TransactionsReportMapperTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/mapper/TransactionsReportMapperTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.mapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankTransactionsReport;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
class TransactionsReportMapperTest {
public static final String COMMERZBANK_TRANSACTIONS_REPORT_PATH = "ais/commerzbank-transactions-report.json";
public static final String TRANSACTIONS_RESPONSE_200_JSON_PATH = "ais/transactions-response-200-json.json";
private final TransactionsReportMapper mapper
= new TransactionsReportMapperImpl();
private final ObjectMapper objectMapper = new ObjectMapper();
@Test
void map() throws IOException {
var commerzbankTransactionsReport = objectMapper.readValue(Resources.getResource(COMMERZBANK_TRANSACTIONS_REPORT_PATH), CommerzbankTransactionsReport.class);
TransactionsResponse200Json actual = mapper.toTransactionsReport(commerzbankTransactionsReport);
var expected = objectMapper.readValue(Resources.getResource(TRANSACTIONS_RESPONSE_200_JSON_PATH), TransactionsResponse200Json.class);
assertThat(actual).isEqualToComparingFieldByField(expected);
}
}
| 2,215 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DateTimeMapperTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/test/java/de/adorsys/xs2a/adapter/commerzbank/mapper/DateTimeMapperTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.mapper;
import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import static org.assertj.core.api.Assertions.assertThat;
class DateTimeMapperTest {
private static final DateTimeMapper dateTimeMapper = new TestDateTimeMapper();
@Test
void toOffsetDateTime_shouldReturnNull() {
OffsetDateTime actual = dateTimeMapper.toOffsetDateTime(null);
assertThat(actual)
.isNull();
}
@Test
void toOffsetDateTime() {
LocalDateTime benchmark = LocalDateTime.now();
OffsetDateTime actual = dateTimeMapper.toOffsetDateTime(benchmark);
assertThat(actual)
.isNotNull()
.matches(offsetDateTime ->
benchmark.getYear() == offsetDateTime.getYear()
&& benchmark.getMonthValue() == offsetDateTime.getMonthValue()
&& benchmark.getDayOfMonth() == offsetDateTime.getDayOfMonth());
}
private static class TestDateTimeMapper implements DateTimeMapper {
}
}
| 1,923 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankOauth2Service.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankOauth2Service.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.PkceOauth2Extension;
import de.adorsys.xs2a.adapter.api.Pkcs12KeyStore;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.HttpLogSanitizer;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.TokenResponse;
import de.adorsys.xs2a.adapter.impl.*;
import de.adorsys.xs2a.adapter.impl.http.StringUri;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import static de.adorsys.xs2a.adapter.api.validation.Validation.requireValid;
/**
* @see <a href="https://psd2.developer.commerzbank.com/content/howto/ais-manage-consents">OAuth2 authorisation</a>
* @see <a href="https://psd2.developer.commerzbank.com/content/howto/sandbox">2 - Authorize the payment</a>
*/
public class CommerzbankOauth2Service extends Oauth2ServiceDecorator implements PkceOauth2Extension {
private static final String AIS_SCOPE_PREFIX = "AIS:";
private static final String PIS_SCOPE_PREFIX = "PIS:";
private final String baseUrl;
private CommerzbankOauth2Service(Oauth2Service oauth2Service, String baseUrl) {
super(oauth2Service);
this.baseUrl = baseUrl;
}
public static CommerzbankOauth2Service create(Aspsp aspsp, HttpClientFactory httpClientFactory) {
HttpClient httpClient = httpClientFactory.getHttpClient(aspsp.getAdapterId());
HttpClientConfig httpClientConfig = httpClientFactory.getHttpClientConfig();
HttpLogSanitizer logSanitizer = httpClientConfig.getLogSanitizer();
Pkcs12KeyStore keyStore = httpClientConfig.getKeyStore();
String baseUrl = aspsp.getIdpUrl() != null ? aspsp.getIdpUrl() : aspsp.getUrl();
BaseOauth2Service baseOauth2Service = new BaseOauth2Service(aspsp, httpClient, logSanitizer);
CertificateSubjectClientIdOauth2Service clientIdOauth2Service =
new CertificateSubjectClientIdOauth2Service(baseOauth2Service, keyStore);
PkceOauth2Service pkceOauth2Service = new PkceOauth2Service(clientIdOauth2Service);
ScopeWithResourceIdOauth2Service scopeOauth2Service =
new ScopeWithResourceIdOauth2Service(pkceOauth2Service, AIS_SCOPE_PREFIX, PIS_SCOPE_PREFIX);
return new CommerzbankOauth2Service(scopeOauth2Service, baseUrl);
}
@Override
public URI getAuthorizationRequestUri(Map<String, String> headers, Parameters parameters) throws IOException {
requireValid(validateGetAuthorizationRequestUri(headers, parameters));
return oauth2Service.getAuthorizationRequestUri(headers, parameters);
}
@Override
public TokenResponse getToken(Map<String, String> headers, Parameters parameters) throws IOException {
parameters.removeScaOAuthLink();
parameters.setTokenEndpoint(StringUri.fromElements(baseUrl, "/v1/token"));
return oauth2Service.getToken(headers, parameters);
}
}
| 3,961 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
public class CommerzbankServiceProvider extends AbstractAdapterServiceProvider implements Oauth2ServiceProvider {
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new CommerzbankAccountInformationService(aspsp,
httpClientFactory,
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new BasePaymentInitiationService(aspsp,
httpClientFactory.getHttpClient(getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public String getAdapterId() {
return "commerzbank-adapter";
}
@Override
public Oauth2Service getOauth2Service(Aspsp aspsp,
HttpClientFactory httpClientFactory) {
return CommerzbankOauth2Service.create(aspsp, httpClientFactory);
}
}
| 2,583 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/CommerzbankAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.ReadAccountBalanceResponse200;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.commerzbank.mapper.BalanceReportMapper;
import de.adorsys.xs2a.adapter.commerzbank.mapper.OK200TransactionDetailsMapper;
import de.adorsys.xs2a.adapter.commerzbank.mapper.TransactionsReportMapper;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankBalanceReport;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankOK200TransactionDetails;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankTransactionsReport;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import org.mapstruct.factory.Mappers;
public class CommerzbankAccountInformationService extends BaseAccountInformationService {
private TransactionsReportMapper transactionsReportMapper = Mappers.getMapper(TransactionsReportMapper.class);
private BalanceReportMapper balanceReportMapper = Mappers.getMapper(BalanceReportMapper.class);
private final OK200TransactionDetailsMapper transactionDetailsMapper = Mappers.getMapper(OK200TransactionDetailsMapper.class);
public CommerzbankAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public Response<TransactionsResponse200Json> getTransactionList(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return getTransactionList(accountId, requestHeaders, requestParams, CommerzbankTransactionsReport.class,
transactionsReportMapper::toTransactionsReport);
}
@Override
public Response<ReadAccountBalanceResponse200> getBalances(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return getBalances(accountId, requestHeaders, requestParams, CommerzbankBalanceReport.class,
balanceReportMapper::toBalanceReport);
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
CommerzbankOK200TransactionDetails.class,
transactionDetailsMapper::toOK200TransactionDetails);
}
}
| 4,548 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
BalanceReportMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/mapper/BalanceReportMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.mapper;
import de.adorsys.xs2a.adapter.api.model.ReadAccountBalanceResponse200;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankBalanceReport;
import org.mapstruct.Mapper;
@Mapper
public interface BalanceReportMapper extends DateTimeMapper {
ReadAccountBalanceResponse200 toBalanceReport(CommerzbankBalanceReport report);
}
| 1,216 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OK200TransactionDetailsMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/mapper/OK200TransactionDetailsMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.mapper;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankOK200TransactionDetails;
import org.mapstruct.Mapper;
@Mapper
public interface OK200TransactionDetailsMapper {
OK200TransactionDetails toOK200TransactionDetails(CommerzbankOK200TransactionDetails value);
}
| 1,220 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
TransactionsReportMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/mapper/TransactionsReportMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.mapper;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.commerzbank.model.CommerzbankTransactionsReport;
import org.mapstruct.Mapper;
@Mapper
public interface TransactionsReportMapper extends DateTimeMapper {
TransactionsResponse200Json toTransactionsReport(CommerzbankTransactionsReport report);
}
| 1,234 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DateTimeMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/mapper/DateTimeMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.mapper;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public interface DateTimeMapper {
default OffsetDateTime toOffsetDateTime(LocalDateTime dateTime) {
if (dateTime == null) {
return null;
}
return ZonedDateTime.of(dateTime, ZoneId.of("Europe/Berlin")).toOffsetDateTime();
}
}
| 1,275 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankBalanceReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/model/CommerzbankBalanceReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.model;
import de.adorsys.xs2a.adapter.api.model.AccountReference;
import java.util.List;
public class CommerzbankBalanceReport {
private List<CommerzbankBalance> balances;
private AccountReference account;
public List<CommerzbankBalance> getBalances() {
return balances;
}
public void setBalances(List<CommerzbankBalance> balances) {
this.balances = balances;
}
public AccountReference getAccount() {
return account;
}
public void setAccount(AccountReference account) {
this.account = account;
}
}
| 1,451 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankOK200TransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/model/CommerzbankOK200TransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.model;
import de.adorsys.xs2a.adapter.api.model.Transactions;
import java.util.Objects;
public class CommerzbankOK200TransactionDetails {
private Transactions transactionsDetails;
public Transactions getTransactionsDetails() {
return transactionsDetails;
}
public void setTransactionsDetails(Transactions transactionsDetails) {
this.transactionsDetails = transactionsDetails;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CommerzbankOK200TransactionDetails that = (CommerzbankOK200TransactionDetails) o;
return Objects.equals(transactionsDetails, that.transactionsDetails);
}
@Override
public int hashCode() {
return Objects.hash(transactionsDetails);
}
}
| 1,724 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankBalance.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/model/CommerzbankBalance.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.model;
import de.adorsys.xs2a.adapter.api.model.Amount;
import de.adorsys.xs2a.adapter.api.model.BalanceType;
import java.time.LocalDate;
import java.time.LocalDateTime;
public class CommerzbankBalance {
private Amount balanceAmount;
private BalanceType balanceType;
private LocalDateTime lastChangeDateTime;
private LocalDate referenceDate;
private String lastCommittedTransaction;
public Amount getBalanceAmount() {
return balanceAmount;
}
public void setBalanceAmount(Amount balanceAmount) {
this.balanceAmount = balanceAmount;
}
public BalanceType getBalanceType() {
return balanceType;
}
public void setBalanceType(BalanceType balanceType) {
this.balanceType = balanceType;
}
public LocalDateTime getLastChangeDateTime() {
return lastChangeDateTime;
}
public void setLastChangeDateTime(LocalDateTime lastChangeDateTime) {
this.lastChangeDateTime = lastChangeDateTime;
}
public LocalDate getReferenceDate() {
return referenceDate;
}
public void setReferenceDate(LocalDate referenceDate) {
this.referenceDate = referenceDate;
}
public String getLastCommittedTransaction() {
return lastCommittedTransaction;
}
public void setLastCommittedTransaction(String lastCommittedTransaction) {
this.lastCommittedTransaction = lastCommittedTransaction;
}
}
| 2,316 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankTransactionsReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/model/CommerzbankTransactionsReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.AccountReference;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
public class CommerzbankTransactionsReport {
private AccountReference account;
private CommerzbankAccountReport transactions;
private List<CommerzbankBalance> balances;
@JsonProperty("_links")
private Map<String, HrefType> links;
public AccountReference getAccount() {
return account;
}
public void setAccount(AccountReference account) {
this.account = account;
}
public CommerzbankAccountReport getTransactions() {
return transactions;
}
public void setTransactions(CommerzbankAccountReport transactions) {
this.transactions = transactions;
}
public List<CommerzbankBalance> getBalances() {
return balances;
}
public void setBalances(List<CommerzbankBalance> balances) {
this.balances = balances;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
}
| 2,083 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
CommerzbankAccountReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/commerzbank-adapter/src/main/java/de/adorsys/xs2a/adapter/commerzbank/model/CommerzbankAccountReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.commerzbank.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import de.adorsys.xs2a.adapter.api.model.Transactions;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class CommerzbankAccountReport {
private List<Transactions> booked;
private List<Transactions> pending;
@JsonProperty("_links")
private Map<String, HrefType> links;
public List<Transactions> getBooked() {
return booked;
}
public void setBooked(List<Transactions> booked) {
this.booked = booked;
}
public List<Transactions> getPending() {
return pending;
}
public void setPending(List<Transactions> pending) {
this.pending = pending;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CommerzbankAccountReport that = (CommerzbankAccountReport) o;
return Objects.equals(booked, that.booked) &&
Objects.equals(pending, that.pending) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(booked,
pending,
links);
}
}
| 2,321 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankPaymentInitiationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankPaymentInitiationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
@ServiceWireMockTest(DeutscheBankServiceProvider.class)
class DeutscheBankPaymentInitiationServiceWireMockTest {
protected static final String SCT_PAYMENT_ID = "de91a99b-5b9d-4f70-8846-81beba089f87";
protected static final String SCT_AUTHORISATION_ID = "43ede576-4b22-4435-ac54-70f2a5eba912";
protected static final String PERIODIC_SCT_PAYMENT_ID = "9f3ad160-f096-4738-baed-7b42f5a5aeb5";
protected static final String PERIODIC_SCT_AUTHORISATION_ID = "89383666-16a8-4cf7-8803-290f9a56628c";
private final PaymentInitiationService service;
private final Map<PaymentService, Pair<String, String>> ids;
DeutscheBankPaymentInitiationServiceWireMockTest(PaymentInitiationService service) {
this.service = service;
this.ids = initiateMap();
}
private Map<PaymentService, Pair<String, String>> initiateMap() {
Map<PaymentService, Pair<String, String>> map = new HashMap<>();
map.put(PaymentService.PAYMENTS, Pair.of(SCT_PAYMENT_ID, SCT_AUTHORISATION_ID));
map.put(PaymentService.PERIODIC_PAYMENTS, Pair.of(PERIODIC_SCT_PAYMENT_ID, PERIODIC_SCT_AUTHORISATION_ID));
return map;
}
@ParameterizedTest
@MethodSource("paymentTypes")
void initiatePayment(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/initiate-payment.json");
Response<PaymentInitationRequestResponse201> response = service.initiatePayment(paymentService,
paymentProduct,
requestResponse.requestHeaders(),
RequestParams.empty(),
isPeriodic(paymentService)
? requestResponse.requestBody(PeriodicPaymentInitiationJson.class)
: requestResponse.requestBody(PaymentInitiationJson.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(PaymentInitationRequestResponse201.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void initiatePayment_redirect(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/initiate-payment-redirect.json");
Response<PaymentInitationRequestResponse201> response = service.initiatePayment(paymentService,
paymentProduct,
requestResponse.requestHeaders(),
RequestParams.empty(),
isPeriodic(paymentService)
? requestResponse.requestBody(PeriodicPaymentInitiationJson.class)
: requestResponse.requestBody(PaymentInitiationJson.class));
PaymentInitationRequestResponse201 expectedBody =
requestResponse.responseBody(PaymentInitationRequestResponse201.class);
// sca redirect link is stubbed via wiremock (has dynamic port)
expectedBody.getLinks().put("scaRedirect", response.getBody().getLinks().get("scaRedirect"));
assertThat(response.getBody()).isEqualTo(expectedBody);
}
private boolean isPeriodic(PaymentService paymentProduct) {
return paymentProduct == PaymentService.PERIODIC_PAYMENTS;
}
@ParameterizedTest
@MethodSource("paymentTypes")
void authenticatePsu(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/authenticate-psu.json");
Response<UpdatePsuAuthenticationResponse> response = service.updatePaymentPsuData(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(UpdatePsuAuthentication.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(UpdatePsuAuthenticationResponse.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void selectScaMethod(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/select-sca-method.json");
Response<SelectPsuAuthenticationMethodResponse> response = service.updatePaymentPsuData(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(SelectPsuAuthenticationMethod.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(SelectPsuAuthenticationMethodResponse.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void authoriseTransaction(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/authorise-transaction.json");
Response<ScaStatusResponse> response = service.updatePaymentPsuData(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(TransactionAuthorisation.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void getScaStatus(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/get-sca-status.json");
Response<ScaStatusResponse> response = service.getPaymentInitiationScaStatus(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
ids.get(paymentService).getRight(),
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@ParameterizedTest
@MethodSource("paymentTypes")
void getPaymentStatus(PaymentService paymentService, PaymentProduct paymentProduct) throws Exception {
TestRequestResponse requestResponse =
new TestRequestResponse("pis/" + paymentService + "/" + paymentProduct + "/get-payment-status.json");
Response<PaymentInitiationStatusResponse200Json> response = service.getPaymentInitiationStatus(paymentService,
paymentProduct,
ids.get(paymentService).getLeft(),
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(PaymentInitiationStatusResponse200Json.class));
}
private static Stream<Arguments> paymentTypes() {
return Stream.of(arguments(PaymentService.PAYMENTS, PaymentProduct.SEPA_CREDIT_TRANSFERS),
arguments(PaymentService.PERIODIC_PAYMENTS, PaymentProduct.SEPA_CREDIT_TRANSFERS));
}
}
| 9,133 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankAccountInformationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankAccountInformationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.io.IOException;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
@ServiceWireMockTest(DeutscheBankServiceProvider.class)
class DeutscheBankAccountInformationServiceWireMockTest {
private static final String CONSENT_ID = "17501be7-1dcd-4ad5-ab30-6d02b170e31a";
private static final String AUTHORISATION_ID = "9cd38df2-1315-41d4-9602-5f63149aacaf";
private static final String ACCOUNT_ID = "8724B81FA1BDDF1775B8C8354221849E";
private static final String ACCOUNT_ID_REDIRECT = "640C6CEAA12923AABCD11EC1AFC40EF5";
private final AccountInformationService service;
DeutscheBankAccountInformationServiceWireMockTest(AccountInformationService service) {
this.service = service;
}
@ParameterizedTest
@ValueSource(strings = {"", "-redirect"})
void createConsent(String suffix) throws Exception {
String relativePath = String.format("ais/create-consent%s.json", suffix);
TestRequestResponse requestResponse = new TestRequestResponse(relativePath);
Response<ConsentsResponse201> response = service.createConsent(requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(Consents.class));
if (isRedirect(relativePath)) {
ConsentsResponse201 expectedBody = requestResponse.responseBody(ConsentsResponse201.class);
expectedBody.getLinks().put("scaRedirect", response.getBody().getLinks().get("scaRedirect"));
assertThat(response.getBody()).isEqualTo(expectedBody);
} else {
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ConsentsResponse201.class));
}
}
private boolean isRedirect(String relativePath) {
return relativePath.contains("-redirect");
}
@Test
void authenticatePsu() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/authenticate-psu.json");
Response<UpdatePsuAuthenticationResponse> response = service.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(UpdatePsuAuthentication.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(UpdatePsuAuthenticationResponse.class));
}
@Test
void selectScaMethod() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/select-sca-method.json");
Response<SelectPsuAuthenticationMethodResponse> response = service.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(SelectPsuAuthenticationMethod.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(SelectPsuAuthenticationMethodResponse.class));
}
@Test
void authoriseTransaction() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/authorise-transaction.json");
Response<ScaStatusResponse> response = service.updateConsentsPsuData(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(TransactionAuthorisation.class));
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@ParameterizedTest
@ValueSource(strings = {"", "-redirect"})
void getAccounts(String suffix) throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse(String.format("ais/get-accounts%s.json", suffix));
Response<AccountList> response = service.getAccountList(requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(AccountList.class));
}
@ParameterizedTest
@MethodSource("testIds")
void getTransactions(String suffix, String accountId) throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse(String.format("ais/get-transactions%s.json", suffix));
Response<TransactionsResponse200Json> response = service.getTransactionList(accountId,
requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(TransactionsResponse200Json.class));
}
@ParameterizedTest
@MethodSource("testIds")
void getBalances(String suffix, String accountId) throws IOException {
TestRequestResponse requestResponse = new TestRequestResponse(String.format("ais/get-balances%s.json", suffix));
Response<ReadAccountBalanceResponse200> response = service.getBalances(accountId,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ReadAccountBalanceResponse200.class));
}
@Test
void getScaStatus() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/get-sca-status.json");
Response<ScaStatusResponse> response = service.getConsentScaStatus(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@Test
void getConsentStatus() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/get-consent-status.json");
Response<ConsentStatusResponse200> response = service.getConsentStatus(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody()).isEqualTo(requestResponse.responseBody(ConsentStatusResponse200.class));
}
@Test
void deleteConsent() throws Exception {
TestRequestResponse requestResponse = new TestRequestResponse("ais/delete-consent.json");
Response<Void> response = service.deleteConsent(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getStatusCode()).isEqualTo(204);
}
private static Stream<Arguments> testIds() {
return Stream.of(arguments("", ACCOUNT_ID), arguments("-redirect", ACCOUNT_ID_REDIRECT));
}
}
| 8,124 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
PsuIdTypeHeaderInterceptorTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/PsuIdTypeHeaderInterceptorTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PsuIdTypeHeaderInterceptorTest {
private PsuIdTypeHeaderInterceptor interceptor;
private RequestBuilderImpl builder;
@BeforeEach
public void setUp() {
interceptor = new PsuIdTypeHeaderInterceptor();
builder = new RequestBuilderImpl(null, null, null);
builder.header(RequestHeaders.PSU_ID, "CHARLES_DICKENS");
}
@Test
void setsPsuIdTypeForDeutscheBankInGermanyWhenPsuIdIsPresent() {
builder.uri("https://xs2a.db.com/ais/DE/DB");
interceptor.preHandle(builder);
assertEquals("DE_ONLB_DB", builder.headers().get(RequestHeaders.PSU_ID_TYPE));
}
@Test
void doesNothingWhenPsuIdIsNotSet() {
builder.uri("https://xs2a.db.com/ais/DE/DB");
builder.headers().remove(RequestHeaders.PSU_ID);
interceptor.preHandle(builder);
assertNull(builder.headers().get(RequestHeaders.PSU_ID_TYPE));
}
@Test
void doesNothingIfPsuIdTypeIsAlreadySet() {
builder.uri("https://xs2a.db.com/ais/DE/DB");
String psuIdTypeOverride = "PSU_ID_TYPE_OVERRIDE";
builder.header(RequestHeaders.PSU_ID_TYPE, psuIdTypeOverride);
interceptor.preHandle(builder);
assertEquals(psuIdTypeOverride, builder.headers().get(RequestHeaders.PSU_ID_TYPE));
}
@Test
void setsPsuIdTypeForPostbankInGermany() {
builder.uri("https://xs2a.db.com/ais/DE/Postbank");
interceptor.preHandle(builder);
assertEquals("DE_ONLB_POBA", builder.headers().get(RequestHeaders.PSU_ID_TYPE));
}
@Test
void hasBoundsChecksInCasePathIsTooShort() {
builder.uri("https://xs2a.db.com/");
try {
interceptor.preHandle(builder);
} catch (IndexOutOfBoundsException e) {
fail();
}
}
@Test
void setsPsuIdTypeForNorisbankInGermany() {
builder.uri("https://xs2a.db.com/ais/DE/Noris");
interceptor.preHandle(builder);
assertEquals("DE_ONLB_NORIS", builder.headers().get(RequestHeaders.PSU_ID_TYPE));
}
}
| 3,163 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.DownloadService;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.HttpLogSanitizer;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BaseDownloadService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;
class DeutscheBankServiceProviderTest {
private static final String URL = "https://url.com/";
private static final String URL_WITH_PLACEHOLDER = URL + DeutscheBankServiceProvider.SERVICE_GROUP_PLACEHOLDER;
private DeutscheBankServiceProvider serviceProvider;
private Aspsp aspsp;
private final HttpClientConfig clientConfig = mock(HttpClientConfig.class);
private final HttpLogSanitizer logSanitizer = mock(HttpLogSanitizer.class);
private final HttpClientFactory factory = mock(HttpClientFactory.class);
ArgumentCaptor<String> urlCaptor = ArgumentCaptor.forClass(String.class);
@BeforeEach
void setUp() {
serviceProvider = new DeutscheBankServiceProvider();
aspsp = spy(getAspsp());
when(factory.getHttpClientConfig()).thenReturn(clientConfig);
when(clientConfig.getLogSanitizer()).thenReturn(logSanitizer);
}
@Test
void getAccountInformationService() {
AccountInformationService ais = serviceProvider.getAccountInformationService(aspsp, factory, null);
assertThat(ais)
.isExactlyInstanceOf(DeutscheBankAccountInformationService.class);
assertUrl("ais");
}
private void assertUrl(String service) {
verify(aspsp, times(1)).getUrl();
verify(aspsp, times(1)).setUrl(urlCaptor.capture());
assertThat(urlCaptor.getValue())
.isNotNull()
.contains(URL + service);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService pis = serviceProvider.getPaymentInitiationService(aspsp, factory, null);
assertThat(pis)
.isExactlyInstanceOf(DeutscheBankPaymentInitiationService.class);
assertUrl("pis");
}
@Test
void getDownloadService() {
DownloadService downloadService = serviceProvider.getDownloadService(URL, factory);
assertThat(downloadService)
.isExactlyInstanceOf(BaseDownloadService.class);
}
private Aspsp getAspsp() {
Aspsp aspsp = new Aspsp();
aspsp.setUrl(URL_WITH_PLACEHOLDER);
return aspsp;
}
}
| 3,663 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankAccountInformationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankAccountInformationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.Request;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import de.adorsys.xs2a.adapter.impl.link.identity.IdentityLinksRewriter;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.util.Map;
import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
class DeutscheBankAccountInformationServiceTest {
private static final String BASE_URL = "https://simulator-xs2a.db.com/ais/DE/SB-DB";
private static final Aspsp ASPSP = buildAspspWithUrl();
private static final String CONSENT_URL = BASE_URL + "/v1/consents";
private static final String ACCOUNT_ID = "accountId";
private static final String REMITTANCE_INFORMATION_STRUCTURED = "remittanceInformationStructuredStringValue";
private final HttpClient httpClient = mock(HttpClient.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private DeutscheBankAccountInformationService service;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
service =
new DeutscheBankAccountInformationService(ASPSP, httpClientFactory, null, new IdentityLinksRewriter(), null);
}
@Test
void createConsent() {
Request.Builder requestBuilder = new RequestBuilderImpl(httpClient, "POST", CONSENT_URL);
when(httpClient.post(eq(CONSENT_URL)))
.thenReturn(requestBuilder);
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(200, new ConsentsResponse201(), ResponseHeaders.fromMap(emptyMap())));
service.createConsent(RequestHeaders.fromMap(emptyMap()), RequestParams.empty(), new Consents());
verify(httpClient, times(1)).post(eq(CONSENT_URL));
Map<String, String> headers = requestBuilder.headers();
assertThat(headers)
.isNotNull()
.isNotEmpty()
.containsKey(RequestHeaders.DATE)
.containsKey(RequestHeaders.PSU_ID)
.containsEntry(RequestHeaders.CONTENT_TYPE, "application/json");
}
@Test
void getTransactionList() {
String rawResponse = "{\n" +
" \"transactions\": {\n" +
" \"booked\": [\n" +
" {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", BASE_URL));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= service.getTransactionList(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(TransactionsResponse200Json.class))
.matches(body ->
body.getTransactions()
.getBooked()
.get(0)
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
@Test
void getTransactionDetails() {
String rawResponse = "{\n" +
" \"transactionsDetails\": {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", BASE_URL));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= service.getTransactionDetails(ACCOUNT_ID, "transactionId", RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(OK200TransactionDetails.class))
.matches(body ->
body.getTransactionsDetails()
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
private static Aspsp buildAspspWithUrl() {
Aspsp aspsp = new Aspsp();
aspsp.setUrl(BASE_URL);
return aspsp;
}
}
| 7,324 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankPsuPasswordEncryptionServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankPsuPasswordEncryptionServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.PsuPasswordEncryptionService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
class DeutscheBankPsuPasswordEncryptionServiceTest {
@Test
void getInstance_shouldNotThrowAnError() {
PsuPasswordEncryptionService encryptionService = new DeutscheBankPsuPasswordEncryptionService();
Assertions.assertThat(encryptionService.encrypt("foo"))
.isNotNull();
}
}
| 1,333 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ServiceLoaderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/ServiceLoaderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.AccountInformationServiceProvider;
import de.adorsys.xs2a.adapter.api.PaymentInitiationServiceProvider;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ServiceLoader;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class ServiceLoaderTest {
private static final Aspsp ASPSP = buildAspspWithUrl();
private HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
}
@Test
void getPaymentInitiationServiceProvider() {
ServiceLoader<PaymentInitiationServiceProvider> loader = ServiceLoader.load(PaymentInitiationServiceProvider.class);
PaymentInitiationServiceProvider provider = loader.iterator().next();
assertThat(provider).isInstanceOf(DeutscheBankServiceProvider.class);
assertThat(provider.getPaymentInitiationService(ASPSP, httpClientFactory, null)).isNotNull();
}
@Test
void getAccountInformationServiceProvider() {
ServiceLoader<AccountInformationServiceProvider> loader = ServiceLoader.load(AccountInformationServiceProvider.class);
AccountInformationServiceProvider provider = loader.iterator().next();
assertThat(provider).isInstanceOf(DeutscheBankServiceProvider.class);
assertThat(provider.getAccountInformationService(ASPSP, httpClientFactory, null)).isNotNull();
}
private static Aspsp buildAspspWithUrl() {
Aspsp aspsp = new Aspsp();
aspsp.setUrl("url");
return aspsp;
}
}
| 2,855 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
PsuIdHeaderInterceptorTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/test/java/de/adorsys/xs2a/adapter/deutschebank/PsuIdHeaderInterceptorTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PsuIdHeaderInterceptorTest {
private PsuIdHeaderInterceptor interceptor;
private RequestBuilderImpl builder;
@BeforeEach
public void setUp() {
interceptor = new PsuIdHeaderInterceptor();
builder = new RequestBuilderImpl(null, null, null);
}
@Test
void trimsPsuIdForDeutscheBankInGermanyWhenPsuIdLengthIsTwelve() {
builder.uri("https://xs2a.db.com/ais/DE/DB");
builder.header(RequestHeaders.PSU_ID, "123456789012");
interceptor.preHandle(builder);
assertEquals("1234567890", builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void trimsPsuIdForNorisbankInGermanyWhenPsuIdLengthIsTwelve() {
builder.uri("https://xs2a.db.com/ais/DE/Noris");
builder.header(RequestHeaders.PSU_ID, "123456789012");
interceptor.preHandle(builder);
assertEquals("1234567890", builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void doesNothingForPostbankInGermanyWhenPsuIdLengthIsTwelve() {
builder.uri("https://xs2a.db.com/ais/DE/Postbank");
builder.header(RequestHeaders.PSU_ID, "123456789012");
interceptor.preHandle(builder);
assertEquals("123456789012", builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void doesNothingForDeutscheBankInGermanyWhenPsuIdLengthIsTen() {
builder.uri("https://xs2a.db.com/ais/DE/DB");
builder.header(RequestHeaders.PSU_ID, "1234567890");
interceptor.preHandle(builder);
assertEquals("1234567890", builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void doesNothingForNorisbankInGermanyWhenPsuIdLengthIsTen() {
builder.uri("https://xs2a.db.com/ais/DE/Noris");
builder.header(RequestHeaders.PSU_ID, "1234567890");
interceptor.preHandle(builder);
assertEquals("1234567890", builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void doesNothingForNorisbankInGermanyWhenPsuIdLengthIsEleven() {
builder.uri("https://xs2a.db.com/ais/DE/Noris");
builder.header(RequestHeaders.PSU_ID, "12345678901");
interceptor.preHandle(builder);
assertEquals("12345678901", builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void doesNothingWhenPsuIdIsNotSet() {
builder.uri("https://xs2a.db.com/ais/DE/DB");
interceptor.preHandle(builder);
assertNull(builder.headers().get(RequestHeaders.PSU_ID));
}
@Test
void hasBoundsChecksInCasePathIsTooShort() {
builder.uri("https://xs2a.db.com/");
try {
interceptor.preHandle(builder);
} catch (IndexOutOfBoundsException e) {
fail();
}
}
}
| 3,829 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankPsuPasswordEncryptionService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankPsuPasswordEncryptionService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.RSAEncrypter;
import com.nimbusds.jose.jwk.RSAKey;
import com.nimbusds.jose.util.Base64;
import de.adorsys.xs2a.adapter.api.PsuPasswordEncryptionService;
import de.adorsys.xs2a.adapter.api.config.AdapterConfig;
import de.adorsys.xs2a.adapter.api.exception.PsuPasswordEncodingException;
import org.apache.commons.io.IOUtils;
import org.bouncycastle.jcajce.provider.asymmetric.x509.CertificateFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/*
* Deutsche bank password encryption flow is based on JWE (RFC7516 - https://tools.ietf.org/html/rfc7516)
*/
// TODO adjust this logic on the additional information from Deutsche bank about the certificates API
public class DeutscheBankPsuPasswordEncryptionService implements PsuPasswordEncryptionService {
private static final String URL_TO_CERTIFICATE
= AdapterConfig.readProperty("deutsche-bank.aspsp.certificate.url", "https://xs2a.db.com/pb/aspsp-certificates/tpp-pb-password_cert.pem");
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception during Deutsche bank adapter PSU password encryption";
private static DeutscheBankPsuPasswordEncryptionService encryptionService;
private JWEHeader jweHeader;
private JWEEncrypter jweEncrypter;
private boolean isInit = false;
@Override
public String encrypt(String password) {
if (!isInit) {
init();
}
JWEObject jweObject = new JWEObject(jweHeader, new Payload(password));
try {
jweObject.encrypt(jweEncrypter);
} catch (JOSEException e) {
throw new PsuPasswordEncodingException(DEFAULT_EXCEPTION_MESSAGE, e);
}
return jweObject.serialize();
}
private void init() {
CertificateFactory certificateFactory = new CertificateFactory();
try {
URI certificateUri = new URI(URL_TO_CERTIFICATE);
InputStream certs = getCertificates(certificateUri);
// Warning for unchecked assignment can be ignored,
// as under the hood CertificateFactory#engineGenerateCertificates returns ArrayList<java.security.cert.Certificate>,
// even though java.util.Collection is mentioned as a return type.
// See org.bouncycastle.jcajce.provider.asymmetric.x509.CertificateFactory#engineGenerateCertificates implementation for further details.
@SuppressWarnings("unchecked")
Collection<Certificate> certificates = certificateFactory.engineGenerateCertificates(certs);
if (certificates.isEmpty()) {
throw new PsuPasswordEncodingException("No certificates have been provided by bank for PSU password encryption");
}
List<X509Certificate> x509Certificates = toX509Certificates(certificates);
List<Base64> x509CertificateChainEncoded = x509Certificates.stream()
.map(this::toBase64)
.collect(Collectors.toList());
jweHeader = new JWEHeader.Builder(JWEAlgorithm.RSA_OAEP_256, EncryptionMethod.A256GCM)
.x509CertURL(certificateUri)
.x509CertChain(x509CertificateChainEncoded)
.build();
jweEncrypter = new RSAEncrypter(RSAKey.parse(getBankCertificate(x509Certificates)));
this.isInit = true;
} catch (Exception e) {
throw new PsuPasswordEncodingException(DEFAULT_EXCEPTION_MESSAGE, e);
}
}
private List<X509Certificate> toX509Certificates(Collection<Certificate> certificates) {
return certificates.stream()
.map(certificate -> {
if (!(certificate instanceof X509Certificate)) {
throw new PsuPasswordEncodingException("Certificate provided by bank is not a X509 type");
}
return (X509Certificate) certificate;
})
.collect(Collectors.toList());
}
private Base64 toBase64(X509Certificate certificate) {
try {
return Base64.encode(certificate.getEncoded());
} catch (CertificateEncodingException e) {
throw new PsuPasswordEncodingException(DEFAULT_EXCEPTION_MESSAGE, e);
}
}
private X509Certificate getBankCertificate(List<X509Certificate> certificates) {
return certificates.get(0);
}
// Bouncy Castle CertificateFactory#engineGenerateCertificates in version 1.64 and higher will fail
// if PEM file ends with more that one trailing new line (e.g. "\n\n"). This condition should be checked and fixed.
// Related issue: https://github.com/adorsys/xs2a-adapter/issues/577
private InputStream getCertificates(URI certificateUri) throws IOException {
byte[] pemBytes = IOUtils.toByteArray(certificateUri);
String pemFile = new String(pemBytes).replace("\n\n", "\n");
return IOUtils.toInputStream(pemFile, (String) null);
}
}
| 6,283 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.PsuPasswordEncryptionService;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.*;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.deutschebank.model.DeutscheBankOK200TransactionDetails;
import de.adorsys.xs2a.adapter.deutschebank.model.DeutscheBankTransactionResponse200Json;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.factory.Mappers;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
public class DeutscheBankAccountInformationService extends BaseAccountInformationService {
private static final String DATE_HEADER = "Date";
private final DeutscheBankMapper deutscheBankMapper = Mappers.getMapper(DeutscheBankMapper.class);
private final PsuPasswordEncryptionService psuPasswordEncryptionService;
public DeutscheBankAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
List<Interceptor> interceptors,
LinksRewriter linksRewriter,
PsuPasswordEncryptionService psuPasswordEncryptionService) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
interceptors,
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
this.psuPasswordEncryptionService = psuPasswordEncryptionService;
}
@Override
public Response<StartScaprocessResponse> startConsentAuthorisation(String consentId,
RequestHeaders requestHeaders,
RequestParams requestParams,
UpdatePsuAuthentication updatePsuAuthentication) {
PsuData psuData = updatePsuAuthentication.getPsuData();
if (passwordEncryptionRequired(psuData)) {
encryptPassword(psuData);
}
return super.startConsentAuthorisation(consentId, requestHeaders, requestParams, updatePsuAuthentication);
}
@Override
public Response<UpdatePsuAuthenticationResponse> updateConsentsPsuData(String consentId,
String authorisationId,
RequestHeaders requestHeaders,
RequestParams requestParams,
UpdatePsuAuthentication updatePsuAuthentication) {
PsuData psuData = updatePsuAuthentication.getPsuData();
if (passwordEncryptionRequired(psuData)) {
encryptPassword(psuData);
}
return super.updateConsentsPsuData(consentId,
authorisationId,
requestHeaders,
requestParams,
updatePsuAuthentication);
}
@Override
public Response<TransactionsResponse200Json> getTransactionList(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionList(accountId,
requestHeaders,
requestParams,
DeutscheBankTransactionResponse200Json.class,
deutscheBankMapper::toTransactionsResponse200Json);
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
DeutscheBankOK200TransactionDetails.class,
deutscheBankMapper::toOK200TransactionDetails);
}
private boolean passwordEncryptionRequired(PsuData psuData) {
return StringUtils.isNotBlank(psuData.getEncryptedPassword());
}
private void encryptPassword(PsuData psuData) {
String password = psuData.getEncryptedPassword();
String encryptedPassword = psuPasswordEncryptionService.encrypt(password);
psuData.setEncryptedPassword(encryptedPassword);
}
@Override
protected Map<String, String> populateGetHeaders(Map<String, String> map) {
Map<String, String> headers = super.populateGetHeaders(map);
headers.put(DATE_HEADER, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now()));
headers.put(ACCEPT_HEADER, ContentType.APPLICATION_JSON);
return headers;
}
@Override
protected Map<String, String> populatePostHeaders(Map<String, String> map) {
map.put(DATE_HEADER, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now()));
map.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return map;
}
@Override
protected Map<String, String> populatePutHeaders(Map<String, String> headers) {
headers.put(DATE_HEADER, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now()));
headers.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return headers;
}
}
| 6,864 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
PsuIdHeaderInterceptor.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/PsuIdHeaderInterceptor.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.http.Interceptor;
import de.adorsys.xs2a.adapter.api.http.Request;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* For DE/DB and DE/Noris the subaccount number will be removed from the PSU-ID if present.
*/
public class PsuIdHeaderInterceptor implements Interceptor {
@Override
public Request.Builder preHandle(Request.Builder builder) {
String psuId = builder.headers().get(RequestHeaders.PSU_ID);
if (psuId != null) {
trimPsuId(builder, psuId);
}
return builder;
}
private void trimPsuId(Request.Builder builder, String psuId) {
URI uri = URI.create(builder.uri());
Path path = Paths.get(uri.getPath());
if (path.getNameCount() < 3) {
return;
}
String countryCode = path.getName(1).toString();
if ("DE".equals(countryCode)) {
String businessEntity = path.getName(2).toString();
if (("DB".equals(businessEntity) || "Noris".equals(businessEntity))
&& psuId.length() == 12) {
builder.header(RequestHeaders.PSU_ID, psuId.substring(0, 10));
}
}
}
}
| 2,148 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankPaymentInitiationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankPaymentInitiationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.http.*;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
public class DeutscheBankPaymentInitiationService extends BasePaymentInitiationService {
private static final String DATE_HEADER = "Date";
public DeutscheBankPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
List<Interceptor> interceptors,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
interceptors,
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
protected Map<String, String> populateGetHeaders(Map<String, String> map) {
Map<String, String> headers = super.populateGetHeaders(map);
headers.put(DATE_HEADER, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now()));
headers.put(ACCEPT_HEADER, ContentType.APPLICATION_JSON);
return headers;
}
@Override
protected Map<String, String> populatePostHeaders(Map<String, String> map) {
Map<String, String> headers = super.populatePostHeaders(map);
headers.put(DATE_HEADER, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now()));
headers.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return headers;
}
@Override
protected Map<String, String> populatePutHeaders(Map<String, String> headers) {
headers.put(DATE_HEADER, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now()));
headers.put(RequestHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
return headers;
}
}
| 2,979 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
PsuIdTypeHeaderInterceptor.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/PsuIdTypeHeaderInterceptor.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.http.Interceptor;
import de.adorsys.xs2a.adapter.api.http.Request;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* Sets an appropriate PSU-ID-Type header value based on the country code and
* business entity specified in the request uri.
* https://xs2a.db.com/{service-group}/{country-code}/{business-entity}/{version}/{service}{?query-parameters}
*/
public class PsuIdTypeHeaderInterceptor implements Interceptor {
@Override
public Request.Builder preHandle(Request.Builder builder) {
if (builder.headers().get(RequestHeaders.PSU_ID) != null
&& builder.headers().get(RequestHeaders.PSU_ID_TYPE) == null) {
setPsuIdType(builder);
}
return builder;
}
private void setPsuIdType(Request.Builder builder) {
URI uri = URI.create(builder.uri());
Path path = Paths.get(uri.getPath());
if (path.getNameCount() < 3) {
return;
}
String countryCode = path.getName(1).toString();
if ("DE".equals(countryCode)) {
String businessEntity = path.getName(2).toString();
if ("DB".equals(businessEntity)) {
builder.header(RequestHeaders.PSU_ID_TYPE, "DE_ONLB_DB");
} else if ("Postbank".equals(businessEntity)) {
builder.header(RequestHeaders.PSU_ID_TYPE, "DE_ONLB_POBA");
} else if ("Noris".equals(businessEntity)) {
builder.header(RequestHeaders.PSU_ID_TYPE, "DE_ONLB_NORIS");
}
}
}
}
| 2,520 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
import de.adorsys.xs2a.adapter.impl.BaseDownloadService;
public class DeutscheBankServiceProvider extends AbstractAdapterServiceProvider implements DownloadServiceProvider {
public static final String SERVICE_GROUP_PLACEHOLDER = "{Service Group}";
private final PsuIdTypeHeaderInterceptor psuIdTypeHeaderInterceptor = new PsuIdTypeHeaderInterceptor();
private final PsuIdHeaderInterceptor psuIdHeaderInterceptor = new PsuIdHeaderInterceptor();
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
aspsp.setUrl(aspsp.getUrl().replace(SERVICE_GROUP_PLACEHOLDER, "ais"));
return new DeutscheBankAccountInformationService(aspsp,
httpClientFactory,
getInterceptors(aspsp, psuIdTypeHeaderInterceptor, psuIdHeaderInterceptor),
linksRewriter,
new DeutscheBankPsuPasswordEncryptionService());
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
aspsp.setUrl(aspsp.getUrl().replace(SERVICE_GROUP_PLACEHOLDER, "pis"));
return new DeutscheBankPaymentInitiationService(aspsp,
httpClientFactory,
getInterceptors(aspsp, psuIdTypeHeaderInterceptor, psuIdHeaderInterceptor),
linksRewriter);
}
@Override
public DownloadService getDownloadService(String baseUrl,
HttpClientFactory httpClientFactory) {
return new BaseDownloadService(baseUrl,
httpClientFactory.getHttpClient(getAdapterId()),
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public String getAdapterId() {
return "deutsche-bank-adapter";
}
}
| 3,284 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/DeutscheBankMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.deutschebank.model.DeutscheBankOK200TransactionDetails;
import de.adorsys.xs2a.adapter.deutschebank.model.DeutscheBankTransactionDetails;
import de.adorsys.xs2a.adapter.deutschebank.model.DeutscheBankTransactionResponse200Json;
import org.mapstruct.Mapper;
@Mapper
public interface DeutscheBankMapper {
TransactionsResponse200Json toTransactionsResponse200Json(DeutscheBankTransactionResponse200Json value);
OK200TransactionDetails toOK200TransactionDetails(DeutscheBankOK200TransactionDetails value);
Transactions toTransactions(DeutscheBankTransactionDetails value);
default String map(RemittanceInformationStructured value) {
return value == null ? null : value.getReference();
}
}
| 1,667 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankOK200TransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/model/DeutscheBankOK200TransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank.model;
import java.util.Objects;
public class DeutscheBankOK200TransactionDetails {
private DeutscheBankTransactionDetails transactionsDetails;
public DeutscheBankTransactionDetails getTransactionsDetails() {
return transactionsDetails;
}
public void setTransactionsDetails(DeutscheBankTransactionDetails transactionsDetails) {
this.transactionsDetails = transactionsDetails;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DeutscheBankOK200TransactionDetails that = (DeutscheBankOK200TransactionDetails) o;
return Objects.equals(transactionsDetails, that.transactionsDetails);
}
@Override
public int hashCode() {
return Objects.hash(transactionsDetails);
}
}
| 1,726 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankTransactionResponse200Json.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/model/DeutscheBankTransactionResponse200Json.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.AccountReference;
import de.adorsys.xs2a.adapter.api.model.Balance;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class DeutscheBankTransactionResponse200Json {
private AccountReference account;
private DeutscheBankAccountReport transactions;
private List<Balance> balances;
@JsonProperty("_links")
private Map<String, HrefType> links;
public AccountReference getAccount() {
return account;
}
public void setAccount(AccountReference account) {
this.account = account;
}
public DeutscheBankAccountReport getTransactions() {
return transactions;
}
public void setTransactions(DeutscheBankAccountReport transactions) {
this.transactions = transactions;
}
public List<Balance> getBalances() {
return balances;
}
public void setBalances(List<Balance> balances) {
this.balances = balances;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DeutscheBankTransactionResponse200Json that = (DeutscheBankTransactionResponse200Json) o;
return Objects.equals(account, that.account) &&
Objects.equals(transactions, that.transactions) &&
Objects.equals(balances, that.balances) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(account,
transactions,
balances,
links);
}
}
| 2,775 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankTransactionDetails.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/model/DeutscheBankTransactionDetails.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.*;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class DeutscheBankTransactionDetails {
private String transactionId;
private String entryReference;
private String endToEndId;
private String mandateId;
private String checkId;
private String creditorId;
private LocalDate bookingDate;
private LocalDate valueDate;
private Amount transactionAmount;
private List<ReportExchangeRate> currencyExchange;
private String creditorName;
private AccountReference creditorAccount;
private String creditorAgent;
private String ultimateCreditor;
private String debtorName;
private AccountReference debtorAccount;
private String debtorAgent;
private String ultimateDebtor;
private String remittanceInformationUnstructured;
private List<String> remittanceInformationUnstructuredArray;
private RemittanceInformationStructured remittanceInformationStructured;
private List<RemittanceInformationStructured> remittanceInformationStructuredArray;
private String additionalInformation;
private AdditionalInformationStructured additionalInformationStructured;
private PurposeCode purposeCode;
private String bankTransactionCode;
private String proprietaryBankTransactionCode;
private Balance balanceAfterTransaction;
@JsonProperty("_links")
private Map<String, HrefType> links;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getEntryReference() {
return entryReference;
}
public void setEntryReference(String entryReference) {
this.entryReference = entryReference;
}
public String getEndToEndId() {
return endToEndId;
}
public void setEndToEndId(String endToEndId) {
this.endToEndId = endToEndId;
}
public String getMandateId() {
return mandateId;
}
public void setMandateId(String mandateId) {
this.mandateId = mandateId;
}
public String getCheckId() {
return checkId;
}
public void setCheckId(String checkId) {
this.checkId = checkId;
}
public String getCreditorId() {
return creditorId;
}
public void setCreditorId(String creditorId) {
this.creditorId = creditorId;
}
public LocalDate getBookingDate() {
return bookingDate;
}
public void setBookingDate(LocalDate bookingDate) {
this.bookingDate = bookingDate;
}
public LocalDate getValueDate() {
return valueDate;
}
public void setValueDate(LocalDate valueDate) {
this.valueDate = valueDate;
}
public Amount getTransactionAmount() {
return transactionAmount;
}
public void setTransactionAmount(Amount transactionAmount) {
this.transactionAmount = transactionAmount;
}
public List<ReportExchangeRate> getCurrencyExchange() {
return currencyExchange;
}
public void setCurrencyExchange(List<ReportExchangeRate> currencyExchange) {
this.currencyExchange = currencyExchange;
}
public String getCreditorName() {
return creditorName;
}
public void setCreditorName(String creditorName) {
this.creditorName = creditorName;
}
public AccountReference getCreditorAccount() {
return creditorAccount;
}
public void setCreditorAccount(AccountReference creditorAccount) {
this.creditorAccount = creditorAccount;
}
public String getCreditorAgent() {
return creditorAgent;
}
public void setCreditorAgent(String creditorAgent) {
this.creditorAgent = creditorAgent;
}
public String getUltimateCreditor() {
return ultimateCreditor;
}
public void setUltimateCreditor(String ultimateCreditor) {
this.ultimateCreditor = ultimateCreditor;
}
public String getDebtorName() {
return debtorName;
}
public void setDebtorName(String debtorName) {
this.debtorName = debtorName;
}
public AccountReference getDebtorAccount() {
return debtorAccount;
}
public void setDebtorAccount(AccountReference debtorAccount) {
this.debtorAccount = debtorAccount;
}
public String getDebtorAgent() {
return debtorAgent;
}
public void setDebtorAgent(String debtorAgent) {
this.debtorAgent = debtorAgent;
}
public String getUltimateDebtor() {
return ultimateDebtor;
}
public void setUltimateDebtor(String ultimateDebtor) {
this.ultimateDebtor = ultimateDebtor;
}
public String getRemittanceInformationUnstructured() {
return remittanceInformationUnstructured;
}
public void setRemittanceInformationUnstructured(String remittanceInformationUnstructured) {
this.remittanceInformationUnstructured = remittanceInformationUnstructured;
}
public List<String> getRemittanceInformationUnstructuredArray() {
return remittanceInformationUnstructuredArray;
}
public void setRemittanceInformationUnstructuredArray(
List<String> remittanceInformationUnstructuredArray) {
this.remittanceInformationUnstructuredArray = remittanceInformationUnstructuredArray;
}
public RemittanceInformationStructured getRemittanceInformationStructured() {
return remittanceInformationStructured;
}
public void setRemittanceInformationStructured(RemittanceInformationStructured remittanceInformationStructured) {
this.remittanceInformationStructured = remittanceInformationStructured;
}
public List<RemittanceInformationStructured> getRemittanceInformationStructuredArray() {
return remittanceInformationStructuredArray;
}
public void setRemittanceInformationStructuredArray(
List<RemittanceInformationStructured> remittanceInformationStructuredArray) {
this.remittanceInformationStructuredArray = remittanceInformationStructuredArray;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public AdditionalInformationStructured getAdditionalInformationStructured() {
return additionalInformationStructured;
}
public void setAdditionalInformationStructured(
AdditionalInformationStructured additionalInformationStructured) {
this.additionalInformationStructured = additionalInformationStructured;
}
public PurposeCode getPurposeCode() {
return purposeCode;
}
public void setPurposeCode(PurposeCode purposeCode) {
this.purposeCode = purposeCode;
}
public String getBankTransactionCode() {
return bankTransactionCode;
}
public void setBankTransactionCode(String bankTransactionCode) {
this.bankTransactionCode = bankTransactionCode;
}
public String getProprietaryBankTransactionCode() {
return proprietaryBankTransactionCode;
}
public void setProprietaryBankTransactionCode(String proprietaryBankTransactionCode) {
this.proprietaryBankTransactionCode = proprietaryBankTransactionCode;
}
public Balance getBalanceAfterTransaction() {
return balanceAfterTransaction;
}
public void setBalanceAfterTransaction(Balance balanceAfterTransaction) {
this.balanceAfterTransaction = balanceAfterTransaction;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DeutscheBankTransactionDetails that = (DeutscheBankTransactionDetails) o;
return Objects.equals(transactionId, that.transactionId) &&
Objects.equals(entryReference, that.entryReference) &&
Objects.equals(endToEndId, that.endToEndId) &&
Objects.equals(mandateId, that.mandateId) &&
Objects.equals(checkId, that.checkId) &&
Objects.equals(creditorId, that.creditorId) &&
Objects.equals(bookingDate, that.bookingDate) &&
Objects.equals(valueDate, that.valueDate) &&
Objects.equals(transactionAmount, that.transactionAmount) &&
Objects.equals(currencyExchange, that.currencyExchange) &&
Objects.equals(creditorName, that.creditorName) &&
Objects.equals(creditorAccount, that.creditorAccount) &&
Objects.equals(creditorAgent, that.creditorAgent) &&
Objects.equals(ultimateCreditor, that.ultimateCreditor) &&
Objects.equals(debtorName, that.debtorName) &&
Objects.equals(debtorAccount, that.debtorAccount) &&
Objects.equals(debtorAgent, that.debtorAgent) &&
Objects.equals(ultimateDebtor, that.ultimateDebtor) &&
Objects.equals(remittanceInformationUnstructured, that.remittanceInformationUnstructured) &&
Objects.equals(remittanceInformationUnstructuredArray, that.remittanceInformationUnstructuredArray) &&
Objects.equals(remittanceInformationStructured, that.remittanceInformationStructured) &&
Objects.equals(remittanceInformationStructuredArray, that.remittanceInformationStructuredArray) &&
Objects.equals(additionalInformation, that.additionalInformation) &&
Objects.equals(additionalInformationStructured, that.additionalInformationStructured) &&
Objects.equals(purposeCode, that.purposeCode) &&
Objects.equals(bankTransactionCode, that.bankTransactionCode) &&
Objects.equals(proprietaryBankTransactionCode, that.proprietaryBankTransactionCode) &&
Objects.equals(balanceAfterTransaction, that.balanceAfterTransaction) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(transactionId,
entryReference,
endToEndId,
mandateId,
checkId,
creditorId,
bookingDate,
valueDate,
transactionAmount,
currencyExchange,
creditorName,
creditorAccount,
creditorAgent,
ultimateCreditor,
debtorName,
debtorAccount,
debtorAgent,
ultimateDebtor,
remittanceInformationUnstructured,
remittanceInformationUnstructuredArray,
remittanceInformationStructured,
remittanceInformationStructuredArray,
additionalInformation,
additionalInformationStructured,
purposeCode,
bankTransactionCode,
proprietaryBankTransactionCode,
balanceAfterTransaction,
links);
}
}
| 12,152 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DeutscheBankAccountReport.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/deutsche-bank-adapter/src/main/java/de/adorsys/xs2a/adapter/deutschebank/model/DeutscheBankAccountReport.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.deutschebank.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.adorsys.xs2a.adapter.api.model.HrefType;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class DeutscheBankAccountReport {
private List<DeutscheBankTransactionDetails> booked;
private List<DeutscheBankTransactionDetails> pending;
@JsonProperty("_links")
private Map<String, HrefType> links;
public List<DeutscheBankTransactionDetails> getBooked() {
return booked;
}
public void setBooked(List<DeutscheBankTransactionDetails> booked) {
this.booked = booked;
}
public List<DeutscheBankTransactionDetails> getPending() {
return pending;
}
public void setPending(List<DeutscheBankTransactionDetails> pending) {
this.pending = pending;
}
public Map<String, HrefType> getLinks() {
return links;
}
public void setLinks(Map<String, HrefType> links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DeutscheBankAccountReport that = (DeutscheBankAccountReport) o;
return Objects.equals(booked, that.booked) &&
Objects.equals(pending, that.pending) &&
Objects.equals(links, that.links);
}
@Override
public int hashCode() {
return Objects.hash(booked,
pending,
links);
}
}
| 2,378 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectPaymentInitiationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/ComdirectPaymentInitiationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static de.adorsys.xs2a.adapter.api.model.PaymentProduct.SEPA_CREDIT_TRANSFERS;
import static de.adorsys.xs2a.adapter.api.model.PaymentService.PAYMENTS;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(ComdirectServiceProvider.class)
class ComdirectPaymentInitiationServiceWireMockTest {
private static final String PAYMENT_ID = "PAYMENT_ID_RCVD_SCT";
private static final String AUTHORISATION_ID = "11111111-1111-1111-1111-111111111111";
private final PaymentInitiationService paymentInitiationService;
ComdirectPaymentInitiationServiceWireMockTest(PaymentInitiationService paymentInitiationService) {
this.paymentInitiationService = paymentInitiationService;
}
@Test
void initiatePayment() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/initiate-payment.json");
var response = paymentInitiationService.initiatePayment(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(PaymentInitiationJson.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(PaymentInitationRequestResponse201.class));
}
@Test
void getPaymentStatus() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/get-payment-status.json");
var response = paymentInitiationService.getPaymentInitiationStatus(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(PaymentInitiationStatusResponse200Json.class));
}
@Test
void getPaymentAuthorisations() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/get-payment-authorisations.json");
var response = paymentInitiationService.getPaymentInitiationAuthorisation(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(Authorisations.class));
}
@Test
void getScaStatus() throws IOException {
var requestResponse = new TestRequestResponse("pis/payments/sepa-credit-transfers/get-sca-status.json");
var response = paymentInitiationService.getPaymentInitiationScaStatus(PAYMENTS,
SEPA_CREDIT_TRANSFERS,
PAYMENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
}
| 4,172 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectOauth2ServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/ComdirectOauth2ServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.model.TokenResponse;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.LinkedHashMap;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(ComdirectServiceProvider.class)
class ComdirectOauth2ServiceWireMockTest {
private final Oauth2Service oauth2Service;
ComdirectOauth2ServiceWireMockTest(Oauth2Service oauth2Service) {
this.oauth2Service = oauth2Service;
}
@Test
void getAccessToken() throws IOException {
var requestResponse = new TestRequestResponse("oauth2/get-access-token.json");
var modifiableParams = new LinkedHashMap<>(requestResponse.requestParams().toMap());
var actualToken = oauth2Service.getToken(requestResponse.requestHeaders().toMap(),
new Oauth2Service.Parameters(modifiableParams));
assertThat(actualToken)
.isNotNull()
.isEqualTo(requestResponse.responseBody(TokenResponse.class));
}
}
| 2,048 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectServiceProviderTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/ComdirectServiceProviderTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.PaymentInitiationService;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class ComdirectServiceProviderTest {
private ComdirectServiceProvider serviceProvider;
private final HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final Aspsp aspsp = new Aspsp();
@BeforeEach
void setUp() {
serviceProvider = new ComdirectServiceProvider();
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
}
@Test
void getAccountInformationService() {
AccountInformationService actualService
= serviceProvider.getAccountInformationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(ComdirectAccountInformationService.class);
}
@Test
void getPaymentInitiationService() {
PaymentInitiationService actualService
= serviceProvider.getPaymentInitiationService(aspsp, httpClientFactory, null);
assertThat(actualService)
.isExactlyInstanceOf(BasePaymentInitiationService.class);
}
@Test
void getOauth2Service() {
Oauth2Service actualService
= serviceProvider.getOauth2Service(aspsp, httpClientFactory);
assertThat(actualService)
.isExactlyInstanceOf(ComdirectOauth2Service.class);
}
}
| 2,855 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectAccountInformationServiceWireMockTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/ComdirectAccountInformationServiceWireMockTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.AccountInformationService;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.model.*;
import de.adorsys.xs2a.adapter.test.ServiceWireMockTest;
import de.adorsys.xs2a.adapter.test.TestRequestResponse;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
@ServiceWireMockTest(ComdirectServiceProvider.class)
class ComdirectAccountInformationServiceWireMockTest {
private static final String CONSENT_ID = "VALID_CONSENT_ID";
private static final String ACCOUNT_ID = "ACCOUNT_ID";
private static final String AUTHORISATION_ID = "11111111-1111-1111-1111-111111111111";
private final AccountInformationService accountInformationService;
ComdirectAccountInformationServiceWireMockTest(AccountInformationService accountInformationService) {
this.accountInformationService = accountInformationService;
}
@Test
void createConsent() throws IOException {
var requestResponse = new TestRequestResponse("ais/create-consent.json");
var response = accountInformationService.createConsent(requestResponse.requestHeaders(),
RequestParams.empty(),
requestResponse.requestBody(Consents.class));
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ConsentsResponse201.class));
}
@Test
void deleteConsent() throws IOException {
var requestResponse = new TestRequestResponse("ais/delete-consent.json");
var response = accountInformationService.deleteConsent(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getStatusCode())
.isEqualTo(204);
}
@Test
void getAccounts() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-accounts.json");
var response = accountInformationService.getAccountList(requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(AccountList.class));
}
@Test
void getBalances() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-balances.json");
var response = accountInformationService.getBalances(ACCOUNT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ReadAccountBalanceResponse200.class));
}
@Test
void getConsentAuthorisation() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-consent-authorisations.json");
var response = accountInformationService.getConsentAuthorisation(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(Authorisations.class));
}
@Test
void getConsentStatus() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-consent-status.json");
var response = accountInformationService.getConsentStatus(CONSENT_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ConsentStatusResponse200.class));
}
@Test
void getScaStatus() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-sca-status.json");
var response = accountInformationService.getConsentScaStatus(CONSENT_ID,
AUTHORISATION_ID,
requestResponse.requestHeaders(),
RequestParams.empty());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(ScaStatusResponse.class));
}
@Test
void getTransactions() throws IOException {
var requestResponse = new TestRequestResponse("ais/get-transactions.json");
var response = accountInformationService.getTransactionList(ACCOUNT_ID,
requestResponse.requestHeaders(),
requestResponse.requestParams());
assertThat(response.getBody())
.isEqualTo(requestResponse.responseBody(TransactionsResponse200Json.class));
}
}
| 5,307 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectOauth2ServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/ComdirectOauth2ServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.Pkcs12KeyStore;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.Request;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.TokenResponse;
import de.adorsys.xs2a.adapter.api.validation.RequestValidationException;
import de.adorsys.xs2a.adapter.impl.oauth2.api.model.AuthorisationServerMetaData;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import static de.adorsys.xs2a.adapter.api.Oauth2Service.Parameters;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
class ComdirectOauth2ServiceTest {
private static final String SCA_OAUTH_LINK =
"https://xs2a-api.comdirect.de/berlingroup/.well-known/openid-configuration?authorizationId=31f68ab6-1ce6-4131-a324-3f37d2ca4b02";
private static final String IDP_URL =
"https://psd.comdirect.de/public/berlingroup/idp";
private static final String AUTHORIZATION_ENDPOINT_LINK
= "https://psd.comdirect.de/berlingroup/authorize/31f68ab6-1ce6-4131-a324-3f37d2ca4b02";
private static final String ORG_ID = "PSDDE-BAFIN-999999";
private static final String STATE = "test";
private static final String REDIRECT_URI = "https://example.com/cb";
private static final String CONSENT_ID = "consent-id";
private static final String AUTHORIZATION_CODE = "authorization-code";
private static final String BASE_URI = "https://psd.comdirect.de/berlingroup";
private static final String TOKEN_ENDPOINT = BASE_URI + "/v1/token";
private ComdirectOauth2Service oauth2Service;
private final HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
private final HttpClient httpClient = mock(HttpClient.class);
private final Request.Builder builder = mock(Request.Builder.class);
@BeforeEach
void setUp() throws Exception {
Pkcs12KeyStore keyStore = mock(Pkcs12KeyStore.class);
when(keyStore.getOrganizationIdentifier())
.thenReturn(ORG_ID);
HttpClientConfig httpClientConfig = mock(HttpClientConfig.class);
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
when(httpClientConfig.getKeyStore()).thenReturn(keyStore);
when(httpClient.get(anyString())).thenReturn(builder);
doReturn(authorizationServerMetadata()).when(builder).send(any());
}
private Response<AuthorisationServerMetaData> authorizationServerMetadata() {
AuthorisationServerMetaData metadata = new AuthorisationServerMetaData();
metadata.setAuthorisationEndpoint(AUTHORIZATION_ENDPOINT_LINK);
return new Response<>(200, metadata, ResponseHeaders.emptyResponseHeaders());
}
@Test
void getAuthorizationRequestUri() throws IOException {
oauth2Service = ComdirectOauth2Service.create(new Aspsp(), httpClientFactory);
Parameters parameters = new Parameters();
parameters.setScaOAuthLink(SCA_OAUTH_LINK);
parameters.setState(STATE);
parameters.setConsentId(CONSENT_ID);
parameters.setRedirectUri(REDIRECT_URI);
URI uri = oauth2Service.getAuthorizationRequestUri(null, parameters);
assertEquals(AUTHORIZATION_ENDPOINT_LINK + "?" +
"response_type=code&" +
"state=" + STATE + "&" +
"redirect_uri=" + URLEncoder.encode(REDIRECT_URI, StandardCharsets.UTF_8.name()) + "&" +
"client_id=" + ORG_ID + "&" +
"code_challenge_method=S256&" +
"code_challenge=" + oauth2Service.codeChallenge() + "&" +
"scope=AIS%3A" + CONSENT_ID, uri.toString());
}
@Test
void getAuthorizationRequestUriForPayment() throws IOException {
oauth2Service = ComdirectOauth2Service.create(new Aspsp(), httpClientFactory);
Parameters parameters = new Parameters();
parameters.setScaOAuthLink(SCA_OAUTH_LINK);
parameters.setState(STATE);
parameters.setPaymentId("payment-id");
parameters.setRedirectUri(REDIRECT_URI);
URI uri = oauth2Service.getAuthorizationRequestUri(null, parameters);
assertEquals(AUTHORIZATION_ENDPOINT_LINK + "?" +
"response_type=code&" +
"state=" + STATE + "&" +
"redirect_uri=" + URLEncoder.encode(REDIRECT_URI, StandardCharsets.UTF_8.name()) + "&" +
"client_id=" + ORG_ID + "&" +
"code_challenge_method=S256&" +
"code_challenge=" + oauth2Service.codeChallenge() + "&" +
"scope=PIS%3Apayment-id", uri.toString());
}
@Test
void getAuthorizationRequestUri_noScaOAuthLink() throws IOException {
Aspsp aspsp = new Aspsp();
aspsp.setIdpUrl(IDP_URL);
AuthorisationServerMetaData metaData = new AuthorisationServerMetaData();
metaData.setAuthorisationEndpoint(AUTHORIZATION_ENDPOINT_LINK);
oauth2Service = ComdirectOauth2Service.create(aspsp, httpClientFactory);
Parameters parameters = new Parameters();
parameters.setState(STATE);
parameters.setConsentId(CONSENT_ID);
parameters.setRedirectUri(REDIRECT_URI);
doReturn(new Response<>(200, metaData, null)).when(builder).send(any());
URI uri = oauth2Service.getAuthorizationRequestUri(null, parameters);
verify(httpClient, times(1)).get(anyString());
verify(builder, times(1)).send(any());
assertEquals(AUTHORIZATION_ENDPOINT_LINK + "?" +
"response_type=code&" +
"state=" + STATE + "&" +
"redirect_uri=" + URLEncoder.encode(REDIRECT_URI, StandardCharsets.UTF_8.name()) + "&" +
"client_id=" + ORG_ID + "&" +
"code_challenge_method=S256&" +
"code_challenge=" + oauth2Service.codeChallenge() + "&" +
"scope=AIS%3A" + CONSENT_ID, uri.toString());
}
@Test
void getAuthorizationRequestUri_noScaOAuthLinkNoIdpUrl() {
oauth2Service = ComdirectOauth2Service.create(new Aspsp(), httpClientFactory);
Parameters parameters = new Parameters();
assertThrows(RequestValidationException.class,
() -> oauth2Service.getAuthorizationRequestUri(null, parameters));
}
@Test
@SuppressWarnings("unchecked")
void getToken() throws IOException {
Aspsp aspsp = new Aspsp();
aspsp.setUrl(BASE_URI);
ArgumentCaptor<Map<String, String>> mapCaptor = ArgumentCaptor.forClass(Map.class);
when(httpClient.post(anyString())).thenReturn(builder);
when(builder.urlEncodedBody(any())).thenReturn(builder);
doReturn(new Response<>(200, new TokenResponse(), ResponseHeaders.emptyResponseHeaders()))
.when(builder).send(any());
oauth2Service = ComdirectOauth2Service.create(aspsp, httpClientFactory);
Parameters parameters = new Parameters();
parameters.setGrantType(Oauth2Service.GrantType.AUTHORIZATION_CODE.toString());
parameters.setAuthorizationCode(AUTHORIZATION_CODE);
parameters.setRedirectUri(REDIRECT_URI);
oauth2Service.getToken(null, parameters);
Map<String, String> expectedBody = new HashMap<>();
expectedBody.put(Parameters.GRANT_TYPE, Oauth2Service.GrantType.AUTHORIZATION_CODE.toString());
expectedBody.put(Parameters.CLIENT_ID, ORG_ID);
expectedBody.put(Parameters.CODE, AUTHORIZATION_CODE);
expectedBody.put(Parameters.REDIRECT_URI, REDIRECT_URI);
expectedBody.put(Parameters.CODE_VERIFIER, oauth2Service.codeVerifier());
verify(httpClient, times(1))
.post(argThat(argument -> argument.equals(TOKEN_ENDPOINT)));
verify(builder, times(1)).urlEncodedBody(mapCaptor.capture());
Map<String, String> actualBody = mapCaptor.getValue();
assertNotNull(actualBody);
assertEquals(expectedBody, actualBody);
}
}
| 9,394 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectAccountInformationServiceTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/ComdirectAccountInformationServiceTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.ResponseHeaders;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.ReadAccountBalanceResponse200;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectBalanceReport;
import de.adorsys.xs2a.adapter.impl.http.RequestBuilderImpl;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.ByteArrayInputStream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class ComdirectAccountInformationServiceTest {
private static final String URI = "https://foo.boo";
private static final String ACCOUNT_ID = "accountId";
private static final String REMITTANCE_INFORMATION_STRUCTURED = "remittanceInformationStructuredStringValue";
private ComdirectAccountInformationService accountInformationService;
@Mock
private HttpClient httpClient;
@Mock
private HttpClientFactory httpClientFactory;
@Mock
private HttpClientConfig httpClientConfig;
@Mock
private Aspsp aspsp;
@Mock
private LinksRewriter linksRewriter;
@BeforeEach
void setUp() {
when(httpClientFactory.getHttpClient(any())).thenReturn(httpClient);
when(httpClientFactory.getHttpClientConfig()).thenReturn(httpClientConfig);
accountInformationService = new ComdirectAccountInformationService(aspsp, httpClientFactory, linksRewriter);
}
@Test
void getBalances() {
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenReturn(new Response<>(-1, new ComdirectBalanceReport(), ResponseHeaders.emptyResponseHeaders()));
Response<?> actualResponse
= accountInformationService.getBalances(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.isInstanceOf(ReadAccountBalanceResponse200.class);
}
@Test
void getTransactionList() {
String rawResponse = "{\n" +
" \"transactions\": {\n" +
" \"booked\": [\n" +
" {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionList(ACCOUNT_ID, RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(TransactionsResponse200Json.class))
.matches(body ->
body.getTransactions()
.getBooked()
.get(0)
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
@Test
void getTransactionDetails() {
String rawResponse = "{\n" +
" \"transactionsDetails\": {\n" +
" \"remittanceInformationStructured\": {" +
" \"reference\": \"" + REMITTANCE_INFORMATION_STRUCTURED + "\"\n" +
" }\n" +
" }\n" +
"}";
when(httpClient.get(anyString()))
.thenReturn(new RequestBuilderImpl(httpClient, "GET", URI));
when(httpClient.send(any(), any()))
.thenAnswer(invocationOnMock -> {
HttpClient.ResponseHandler responseHandler = invocationOnMock.getArgument(1, HttpClient.ResponseHandler.class);
return new Response<>(-1,
responseHandler.apply(200,
new ByteArrayInputStream(rawResponse.getBytes()),
ResponseHeaders.emptyResponseHeaders()),
null);
});
Response<?> actualResponse
= accountInformationService.getTransactionDetails(ACCOUNT_ID, "transactionId", RequestHeaders.empty(), RequestParams.empty());
verify(httpClient, times(1)).get(anyString());
verify(httpClient, times(1)).send(any(), any());
assertThat(actualResponse)
.isNotNull()
.extracting(Response::getBody)
.asInstanceOf(InstanceOfAssertFactories.type(OK200TransactionDetails.class))
.matches(body ->
body.getTransactionsDetails()
.getRemittanceInformationStructured()
.equals(REMITTANCE_INFORMATION_STRUCTURED));
}
}
| 7,294 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
RemittanceInformationStructuredMapperTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/mapper/RemittanceInformationStructuredMapperTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import de.adorsys.xs2a.adapter.api.model.RemittanceInformationStructured;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class RemittanceInformationStructuredMapperTest {
public static final String REFERENCE = "reference";
private final RemittanceInformationStructuredMapper mapper
= new TestRemittanceInformationStructuredMapper();
@Test
void map() {
String actual = mapper.map(getRemittanceInformationStructured());
assertThat(actual)
.isNotBlank()
.isEqualTo(REFERENCE);
}
private RemittanceInformationStructured getRemittanceInformationStructured() {
RemittanceInformationStructured instance = new RemittanceInformationStructured();
instance.setReference(REFERENCE);
return instance;
}
private static class TestRemittanceInformationStructuredMapper implements RemittanceInformationStructuredMapper { }
}
| 1,846 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
DateTimeMapperTest.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/test/java/de/adorsys/xs2a/adapter/comdirect/mapper/DateTimeMapperTest.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import static org.assertj.core.api.Assertions.assertThat;
class DateTimeMapperTest {
private static final DateTimeMapper dateTimeMapper = new TestDateTimeMapper();
@Test
void toOffsetDateTime_shouldReturnNull() {
OffsetDateTime actual = dateTimeMapper.toOffsetDateTime(null);
assertThat(actual)
.isNull();
}
@Test
void toOffsetDateTime() {
LocalDateTime benchmark = LocalDateTime.now();
OffsetDateTime actual = dateTimeMapper.toOffsetDateTime(benchmark);
assertThat(actual)
.isNotNull()
.matches(offsetDateTime ->
benchmark.getYear() == offsetDateTime.getYear()
&& benchmark.getMonthValue() == offsetDateTime.getMonthValue()
&& benchmark.getDayOfMonth() == offsetDateTime.getDayOfMonth());
}
private static class TestDateTimeMapper implements DateTimeMapper {
}
}
| 1,922 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectAccountInformationService.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/ComdirectAccountInformationService.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.api.Response;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.api.model.ReadAccountBalanceResponse200;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.comdirect.mapper.BalanceReportMapper;
import de.adorsys.xs2a.adapter.comdirect.mapper.OK200TransactionDetailsMapper;
import de.adorsys.xs2a.adapter.comdirect.mapper.TransactionsResponseMapper;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectBalanceReport;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectOK200TransactionDetails;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectTransactionResponse200Json;
import de.adorsys.xs2a.adapter.impl.BaseAccountInformationService;
import org.mapstruct.factory.Mappers;
public class ComdirectAccountInformationService extends BaseAccountInformationService {
private BalanceReportMapper balanceReportMapper = Mappers.getMapper(BalanceReportMapper.class);
private TransactionsResponseMapper transactionsResponseMapper = Mappers.getMapper(TransactionsResponseMapper.class);
private OK200TransactionDetailsMapper transactionDetailsMapper = Mappers.getMapper(OK200TransactionDetailsMapper.class);
public ComdirectAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
super(aspsp,
httpClientFactory.getHttpClient(aspsp.getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public Response<ReadAccountBalanceResponse200> getBalances(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return getBalances(accountId, requestHeaders, requestParams, ComdirectBalanceReport.class,
balanceReportMapper::toBalanceReport);
}
@Override
public Response<TransactionsResponse200Json> getTransactionList(String accountId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionList(accountId,
requestHeaders,
requestParams,
ComdirectTransactionResponse200Json.class,
transactionsResponseMapper::toTransactionsResponse200Json);
}
@Override
public Response<OK200TransactionDetails> getTransactionDetails(String accountId,
String transactionId,
RequestHeaders requestHeaders,
RequestParams requestParams) {
return super.getTransactionDetails(accountId,
transactionId,
requestHeaders,
requestParams,
ComdirectOK200TransactionDetails.class,
transactionDetailsMapper::toOK200TransactionDetails);
}
}
| 4,697 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectOauth2Service.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/ComdirectOauth2Service.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.Oauth2Service;
import de.adorsys.xs2a.adapter.api.PkceOauth2Extension;
import de.adorsys.xs2a.adapter.api.Pkcs12KeyStore;
import de.adorsys.xs2a.adapter.api.http.HttpClient;
import de.adorsys.xs2a.adapter.api.http.HttpClientConfig;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.http.HttpLogSanitizer;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.api.model.TokenResponse;
import de.adorsys.xs2a.adapter.api.validation.ValidationError;
import de.adorsys.xs2a.adapter.impl.*;
import de.adorsys.xs2a.adapter.impl.http.StringUri;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static de.adorsys.xs2a.adapter.api.validation.Validation.requireValid;
/**
* @see <a href="https://xs2a-developer.comdirect.de/content/howto/ais-manage-consents">Authorisation</a>
*/
public class ComdirectOauth2Service extends Oauth2ServiceDecorator implements PkceOauth2Extension {
private static final String SCA_OAUTH_LINK_MISSING_ERROR_MESSAGE = "SCA OAuth link is missing or has a wrong format: " +
"it has to be either provided as a request parameter or preconfigured for the current ASPSP";
private static final String AIS_SCOPE_PREFIX = "AIS:";
private static final String PIS_SCOPE_PREFIX = "PIS:";
private final String baseUrl;
private final Aspsp aspsp;
private ComdirectOauth2Service(Oauth2Service oauth2Service, String baseUrl, Aspsp aspsp) {
super(oauth2Service);
this.baseUrl = baseUrl;
this.aspsp = aspsp;
}
public static ComdirectOauth2Service create(Aspsp aspsp, HttpClientFactory httpClientFactory) {
HttpClient httpClient = httpClientFactory.getHttpClient(aspsp.getAdapterId());
HttpClientConfig httpClientConfig = httpClientFactory.getHttpClientConfig();
HttpLogSanitizer logSanitizer = httpClientConfig.getLogSanitizer();
Pkcs12KeyStore keyStore = httpClientConfig.getKeyStore();
String baseUrl = aspsp.getIdpUrl() != null ? aspsp.getIdpUrl() : aspsp.getUrl();
BaseOauth2Service baseOauth2Service = new BaseOauth2Service(aspsp, httpClient, logSanitizer);
CertificateSubjectClientIdOauth2Service clientIdOauth2Service =
new CertificateSubjectClientIdOauth2Service(baseOauth2Service, keyStore);
PkceOauth2Service pkceOauth2Service = new PkceOauth2Service(clientIdOauth2Service);
ScopeWithResourceIdOauth2Service scopeOauth2Service =
new ScopeWithResourceIdOauth2Service(pkceOauth2Service, AIS_SCOPE_PREFIX, PIS_SCOPE_PREFIX);
return new ComdirectOauth2Service(scopeOauth2Service, baseUrl, aspsp);
}
@Override
public URI getAuthorizationRequestUri(Map<String, String> headers, Parameters parameters) throws IOException {
requireValid(validateGetAuthorizationRequestUri(headers, parameters));
return oauth2Service.getAuthorizationRequestUri(headers, parameters);
}
@Override
public List<ValidationError> validateGetAuthorizationRequestUri(Map<String, String> headers,
Parameters parameters) {
List<ValidationError> validationErrors =
new ArrayList<>(oauth2Service.validateGetAuthorizationRequestUri(headers, parameters));
if (StringUtils.isBlank(getScaOAuthUrl(parameters))) {
validationErrors.add(new ValidationError(ValidationError.Code.REQUIRED,
Parameters.SCA_OAUTH_LINK,
SCA_OAUTH_LINK_MISSING_ERROR_MESSAGE));
}
return Collections.unmodifiableList(validationErrors);
}
@Override
public TokenResponse getToken(Map<String, String> headers, Parameters parameters) throws IOException {
parameters.removeScaOAuthLink();
parameters.setTokenEndpoint(StringUri.fromElements(baseUrl, "/v1/token"));
return oauth2Service.getToken(headers, parameters);
}
private String getScaOAuthUrl(Parameters parameters) {
String baseScaOAuthUrl = parameters.getScaOAuthLink();
if (StringUtils.isBlank(baseScaOAuthUrl)) {
baseScaOAuthUrl = aspsp.getIdpUrl();
}
return baseScaOAuthUrl;
}
}
| 5,282 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
ComdirectServiceProvider.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/ComdirectServiceProvider.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect;
import de.adorsys.xs2a.adapter.api.*;
import de.adorsys.xs2a.adapter.api.http.HttpClientFactory;
import de.adorsys.xs2a.adapter.api.link.LinksRewriter;
import de.adorsys.xs2a.adapter.api.model.Aspsp;
import de.adorsys.xs2a.adapter.impl.AbstractAdapterServiceProvider;
import de.adorsys.xs2a.adapter.impl.BasePaymentInitiationService;
public class ComdirectServiceProvider extends AbstractAdapterServiceProvider implements Oauth2ServiceProvider {
@Override
public AccountInformationService getAccountInformationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new ComdirectAccountInformationService(aspsp,
httpClientFactory,
linksRewriter);
}
@Override
public PaymentInitiationService getPaymentInitiationService(Aspsp aspsp,
HttpClientFactory httpClientFactory,
LinksRewriter linksRewriter) {
return new BasePaymentInitiationService(aspsp,
httpClientFactory.getHttpClient(getAdapterId()),
linksRewriter,
httpClientFactory.getHttpClientConfig().getLogSanitizer());
}
@Override
public String getAdapterId() {
return "comdirect-adapter";
}
@Override
public Oauth2Service getOauth2Service(Aspsp aspsp, HttpClientFactory httpClientFactory) {
return ComdirectOauth2Service.create(aspsp, httpClientFactory);
}
}
| 2,531 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
BalanceReportMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/mapper/BalanceReportMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import de.adorsys.xs2a.adapter.api.model.ReadAccountBalanceResponse200;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectBalanceReport;
import org.mapstruct.Mapper;
@Mapper
public interface BalanceReportMapper extends DateTimeMapper {
ReadAccountBalanceResponse200 toBalanceReport(ComdirectBalanceReport report);
}
| 1,208 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
OK200TransactionDetailsMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/mapper/OK200TransactionDetailsMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import de.adorsys.xs2a.adapter.api.model.OK200TransactionDetails;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectOK200TransactionDetails;
import org.mapstruct.Mapper;
@Mapper
public interface OK200TransactionDetailsMapper extends RemittanceInformationStructuredMapper {
OK200TransactionDetails toOK200TransactionDetails(ComdirectOK200TransactionDetails value);
}
| 1,258 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
RemittanceInformationStructuredMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/mapper/RemittanceInformationStructuredMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import de.adorsys.xs2a.adapter.api.model.RemittanceInformationStructured;
public interface RemittanceInformationStructuredMapper extends DateTimeMapper {
default String map(RemittanceInformationStructured value) {
return value == null ? null : value.getReference();
}
}
| 1,168 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
TransactionsResponseMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/mapper/TransactionsResponseMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import de.adorsys.xs2a.adapter.api.model.TransactionsResponse200Json;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectTransactionResponse200Json;
import org.mapstruct.Mapper;
@Mapper
public interface TransactionsResponseMapper extends RemittanceInformationStructuredMapper {
TransactionsResponse200Json toTransactionsResponse200Json(ComdirectTransactionResponse200Json value);
}
| 1,273 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |
TransactionsMapper.java | /FileExtraction/Java_unseen/adorsys_xs2a-adapter/adapters/comdirect-adapter/src/main/java/de/adorsys/xs2a/adapter/comdirect/mapper/TransactionsMapper.java | /*
* Copyright 2018-2022 adorsys GmbH & Co KG
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version. This program is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* This project is also available under a separate commercial license. You can
* contact us at [email protected].
*/
package de.adorsys.xs2a.adapter.comdirect.mapper;
import de.adorsys.xs2a.adapter.api.model.Transactions;
import de.adorsys.xs2a.adapter.comdirect.model.ComdirectTransactionDetails;
public interface TransactionsMapper {
Transactions toTransactions(ComdirectTransactionDetails value);
}
| 1,121 | Java | .java | adorsys/xs2a-adapter | 37 | 25 | 5 | 2019-04-01T09:31:44Z | 2024-03-09T08:27:14Z |