From 0a9922b8fef4331e048c6a5e35094365600154ee Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 9 Mar 2020 16:12:17 +0100 Subject: [PATCH] Merge branch 'event-db' of /home/christoph/Documents/repos/abschlussprojekt-it-bois with conflicts. --- .../controller/SwaggerAPIControllerExample.java | 2 +- .../mops/gruppen2/repository/EventRepository.java | 1 - .../gruppen2/service/SerializationService.java | 6 ++++++ .../service/SerializationServiceTest.java | 15 ++++++++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/mops/gruppen2/controller/SwaggerAPIControllerExample.java b/src/main/java/mops/gruppen2/controller/SwaggerAPIControllerExample.java index 5caa747..140c5c9 100644 --- a/src/main/java/mops/gruppen2/controller/SwaggerAPIControllerExample.java +++ b/src/main/java/mops/gruppen2/controller/SwaggerAPIControllerExample.java @@ -53,7 +53,7 @@ public class SwaggerAPIControllerExample { return "Product saved successfully"; } - /*@GetMapping("/json") //just for testing + @GetMapping("/json") public void json() { AddUserEvent aEvent = new AddUserEvent( 1, diff --git a/src/main/java/mops/gruppen2/repository/EventRepository.java b/src/main/java/mops/gruppen2/repository/EventRepository.java index 4352a97..c4b1249 100644 --- a/src/main/java/mops/gruppen2/repository/EventRepository.java +++ b/src/main/java/mops/gruppen2/repository/EventRepository.java @@ -1,7 +1,6 @@ package mops.gruppen2.repository; import mops.gruppen2.domain.EventDTO; -import mops.gruppen2.domain.event.Event; import org.springframework.data.repository.CrudRepository; public interface EventRepository extends CrudRepository { diff --git a/src/main/java/mops/gruppen2/service/SerializationService.java b/src/main/java/mops/gruppen2/service/SerializationService.java index c20af44..dd79d5c 100644 --- a/src/main/java/mops/gruppen2/service/SerializationService.java +++ b/src/main/java/mops/gruppen2/service/SerializationService.java @@ -41,4 +41,10 @@ public class SerializationService { } } + + public Event deserializeEvent(String json) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + Event event = mapper.readValue(json, Event.class); + return event; + } } diff --git a/src/test/java/mops/gruppen2/service/SerializationServiceTest.java b/src/test/java/mops/gruppen2/service/SerializationServiceTest.java index 21c4555..83ca5eb 100644 --- a/src/test/java/mops/gruppen2/service/SerializationServiceTest.java +++ b/src/test/java/mops/gruppen2/service/SerializationServiceTest.java @@ -1,7 +1,6 @@ package mops.gruppen2.service; import com.fasterxml.jackson.core.JsonProcessingException; -import mops.gruppen2.domain.event.AddUserEvent; import mops.gruppen2.domain.event.Event; import mops.gruppen2.repository.EventRepository; import org.junit.jupiter.api.BeforeEach; @@ -14,10 +13,9 @@ import static org.junit.jupiter.api.Assertions.*; class SerializationServiceTest { EventRepository eventRepository; - Event event; @BeforeEach - public void setUp(){ + public void setUp() { } @@ -28,7 +26,7 @@ class SerializationServiceTest { @Test void serializeEventTest() { - event = new Event(1,1,"1"); + Event event = new Event(1,1,"1"); SerializationService serializationService = new SerializationService(eventRepository); try { assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"Event\":{\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}}"); @@ -37,5 +35,12 @@ class SerializationServiceTest { } } + @Test + void deserializeAddUserEvent() { + SerializationService serializationService = new SerializationService(); -} \ No newline at end of file + Event event = EventBuilder.randomAddUserEvent(); + + } + +}