feat: completed RequestDeserializer

This commit is contained in:
2021-05-28 14:50:38 +02:00
parent b2b963579e
commit a92f437412
5 changed files with 148 additions and 33 deletions

View File

@ -0,0 +1,31 @@
package uulm.teamname.marvelous.gamelibrary.json.ingame;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
import uulm.teamname.marvelous.gamelibrary.requests.GameRequest;
import uulm.teamname.marvelous.gamelibrary.requests.Request;
import uulm.teamname.marvelous.gamelibrary.requests.RequestType;
public class RequestDeserializerTest {
private ObjectMapper mapper;
@BeforeEach
void beforeEach() {
mapper = new ObjectMapper();
}
@Test
void gameRequestDeserialization() throws JsonProcessingException {
var request = new GameRequest();
request.type = RequestType.DisconnectRequest;
var jsonRepresentingRequest = "{ \"requestType\": \"DisconnectRequest\" }";
assertThat((GameRequest) (mapper.readValue(jsonRepresentingRequest, Request.class)))
.isEqualTo(request);
}
}