Skip to content

Commit

Permalink
45: Use latest uk-datamodel with 3.1.8r5 swagger models
Browse files Browse the repository at this point in the history
Some changes to VRP and Funds Conformation

Issue: OpenBankingToolkit/openbanking-toolkit#45
  • Loading branch information
BohoCode committed Nov 26, 2021
1 parent 18b50ef commit cfe1045
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 47 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ Changelog of Git Changelog Maven plugin.
- Issue: https://github.com/ForgeCloud/ob-deploy/issues/794

* Fix ng lint
### GitHub [#457](https://github.com/OpenBankingToolkit/openbanking-aspsp/pull/457) Release/1.5.5
[18b50ef6ffaf807](https://github.com/OpenBankingToolkit/openbanking-aspsp/commit/18b50ef6ffaf807) Jorge Sanchez Perez *2021-11-17 08:34:07*
Release/1.5.5 (#457)

* Changelog updated

* Release candidate: prepare release 1.5.5

* Release candidate: prepare for next development iteration
[eef7145f5305af3](https://github.com/OpenBankingToolkit/openbanking-aspsp/commit/eef7145f5305af3) JamieB *2021-10-12 06:53:39*
Release candidate: prepare for next development iteration
## 1.5.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier;
import com.forgerock.openbanking.common.services.openbanking.converter.FRModelMapper;
import uk.org.openbanking.datamodel.account.*;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsent1DataDebtorAccount;
import uk.org.openbanking.datamodel.payment.*;

public class FRAccountIdentifierConverter {
Expand Down Expand Up @@ -94,7 +95,20 @@ public static FRAccountIdentifier toFRAccountIdentifier(OBCashAccountCreditor1 a
.build();
}

public static FRAccountIdentifier toFRAccountIdentifier(OBFundsConfirmationConsent1DataDebtorAccount account) {
return account == null ? null :FRAccountIdentifier.builder()
.schemeName(account.getSchemeName() == null ? null : account.getSchemeName())
.identification(account.getIdentification())
.name(account.getName())
.secondaryIdentification(account.getSecondaryIdentification())
.build();
}

// FR to OB
public static OBFundsConfirmationConsent1DataDebtorAccount toOBFundsConfirmationConsent1DataDebtorAccount(FRAccountIdentifier account){
return FRModelMapper.map(account, OBFundsConfirmationConsent1DataDebtorAccount.class);
}

public static OBCashAccountCreditor3 toOBCashAccountCreditor3(FRAccountIdentifier account) {
return FRModelMapper.map(account, OBCashAccountCreditor3.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount;
import com.forgerock.openbanking.common.services.openbanking.converter.FRModelMapper;
import uk.org.openbanking.datamodel.account.*;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmation1DataInstructedAmount;
import uk.org.openbanking.datamodel.payment.OBActiveOrHistoricCurrencyAndAmount;
import uk.org.openbanking.datamodel.payment.*;

Expand Down Expand Up @@ -125,6 +126,10 @@ public static FRAmount toFRAmount(uk.org.openbanking.datamodel.account.OBTransac
return FRModelMapper.map(amount, FRAmount.class);
}

public static FRAmount toFRAmount(OBFundsConfirmation1DataInstructedAmount amount) {
return FRModelMapper.map(amount, FRAmount.class);
}

// FR to OB
public static OBActiveOrHistoricCurrencyAndAmount toOBActiveOrHistoricCurrencyAndAmount(FRAmount amount) {
return FRModelMapper.map(amount, OBActiveOrHistoricCurrencyAndAmount.class);
Expand Down Expand Up @@ -237,4 +242,10 @@ public static OBReadBalance1DataAmount toOBReadBalance1DataAmount(FRAmount amoun
public static OBReadBalance1DataAmount1 toOBReadBalance1DataAmount1(FRAmount amount) {
return FRModelMapper.map(amount, OBReadBalance1DataAmount1.class);
}

public static OBFundsConfirmation1DataInstructedAmount toOBFundsConfirmation1DataInstructedAmount(FRAmount amount){
return FRModelMapper.map(amount, OBFundsConfirmation1DataInstructedAmount.class);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
*/
package com.forgerock.openbanking.common.services.openbanking.converter.fund;

import com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier;
import com.forgerock.openbanking.common.model.openbanking.domain.funds.FRFundsConfirmationConsentData;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsent1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsent1DataDebtorAccount;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toFRAccountIdentifier;

Expand All @@ -33,4 +35,6 @@ public static FRFundsConfirmationConsentData toFRFundsConfirmationConsentData(OB
.debtorAccount(toFRAccountIdentifier(obFundsConfirmationConsent.getData().getDebtorAccount()))
.build();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
package com.forgerock.openbanking.common.services.openbanking.converter.fund;

import com.forgerock.openbanking.common.model.openbanking.domain.funds.FRFundsConfirmationData;
import com.forgerock.openbanking.common.services.openbanking.converter.common.FRAmountConverter;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmation1;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAmountConverter.toFRAmount;

public class FRFundsConfirmationConverter {

public static FRFundsConfirmationData toFRFundsConfirmationData(OBFundsConfirmation1 obFundsConfirmation) {
return obFundsConfirmation == null ? null : FRFundsConfirmationData.builder()
.consentId(obFundsConfirmation.getData().getConsentId())
.reference(obFundsConfirmation.getData().getReference())
.instructedAmount(toFRAmount(obFundsConfirmation.getData().getInstructedAmount()))
.instructedAmount(FRAmountConverter.toFRAmount(obFundsConfirmation.getData().getInstructedAmount()))
.build();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* Copyright 2019 ForgeRock AS.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.forgerock.openbanking.common.services.openbanking.converter.common;

import com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsent1DataDebtorAccount;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toOBFundsConfirmationConsent1DataDebtorAccount;
import static org.assertj.core.api.Assertions.assertThat;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toFRAccountIdentifier;


@RunWith(MockitoJUnitRunner.class)
public class FRAccountIdentifierConverterTest {


private final String schemeName = "schemeName";
private final String identification = "32436tgf";
private final String name = "fred titmus";
private final String secondaryIdentification = "34326dljf";


@Test
public void OBFundsConfirmationConsent1DataDebtorAccount_toFRAccountIdentifier() {
// Given
OBFundsConfirmationConsent1DataDebtorAccount obFundsConfirmationConsent1DataDebtorAccount =
new OBFundsConfirmationConsent1DataDebtorAccount();
obFundsConfirmationConsent1DataDebtorAccount.schemeName(this.schemeName)
.identification(this.identification)
.name(this.name)
.secondaryIdentification(this.secondaryIdentification);

// When
FRAccountIdentifier accountIdentifier = toFRAccountIdentifier(obFundsConfirmationConsent1DataDebtorAccount);

// Then
assertThat(accountIdentifier.getSchemeName()).isEqualTo(this.schemeName);
assertThat(accountIdentifier.getIdentification()).isEqualTo(this.identification);
assertThat(accountIdentifier.getName()).isEqualTo(this.name);
assertThat(accountIdentifier.getSecondaryIdentification()).isEqualTo(this.secondaryIdentification);
}

@Test
public void FRAccountIdentifier_toOBFundsConfirmationConsent1DataDebtorAccount() {
// Given
FRAccountIdentifier accountIdentifier = new FRAccountIdentifier();
accountIdentifier.setName(this.name);
accountIdentifier.setIdentification(this.identification);
accountIdentifier.setSchemeName(this.schemeName);
accountIdentifier.setSecondaryIdentification(this.secondaryIdentification);

// When
OBFundsConfirmationConsent1DataDebtorAccount account =
toOBFundsConfirmationConsent1DataDebtorAccount(accountIdentifier);

// Then
assertThat(account.getName()).isEqualTo(this.name);
assertThat(account.getIdentification()).isEqualTo(this.identification);
assertThat(account.getSchemeName()).isEqualTo(this.schemeName);
assertThat(account.getSecondaryIdentification()).isEqualTo(this.secondaryIdentification);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright 2019 ForgeRock AS.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.forgerock.openbanking.common.services.openbanking.converter.common;

import com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmation1DataInstructedAmount;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAmountConverter.toFRAmount;
import static org.assertj.core.api.Assertions.assertThat;


@RunWith(MockitoJUnitRunner.class)
public class FRAmountConverterTest {

static final String amount = "32.45";
static final String currency = "GBP";

@Test
public void OBFundsConfirmation1DataInstructedAmount_toFRAmount() {
// Given
OBFundsConfirmation1DataInstructedAmount obFundsConfirmation1DataInstructedAmount =
new OBFundsConfirmation1DataInstructedAmount();
obFundsConfirmation1DataInstructedAmount.amount(amount)
.currency(currency);

// When
FRAmount frAmount = toFRAmount(obFundsConfirmation1DataInstructedAmount);

assertThat(frAmount.getAmount()).isEqualTo(amount);
assertThat(frAmount.getCurrency()).isEqualTo(currency);

}

@Test
public void toOBFundsConfirmation1DataInstructedAmount() {
// Given
FRAmount frAmount = new FRAmount();
frAmount.setAmount(amount);
frAmount.setCurrency(currency);

// When
OBFundsConfirmation1DataInstructedAmount obFundsConfirmation1DataInstructedAmount =
FRAmountConverter.toOBFundsConfirmation1DataInstructedAmount(frAmount);

// Then
assertThat(obFundsConfirmation1DataInstructedAmount.getAmount()).isEqualTo(amount);
assertThat(obFundsConfirmation1DataInstructedAmount.getCurrency()).isEqualTo(currency);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,29 @@
import com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry;
import com.forgerock.openbanking.analytics.services.ConsentMetricService;
import com.forgerock.openbanking.aspsp.rs.store.repository.funds.FundsConfirmationConsentRepository;
import com.forgerock.openbanking.common.conf.discovery.DiscoveryConfigurationProperties;
import com.forgerock.openbanking.common.model.version.OBVersion;
import com.forgerock.openbanking.exceptions.OBErrorResponseException;
import com.forgerock.openbanking.repositories.TppRepository;
import com.forgerock.openbanking.aspsp.rs.store.utils.VersionPathExtractor;
import com.forgerock.openbanking.common.conf.discovery.ResourceLinkService;
import com.forgerock.openbanking.common.model.openbanking.IntentType;
import com.forgerock.openbanking.common.model.openbanking.persistence.funds.FRFundsConfirmationConsent;
import com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode;
import com.forgerock.openbanking.model.Tpp;
import io.swagger.annotations.ApiParam;
import com.forgerock.openbanking.repositories.TppRepository;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.org.openbanking.datamodel.account.Meta;
import uk.org.openbanking.datamodel.discovery.OBDiscoveryAPILinksFundsConfirmation3;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsent1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsentDataResponse1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsentResponse1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsentResponse1Data;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.security.Principal;
import java.util.Optional;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toOBCashAccount3;
import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toOBFundsConfirmationConsent1DataDebtorAccount;
import static com.forgerock.openbanking.common.services.openbanking.converter.fund.FRFundsConfirmationConsentConverter.toFRFundsConfirmationConsentData;
import static com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT;

@Controller("FundsConfirmationConsentsApiV3.0")
@Slf4j
Expand Down Expand Up @@ -149,8 +138,8 @@ public ResponseEntity deleteFundsConfirmationConsentsConsentId(

private OBFundsConfirmationConsentResponse1 packageResponse(FRFundsConfirmationConsent consent, HttpServletRequest request) {
return new OBFundsConfirmationConsentResponse1()
.data(new OBFundsConfirmationConsentDataResponse1()
.debtorAccount(toOBCashAccount3(consent.getFundsConfirmationConsent().getDebtorAccount()))
.data(new OBFundsConfirmationConsentResponse1Data()
.debtorAccount(toOBFundsConfirmationConsent1DataDebtorAccount(consent.getFundsConfirmationConsent().getDebtorAccount()))
.creationDateTime(consent.getCreated())
.status(consent.getStatus().toOBExternalRequestStatus1Code())
.statusUpdateDateTime(consent.getStatusUpdate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,29 @@
import com.forgerock.openbanking.aspsp.rs.store.repository.funds.FundsConfirmationConsentRepository;
import com.forgerock.openbanking.aspsp.rs.store.repository.funds.FundsConfirmationRepository;
import com.forgerock.openbanking.aspsp.rs.store.utils.VersionPathExtractor;
import com.forgerock.openbanking.common.conf.discovery.DiscoveryConfigurationProperties;
import com.forgerock.openbanking.common.conf.discovery.ResourceLinkService;
import com.forgerock.openbanking.common.model.openbanking.domain.funds.FRFundsConfirmationData;
import com.forgerock.openbanking.common.model.openbanking.persistence.funds.FRFundsConfirmation;
import com.forgerock.openbanking.common.model.openbanking.persistence.funds.FRFundsConfirmationConsent;
import com.forgerock.openbanking.common.services.openbanking.FundsAvailabilityService;
import com.forgerock.openbanking.exceptions.OBErrorResponseException;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import uk.org.openbanking.datamodel.account.Meta;
import uk.org.openbanking.datamodel.discovery.OBDiscoveryAPILinksFundsConfirmation3;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmation1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationDataResponse1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationResponse1;
import uk.org.openbanking.datamodel.fund.OBFundsConfirmationResponse1Data;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.security.Principal;
import java.util.Optional;

import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAmountConverter.toOBActiveOrHistoricCurrencyAndAmount;
import static com.forgerock.openbanking.common.services.openbanking.converter.common.FRAmountConverter.toOBFundsConfirmation1DataInstructedAmount;
import static com.forgerock.openbanking.common.services.openbanking.converter.fund.FRFundsConfirmationConverter.toFRFundsConfirmationData;
import static com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT;


@Controller("FundsConfirmationsApiV3.0")
@Slf4j
Expand Down Expand Up @@ -141,8 +133,8 @@ public ResponseEntity getFundsConfirmationId(
private OBFundsConfirmationResponse1 packageResponse(FRFundsConfirmation fundsConfirmation, FRFundsConfirmationConsent consent, HttpServletRequest request) {
final FRFundsConfirmationData obFundsConfirmationData = fundsConfirmation.getFundsConfirmation();
return new OBFundsConfirmationResponse1()
.data(new OBFundsConfirmationDataResponse1()
.instructedAmount(toOBActiveOrHistoricCurrencyAndAmount(obFundsConfirmationData.getInstructedAmount()))
.data(new OBFundsConfirmationResponse1Data()
.instructedAmount(toOBFundsConfirmation1DataInstructedAmount(obFundsConfirmationData.getInstructedAmount()))
.creationDateTime(fundsConfirmation.getCreated())
.fundsConfirmationId(fundsConfirmation.getId())
.fundsAvailable(fundsConfirmation.isFundsAvailable())
Expand Down
Loading

0 comments on commit cfe1045

Please sign in to comment.