Skip to content

Commit

Permalink
#134 (ed-pilots-network/backend#134) adding JournalDocked Message
Browse files Browse the repository at this point in the history
  • Loading branch information
pveeckhout committed Nov 23, 2023
1 parent 91cc1bf commit 3e779f5
Show file tree
Hide file tree
Showing 17 changed files with 615 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repositories {
}

ext {
backendUtilVersion = '0.0.3-SNAPSHOT'
backendUtilVersion = '0.0.4-SNAPSHOT'
jacksonVersion = '2.14.2'
junitJupiterVersion = "5.9.3"
}
Expand Down
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
) {
}
}
}
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

public class JournalScanMessageTest {

private static final String SAMPLES_DIRECTORY = "data/eddn-observed-messages/journal/scan/";
private static final String SAMPLES_DIRECTORY = "data/eddn-observed-messages/journal/1_dir/scan/";

@ParameterizedTest
@MethodSource
public void fssSignalDiscoveredMessageV1Deserializes(JsonNode jsonNode) throws JsonProcessingException {
public void journalScanMessageV1Deserializes(JsonNode jsonNode) throws JsonProcessingException {
ScanMessage.V1 message = deserialize(jsonNode, ScanMessage.V1.class);
assertNotNull(message);
}

private static Stream<JsonNode> fssSignalDiscoveredMessageV1Deserializes() {
private static Stream<JsonNode> journalScanMessageV1Deserializes() {
return readSampleJsonFiles(SAMPLES_DIRECTORY);
}
}
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"
}
}
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"
}
}
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"
}
}
Loading

0 comments on commit 3e779f5

Please sign in to comment.