Update ControllerServiceTest.java
Co-Authored-By: tomvahl <tomvahl@users.noreply.github.com> Co-Authored-By: kasch309 <kasch309@users.noreply.github.com>
This commit is contained in:
@ -1,39 +1,30 @@
|
|||||||
package mops.gruppen2.service;
|
package mops.gruppen2.service;
|
||||||
|
|
||||||
import com.github.javafaker.Faker;
|
|
||||||
import mops.gruppen2.Gruppen2Application;
|
import mops.gruppen2.Gruppen2Application;
|
||||||
import mops.gruppen2.domain.Group;
|
import mops.gruppen2.domain.*;
|
||||||
import mops.gruppen2.domain.GroupType;
|
|
||||||
import mops.gruppen2.domain.User;
|
|
||||||
import mops.gruppen2.domain.Visibility;
|
|
||||||
import mops.gruppen2.domain.exception.UserNotFoundException;
|
import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||||
import mops.gruppen2.repository.EventRepository;
|
import mops.gruppen2.repository.EventRepository;
|
||||||
import mops.gruppen2.security.Account;
|
import mops.gruppen2.security.Account;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.test.annotation.Rollback;
|
import org.springframework.test.annotation.Rollback;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@SpringBootTest(classes = Gruppen2Application.class)
|
@SpringBootTest(classes = Gruppen2Application.class)
|
||||||
@Transactional
|
@Transactional
|
||||||
@Rollback
|
@Rollback
|
||||||
class ControllerServiceTest {
|
class ControllerServiceTest {
|
||||||
Account account, account2;
|
Account account, account2, account3;
|
||||||
ControllerService controllerService;
|
ControllerService controllerService;
|
||||||
EventService eventService;
|
EventService eventService;
|
||||||
UserService userService;
|
UserService userService;
|
||||||
@ -53,11 +44,12 @@ class ControllerServiceTest {
|
|||||||
roles.add("l");
|
roles.add("l");
|
||||||
account = new Account("ich", "ich@hhu.de", "l", "ichdude", "jap", roles);
|
account = new Account("ich", "ich@hhu.de", "l", "ichdude", "jap", roles);
|
||||||
account2 = new Account("ich2", "ich2@hhu.de", "l", "ichdude2", "jap2", roles);
|
account2 = new Account("ich2", "ich2@hhu.de", "l", "ichdude2", "jap2", roles);
|
||||||
|
account3 = new Account("ich3", "ich3@hhu.de", "l", "ichdude3", "jap3", roles);
|
||||||
|
eventRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPublicGroupWithNoParentAndLimitedNumberTest() {
|
void createPublicGroupWithNoParentAndLimitedNumberTest() {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createGroup(account,"test", "hi", null, null, 20L, null);
|
controllerService.createGroup(account,"test", "hi", null, null, 20L, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -68,7 +60,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPublicGroupWithNoParentAndUnlimitedNumberTest() {
|
void createPublicGroupWithNoParentAndUnlimitedNumberTest() {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createGroup(account,"test", "hi", null, true, null, null);
|
controllerService.createGroup(account,"test", "hi", null, true, null, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -79,7 +70,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPrivateGroupWithNoParentAndUnlimitedNumberTest() {
|
void createPrivateGroupWithNoParentAndUnlimitedNumberTest() {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -90,7 +80,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPrivateGroupWithNoParentAndLimitedNumberTest() {
|
void createPrivateGroupWithNoParentAndLimitedNumberTest() {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createGroup(account,"test", "hi", true, null, 20L, null);
|
controllerService.createGroup(account,"test", "hi", true, null, 20L, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -101,7 +90,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPrivateGroupWithParentAndLimitedNumberTest() throws IOException {
|
void createPrivateGroupWithParentAndLimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
||||||
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
controllerService.createGroup(account,"test", "hi", true, null, 20L, groups1.get(0).getId());
|
controllerService.createGroup(account,"test", "hi", true, null, 20L, groups1.get(0).getId());
|
||||||
@ -114,7 +102,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPublicGroupWithParentAndLimitedNumberTest() throws IOException {
|
void createPublicGroupWithParentAndLimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
||||||
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
controllerService.createGroup(account,"test", "hi", null, null, 20L, groups1.get(0).getId());
|
controllerService.createGroup(account,"test", "hi", null, null, 20L, groups1.get(0).getId());
|
||||||
@ -127,7 +114,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPublicGroupWithParentAndUnlimitedNumberTest() throws IOException {
|
void createPublicGroupWithParentAndUnlimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
||||||
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
controllerService.createGroup(account,"test", "hi", null, true, null, groups1.get(0).getId());
|
controllerService.createGroup(account,"test", "hi", null, true, null, groups1.get(0).getId());
|
||||||
@ -140,7 +126,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPrivateGroupWithParentAndUnlimitedNumberTest() throws IOException {
|
void createPrivateGroupWithParentAndUnlimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
controllerService.createOrga(account2, "test", "hi", null, null, true, null, null);
|
||||||
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
List<Group> groups1= userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
controllerService.createGroup(account,"test", "hi", true, true, null, groups1.get(0).getId());
|
controllerService.createGroup(account,"test", "hi", true, true, null, groups1.get(0).getId());
|
||||||
@ -153,7 +138,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPublicOrgaGroupWithNoParentAndLimitedNumberTest() throws IOException {
|
void createPublicOrgaGroupWithNoParentAndLimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account, "test", "hi", null, null, null, 20L, null);
|
controllerService.createOrga(account, "test", "hi", null, null, null, 20L, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -165,7 +149,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPublicOrgaGroupWithNoParentAndUnlimitedNumberTest() throws IOException {
|
void createPublicOrgaGroupWithNoParentAndUnlimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account, "test", "hi", null, null, true, null, null);
|
controllerService.createOrga(account, "test", "hi", null, null, true, null, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -177,7 +160,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPrivateOrgaGroupWithNoParentAndLimitedNumberTest() throws IOException {
|
void createPrivateOrgaGroupWithNoParentAndLimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account, "test", "hi", true, null, null, 20L, null);
|
controllerService.createOrga(account, "test", "hi", true, null, null, 20L, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -189,7 +171,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createPrivateOrgaGroupWithNoParentAndUnlimitedNumberTest() throws IOException {
|
void createPrivateOrgaGroupWithNoParentAndUnlimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account, "test", "hi", true, null, true, null, null);
|
controllerService.createOrga(account, "test", "hi", true, null, true, null, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -201,7 +182,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createOrgaLectureGroupAndLimitedNumberTest() throws IOException {
|
void createOrgaLectureGroupAndLimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account, "test", "hi", null, true, null, 20L, null);
|
controllerService.createOrga(account, "test", "hi", null, true, null, 20L, null);
|
||||||
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups= userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -213,7 +193,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createOrgaLectureGroupAndUnlimitedNumberTest() throws IOException {
|
void createOrgaLectureGroupAndUnlimitedNumberTest() throws IOException {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createOrga(account, "test", "hi", null, true, true, null, null);
|
controllerService.createOrga(account, "test", "hi", null, true, true, null, null);
|
||||||
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
testTitleAndDescription(groups.get(0).getTitle(), groups.get(0).getDescription());
|
||||||
@ -225,7 +204,6 @@ class ControllerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteUserTest() {
|
public void deleteUserTest() {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
controllerService.addUser(account2,groups.get(0).getId());
|
controllerService.addUser(account2,groups.get(0).getId());
|
||||||
@ -233,17 +211,41 @@ class ControllerServiceTest {
|
|||||||
assertTrue(userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail())).isEmpty());
|
assertTrue(userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail())).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteNonUserTest() {
|
public void updateRoleAdminTest() {
|
||||||
eventRepository.deleteAll();
|
|
||||||
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
controllerService.addUser(account2,groups.get(0).getId());
|
||||||
Throwable exception = assertThrows(UserNotFoundException.class, () -> controllerService.deleteUser(account2.getName(), groups.get(0).getId()));
|
controllerService.updateRole(account.getName(), groups.get(0).getId());
|
||||||
assertEquals(HttpStatus.NOT_FOUND, "Der User wurde nicht gefunden. (class mops.gruppen2.service.ControllerService)", exception.getMessage()); //noch fixen
|
groups = userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
assertEquals(Role.MEMBER,groups.get(0).getRoles().get(account.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateRoleMemberTest() {
|
||||||
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
controllerService.addUser(account2,groups.get(0).getId());
|
||||||
|
controllerService.updateRole(account2.getName(), groups.get(0).getId());
|
||||||
|
groups = userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
assertEquals(Role.ADMIN,groups.get(0).getRoles().get(account2.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateRoleNonUserTest() {
|
||||||
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
Throwable exception=assertThrows(UserNotFoundException.class, () -> controllerService.updateRole(account2.getName(), groups.get(0).getId()));
|
||||||
|
assertEquals("404 NOT_FOUND \"Der User wurde nicht gefunden. (class mops.gruppen2.service.ControllerService)\"", exception.getMessage()); //noch fixen
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deleteNonUserTest() {
|
||||||
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
Throwable exception=assertThrows(UserNotFoundException.class, () -> controllerService.deleteUser(account2.getName(), groups.get(0).getId()));
|
||||||
|
assertEquals("404 NOT_FOUND \"Der User wurde nicht gefunden. (class mops.gruppen2.service.ControllerService)\"", exception.getMessage()); //noch fixen
|
||||||
|
}
|
||||||
|
|
||||||
void testTitleAndDescription(String title, String description) {
|
void testTitleAndDescription(String title, String description) {
|
||||||
assertEquals("test", title);
|
assertEquals("test", title);
|
||||||
@ -251,6 +253,39 @@ class ControllerServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void passIfLastAdmin() {
|
void passIfLastAdminTest() {
|
||||||
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
controllerService.addUser(account2,groups.get(0).getId());
|
||||||
|
controllerService.passIfLastAdmin(account, groups.get(0).getId());
|
||||||
|
controllerService.deleteUser(account.getName(), groups.get(0).getId());
|
||||||
|
groups = userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
|
assertEquals(Role.ADMIN,groups.get(0).getRoles().get(account2.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void dontPassIfNotLastAdminTest() {
|
||||||
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
controllerService.addUser(account2,groups.get(0).getId());
|
||||||
|
controllerService.updateRole(account2.getName(), groups.get(0).getId());
|
||||||
|
controllerService.addUser(account3, groups.get(0).getId());
|
||||||
|
controllerService.passIfLastAdmin(account, groups.get(0).getId());
|
||||||
|
controllerService.deleteUser(account.getName(), groups.get(0).getId());
|
||||||
|
groups = userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
|
assertEquals(Role.MEMBER, groups.get(0).getRoles().get(account3.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getVeteranMemberTest(){
|
||||||
|
controllerService.createGroup(account,"test", "hi", true, true, null, null);
|
||||||
|
List<Group> groups=userService.getUserGroups(new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()));
|
||||||
|
controllerService.addUser(account2,groups.get(0).getId());
|
||||||
|
controllerService.addUser(account3, groups.get(0).getId());
|
||||||
|
controllerService.passIfLastAdmin(account, groups.get(0).getId());
|
||||||
|
controllerService.deleteUser(account.getName(), groups.get(0).getId());
|
||||||
|
groups = userService.getUserGroups(new User(account2.getName(),account2.getGivenname(),account2.getFamilyname(),account2.getEmail()));
|
||||||
|
assertEquals(Role.ADMIN,groups.get(0).getRoles().get(account2.getName()));
|
||||||
|
assertEquals(Role.MEMBER, groups.get(0).getRoles().get(account3.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user