1

change SerializationServiceTest

This commit is contained in:
tomvahl
2020-03-10 13:02:06 +01:00
parent 1eeda87c7f
commit 5f8d9a8603
3 changed files with 16 additions and 24 deletions

View File

@ -1,6 +1,8 @@
package mops.gruppen2.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import mops.gruppen2.builder.EventBuilder;
import mops.gruppen2.domain.event.AddUserEvent;
import mops.gruppen2.domain.event.Event;
import mops.gruppen2.repository.EventRepository;
import org.junit.jupiter.api.BeforeEach;
@ -12,24 +14,18 @@ import static org.mockito.Mockito.mock;
class SerializationServiceTest {
EventRepository eventRepository;
@BeforeEach
public void setUp() {
}
@Disabled
@Test
void applyEvent() {
}
@Test
void serializeEventTest() {
Event event = new Event(1,1,"1");
SerializationService serializationService = new SerializationService(eventRepository);
SerializationService serializationService = new SerializationService(mock(EventRepository.class));
try {
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"Event\":{\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}}");
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"type\":\"Event\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}");
} catch (JsonProcessingException e) {
e.printStackTrace();
}
@ -46,4 +42,14 @@ class SerializationServiceTest {
assertThat(event).isInstanceOf(Event.class);
}
@Test
void serializeEventTestAddUserEvent(){
AddUserEvent event = new AddUserEvent(1,1,"user_id","peter","mueller","a@a");
SerializationService serializationService = new SerializationService(mock(EventRepository.class));
try {
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"type\":\"AddUserEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":\"user_id\",\"givenname\":\"peter\",\"familyname\":\"mueller\",\"email\":\"a@a\"}");
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}