Skip to content

Commit

Permalink
cleanup, removed outdated adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
age-77 committed Oct 25, 2021
1 parent efa5cb8 commit 2257b89
Show file tree
Hide file tree
Showing 67 changed files with 7 additions and 3,928 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.Collections;
import java.util.HashMap;
import java.util.Optional;
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -41,7 +40,7 @@ public void test() {
assertThat(repository.findByUserId(bankAccess.getUserId())).isNotEmpty();

BankAccessEntity bankAccessEntity = repository.findByUserIdAndId(bankAccess.getUserId(), bankAccess.getId())
.orElseThrow(() -> new IllegalStateException("bankaccess is null"));
.orElseThrow(() -> new IllegalStateException("bankaccess is null"));

assertThat(bankAccessEntity.getTanTransportTypes()).isNotEmpty();

Expand All @@ -61,12 +60,8 @@ public BankAccessEntity createBankAccess() {

entity.setTanTransportTypes(new HashMap<>());
entity.getTanTransportTypes().put(BankApi.HBCI, Collections.singletonList(TanTransportType.builder()
.id("SMS_OTP")
.build()));

entity.getTanTransportTypes().put(BankApi.FIGO, Collections.singletonList(TanTransportType.builder()
.id("PUSH_OTP")
.build()));
.id("SMS_OTP")
.build()));

repository.save(entity);

Expand Down
5 changes: 0 additions & 5 deletions multibanking-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<artifactId>onlinebanking-hbci4java</artifactId>
<version>5.5.35-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.adorsys.multibanking</groupId>
<artifactId>onlinebanking-ing</artifactId>
<version>5.5.35-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.adorsys.multibanking</groupId>
<artifactId>onlinebanking-bankinggateway</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package de.adorsys.multibanking.config;

import de.adorsys.multibanking.bg.BankingGatewayAdapter;
import de.adorsys.multibanking.domain.BankApi;
import de.adorsys.multibanking.figo.FigoBanking;
import de.adorsys.multibanking.hbci.HbciBanking;
import de.adorsys.multibanking.ing.IngAdapter;
import lombok.extern.slf4j.Slf4j;
import org.kapott.hbci.manager.HBCIProduct;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -45,16 +42,11 @@ public class AdapterConfig {
@Value("${fints.bpdCacheExpirationMs:86400000}") //one day
private long fintsBpdCacheExpirationMs;

private IngAdapter ingAdapter;
private BankingGatewayAdapter bankingGatewayAdapter;
private HbciBanking hbci4JavaBanking;
private FigoBanking figoBanking = new FigoBanking(BankApi.FIGO);
private FigoBanking figoBankingAlternative = new FigoBanking(BankApi.FIGO_ALTERNATIVE);

@PostConstruct
public void postConstruct() {
ingAdapter = new IngAdapter(ingBaseUrl, keyStoreUrl, keyStorePassword, ingQwacAlias,
ingQsealAlias);
bankingGatewayAdapter = new BankingGatewayAdapter(bankingGatewayBaseUrl,
bankingAdapterBaseUrl, dumpDownloadFiles);

Expand All @@ -66,11 +58,6 @@ public void postConstruct() {
}
}

@Bean
public IngAdapter ingAdapter() {
return ingAdapter;
}

@Bean
public BankingGatewayAdapter bankingGatewayAdapter() {
return bankingGatewayAdapter;
Expand All @@ -81,13 +68,4 @@ public HbciBanking hbci4JavaBanking() {
return hbci4JavaBanking;
}

@Bean
public FigoBanking figoBanking() {
return figoBanking;
}

@Bean
public FigoBanking figoBankingAlternative() {
return figoBankingAlternative;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import de.adorsys.multibanking.domain.response.AccountInformationResponse;
import de.adorsys.multibanking.domain.spi.OnlineBankingService;
import de.adorsys.multibanking.domain.transaction.LoadAccounts;
import de.adorsys.multibanking.exception.BankAccessAlreadyExistException;
import de.adorsys.multibanking.exception.InvalidBankAccessException;
import de.adorsys.multibanking.exception.ResourceNotFoundException;
import de.adorsys.multibanking.metrics.MetricsCollector;
Expand All @@ -19,11 +18,9 @@
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static de.adorsys.multibanking.domain.ScaStatus.FINALISED;

Expand Down Expand Up @@ -82,13 +79,7 @@ public List<BankAccountEntity> loadBankAccountsOnline(BankEntity bankEntity, Ban
List<BankAccount> bankAccounts = loadBankAccountsOnline(expectedConsentStatus, bankAccess,
onlineBankingService, bankApiUser, bankEntity);

if (onlineBankingService.bankApi() == BankApi.FIGO) {
filterAccounts(bankAccess, onlineBankingService, bankAccounts);
}

return Optional.ofNullable(bankAccounts)
.map(Collection::stream)
.orElseGet(Stream::empty)
return Optional.ofNullable(bankAccounts).stream().flatMap(Collection::stream)
.map(source -> {
BankAccountEntity target = new BankAccountEntity();
BeanUtils.copyProperties(source, target);
Expand Down Expand Up @@ -123,29 +114,4 @@ private List<BankAccount> loadBankAccountsOnline(ScaStatus expectedConsentStatus
throw e;
}
}

private void filterAccounts(BankAccessEntity bankAccess, OnlineBankingService onlineBankingService,
List<BankAccount> bankAccounts) {
List<BankAccountEntity> userBankAccounts = bankAccountRepository.findByUserId(bankAccess.getUserId());
//filter out previous created accounts
Iterator<BankAccount> accountIterator = bankAccounts.iterator();
while (accountIterator.hasNext()) {
BankAccount newAccount = accountIterator.next();
userBankAccounts.stream()
.filter(bankAccountEntity -> {
String newAccountExternalID = newAccount.getExternalIdMap().get(onlineBankingService.bankApi());
String existingAccountExternalID =
bankAccountEntity.getExternalIdMap().get(onlineBankingService.bankApi());
return newAccountExternalID.equals(existingAccountExternalID);
})
.findFirst()
.ifPresent(bankAccountEntity -> accountIterator.remove());
}
//all accounts created in the past
if (bankAccounts.isEmpty()) {
throw new BankAccessAlreadyExistException();
}
bankAccess.setBankName(bankAccounts.get(0).getBankName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import de.adorsys.multibanking.domain.BankApi;
import de.adorsys.multibanking.domain.BankEntity;
import de.adorsys.multibanking.domain.spi.OnlineBankingService;
import de.adorsys.multibanking.figo.FigoBanking;
import de.adorsys.multibanking.hbci.HbciBanking;
import de.adorsys.multibanking.ing.IngAdapter;
import de.adorsys.multibanking.pers.spi.repository.BankRepositoryIf;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -16,11 +14,8 @@
@Service
public class OnlineBankingServiceProducer {

private final IngAdapter ingAdapter;
private final BankingGatewayAdapter bankingGatewayAdapter;
private final HbciBanking hbci4JavaBanking;
private final FigoBanking figoBanking;
private final FigoBanking figoBankingAlternative;
private final BankRepositoryIf bankRepository;
@Value("${defaultBankApi:HBCI}")
private String defaultBankApi;
Expand All @@ -44,12 +39,6 @@ public OnlineBankingService getBankingService(BankApi bankApi) {
switch (bankApi) {
case HBCI:
return hbci4JavaBanking;
case FIGO:
return figoBanking;
case ING:
return ingAdapter;
case FIGO_ALTERNATIVE:
return figoBankingAlternative;
case XS2A:
return bankingGatewayAdapter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

@Schema(name = "BankApi", description = "The banking access backend")
public enum BankApiTO {
HBCI, FIGO, XS2A, FIGO_ALTERNATIVE, ING
HBCI, XS2A
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import de.adorsys.multibanking.exception.domain.Messages;
import de.adorsys.multibanking.hbci.HbciBanking;
import de.adorsys.multibanking.hbci.model.HbciConsent;
import de.adorsys.multibanking.ing.IngAdapter;
import de.adorsys.multibanking.pers.spi.repository.BankRepositoryIf;
import de.adorsys.multibanking.pers.spi.repository.ConsentRepositoryIf;
import de.adorsys.multibanking.web.DirectAccessControllerV2;
Expand Down Expand Up @@ -58,7 +57,6 @@
import static de.adorsys.multibanking.domain.exception.MultibankingError.INVALID_CONSENT_STATUS;
import static de.adorsys.multibanking.domain.exception.MultibankingError.INVALID_SCA_METHOD;
import static de.adorsys.multibanking.service.TestUtil.createBooking;
import static de.adorsys.multibanking.web.model.ScaApproachTO.OAUTH;
import static de.adorsys.multibanking.web.model.ScaStatusTO.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.kapott.hbci.manager.HBCIVersion.HBCI_300;
Expand Down Expand Up @@ -188,48 +186,6 @@ public void consent_authorisation_bankinggateway_decoupled() {
assertThat(jsonPath.getString("scaStatus")).isIn(FINALISED.toString());
}

@Ignore("uses real data - please setup ENV")
@Test
public void consent_authorisation_ing() {
ConsentTO consentTO = createConsentTO();

prepareBank(new IngAdapter(ingBaseUrl, keyStoreUrl, keyStorePassword, ingQwacAlias, ingQsealAlias),
consentTO.getPsuAccountIban(), false);

//1. create consent
JsonPath jsonPath = request.body(consentTO)
.header("Correlation-ID", "TEST123")
.post(getRemoteMultibankingUrl() + "/api/v1/consents")
.then().assertThat().statusCode(HttpStatus.CREATED.value())
.and().extract().jsonPath();

assertThat(jsonPath.getString("_links.redirectUrl")).isNotBlank();

BankAccessTO bankAccess = createBankAccess();
bankAccess.setConsentId(jsonPath.getString("consentId"));

//2. get consent authorisation status
jsonPath = request.get(jsonPath.getString("_links.authorisationStatus.href"))
.then().assertThat().statusCode(HttpStatus.OK.value())
.and().extract().jsonPath();

assertThat(jsonPath.getString("scaApproach")).isEqualTo(OAUTH.toString());

//3. load bookings
DirectAccessControllerV2.LoadBookingsRequest LoadBookingsRequest =
new DirectAccessControllerV2.LoadBookingsRequest();
LoadBookingsRequest.setBankAccess(bankAccess);
LoadBookingsRequest.setAuthorisationCode("8b6cd77a-aa44-4527-ab08-a58d70cca286");

jsonPath = request
.body(LoadBookingsRequest)
.post(getRemoteMultibankingUrl() + "/api/v2/direct/bookings")
.then().assertThat().statusCode(HttpStatus.OK.value())
.and().extract().jsonPath();

assertThat(jsonPath.getString("bookings")).isNotBlank();
}

@Ignore("uses real data - please setup ENV")
@Test
public void consent_authorisation_bankinggateway() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public static void beforeClass() {
public void beforeTest() {
MockitoAnnotations.initMocks(this);
when(bankingServiceProducer.getBankingService(anyString())).thenReturn(new HbciBanking(null, 0, 0, 0));
when(bankingServiceProducer.getBankingService(BankApi.FIGO)).thenReturn(new HbciBanking(null, 0, 0, 0));
when(bankingServiceProducer.getBankingService(BankApi.HBCI)).thenReturn(new HbciBanking(null, 0, 0, 0));

bankRepository.findByBankCode(System.getProperty("blz")).orElseGet(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void beforeTest() throws IOException {

MockitoAnnotations.initMocks(this);
when(bankingServiceProducer.getBankingService(anyString())).thenReturn(hbci4JavaBanking);
when(bankingServiceProducer.getBankingService(BankApi.FIGO)).thenReturn(hbci4JavaBanking);
when(bankingServiceProducer.getBankingService(BankApi.HBCI)).thenReturn(hbci4JavaBanking);

bankRepository.findByBankCode(System.getProperty("blz")).orElseGet(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public static void beforeClass() {
public void beforeTest() {
MockitoAnnotations.initMocks(this);
when(bankingServiceProducer.getBankingService(anyString())).thenReturn(new HbciBanking(null, 0, 0, 0));
when(bankingServiceProducer.getBankingService(BankApi.FIGO)).thenReturn(new HbciBanking(null, 0, 0, 0));
when(bankingServiceProducer.getBankingService(BankApi.HBCI)).thenReturn(new HbciBanking(null, 0, 0, 0));

bankRepository.findByBankCode(System.getProperty("blz")).orElseGet(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ private static void merge() throws IOException {
}

bankEntity.setBic(bankInfo.getBic());
if (bankInfo.getPinTanVersion() != null) {
bankEntity.setBankApi(BankApi.HBCI);
} else {
bankEntity.setBankApi(BankApi.FIGO);
}
bankEntity.setBankApi(BankApi.HBCI);
});
}

Expand Down
Loading

0 comments on commit 2257b89

Please sign in to comment.