Skip to content

Commit 85f837c

Browse files
LOB-updated-test-data (#247)
* Update FRFinancialAccountConverter.java * Refactoring Converters * Update FRFinancialAccountConverter.java * Update FRFinancialAccountConverter.java * Update FRFinancialAccountConverter.java
1 parent b8231e7 commit 85f837c

File tree

9 files changed

+67
-34
lines changed

9 files changed

+67
-34
lines changed

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRAccountSubTypeConverter.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public static OBExternalAccountSubType1Code toOBExternalAccountSubType1Code(FRAc
5555
case LOAN -> OBExternalAccountSubType1Code.LOAN;
5656
case MORTGAGE -> OBExternalAccountSubType1Code.MORT;
5757
case SAVINGS -> OBExternalAccountSubType1Code.SVGS;
58-
//case CURRENTACCOUNT -> OBExternalAccountSubType1Code.CACC;
59-
default -> OBExternalAccountSubType1Code.CACC;
58+
case CURRENTACCOUNT -> OBExternalAccountSubType1Code.CACC;
59+
default -> OBExternalAccountSubType1Code.CASH;
6060
};
6161
}
6262

@@ -67,5 +67,12 @@ public static OBExternalAccountSubType1Code toOBExternalAccountSubType1CodeV4(St
6767
throw new IllegalArgumentException("Unknown consent status: " + accountSubType);
6868
}
6969

70+
public static FRAccountSubTypeCode toFRAccountSubTypeCodeV3(String accountSubType) {
71+
if (v4tov3AccountSubType.containsKey(accountSubType)) {
72+
return FRAccountSubTypeCode.fromValue(v4tov3AccountSubType.get(accountSubType));
73+
}
74+
throw new IllegalArgumentException("Unknown consent status: " + accountSubType);
75+
}
76+
7077
//TODO - add for other acccount types
7178
}

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRBalanceTypeConverter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@ public static OBBalanceType1Code toOBBalanceType1CodeV4(String balanceType) {
7474
throw new IllegalArgumentException("Unknown balanceType: " + balanceType);
7575
}
7676

77+
public static FRBalanceType toFRBalanceTypeV3(String balanceType) {
78+
if (v4tov3BalanceType.containsKey(balanceType)) {
79+
return FRBalanceType.fromValue(v4tov3BalanceType.get(balanceType));
80+
}
81+
throw new IllegalArgumentException("Unknown balanceType: " + balanceType);
82+
}
83+
7784
//TODO - add for other balance Types
7885
}

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRCashBalanceConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.util.List;
2727

28+
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRBalanceTypeConverter.toFRBalanceTypeV3;
2829
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRBalanceTypeConverter.toOBBalanceType1CodeV4;
2930
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRCreditDebitIndicatorConverter.toFRCreditDebitIndicator;
3031
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.common.FRAmountConverter.*;
@@ -85,7 +86,7 @@ public static OBReadBalance1DataTotalValue toOBReadBalance1DataTotalValue(FRTota
8586

8687
// OB to FR
8788
public static FRBalanceType toFRBalanceType(OBBalanceType1Code type) {
88-
return type == null ? null : FRBalanceType.valueOf(type.name());
89+
return type == null ? null : FRBalanceType.fromValue(String.valueOf(toFRBalanceTypeV3(type.name())));
8990
}
9091

9192
public static FRCashBalanceData toFRCashBalanceData(OBReadBalance1Data balanceData) {

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRDirectDebitConverter.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import uk.org.openbanking.datamodel.v4.common.ExternalCategoryPurpose1Code;
2626

2727
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRExternalMandateStatusConverter.toExternalMandateStatus1CodeV4;
28+
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRExternalMandateStatusConverter.toFRStandingOrderStatusV3;
2829

2930

3031
/**
@@ -65,16 +66,16 @@ public static OBFrequency6 toOBFrequency6(FRStandingOrderFrequency frStandingOrd
6566
}
6667

6768
public static ExternalMandateStatus1Code toOBExternalDirectDebitStatus1Code(FRDirectDebitData.FRDirectDebitStatus status) {
68-
return status == null ? null : ExternalMandateStatus1Code.valueOf(status.name());
69+
return status == null ? null : ExternalMandateStatus1Code.fromValue(status.name());
6970
}
7071
public static ExternalCategoryPurpose1Code toOBExternalCategoryPurpose1Code(FRExternalCategoryPurposeCode externalCategoryPurposeCode) {
71-
return externalCategoryPurposeCode == null ? null : ExternalCategoryPurpose1Code.valueOf(externalCategoryPurposeCode.name());
72+
return externalCategoryPurposeCode == null ? null : ExternalCategoryPurpose1Code.fromValue(externalCategoryPurposeCode.name());
7273
}
7374
public static OBExternalMandateClassification1Code toOBExternalMandateClassification1Code(FRMandateRelatedInformation.FRExternalMandateClassificationCode externalMandateClassificationCode) {
74-
return externalMandateClassificationCode == null ? null : OBExternalMandateClassification1Code.valueOf(externalMandateClassificationCode.name());
75+
return externalMandateClassificationCode == null ? null : OBExternalMandateClassification1Code.fromValue(externalMandateClassificationCode.name());
7576
}
7677
public static OBFrequency6Code toOBFrequency6Code(FRStandingOrderFrequencyCode frStandingOrderFrequencyCode) {
77-
return frStandingOrderFrequencyCode == null ? null : OBFrequency6Code.valueOf(frStandingOrderFrequencyCode.name());
78+
return frStandingOrderFrequencyCode == null ? null : OBFrequency6Code.fromValue(frStandingOrderFrequencyCode.name());
7879
}
7980

8081
// OB to FR
@@ -112,19 +113,19 @@ public static FRStandingOrderFrequency toFRStandingOrderFrequency(OBFrequency6 o
112113
}
113114

114115
public static FRDirectDebitData.FRDirectDebitStatus toFRDirectDebitStatus(ExternalMandateStatus1Code status) {
115-
return status == null ? null : FRDirectDebitData.FRDirectDebitStatus.valueOf(status.name());
116+
return status == null ? null : FRDirectDebitData.FRDirectDebitStatus.fromValue(String.valueOf(toFRStandingOrderStatusV3(status.name())));
116117
}
117118

118119
public static FRExternalCategoryPurposeCode toFRExternalCategoryPurposeCode(ExternalCategoryPurpose1Code externalCategoryPurpose1Code) {
119-
return externalCategoryPurpose1Code == null ? null : FRExternalCategoryPurposeCode.valueOf(externalCategoryPurpose1Code.name());
120+
return externalCategoryPurpose1Code == null ? null : FRExternalCategoryPurposeCode.fromValue(externalCategoryPurpose1Code.name());
120121
}
121122

122123
public static FRMandateRelatedInformation.FRExternalMandateClassificationCode toFRExternalMandateClassificationCode(OBExternalMandateClassification1Code externalMandateClassification1Code) {
123-
return externalMandateClassification1Code == null ? null : FRMandateRelatedInformation.FRExternalMandateClassificationCode.valueOf(externalMandateClassification1Code.name());
124+
return externalMandateClassification1Code == null ? null : FRMandateRelatedInformation.FRExternalMandateClassificationCode.fromValue(externalMandateClassification1Code.name());
124125
}
125126

126127
public static FRStandingOrderFrequencyCode toFRStandingOrderFrequencyCode(OBFrequency6Code obFrequency6Code) {
127-
return obFrequency6Code == null ? null : FRStandingOrderFrequencyCode.valueOf(obFrequency6Code.name());
128+
return obFrequency6Code == null ? null : FRStandingOrderFrequencyCode.fromValue(obFrequency6Code.name());
128129
}
129130

130131
}

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FREntryStatusConverter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,12 @@ public static ExternalEntryStatus1Code toExternalEntryStatus1CodeV4(String entry
5858
throw new IllegalArgumentException("Unknown entry Status: " + entryStatus);
5959
}
6060

61+
public static FREntryStatus toFREntryStatusV3(String entryStatus) {
62+
if (v4tov3EntryStatus.containsKey(entryStatus)) {
63+
return FREntryStatus.fromValue(v4tov3EntryStatus.get(entryStatus));
64+
}
65+
throw new IllegalArgumentException("Unknown entry Status: " + entryStatus);
66+
}
67+
6168
//TODO - add for other entry Status
6269
}

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRExternalMandateStatusConverter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public static ExternalMandateStatus1Code toExternalMandateStatus1CodeV4(String e
5959
throw new IllegalArgumentException("Unknown external Mandate Status: " + externalMandateStatus);
6060
}
6161

62+
public static FRStandingOrderData.FRStandingOrderStatus toFRStandingOrderStatusV3(String externalMandateStatus) {
63+
if (v4tov3ExternalMandateStatus.containsKey(externalMandateStatus)) {
64+
return FRStandingOrderData.FRStandingOrderStatus.fromValue(v4tov3ExternalMandateStatus.get(externalMandateStatus));
65+
}
66+
throw new IllegalArgumentException("Unknown external Mandate Status: " + externalMandateStatus);
67+
}
68+
6269
//TODO - add for other external Mandate Status
6370

6471
// FR to OB

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRFinancialAccountConverter.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v3.common.FRPostalAddressConverter.toFRPostalAddress;
2828
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v3.common.FRPostalAddressConverter.toOBPostalAddress7;
29+
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRAccountSubTypeConverter.toFRAccountSubTypeCodeV3;
2930
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRAccountSubTypeConverter.toOBExternalAccountSubType1CodeV4;
3031

3132
public class FRFinancialAccountConverter {
@@ -115,15 +116,15 @@ public static FRFinancialAccount toFRFinancialAccount(OBAccount6 account) {
115116
}
116117

117118
public static FRFinancialAccount.FRAccountStatusCode toFRAccountStatusCode(OBInternalAccountStatus1Code status) {
118-
return status == null ? null : FRFinancialAccount.FRAccountStatusCode.valueOf(status.name());
119+
return status == null ? null : FRFinancialAccount.FRAccountStatusCode.fromValue(status.name());
119120
}
120121

121122
public static FRFinancialAccount.FRAccountTypeCode toFRAccountTypeCode(OBInternalAccountType1Code accountType) {
122-
return accountType == null ? null : FRFinancialAccount.FRAccountTypeCode.valueOf(accountType.name());
123+
return accountType == null ? null : FRFinancialAccount.FRAccountTypeCode.fromValue(accountType.name());
123124
}
124125

125126
public static FRFinancialAccount.FRAccountSubTypeCode toFRAccountSubTypeCode(OBExternalAccountSubType1Code accountSubType) {
126-
return accountSubType == null ? null : FRFinancialAccount.FRAccountSubTypeCode.valueOf(accountSubType.name());
127+
return accountSubType == null ? null : FRFinancialAccount.FRAccountSubTypeCode.fromValue(String.valueOf(toFRAccountSubTypeCodeV3(accountSubType.name())));
127128
}
128129

129130
public static <T> List<FRAccountIdentifier> toFRAccountIdentifierList(List<T> accounts, Function<T, FRAccountIdentifier> converter) {
@@ -142,15 +143,15 @@ public static FRFinancialAccount.FRStatementFrequencyAndFormat toFRStatementFreq
142143
}
143144

144145
public static FRFinancialAccount.FRFormat toFRFormat(OBFileFormat fileFormat) {
145-
return fileFormat == null ? null : FRFinancialAccount.FRFormat.valueOf(fileFormat.name());
146+
return fileFormat == null ? null : FRFinancialAccount.FRFormat.fromValue(fileFormat.name());
146147
}
147148

148149
public static FRFinancialAccount.FRCommunicationMethod toFRCommunicationMethod(OBCommunicationMethod communicationMethod) {
149-
return communicationMethod == null ? null : FRFinancialAccount.FRCommunicationMethod.valueOf(communicationMethod.name());
150+
return communicationMethod == null ? null : FRFinancialAccount.FRCommunicationMethod.fromValue(communicationMethod.name());
150151
}
151152

152153
public static FRFinancialAccount.FRStatementFrequency toFRStatementFrequency(OBFrequency2 obFrequency2) {
153-
return obFrequency2 == null ? null : FRFinancialAccount.FRStatementFrequency.valueOf(obFrequency2.name());
154+
return obFrequency2 == null ? null : FRFinancialAccount.FRStatementFrequency.fromValue(obFrequency2.name());
154155
}
155156

156157
public static <T> List<FRFinancialAccount.FRStatementFrequencyAndFormat> toFRStatementFrequencyAndFormatList(List<T> accounts, Function<T, FRFinancialAccount.FRStatementFrequencyAndFormat> converter) {

secure-api-gateway-ob-uk-common-datamodel/src/main/java/com/forgerock/sapi/gateway/ob/uk/common/datamodel/converter/v4/account/FRTransactionConverter.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRBalanceTypeConverter.toOBBalanceType1CodeV4;
3535
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FRCashBalanceConverter.toFRBalanceType;
3636
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FREntryStatusConverter.toExternalEntryStatus1CodeV4;
37+
import static com.forgerock.sapi.gateway.ob.uk.common.datamodel.converter.v4.account.FREntryStatusConverter.toFREntryStatusV3;
3738

3839
public class FRTransactionConverter {
3940

@@ -71,19 +72,19 @@ public static OBTransaction6 toOBTransaction6(FRTransactionData transaction) {
7172
}
7273

7374
public static ExternalEntryStatus1Code toOBEntryStatus1Code(FRTransactionData.FREntryStatus status) {
74-
return status == null ? null : ExternalEntryStatus1Code.valueOf(status.name());
75+
return status == null ? null : ExternalEntryStatus1Code.fromValue(status.name());
7576
}
7677

7778
public static ExternalCategoryPurpose1Code toOBExternalCategoryPurpose1Code(FRExternalCategoryPurposeCode categoryPurposeCode) {
78-
return categoryPurposeCode == null ? null : ExternalCategoryPurpose1Code.valueOf(categoryPurposeCode.name());
79+
return categoryPurposeCode == null ? null : ExternalCategoryPurpose1Code.fromValue(categoryPurposeCode.name());
7980
}
8081

8182
public static OBExternalPurpose1Code toExternalPurpose1Code(FRExternalPaymentPurposeCode externalPaymentPurposeCode) {
82-
return externalPaymentPurposeCode == null ? null : OBExternalPurpose1Code.valueOf(externalPaymentPurposeCode.name());
83+
return externalPaymentPurposeCode == null ? null : OBExternalPurpose1Code.fromValue(externalPaymentPurposeCode.name());
8384
}
8485

8586
public static OBInternalTransactionMutability1Code toOBTransactionMutability1Code(FRTransactionData.FRTransactionMutability transactionMutability) {
86-
return transactionMutability == null ? null : OBInternalTransactionMutability1Code.valueOf(transactionMutability.name());
87+
return transactionMutability == null ? null : OBInternalTransactionMutability1Code.fromValue(transactionMutability.name());
8788
}
8889

8990
public static OBBankTransactionCodeStructure1 toOBBankTransactionCodeStructure1(FRTransactionData.FRBankTransactionCodeStructure transactionCode) {
@@ -133,11 +134,11 @@ public static OBMerchantDetails1 toOBMerchantDetails1(FRTransactionData.FRMercha
133134
}
134135

135136
public static OBTransactionCardInstrument1CardSchemeName toOBTransactionCardInstrument1CardSchemeName(FRTransactionData.FRCardScheme cardSchemeName) {
136-
return cardSchemeName == null ? null : OBTransactionCardInstrument1CardSchemeName.valueOf(cardSchemeName.name());
137+
return cardSchemeName == null ? null : OBTransactionCardInstrument1CardSchemeName.fromValue(cardSchemeName.name());
137138
}
138139

139140
public static OBTransactionCardInstrument1AuthorisationType toOBTransactionCardInstrument1AuthorisationType(FRTransactionData.FRCardAuthorisationType authorisationType) {
140-
return authorisationType == null ? null : OBTransactionCardInstrument1AuthorisationType.valueOf(authorisationType.name());
141+
return authorisationType == null ? null : OBTransactionCardInstrument1AuthorisationType.fromValue(authorisationType.name());
141142
}
142143

143144
// OB to FR
@@ -176,19 +177,19 @@ public static FRTransactionData toFRTransactionData(OBTransaction6 transaction)
176177
}
177178

178179
public static FRTransactionData.FREntryStatus toFREntryStatus(ExternalEntryStatus1Code status) {
179-
return status == null ? null : FRTransactionData.FREntryStatus.valueOf(status.name());
180+
return status == null ? null : FRTransactionData.FREntryStatus.fromValue(String.valueOf(toFREntryStatusV3(status.name())));
180181
}
181182

182183
public static FRTransactionData.FRTransactionMutability toFRTransactionMutability(OBInternalTransactionMutability1Code transactionMutability) {
183-
return transactionMutability == null ? null : FRTransactionData.FRTransactionMutability.valueOf(transactionMutability.name());
184+
return transactionMutability == null ? null : FRTransactionData.FRTransactionMutability.fromValue(transactionMutability.name());
184185
}
185186

186187
public static FRExternalCategoryPurposeCode toFRExternalCategoryPurposeCode(ExternalCategoryPurpose1Code externalCategoryPurpose1Code) {
187-
return externalCategoryPurpose1Code == null ? null : FRExternalCategoryPurposeCode.valueOf(externalCategoryPurpose1Code.name());
188+
return externalCategoryPurpose1Code == null ? null : FRExternalCategoryPurposeCode.fromValue(externalCategoryPurpose1Code.name());
188189
}
189190

190191
public static FRExternalPaymentPurposeCode toFRExternalCategoryPurposeCode(OBExternalPurpose1Code obExternalPurpose1Code) {
191-
return obExternalPurpose1Code == null ? null : FRExternalPaymentPurposeCode.valueOf(obExternalPurpose1Code.name());
192+
return obExternalPurpose1Code == null ? null : FRExternalPaymentPurposeCode.fromValue(obExternalPurpose1Code.name());
192193
}
193194

194195
public static FRTransactionData.FRBankTransactionCodeStructure toFRBankTransactionCodeStructure(OBBankTransactionCodeStructure1 transactionCode) {
@@ -244,10 +245,10 @@ public static FRTransactionData.FRTransactionCardInstrument toFRTransactionCardI
244245
}
245246

246247
public static FRTransactionData.FRCardScheme toFRCardScheme(OBTransactionCardInstrument1CardSchemeName cardSchemeName) {
247-
return cardSchemeName == null ? null : FRTransactionData.FRCardScheme.valueOf(cardSchemeName.name());
248+
return cardSchemeName == null ? null : FRTransactionData.FRCardScheme.fromValue(cardSchemeName.name());
248249
}
249250

250251
public static FRTransactionData.FRCardAuthorisationType toFRCardAuthorisationType(OBTransactionCardInstrument1AuthorisationType authorisationType) {
251-
return authorisationType == null ? null : FRTransactionData.FRCardAuthorisationType.valueOf(authorisationType.name());
252+
return authorisationType == null ? null : FRTransactionData.FRCardAuthorisationType.fromValue(authorisationType.name());
252253
}
253254
}

0 commit comments

Comments
 (0)