created createGroup - test
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package mops.gruppen2.entities;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import mops.gruppen2.events.AddUser;
|
||||
import mops.gruppen2.events.CreateGroupEvent;
|
||||
import mops.gruppen2.events.UpdateGroupDescriptionEvent;
|
||||
@ -10,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
public class Gruppe extends Aggregat {
|
||||
long id;
|
||||
String titel;
|
||||
@ -21,6 +23,7 @@ public class Gruppe extends Aggregat {
|
||||
}
|
||||
|
||||
public void applyEvent(CreateGroupEvent event){
|
||||
this.id = event.getGruppe_id();
|
||||
this.titel = event.getTitel();
|
||||
this.beschreibung = event.getBeschreibung();
|
||||
}
|
||||
|
||||
@ -12,17 +12,6 @@ import java.util.List;
|
||||
@Service
|
||||
public class GruppenService {
|
||||
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L,1L,1L,"hello", "foo");
|
||||
AddUser addUser = new AddUser(1L, 1L, 1L, "jens","bendiest","jb@gmail.ru");
|
||||
|
||||
public GruppenService(){
|
||||
List<Event> eventList = new ArrayList<>();
|
||||
eventList.add(createGroupEvent);
|
||||
eventList.add(addUser);
|
||||
Gruppe newGroup = buildGroup(eventList);
|
||||
System.out.println(newGroup.toString());
|
||||
}
|
||||
|
||||
Gruppe buildGroup(List<Event> eventList){
|
||||
Gruppe newGroup = new Gruppe();
|
||||
eventList.forEach(newGroup::applyEvent);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package mops.gruppen2.entities;
|
||||
|
||||
import mops.gruppen2.events.CreateGroupEvent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
@ -7,6 +8,17 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
class GruppeTest {
|
||||
|
||||
@Test
|
||||
void applyEvent() {
|
||||
void applyCreteGroupEvent() {
|
||||
CreateGroupEvent event = new CreateGroupEvent(1L,2L,3L,"hello", "foo");
|
||||
|
||||
Gruppe gruppe1 = new Gruppe();
|
||||
gruppe1.applyEvent(event);
|
||||
|
||||
Gruppe gruppe2 = new Gruppe();
|
||||
gruppe2.id = 2;
|
||||
gruppe2.titel = "hello";
|
||||
gruppe2.beschreibung = "foo";
|
||||
|
||||
assertEquals(gruppe2, gruppe1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user