Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import fr.insee.sugoi.core.model.ProviderResponse;
import fr.insee.sugoi.core.model.ProviderResponse.ProviderResponseStatus;
import fr.insee.sugoi.core.model.SugoiUser;
import fr.insee.sugoi.core.service.ApplicationService;
import fr.insee.sugoi.core.service.GroupService;
import fr.insee.sugoi.model.Group;
import fr.insee.sugoi.model.exceptions.ApplicationNotFoundException;
import fr.insee.sugoi.model.exceptions.IdNotMatchingException;
import fr.insee.sugoi.model.paging.PageResult;
import fr.insee.sugoi.model.paging.PageableResult;
Expand Down Expand Up @@ -67,6 +69,8 @@ public class GroupController {

@Autowired private GroupService groupService;

@Autowired private ApplicationService applicationService;

@GetMapping(
path = {"/realms/{realm}/applications/{application}/groups"},
produces = {MediaType.APPLICATION_JSON_VALUE})
Expand Down Expand Up @@ -111,8 +115,14 @@ public ResponseEntity<PageResult<Group>> getGroups(
filterGroup.setName(name);
filterGroup.setDescription(description);
PageableResult pageableResult = new PageableResult(size, offset, searchCookie);
PageResult<Group> foundGroups = null;
try {
applicationService.findById(realm, applicationName);

PageResult<Group> foundGroups =
} catch (ApplicationNotFoundException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
foundGroups =
groupService.findByProperties(realm, applicationName, filterGroup, pageableResult);

if (foundGroups.isHasMoreResult()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import fr.insee.sugoi.commons.services.controller.technics.SugoiAdviceController;
import fr.insee.sugoi.core.model.ProviderResponse;
import fr.insee.sugoi.core.model.ProviderResponse.ProviderResponseStatus;
import fr.insee.sugoi.core.service.ApplicationService;
import fr.insee.sugoi.core.service.GroupService;
import fr.insee.sugoi.model.Group;
import fr.insee.sugoi.model.exceptions.GroupAlreadyExistException;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class GroupControllerTest {

@MockBean private GroupService groupService;

@MockBean private ApplicationService applicationService;

ObjectMapper objectMapper = new ObjectMapper();
Group group1, group2, group2Updated;
PageResult<Group> pageResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Feature: Groups scenario admin
Then the client receives status code 200
Then the client expect to receive a list of groups

Scenario: Get groups application not exist
When the client perform GET request on url /realms/domaine1/applications/non/groups
Then the client receives status code 404

Scenario: Get group
When the client perform GET request on url /realms/domaine1/applications/applitest/groups/Administrateurs_AppliTest
And show body received
Expand All @@ -22,6 +26,10 @@ Feature: Groups scenario admin
And show body received
Then the client receives status code 200

Scenario: Get group application not exist
When the client perform GET request on url /realms/domaine1/applications/non/groups/Administrateurs_AppliTest
Then the client receives status code 404

Scenario: Post group
When the client perform POST request with body on url /realms/domaine1/applications/applitest/groups body:
"""
Expand Down