1

Jackson serialization test

This commit is contained in:
Christoph
2020-03-09 13:48:01 +01:00
parent 1a3b1c52b3
commit 2da89300e3
4 changed files with 46 additions and 3 deletions

View File

@ -1,10 +1,13 @@
package mops.gruppen2.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.javafaker.Faker;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import mops.gruppen2.domain.ProductSwaggerExample;
import mops.gruppen2.domain.event.AddUserEvent;
import mops.gruppen2.service.SerializationService;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@ -19,6 +22,11 @@ public class SwaggerAPIControllerExample {
private final Faker faker = new Faker();
private final List<ProductSwaggerExample> products = new ArrayList<>();
private final SerializationService serializationService;
public SwaggerAPIControllerExample(SerializationService serializationService) {
this.serializationService = serializationService;
}
@GetMapping("/get/all")
@ApiOperation(value = "Erzeugt eine Liste mit allen gespeicherten Produkten")
@ -44,4 +52,19 @@ public class SwaggerAPIControllerExample {
return "Product saved successfully";
}
@GetMapping("/json")
public void json() {
try {
serializationService.serializeEvent(new AddUserEvent(
1,
1,
"Eins",
faker.leagueOfLegends().location(),
faker.name().lastName(),
"123@email.de"));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}