feat: completed RequestDeserializer
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user