Resolve effective name from map key in all bulk set services#474
Draft
pathob wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates multiple “bulk set” services to treat the map key as the effective entity name when the model’s name field is null, and adds explicit validation for null models in map-based requests (with BadRequestException messages). It also updates and expands unit tests for these behaviors in most affected services.
Changes:
- Add
null-model validation in bulk set loops for applications, directories, and application links (throwingBadRequestExceptionwith an entity-specific message). - Populate missing model names from the map key in applications, directories, and application links; add similar “effective name” handling for group creation.
- Add new unit tests for the new validations/fallbacks (directories, applications, application links) and adjust group tests for the new
createGroupoverload.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crowd/src/test/java/com/deftdevs/bootstrapi/crowd/service/GroupsServiceTest.java | Updates mocking/verification to match the new createGroup(directoryId, groupName, model) overload. |
| crowd/src/test/java/com/deftdevs/bootstrapi/crowd/service/DirectoriesServiceTest.java | Adds tests for null model rejection and map-key name fallback in directory bulk set. |
| crowd/src/test/java/com/deftdevs/bootstrapi/crowd/service/ApplicationsServiceTest.java | Adds tests for null model rejection and map-key name fallback in application bulk set. |
| crowd/src/main/java/com/deftdevs/bootstrapi/crowd/service/GroupsServiceImpl.java | Introduces an overload to resolve the “effective” group name using the map key during group creation. |
| crowd/src/main/java/com/deftdevs/bootstrapi/crowd/service/ApplicationsServiceImpl.java | Validates null models and fills missing names from map keys during bulk set. |
| commons/src/test/java/com/deftdevs/bootstrapi/commons/service/DefaultApplicationLinkServiceTest.java | Adds tests for null model rejection and map-key name fallback in application link bulk set. |
| commons/src/main/java/com/deftdevs/bootstrapi/commons/service/DefaultApplicationLinksServiceImpl.java | Validates null models and fills missing names from map keys during bulk set. |
| commons/src/main/java/com/deftdevs/bootstrapi/commons/service/AbstractDirectoriesService.java | Validates null models and fills missing names from map keys during bulk set; uses the key consistently for lookups/updates. |
Comments suppressed due to low confidence (1)
crowd/src/main/java/com/deftdevs/bootstrapi/crowd/service/GroupsServiceImpl.java:133
- This PR description says null models in map-based requests should be rejected with BadRequestException across groups/directories/app links/applications, but
setGroup()still treats a null model as "not found" when the group doesn't exist (and as a no-op when it does exist). If the intent is to validate null entries like the other bulk-set services,setGroup()(orsetGroups()) should throw BadRequestException whengroupModelis null rather than returning/throwing NotFound.
final Group group = findGroup(directoryId, groupName);
if (group == null) {
if (groupModel == null) {
throw new GroupNotFoundException(groupName);
}
return createGroup(directoryId, groupName, groupModel);
}
if (groupModel == null) {
return GroupModelUtil.toGroupModel(group);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
48
to
+53
| public GroupModel createGroup( | ||
| final long directoryId, | ||
| final GroupModel groupModel) { | ||
|
|
||
| if (groupModel.getName() == null) { | ||
| return createGroup(directoryId, groupModel.getName(), groupModel); | ||
| } |
| verify(spy).createGroup(anyLong(), anyString(), any()); | ||
| } | ||
|
|
||
| @Test |
When a model's name field is null in a map-based request, fall back to the map key as the effective name. Also validate null models and throw BadRequestException with a descriptive message. Applies to groups, directories, application links, and applications. Covered by new unit tests for both cases in each service.
5287b03 to
3264f4e
Compare
|
Comment on lines
+70
to
+72
| if (groupName != null && !effectiveGroupName.equals(groupName)) { | ||
| throw new BadRequestException("Cannot create group, two different group names provided"); | ||
| } |
Comment on lines
+161
to
+164
| if (groupModel.getName() == null) { | ||
| groupModel.setName(groupName); | ||
| } | ||
|
|
Comment on lines
+75
to
+77
| if (applicationModel.getName() == null) { | ||
| applicationModel.setName(applicationName); | ||
| } |
Comment on lines
+114
to
+116
| if (applicationLinkModel.getName() == null) { | ||
| applicationLinkModel.setName(name); | ||
| } |
Comment on lines
+33
to
+35
| if (directoryModel.getName() == null) { | ||
| directoryModel.setName(directoryName); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


When a model's name field is null in a map-based request, fall back to the map key as the effective name. Also validate null models and throw BadRequestException with a descriptive message. Applies to groups, directories, application links, and applications. Covered by new unit tests for both cases in each service.