Jackson serialization test
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@ -7,4 +13,18 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class SerializationService {
|
||||
|
||||
private final EventRepository eventStore;
|
||||
private final Logger log = LoggerFactory.getLogger(SerializationService.class);
|
||||
|
||||
public SerializationService(EventRepository eventStore) {
|
||||
this.eventStore = eventStore;
|
||||
}
|
||||
|
||||
public String serializeEvent(Event event) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json = mapper.writeValueAsString(event);
|
||||
log.info(json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user