Skip to content

Commit

Permalink
chore: minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mebo4b committed Nov 23, 2020
1 parent 2d1750f commit 37599dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions api/useradminservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ paths:
parameters:
- name: filter
in: query
description: The filter parameters to search for
description: 'The filter parameters to search for. If no filter is set all sessions are
being returned. If more than one filter is set the first given filter is used only.'
schema:
type: object
properties:
consultant:
type: string
asker:
type: string
agency:
type: integer
asker:
type: string
consultant:
type: string
consultingType:
type: integer
- name: page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.springframework.web.bind.annotation.RestController;

/**
* Controller to handle all agency admin requests.
* Controller to handle all session admin requests.
*/
@RestController
@RequiredArgsConstructor
Expand All @@ -25,7 +25,7 @@ public class SessionAdminController implements UseradminApi {
/**
* Creates the root hal based navigation entity.
*
* @return a entity containing the available navigation hal links
* @return an entity containing the available navigation hal links
*/
@Override
public ResponseEntity<RootDTO> getRoot() {
Expand All @@ -39,7 +39,7 @@ public ResponseEntity<RootDTO> getRoot() {
* @param page Number of page where to start in the query (1 = first page) (required)
* @param perPage Number of items which are being returned (required)
* @param filter The filters to restrict results (optional)
* @return a entity conatining the filtered sessions
* @return an entity containing the filtered sessions
*/
@Override
public ResponseEntity<SessionAdminResultDTO> getSessions(@NotNull @Valid Integer page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public enum Authorities {
USER_ADMIN(UserRole.USER_ADMIN, singletonList(Authority.USER_ADMIN));

private final UserRole userRole;
private final List<String> auhorities;
private final List<String> grantedAuthorities;

public static List<String> getAuthoritiesByUserRole(UserRole userRole) {
Optional<Authorities> authorityByUserRole = Stream.of(values())
.filter(authority -> authority.userRole.equals(userRole))
.findFirst();

return authorityByUserRole.isPresent() ? authorityByUserRole.get().getAuhorities()
return authorityByUserRole.isPresent() ? authorityByUserRole.get().getGrantedAuthorities()
: emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void build_Should_returnSessionAdminResultDTOWithoutPreviousLink_When_par
}

@Test
public void build_Should_returnSessionAdminResultDTOWithoutNextLink_When_parametersPageIsTheFirst() {
public void build_Should_returnSessionAdminResultDTOWithoutNextLink_When_parametersPageIsTheLast() {
when(this.resultPage.getTotalPages()).thenReturn(MOCKED_SESSIONS_SIZE / 2);

SessionAdminResultDTO resultDTO = SessionAdminResultDTOBuilder.getInstance()
Expand Down

0 comments on commit 37599dd

Please sign in to comment.