feat: created BasicAnswer, and cleaned up some code
This commit is contained in:
parent
2d33f150a8
commit
37e84b6e15
@ -0,0 +1,10 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.json.basic;
|
||||
|
||||
import uulm.teamname.marvelous.gamelibrary.json.MessageType;
|
||||
|
||||
/** Basic answer to a message. It contains */
|
||||
public class BasicAnswer {
|
||||
String userID;
|
||||
MessageType messageType;
|
||||
boolean optionals;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.json.ingame;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import uulm.teamname.marvelous.gamelibrary.events.Event;
|
||||
import uulm.teamname.marvelous.gamelibrary.json.MessageType;
|
||||
|
||||
|
@ -30,31 +30,31 @@ class JSONTest {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
messageStructureStart = """
|
||||
{
|
||||
"messages":[
|
||||
""";
|
||||
{
|
||||
"messages":[
|
||||
""";
|
||||
messageStructureEnd = new String[] {
|
||||
"""
|
||||
],
|
||||
"messageType": "REQUESTS",
|
||||
"customContentType": "TestCustomContent",
|
||||
"customContent": {
|
||||
"""
|
||||
],
|
||||
"messageType": "REQUESTS",
|
||||
"customContentType": "TestCustomContent",
|
||||
"customContent": {
|
||||
"customKey" = "customResult",
|
||||
"customNumber" = 15,
|
||||
"customProperty" = true
|
||||
}
|
||||
""",
|
||||
"""
|
||||
],
|
||||
"messageType": "EVENTS",
|
||||
"customContentType": "TestCustomContent",
|
||||
"customContent": {
|
||||
}
|
||||
""",
|
||||
"""
|
||||
],
|
||||
"messageType": "EVENTS",
|
||||
"customContentType": "TestCustomContent",
|
||||
"customContent": {
|
||||
"customKey": "customResult",
|
||||
"customNumber": 15,
|
||||
"customProperty": true
|
||||
}
|
||||
}
|
||||
""",
|
||||
}
|
||||
""",
|
||||
};
|
||||
target = new MessageStructure();
|
||||
target.customContentType = "TestCustomContent";
|
||||
@ -76,9 +76,9 @@ class JSONTest {
|
||||
};
|
||||
|
||||
String eventRepresentation = """
|
||||
{"eventType": "Ack"},
|
||||
{"eventType": "Nack"}
|
||||
""";
|
||||
{"eventType": "Ack"},
|
||||
{"eventType": "Nack"}
|
||||
""";
|
||||
String completeMessageStructure = messageStructureStart + eventRepresentation + messageStructureEnd[1];
|
||||
|
||||
target.messageType = MessageType.EVENTS;
|
||||
@ -91,7 +91,7 @@ class JSONTest {
|
||||
@Test
|
||||
void parseMoreComplicatedEvents() {
|
||||
String eventRepresentation = """
|
||||
{
|
||||
{
|
||||
"eventType": "GamestateEvent",
|
||||
"activeCharacter": {"entityID": "P2", "ID": 4},
|
||||
"turnOrder": [
|
||||
@ -102,8 +102,8 @@ class JSONTest {
|
||||
{"entityID": "InfinityStones", "ID": 5},
|
||||
{"entityID": "Rocks", "ID": 0}
|
||||
]
|
||||
}
|
||||
""";
|
||||
}
|
||||
""";
|
||||
String completeMessageStructure = messageStructureStart + eventRepresentation + messageStructureEnd[1];
|
||||
|
||||
System.out.println(JSON.parse(completeMessageStructure));
|
||||
@ -113,11 +113,11 @@ class JSONTest {
|
||||
@Disabled
|
||||
void simpleInDevTest() throws JsonProcessingException {
|
||||
String simpleEntity = """
|
||||
{
|
||||
{
|
||||
"entityID": "P2",
|
||||
"ID": 4
|
||||
}
|
||||
""";
|
||||
}
|
||||
""";
|
||||
System.out.println(new ObjectMapper().readValue(simpleEntity, EntityID.class));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user