1

Added DeleteGroupEvent and GroupDoesNotExistException

This commit is contained in:
Mahgs
2020-03-10 15:09:35 +01:00
parent 3425e1fcec
commit c0d2bbbf7f
8 changed files with 162 additions and 30 deletions

View File

@ -30,8 +30,7 @@ public abstract class Aggregate {
Method method = this.getClass().getDeclaredMethod("applyEvent", event.getClass());
method.setAccessible(true);
method.invoke(this, event);
}
catch (IllegalAccessException e) {
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();

View File

@ -0,0 +1,9 @@
package mops.gruppen2.domain.Exceptions;
import mops.gruppen2.domain.event.Event;
public class GroupDoesNotExistException extends EventException {
public GroupDoesNotExistException(String msg) {
super(msg);
}
}

View File

@ -68,8 +68,8 @@ public class Group extends Aggregate {
this.description = event.getNewGroupDescription();
}
private void applyEvent(DeleteUserEvent event) throws UserNotFoundException{
User user = new User(event.getUser_id(), "","","");
private void applyEvent(DeleteUserEvent event) throws UserNotFoundException {
User user = new User(event.getUser_id(), "", "", "");
if (this.members.contains(user)) {
this.members.remove(user);
@ -77,4 +77,8 @@ public class Group extends Aggregate {
throw new UserNotFoundException("Nutzer wurde nicht gefunden!");
}
}
private void applyEvent(DeleteGroupEvent event) {
this.id = this.id * -1;
}
}

View File

@ -0,0 +1,13 @@
package mops.gruppen2.domain.event;
import lombok.EqualsAndHashCode;
import lombok.Value;
@EqualsAndHashCode(callSuper = true)
@Value
public class DeleteGroupEvent extends Event {
public DeleteGroupEvent(long event_id, long group_id, String user_id) {
super(event_id, group_id, user_id);
}
}