new GroupCreationController mappings
This commit is contained in:
@ -47,8 +47,8 @@ public class APIController {
|
||||
@GetMapping("/update/{id}")
|
||||
@Secured("ROLE_api_user")
|
||||
@ApiOperation("Gibt veränderte Gruppen zurück")
|
||||
public GroupRequestWrapper update(@ApiParam("Letzte gespeicherte EventId des Anfragestellers")
|
||||
@PathVariable("id") long eventId) {
|
||||
public GroupRequestWrapper getApiUpdate(@ApiParam("Letzte gespeicherte EventId des Anfragestellers")
|
||||
@PathVariable("id") long eventId) {
|
||||
|
||||
return APIService.wrap(eventStoreService.findMaxEventId(),
|
||||
projectionService.projectNewGroups(eventId));
|
||||
@ -60,8 +60,8 @@ public class APIController {
|
||||
@GetMapping("/usergroups/{id}")
|
||||
@Secured("ROLE_api_user")
|
||||
@ApiOperation("Gibt Gruppen zurück, in welchen ein Nutzer teilnimmt")
|
||||
public List<String> usergroups(@ApiParam("Nutzer-Id")
|
||||
@PathVariable("id") String userId) {
|
||||
public List<String> getApiUserGroups(@ApiParam("Nutzer-Id")
|
||||
@PathVariable("id") String userId) {
|
||||
|
||||
return IdService.uuidsToString(eventStoreService.findExistingUserGroups(new User(userId)));
|
||||
}
|
||||
@ -72,8 +72,8 @@ public class APIController {
|
||||
@GetMapping("/group/{id}")
|
||||
@Secured("ROLE_api_user")
|
||||
@ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
|
||||
public Group getGroupById(@ApiParam("Gruppen-Id der gefordeten Gruppe")
|
||||
@PathVariable("id") String groupId) {
|
||||
public Group getApiGroup(@ApiParam("Gruppen-Id der gefordeten Gruppe")
|
||||
@PathVariable("id") String groupId) {
|
||||
|
||||
return projectionService.projectSingleGroup(UUID.fromString(groupId));
|
||||
}
|
||||
|
@ -41,19 +41,17 @@ public class GroupCreationController {
|
||||
this.projectionService = projectionService;
|
||||
}
|
||||
|
||||
//TODO: /create/orga
|
||||
@RolesAllowed("ROLE_orga")
|
||||
@GetMapping("/createOrga")
|
||||
public String getCreateOrgaPage(Model model) {
|
||||
@GetMapping("/create/orga")
|
||||
public String getCreateOrga(Model model) {
|
||||
|
||||
model.addAttribute("lectures", projectionService.projectLectures());
|
||||
|
||||
return "createOrga";
|
||||
}
|
||||
|
||||
//TODO: /create/orga
|
||||
@RolesAllowed("ROLE_orga")
|
||||
@PostMapping("/createOrga")
|
||||
@PostMapping("/create/orga")
|
||||
@CacheEvict(value = "groups", allEntries = true)
|
||||
public String postCreateOrga(KeycloakAuthenticationToken token,
|
||||
@RequestParam("title") String title,
|
||||
@ -79,19 +77,17 @@ public class GroupCreationController {
|
||||
return "redirect:/gruppen2/details/" + IdService.uuidToString(group.getId());
|
||||
}
|
||||
|
||||
//TODO: /create/student
|
||||
@RolesAllowed("ROLE_studentin")
|
||||
@GetMapping("/createStudent")
|
||||
public String getCreateStudentPage(Model model) {
|
||||
@GetMapping("/create/student")
|
||||
public String getCreateStudent(Model model) {
|
||||
|
||||
model.addAttribute("lectures", projectionService.projectLectures());
|
||||
|
||||
return "createStudent";
|
||||
}
|
||||
|
||||
//TODO: /create/student
|
||||
@RolesAllowed("ROLE_studentin")
|
||||
@PostMapping("/createStudent")
|
||||
@PostMapping("/create/student")
|
||||
@CacheEvict(value = "groups", allEntries = true)
|
||||
public String postCreateStudent(KeycloakAuthenticationToken token,
|
||||
@RequestParam("title") String title,
|
||||
|
@ -24,10 +24,10 @@
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
|
||||
|
@ -25,10 +25,10 @@
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}" class="active">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}" class="active">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
|
||||
@ -42,7 +42,7 @@
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Gruppenerstellung</h1>
|
||||
<form enctype="multipart/form-data" method="post" th:action="@{/gruppen2/createOrga}">
|
||||
<form enctype="multipart/form-data" method="post" th:action="@{/gruppen2/create/orga}">
|
||||
<div class="shadow-sm p-2" style=" border: 10px solid aliceblue; background: aliceblue;">
|
||||
<div class="form-group">
|
||||
<label for="titel">Titel</label>
|
||||
|
@ -21,10 +21,10 @@
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}" class="active">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}" class="active">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
|
||||
@ -37,7 +37,7 @@
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Gruppenerstellung</h1>
|
||||
<form method="post" th:action="@{/gruppen2/createStudent}">
|
||||
<form method="post" th:action="@{/gruppen2/create/student}">
|
||||
<div class="shadow-sm p-2"
|
||||
style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue;">
|
||||
|
||||
|
@ -18,10 +18,10 @@
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
|
||||
|
@ -16,10 +16,10 @@
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
|
||||
|
@ -21,10 +21,10 @@
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
|
||||
|
@ -17,10 +17,10 @@
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
|
||||
|
@ -19,10 +19,10 @@
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
|
||||
|
@ -17,10 +17,10 @@
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
|
||||
|
@ -53,10 +53,10 @@ class APIControllerTest {
|
||||
@Test
|
||||
@WithMockUser(username = "api_user", roles = "api_user")
|
||||
void updateGroup_noGroup() {
|
||||
assertThat(apiController.update(0L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.update(4L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.update(10L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.update(0L).getStatus()).isEqualTo(0);
|
||||
assertThat(apiController.getApiUpdate(0L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.getApiUpdate(4L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.getApiUpdate(10L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.getApiUpdate(0L).getStatus()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -69,10 +69,10 @@ class APIControllerTest {
|
||||
addUserEvent(uuidMock(0)),
|
||||
addUserEvent(uuidMock(0)));
|
||||
|
||||
assertThat(apiController.update(0L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.update(4L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.update(10L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.update(0L).getStatus()).isEqualTo(6);
|
||||
assertThat(apiController.getApiUpdate(0L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.getApiUpdate(4L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.getApiUpdate(10L).getGroupList()).hasSize(0);
|
||||
assertThat(apiController.getApiUpdate(0L).getStatus()).isEqualTo(6);
|
||||
}
|
||||
|
||||
|
||||
@ -89,17 +89,17 @@ class APIControllerTest {
|
||||
addUserEvent(uuidMock(1)),
|
||||
addUserEvent(uuidMock(1)));
|
||||
|
||||
assertThat(apiController.update(0L).getGroupList()).hasSize(2);
|
||||
assertThat(apiController.update(4L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.update(6L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.update(7L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.update(0L).getStatus()).isEqualTo(9);
|
||||
assertThat(apiController.getApiUpdate(0L).getGroupList()).hasSize(2);
|
||||
assertThat(apiController.getApiUpdate(4L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.getApiUpdate(6L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.getApiUpdate(7L).getGroupList()).hasSize(1);
|
||||
assertThat(apiController.getApiUpdate(0L).getStatus()).isEqualTo(9);
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "api_user", roles = "api_user")
|
||||
void getGroupsOfUser_noGroup() {
|
||||
assertThat(apiController.usergroups("A")).isEmpty();
|
||||
assertThat(apiController.getApiUserGroups("A")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -110,7 +110,7 @@ class APIControllerTest {
|
||||
createPrivateGroupEvent(uuidMock(2)),
|
||||
addUserEvent(uuidMock(0), "A"));
|
||||
|
||||
assertThat(apiController.usergroups("A")).hasSize(1);
|
||||
assertThat(apiController.getApiUserGroups("A")).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -120,7 +120,7 @@ class APIControllerTest {
|
||||
addUserEvent(uuidMock(0), "A"),
|
||||
deleteUserEvent(uuidMock(0), "A"));
|
||||
|
||||
assertThat(apiController.usergroups("A")).isEmpty();
|
||||
assertThat(apiController.getApiUserGroups("A")).isEmpty();
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@ -131,7 +131,7 @@ class APIControllerTest {
|
||||
addUserEvent(uuidMock(0), "A"),
|
||||
deleteGroupEvent(uuidMock(0)));
|
||||
|
||||
assertThat(apiController.usergroups("A")).isEmpty();
|
||||
assertThat(apiController.getApiUserGroups("A")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -146,14 +146,14 @@ class APIControllerTest {
|
||||
addUserEvent(uuidMock(2), "A"),
|
||||
addUserEvent(uuidMock(2), "B"));
|
||||
|
||||
assertThat(apiController.usergroups("A")).hasSize(3);
|
||||
assertThat(apiController.usergroups("B")).hasSize(2);
|
||||
assertThat(apiController.getApiUserGroups("A")).hasSize(3);
|
||||
assertThat(apiController.getApiUserGroups("B")).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "api_user", roles = "api_user")
|
||||
void getGroupFromId_noGroup() {
|
||||
assertThrows(GroupNotFoundException.class, () -> apiController.getGroupById(uuidMock(0).toString()));
|
||||
assertThrows(GroupNotFoundException.class, () -> apiController.getApiGroup(uuidMock(0).toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -161,7 +161,7 @@ class APIControllerTest {
|
||||
void getGroupFromId_singleGroup() {
|
||||
eventStoreService.saveAll(createPrivateGroupEvent(uuidMock(0)));
|
||||
|
||||
assertThat(apiController.getGroupById(uuidMock(0).toString()).getId()).isEqualTo(uuidMock(0));
|
||||
assertThat(apiController.getApiGroup(uuidMock(0).toString()).getId()).isEqualTo(uuidMock(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -171,6 +171,6 @@ class APIControllerTest {
|
||||
updateGroupTitleEvent(uuidMock(0)),
|
||||
deleteGroupEvent(uuidMock(0)));
|
||||
|
||||
assertThat(apiController.getGroupById(uuidMock(0).toString()).getTitle()).isEqualTo(null);
|
||||
assertThat(apiController.getApiGroup(uuidMock(0).toString()).getTitle()).isEqualTo(null);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user