Implemented Exeption and their handling
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
package mops.gruppen2.domain;
|
||||
|
||||
import mops.gruppen2.domain.Exceptions.UserAlreadyExistsException;
|
||||
import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.DeleteUserEvent;
|
||||
import mops.gruppen2.domain.event.UpdateRoleEvent;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -23,12 +25,14 @@ class GroupTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void createSingleGroup() {
|
||||
void createSingleGroup() throws Exception{
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1,2, "asd", "hello", "foo");
|
||||
|
||||
Group group = new Group();
|
||||
|
||||
group.applyEvent(createGroupEvent);
|
||||
|
||||
|
||||
assertThat(group.getDescription()).isEqualTo("foo");
|
||||
assertThat(group.getTitle()).isEqualTo("hello");
|
||||
assertThat(group.getId()).isEqualTo(2);
|
||||
@ -36,7 +40,7 @@ class GroupTest {
|
||||
|
||||
// Verwendet CreateGroupEvent
|
||||
@Test
|
||||
void addSingleUser() {
|
||||
void addSingleUser() throws Exception{
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1,1,"prof1", "hi", "foo");
|
||||
Group group = new Group();
|
||||
group.applyEvent(createGroupEvent);
|
||||
@ -49,7 +53,7 @@ class GroupTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void addExistingUser() {
|
||||
void addExistingUser() throws Exception{
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1,1,"prof1", "hi", "foo");
|
||||
Group group = new Group();
|
||||
group.applyEvent(createGroupEvent);
|
||||
@ -60,13 +64,16 @@ class GroupTest {
|
||||
|
||||
User user2 = new User("prof", "olga", "bendi", "hi@gmail.com");
|
||||
AddUserEvent addUserEvent2 = new AddUserEvent(3,1, user2);
|
||||
group.applyEvent(addUserEvent2);
|
||||
Assertions.assertThrows(UserAlreadyExistsException.class, () ->{
|
||||
group.applyEvent(addUserEvent2);
|
||||
});
|
||||
|
||||
assertThat(group.getMembers().size()).isEqualTo(1);
|
||||
|
||||
//assertThat(group.getMembers().size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteSingleUser() {
|
||||
void deleteSingleUser() throws Exception{
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1, 2, "Prof", "Tolle Gruppe", "Tolle Beshreibung");
|
||||
User user = new User("Prof", "Pro", "fessor", "pro@fessor.de");
|
||||
AddUserEvent addUserEvent = new AddUserEvent(2, 2, user);
|
||||
@ -82,7 +89,7 @@ class GroupTest {
|
||||
|
||||
// Verwendet CreateGroupEvent und AddUserEvent
|
||||
@Test
|
||||
void updateRoleForExistingUser() {
|
||||
void updateRoleForExistingUser() throws Exception{
|
||||
// Arrange
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L, 1L, "1L", "gruppe1", "Eine Testgruppe");
|
||||
AddUserEvent addUserEvent = new AddUserEvent(1L, 1L, "5L", "Peter", "Pan", "123@mail.de");
|
||||
|
||||
Reference in New Issue
Block a user