Added DeleteGroupEvent and GroupDoesNotExistException
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user