Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
All notable changes to this project will be documented in this file.

## [9.14.0]
<<<<<<< investment-service/WLNP-12501-Define-investment-portfolio-property
### Added
- Add investmentPortfolios ingestion support to BaseProductGroup (similar to investmentAccounts)
=======
### Changed
- Remove custom workaround to connect with Investment service
>>>>>>> master

## [9.13.0]
### Changed
Expand Down
6 changes: 5 additions & 1 deletion api/stream-legal-entity/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.1
info:
title: Ingest Legal Entity API
description: Ingestion Saga for Legal Entities and their products
version: 3.1.0
version: 3.2.0
x-logo:
url: "http://www.backbase.com/wp-content/uploads/2017/04/backbase-logo-png.png"
backgroundColor: "#FFFFFF"
Expand Down Expand Up @@ -304,6 +304,10 @@ components:
type: array
items:
$ref: '#/components/schemas/InvestmentAccount'
investmentPortfolios:
type: array
items:
$ref: '#/components/schemas/Product'
customProducts:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: Transaction composition API
version: 2.0.0
version: 2.1.0
servers:
- url: http://localhost:8080/service-api/v2
description: The server
Expand Down Expand Up @@ -180,6 +180,10 @@ components:
type: array
items:
$ref: '#/components/schemas/InvestmentAccount'
investmentPortfolios:
type: array
items:
$ref: '#/components/schemas/Product'

BaseProduct:
title: Base Product
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
log.debug("Credit Cards received from Integration: {}", productGroup.getCreditCards());
log.debug("Debit Cards received from Integration: {}", productGroup.getDebitCards());
log.debug("Investment accounts received from Integration: {}", productGroup.getInvestmentAccounts());
log.debug("Investment portfolios received from Integration: {}", productGroup.getInvestmentPortfolios());
log.debug("Term Deposit Accounts received from Integration: {}", productGroup.getTermDeposits());
log.debug("Custom Accounts received from Integration: {}", productGroup.getCustomProducts());
log.debug("Custom Data group items received from Integration: {}", productGroup.getCustomDataGroupItems());
Expand All @@ -86,7 +87,7 @@
}
if (sourceAdditions != null) {
for (String key : sourceAdditions.keySet()) {
if (!additions.containsKey(key)) {

Check warning on line 90 in stream-compositions/services/product-composition-service/src/main/java/com/backbase/stream/compositions/product/core/service/impl/ProductIntegrationServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()".

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE35kQx3VfvTAWrT&open=AZ12YE35kQx3VfvTAWrT&pullRequest=595
additions.put(key, sourceAdditions.get(key));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
log.info("Emitting product completed event for userExternalId: {}, legalEntityExternalId: {}",
res.getUserExternalId(), res.getLegalEntityExternalId());
ProductCompletedEvent event = new ProductCompletedEvent()
.withProductGroups(res.getProductGroups().stream().map(p -> mapper.mapStreamToEvent(p)).toList())

Check warning on line 146 in stream-compositions/services/product-composition-service/src/main/java/com/backbase/stream/compositions/product/core/service/impl/ProductPostIngestionServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this lambda with method reference 'mapper::mapStreamToEvent'.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE7LkQx3VfvTAWrU&open=AZ12YE7LkQx3VfvTAWrU&pullRequest=595
.withUserExternalId(res.getUserExternalId())
.withUserInternalId(res.getUserInternalId())
.withLegalEntityInternalId(res.getLegalEntityInternalId())
Expand Down Expand Up @@ -197,6 +197,10 @@
.flatMap(group -> productStream(group.getInvestmentAccounts()))
.toList())
.orElseGet(Collections::emptyList)),
Flux.fromIterable(Optional.of(productGroups.stream()
.flatMap(group -> productStream(group.getInvestmentPortfolios()))
.toList())
.orElseGet(Collections::emptyList)),
Flux.fromIterable(Optional.of(productGroups.stream()
.flatMap(group -> productStream(group.getCustomProducts()))
.toList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
* Fine-grained configuration properties for {@code InvestmentPortfolioService}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ private Mono<UpdatedServiceAgreementTask> retrieveInternalProducts(UpdatedServic
pg.getCustomProducts(),
pg.getDebitCards(),
pg.getInvestmentAccounts(),
pg.getInvestmentPortfolios(),
pg.getSavingAccounts(),
pg.getTermDeposits()))
.filter(Objects::nonNull)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.backbase.stream.legalentity.model.JobProfileUser;
import com.backbase.stream.legalentity.model.LegalEntityParticipant;
import com.backbase.stream.legalentity.model.Loan;
import com.backbase.stream.legalentity.model.Product;
import com.backbase.stream.legalentity.model.ProductGroup;
import com.backbase.stream.legalentity.model.ServiceAgreement;
import com.backbase.stream.legalentity.model.ServiceAgreementUserAction;
Expand Down Expand Up @@ -135,4 +136,89 @@
permissionsRequest.put(user2, permissionUser2);
verify(accessGroupService).assignPermissionsBatch(any(), eq(permissionsRequest));
}

@Test
void updateServiceAgreementWithInvestmentPortfolios() {
final String saExternalId = "somePortfolioSaExternalId";
final String saInternalId = "somePortfolioSaInternalId";
final String portfolioExId = "somePortfolioExId";
final String portfolioInId = "somePortfolioInId";
User user1 = new User().externalId("someUserExId1");
User user2 = new User().externalId("someUserExId2");
Product investmentPortfolio = new Product();
investmentPortfolio.setExternalId(portfolioExId);
LegalEntityParticipant participant =
new LegalEntityParticipant().externalId("someLeExId").sharingAccounts(true).sharingUsers(true);
BaseProductGroup baseProductGroup = new BaseProductGroup().addInvestmentPortfoliosItem(investmentPortfolio);
JobProfileUser jobProfileUser1 = new JobProfileUser().user(user1).addReferenceJobRoleNamesItem("someJobRole1");
JobProfileUser jobProfileUser2 = new JobProfileUser().user(user2).addReferenceJobRoleNamesItem("someJobRole2");
UpdatedServiceAgreement serviceAgreement = new UpdatedServiceAgreement().addProductGroupsItem(baseProductGroup)
.addSaAdminsItem(new ServiceAgreementUserAction().userProfile(jobProfileUser1))
.addSaUsersItem(new ServiceAgreementUserAction().userProfile(jobProfileUser2));
serviceAgreement.externalId(saExternalId).internalId(saInternalId).name("someSa")
.addParticipantsItem(participant);
ServiceAgreement internalSA = new ServiceAgreement().externalId(saExternalId).internalId(saInternalId);
UpdatedServiceAgreementTask task = new UpdatedServiceAgreementTask(serviceAgreement);
List<FunctionGroupItem> serviceAgreementFunctionGroups = asList(
new FunctionGroupItem().name("someJobRole1").type(TypeEnum.CUSTOM),
new FunctionGroupItem().name("someJobRole2").type(TypeEnum.CUSTOM),
new FunctionGroupItem().name("someJobRole3").type(TypeEnum.CUSTOM));
ProductGroup productGroup = new ProductGroup().serviceAgreement(serviceAgreement);
productGroup.investmentPortfolios(baseProductGroup.getInvestmentPortfolios());

when(accessGroupService.updateServiceAgreementAssociations(eq(task), eq(serviceAgreement), any()))
.thenReturn(Mono.just(serviceAgreement));

Mono<ProductGroupTask> productGroupTaskMono = Mono.just(new ProductGroupTask(productGroup));
when(accessGroupService.setupProductGroups(any())).thenReturn(productGroupTaskMono);

when(accessGroupService.getUserByExternalId(eq("someUserExId1"), eq(true)))

Check warning on line 175 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this and every subsequent useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrM&open=AZ12YE0ekQx3VfvTAWrM&pullRequest=595
.thenReturn(Mono.just(new GetUser().id("someUserInId1").externalId("someUserExId1")));
when(accessGroupService.getUserByExternalId(eq("someUserExId2"), eq(true)))

Check warning on line 177 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this and every subsequent useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrN&open=AZ12YE0ekQx3VfvTAWrN&pullRequest=595
.thenReturn(Mono.just(new GetUser().id("someUserInId2").externalId("someUserExId2")));

when(accessGroupService.getFunctionGroupsForServiceAgreement(eq(saInternalId)))

Check warning on line 180 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrO&open=AZ12YE0ekQx3VfvTAWrO&pullRequest=595
.thenReturn(Mono.just(serviceAgreementFunctionGroups));

BatchProductGroupTask bpgTask =
new BatchProductGroupTask().data(new BatchProductGroup().serviceAgreement(serviceAgreement));
when(accessGroupService.assignPermissionsBatch(any(), any())).thenReturn(Mono.just(bpgTask));

when(accessGroupService.getServiceAgreementByExternalId(eq(saExternalId))).thenReturn(Mono.just(internalSA));

Check warning on line 187 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrP&open=AZ12YE0ekQx3VfvTAWrP&pullRequest=595

when(arrangementService.getArrangementByExternalId(ArgumentMatchers.<List<String>>any()))
.thenReturn(Flux.fromIterable(
Collections.singletonList(
new ArrangementItem().id(portfolioInId).externalArrangementId(portfolioExId))));

UpdatedServiceAgreementTask actual = updatedServiceAgreementSaga.executeTask(task).block();

assertEquals(StreamTask.State.COMPLETED, actual.getState());

// Verify the investment portfolio's internal ID was resolved from the arrangement service
assertEquals(portfolioInId, investmentPortfolio.getInternalId());

verify(accessGroupService).updateServiceAgreementAssociations(any(), eq(serviceAgreement), any());

verify(accessGroupService).setupProductGroups(productGroupTaskCaptor.capture());
ProductGroupTask productGroupTask = productGroupTaskCaptor.getValue();
assertEquals(productGroup, productGroupTask.getData());

verify(arrangementService).getArrangementByExternalId(
ArgumentMatchers.<List<String>>argThat(ids -> ids.contains(portfolioExId)));

verify(accessGroupService).getUserByExternalId(eq("someUserExId1"), eq(true));

Check warning on line 210 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this and every subsequent useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrQ&open=AZ12YE0ekQx3VfvTAWrQ&pullRequest=595
verify(accessGroupService).getUserByExternalId(eq("someUserExId2"), eq(true));

Check warning on line 211 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this and every subsequent useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrR&open=AZ12YE0ekQx3VfvTAWrR&pullRequest=595

verify(accessGroupService).getFunctionGroupsForServiceAgreement(eq(saInternalId));

Check warning on line 213 in stream-legal-entity/legal-entity-core/src/test/java/com/backbase/stream/UpdatedServiceAgreementSagaTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=com.backbase.stream%3Astream-services&issues=AZ12YE0ekQx3VfvTAWrS&open=AZ12YE0ekQx3VfvTAWrS&pullRequest=595

Map<BusinessFunctionGroup, List<BaseProductGroup>> permissionUser1 = new HashMap<>();
permissionUser1.put(new BusinessFunctionGroup().name("someJobRole1"), asList(baseProductGroup));
Map<BusinessFunctionGroup, List<BaseProductGroup>> permissionUser2 = new HashMap<>();
permissionUser2.put(new BusinessFunctionGroup().name("someJobRole2"), asList(baseProductGroup));
Map<User, Map<BusinessFunctionGroup, List<BaseProductGroup>>> permissionsRequest = new HashMap<>();
permissionsRequest.put(user1, permissionUser1);
permissionsRequest.put(user2, permissionUser2);
verify(accessGroupService).assignPermissionsBatch(any(), eq(permissionsRequest));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static Stream<BaseProduct> getAllProducts(BaseProductGroup productGroup)
productGroup.getLoans(),
productGroup.getTermDeposits(),
productGroup.getInvestmentAccounts(),
productGroup.getInvestmentPortfolios(),
productGroup.getCustomProducts())
.filter(Objects::nonNull)
.flatMap(List::stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ protected Mono<BatchProductGroupTask> upsertArrangementsBatch(BatchProductGroupT
StreamUtils.nullableCollectionToStream(pg.getLoans()).map(productMapper::toPresentation),
StreamUtils.nullableCollectionToStream(pg.getTermDeposits()).map(productMapper::toPresentation),
StreamUtils.nullableCollectionToStream(pg.getInvestmentAccounts()).map(productMapper::toPresentation),
StreamUtils.nullableCollectionToStream(pg.getInvestmentPortfolios()).map(productMapper::toPresentation),
StreamUtils.nullableCollectionToStream(pg.getCustomProducts()).map(productMapper::toPresentation)
)
.flatMap(i -> i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public Mono<ProductGroupTask> upsertArrangements(ProductGroupTask streamTask) {
Flux<Loan> loanFlux = getLoanFlux(productGroup);
Flux<TermDeposit> termDepositFlux = getTermDepositFlux(productGroup);
Flux<InvestmentAccount> investmentAccountFlux = getInvestmentAccountFlux(productGroup);
Flux<Product> investmentPortfolioFlux = getInvestmentPortfolioFlux(productGroup);
Flux<Product> productFlux = getProductFlux(productGroup);


Expand All @@ -234,6 +235,7 @@ public Mono<ProductGroupTask> upsertArrangements(ProductGroupTask streamTask) {
Mono<List<ArrangementItem>> loansRequests = upsertArrangements(streamTask, loanFlux.map(productMapper::toPresentation));
Mono<List<ArrangementItem>> termDepositsRequests = upsertArrangements(streamTask, termDepositFlux.map(productMapper::toPresentation));
Mono<List<ArrangementItem>> investmentAccountsRequests = upsertArrangements(streamTask, investmentAccountFlux.map(productMapper::toPresentation));
Mono<List<ArrangementItem>> investmentPortfoliosRequests = upsertArrangements(streamTask, investmentPortfolioFlux.map(productMapper::toPresentation));
Mono<List<ArrangementItem>> customProductsRequests = upsertArrangements(streamTask, productFlux.map(productMapper::toPresentation));

return Mono.just(productGroup)
Expand All @@ -247,6 +249,7 @@ public Mono<ProductGroupTask> upsertArrangements(ProductGroupTask streamTask) {
.zipWith(loansRequests, (actual, arrangements) -> actual.loans(arrangements.stream().map(productMapper::mapLoan).toList()))
.zipWith(termDepositsRequests, (actual, arrangements) -> actual.termDeposits(arrangements.stream().map(productMapper::mapTermDeposit).toList()))
.zipWith(investmentAccountsRequests, (actual, arrangements) -> actual.investmentAccounts(arrangements.stream().map(productMapper::mapInvestmentAccount).toList()))
.zipWith(investmentPortfoliosRequests, (actual, arrangements) -> actual.investmentPortfolios(arrangements.stream().map(productMapper::mapCustomProduct).toList()))
.zipWith(customProductsRequests, (actual, arrangements) -> actual.customProducts(arrangements.stream().map(productMapper::mapCustomProduct).toList()))
.cast(ProductGroup.class)
.map(streamTask::data);
Expand Down Expand Up @@ -328,6 +331,12 @@ private Flux<InvestmentAccount> getInvestmentAccountFlux(ProductGroup productGro
: Flux.fromIterable(productGroup.getInvestmentAccounts());
}

private Flux<Product> getInvestmentPortfolioFlux(ProductGroup productGroup) {
return productGroup.getInvestmentPortfolios() == null
? Flux.empty()
: Flux.fromIterable(productGroup.getInvestmentPortfolios());
}

private Flux<TermDeposit> getTermDepositFlux(ProductGroup productGroup) {
return productGroup.getTermDeposits() == null
? Flux.empty()
Expand Down
Loading