change SerializationServiceTest
This commit is contained in:
@ -53,20 +53,4 @@ public class SwaggerAPIControllerExample {
|
|||||||
return "Product saved successfully";
|
return "Product saved successfully";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@GetMapping("/json")
|
|
||||||
public void json() {
|
|
||||||
AddUserEvent aEvent = new AddUserEvent(
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
"Eins",
|
|
||||||
faker.leagueOfLegends().location(),
|
|
||||||
faker.name().lastName(),
|
|
||||||
"123@email.de");
|
|
||||||
try {
|
|
||||||
serializationService.serializeEvent(aEvent);
|
|
||||||
serializationService.saveEvent(aEvent);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,8 @@ public class SerializationService {
|
|||||||
return mapper.writeValueAsString(event);
|
return mapper.writeValueAsString(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create DTO methode schreiben also kurz auslagern
|
||||||
public void saveEvent(Event event){
|
public void saveEvent(Event event){
|
||||||
try {
|
try {
|
||||||
EventDTO eventDTO = new EventDTO();
|
EventDTO eventDTO = new EventDTO();
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package mops.gruppen2.service;
|
package mops.gruppen2.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
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.domain.event.Event;
|
||||||
import mops.gruppen2.repository.EventRepository;
|
import mops.gruppen2.repository.EventRepository;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -12,24 +14,18 @@ import static org.mockito.Mockito.mock;
|
|||||||
|
|
||||||
class SerializationServiceTest {
|
class SerializationServiceTest {
|
||||||
|
|
||||||
EventRepository eventRepository;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Test
|
|
||||||
void applyEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void serializeEventTest() {
|
void serializeEventTest() {
|
||||||
Event event = new Event(1,1,"1");
|
Event event = new Event(1,1,"1");
|
||||||
SerializationService serializationService = new SerializationService(eventRepository);
|
SerializationService serializationService = new SerializationService(mock(EventRepository.class));
|
||||||
try {
|
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) {
|
} catch (JsonProcessingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -46,4 +42,14 @@ class SerializationServiceTest {
|
|||||||
assertThat(event).isInstanceOf(Event.class);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user