Skip to content

Commit 9b4e527

Browse files
Merge pull request #574 from Backbase/ac-fix-2
Add missing ifPresent check to fix NoSuchElementException (No value present)
2 parents 4291272 + 7e9dc3b commit 9b4e527

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [9.3.0](https://github.com/Backbase/stream-services/compare/9.2.0...9.3.0)
5+
### Changed
6+
- fix for NoSuchElementException (No value present) thrown while update data groups
7+
48
## [9.1.0](https://github.com/Backbase/stream-services/compare/9.0.0...9.1.0)
59
### Changed
610
- added partitioning to a batch permission update request

stream-access-control/access-control-core/src/main/java/com/backbase/stream/service/AccessGroupService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ public Mono<BatchProductGroupTask> updateExistingDataGroupsBatch(BatchProductGro
10301030
// it should be external data item ids (both add and remove)
10311031
Set<String> arrangementsToAdd = new HashSet<>();
10321032
Set<String> arrangementsToRemove = new HashSet<>();
1033-
affectedArrangements.forEach((internalId, externalId) -> {
1033+
affectedArrangements.forEach((internalId, externalId) -> pg.ifPresent(p -> {
10341034
boolean shouldBeInGroup =
10351035
StreamUtils.getInternalProductIds(pg.get()).contains(internalId) ||
10361036
pg.get().getCustomDataGroupItems().stream()
@@ -1048,7 +1048,7 @@ public Mono<BatchProductGroupTask> updateExistingDataGroupsBatch(BatchProductGro
10481048
internalId, externalId, dbsDataGroup.getName());
10491049
arrangementsToRemove.add(externalId);
10501050
}
1051-
});
1051+
}));
10521052
if (!CollectionUtils.isEmpty(arrangementsToAdd)) {
10531053
batchUpdateRequest.add(new DataItemBatchUpdate()
10541054
.dataGroupIdentifier(new DataGroupNameIdentifier()

stream-access-control/access-control-core/src/test/java/com/backbase/stream/service/AccessGroupServiceTest.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,55 @@ void updateExistingDataGroupsBatchWithSameInDbsIngestionModeReplace() {
849849
verify(dataGroupIntegrationApi, times(0)).batchUpdateDataItems(any());
850850
}
851851

852+
@Test
853+
void updateExistingDataGroupsBatchWhenNoMatchingInDbsIngestionModeReplace() {
854+
// Given
855+
BatchProductGroupTask batchProductGroupTask = new BatchProductGroupTask();
856+
batchProductGroupTask.setIngestionMode(BatchProductIngestionMode.REPLACE);
857+
batchProductGroupTask.setBatchProductGroup(new BatchProductGroup().productGroups(
858+
List.of(new BaseProductGroup().name("Test product group"))));
859+
860+
DataGroup unmatchedDataGroup1 = buildDataGroupItem(
861+
"Unmatched Data Group 1",
862+
"Unmatched Data Group 1",
863+
"unmatched-1"
864+
);
865+
DataGroup unmatchedDataGroup2 = buildDataGroupItem(
866+
"Unmatched Data Group 2",
867+
"Unmatched Data Group 2",
868+
"unmatched-2"
869+
);
870+
871+
BaseProductGroup productGroup1 = buildBaseProductGroup(
872+
"Different Product Group 1",
873+
"Different Product Group 1",
874+
BaseProductGroup.ProductGroupTypeEnum.REPOSITORIES,
875+
"different-1"
876+
);
877+
BaseProductGroup productGroup2 = buildBaseProductGroup(
878+
"Different Product Group 2",
879+
"Different Product Group 2",
880+
BaseProductGroup.ProductGroupTypeEnum.REPOSITORIES,
881+
"different-2"
882+
);
883+
884+
when(arrangementsApi.postSearchArrangements(any()))
885+
.thenReturn(Mono.just(new ArrangementSearchesListResponse()
886+
.arrangementElements(List.of(
887+
new ArrangementItem().id("unmatched-1").externalArrangementId("ext-unmatched-1"),
888+
new ArrangementItem().id("unmatched-2").externalArrangementId("ext-unmatched-2")
889+
))));
890+
891+
// When
892+
subject.updateExistingDataGroupsBatch(batchProductGroupTask,
893+
List.of(unmatchedDataGroup1, unmatchedDataGroup2),
894+
List.of(productGroup1, productGroup2))
895+
.block();
896+
897+
// Then
898+
verify(dataGroupIntegrationApi, times(0)).batchUpdateDataItems(any());
899+
}
900+
852901
@Test
853902
void updateExistingDataGroupsBatchWithMissingInDbsIngestionModeReplace() {
854903
// Given

0 commit comments

Comments
 (0)