-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#134 (ed-pilots-network/backend#134) adding JournalDocked Message
- Loading branch information
1 parent
91cc1bf
commit 3e779f5
Showing
17 changed files
with
615 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../java/io/edpn/backend/messageprocessorlib/application/dto/eddn/journal/DockedMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package io.edpn.backend.messageprocessorlib.application.dto.eddn.journal; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.edpn.backend.messageprocessorlib.application.dto.eddn.EddnMessage; | ||
import io.edpn.backend.messageprocessorlib.application.dto.eddn.TimestampedEddnMessage; | ||
import io.edpn.backend.util.TimestampConverter; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public interface DockedMessage { | ||
|
||
String EVENT = "JournalDocked"; | ||
|
||
record V1( | ||
@JsonProperty("$schemaRef") String schemaRef, | ||
@JsonProperty("header") EddnMessage.Header header, | ||
@JsonProperty("message") Payload message) implements TimestampedEddnMessage<EddnMessage.Payload> { | ||
|
||
@Override | ||
public LocalDateTime messageTimeStamp() { | ||
return TimestampConverter.convertToLocalDateTime(message.timestamp); | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record Payload( | ||
@JsonProperty("DistFromStarLS") Double distanceFromStar, | ||
@JsonProperty("LandingPads") LandingPads landingPads, | ||
@JsonProperty("MarketID") Long marketId, | ||
@JsonProperty("StarPos") List<Double> starPosition, | ||
@JsonProperty("StarSystem") String starSystem, | ||
@JsonProperty("StationEconomies") List<Economy> stationEconomies, | ||
@JsonProperty("StationEconomy") String stationEconomy, | ||
@JsonProperty("StationFaction") Faction stationFaction, | ||
@JsonProperty("StationGovernment") String stationGovernment, | ||
@JsonProperty("StationName") String stationName, | ||
@JsonProperty("StationServices") List<String> stationServices, | ||
@JsonProperty("StationType") String stationType, | ||
@JsonProperty("SystemAddress") Long systemAddress, | ||
@JsonProperty("Taxi") Boolean taxi, | ||
@JsonProperty("event") String event, | ||
@JsonProperty("horizons") Boolean horizons, | ||
@JsonProperty("odyssey") Boolean odyssey, | ||
@JsonProperty("timestamp") String timestamp | ||
) implements EddnMessage.Payload { | ||
|
||
@JsonProperty(value = "event", access = JsonProperty.Access.READ_ONLY) | ||
public String event() { | ||
return EVENT; | ||
} | ||
|
||
public record LandingPads( | ||
@JsonProperty("Large") Integer large, | ||
@JsonProperty("Medium") Integer medium, | ||
@JsonProperty("Small") Integer small | ||
) { | ||
} | ||
|
||
public record Economy( | ||
@JsonProperty("Name") String name, | ||
@JsonProperty("Proportion") Double proportion | ||
) { | ||
} | ||
|
||
public record Faction( | ||
@JsonProperty("Name") String name, | ||
@JsonProperty("FactionState") String factionState | ||
) { | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/test/java/io/edpn/backend/messageprocessorlib/JournalDockedMessageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.edpn.backend.messageprocessorlib; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.edpn.backend.messageprocessorlib.application.dto.eddn.journal.DockedMessage; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static io.edpn.backend.messageprocessorlib.EddnMessageTestHelper.deserialize; | ||
import static io.edpn.backend.messageprocessorlib.EddnMessageTestHelper.readSampleJsonFiles; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class JournalDockedMessageTest { | ||
|
||
private static final String SAMPLES_DIRECTORY = "data/eddn-observed-messages/journal/1_dir/docked/"; | ||
|
||
@ParameterizedTest | ||
@MethodSource | ||
public void journalDockedMessageV1Deserializes(JsonNode jsonNode) throws JsonProcessingException { | ||
DockedMessage.V1 message = deserialize(jsonNode, DockedMessage.V1.class); | ||
assertNotNull(message); | ||
} | ||
|
||
private static Stream<JsonNode> journalDockedMessageV1Deserializes() { | ||
return readSampleJsonFiles(SAMPLES_DIRECTORY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/test/resources/data/eddn-observed-messages/journal/1_dir/docked/1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"$schemaRef": "https://eddn.edcd.io/schemas/journal/1", | ||
"header": { | ||
"gamebuild": "r297330/r0 ", | ||
"gameversion": "4.0.0.1700", | ||
"gatewayTimestamp": "2023-11-23T21:02:52.541242Z", | ||
"softwareName": "EDDiscovery", | ||
"softwareVersion": "16.2.0.0", | ||
"uploaderID": "a363c3d9ac662a48937942bff76d2d476ec76371" | ||
}, | ||
"message": { | ||
"DistFromStarLS": 829.334255, | ||
"LandingPads": { | ||
"Large": 0, | ||
"Medium": 1, | ||
"Small": 4 | ||
}, | ||
"MarketID": 3229466880, | ||
"StarPos": [ | ||
61.28125, | ||
115.875, | ||
-0.5625 | ||
], | ||
"StarSystem": "Kungkalenja", | ||
"StationEconomies": [ | ||
{ | ||
"Name": "$economy_Industrial;", | ||
"Proportion": 1.0 | ||
} | ||
], | ||
"StationEconomy": "$economy_Industrial;", | ||
"StationFaction": { | ||
"Name": "Kungkalenja Silver Federal Ltd" | ||
}, | ||
"StationGovernment": "$government_Corporate;", | ||
"StationName": "Piaget Hub", | ||
"StationServices": [ | ||
"dock", | ||
"autodock", | ||
"commodities", | ||
"contacts", | ||
"exploration", | ||
"missions", | ||
"outfitting", | ||
"crewlounge", | ||
"rearm", | ||
"refuel", | ||
"engineer", | ||
"missionsgenerated", | ||
"facilitator", | ||
"flightcontroller", | ||
"stationoperations", | ||
"powerplay", | ||
"searchrescue", | ||
"stationMenu", | ||
"livery", | ||
"socialspace", | ||
"bartender", | ||
"pioneersupplies", | ||
"apexinterstellar" | ||
], | ||
"StationType": "Outpost", | ||
"SystemAddress": 2870783452585, | ||
"Taxi": false, | ||
"event": "Docked", | ||
"horizons": true, | ||
"odyssey": true, | ||
"timestamp": "2023-11-23T21:02:47Z" | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/test/resources/data/eddn-observed-messages/journal/1_dir/docked/2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"$schemaRef": "https://eddn.edcd.io/schemas/journal/1", | ||
"header": { | ||
"gamebuild": "r297330/r0 ", | ||
"gameversion": "4.0.0.1700", | ||
"gatewayTimestamp": "2023-11-23T21:02:52.929362Z", | ||
"softwareName": "E:D Market Connector [Windows]", | ||
"softwareVersion": "5.9.5", | ||
"uploaderID": "5e1b20dfcdcd52d9ab5275c04d4413770874e220" | ||
}, | ||
"message": { | ||
"DistFromStarLS": 8924.504273, | ||
"LandingPads": { | ||
"Large": 6, | ||
"Medium": 12, | ||
"Small": 7 | ||
}, | ||
"MarketID": 3226769408, | ||
"Multicrew": false, | ||
"StarPos": [ | ||
-68.59375, | ||
-7.03125, | ||
49.6875 | ||
], | ||
"StarSystem": "Chimba", | ||
"StationAllegiance": "Federation", | ||
"StationEconomies": [ | ||
{ | ||
"Name": "$economy_Refinery;", | ||
"Proportion": 1.0 | ||
} | ||
], | ||
"StationEconomy": "$economy_Refinery;", | ||
"StationFaction": { | ||
"FactionState": "CivilWar", | ||
"Name": "Chimba Public Industries" | ||
}, | ||
"StationGovernment": "$government_Corporate;", | ||
"StationName": "Hurley Port", | ||
"StationServices": [ | ||
"dock", | ||
"autodock", | ||
"commodities", | ||
"contacts", | ||
"exploration", | ||
"missions", | ||
"outfitting", | ||
"crewlounge", | ||
"rearm", | ||
"refuel", | ||
"repair", | ||
"shipyard", | ||
"tuning", | ||
"engineer", | ||
"missionsgenerated", | ||
"flightcontroller", | ||
"stationoperations", | ||
"powerplay", | ||
"searchrescue", | ||
"stationMenu", | ||
"shop", | ||
"livery", | ||
"socialspace", | ||
"bartender", | ||
"vistagenomics", | ||
"pioneersupplies", | ||
"apexinterstellar", | ||
"frontlinesolutions" | ||
], | ||
"StationType": "Orbis", | ||
"SystemAddress": 7266950456761, | ||
"Taxi": false, | ||
"event": "Docked", | ||
"horizons": true, | ||
"odyssey": true, | ||
"timestamp": "2023-11-23T21:02:52Z" | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/test/resources/data/eddn-observed-messages/journal/1_dir/docked/3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"$schemaRef": "https://eddn.edcd.io/schemas/journal/1", | ||
"header": { | ||
"gamebuild": "r297330/r0 ", | ||
"gameversion": "4.0.0.1700", | ||
"gatewayTimestamp": "2023-11-23T21:02:53.351460Z", | ||
"softwareName": "EDO Materials Helper", | ||
"softwareVersion": "2.44", | ||
"uploaderID": "37bcdf85deeb91c7e3bac76bfd1d7779845f7cf3" | ||
}, | ||
"message": { | ||
"DistFromStarLS": 18.709711, | ||
"LandingPads": { | ||
"Large": 8, | ||
"Medium": 4, | ||
"Small": 4 | ||
}, | ||
"MarketID": 3708440320, | ||
"StarPos": [ | ||
-43.375, | ||
1.0, | ||
-15.125 | ||
], | ||
"StarSystem": "LFT 1748", | ||
"StationEconomies": [ | ||
{ | ||
"Name": "$economy_Carrier;", | ||
"Proportion": 1.0 | ||
} | ||
], | ||
"StationEconomy": "$economy_Carrier;", | ||
"StationFaction": { | ||
"Name": "FleetCarrier" | ||
}, | ||
"StationGovernment": "$government_Carrier;", | ||
"StationName": "TBB-0TJ", | ||
"StationServices": [ | ||
"dock", | ||
"autodock", | ||
"commodities", | ||
"contacts", | ||
"exploration", | ||
"crewlounge", | ||
"rearm", | ||
"refuel", | ||
"repair", | ||
"engineer", | ||
"flightcontroller", | ||
"stationoperations", | ||
"stationMenu", | ||
"carriermanagement", | ||
"carrierfuel", | ||
"voucherredemption", | ||
"socialspace", | ||
"bartender", | ||
"vistagenomics", | ||
"pioneersupplies" | ||
], | ||
"StationType": "FleetCarrier", | ||
"SystemAddress": 22660650182049, | ||
"event": "Docked", | ||
"horizons": true, | ||
"odyssey": true, | ||
"timestamp": "2023-11-23T21:02:36Z" | ||
} | ||
} |
Oops, something went wrong.