From 6324a2621c88c27d43ff85c5c3094a2e277cbdbd Mon Sep 17 00:00:00 2001 From: dernasherbrezon Date: Sun, 24 Nov 2024 22:16:53 +0000 Subject: [PATCH] transparently load tle source from leosatdata --- src/main/java/ru/r2cloud/cloud/LeoSatDataClient.java | 5 ++++- src/test/java/ru/r2cloud/cloud/LeoSatDataClientTest.java | 1 + src/test/resources/r2cloudclienttest/newlaunch.json | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/r2cloud/cloud/LeoSatDataClient.java b/src/main/java/ru/r2cloud/cloud/LeoSatDataClient.java index 1164c3fd..39e7eaef 100644 --- a/src/main/java/ru/r2cloud/cloud/LeoSatDataClient.java +++ b/src/main/java/ru/r2cloud/cloud/LeoSatDataClient.java @@ -361,7 +361,10 @@ private Tle readTle(JsonValue tle) { Tle result = new Tle(new String[] { line1, line2, line3 }); // assume downloaded TLE is always fresh result.setLastUpdateTime(clock.millis()); - result.setSource(hostname); + result.setSource(tleObj.getString("source", null)); + if (result.getSource() == null) { + result.setSource(hostname); + } return result; } diff --git a/src/test/java/ru/r2cloud/cloud/LeoSatDataClientTest.java b/src/test/java/ru/r2cloud/cloud/LeoSatDataClientTest.java index a35601f5..64c56017 100644 --- a/src/test/java/ru/r2cloud/cloud/LeoSatDataClientTest.java +++ b/src/test/java/ru/r2cloud/cloud/LeoSatDataClientTest.java @@ -176,6 +176,7 @@ public void testLoadNewLaunch() throws Exception { List result = client.loadNewLaunches(0); assertEquals(2, result.size()); assertSatellite("LUCKY-7", true, result.get(0)); + assertEquals("Satellite team", result.get(0).getTle().getSource()); // by default all enabled assertSatellite("PAINANI 1", true, result.get(1)); } diff --git a/src/test/resources/r2cloudclienttest/newlaunch.json b/src/test/resources/r2cloudclienttest/newlaunch.json index b329d4fc..dcb8a1be 100644 --- a/src/test/resources/r2cloudclienttest/newlaunch.json +++ b/src/test/resources/r2cloudclienttest/newlaunch.json @@ -19,7 +19,8 @@ "tle": { "line1": "LUCKY-7", "line2": "1 44406U 19038W 20069.88080907 .00000505 00000-0 32890-4 0 9992", - "line3": "2 44406 97.5270 32.5584 0026284 107.4758 252.9348 15.12089395 37524" + "line3": "2 44406 97.5270 32.5584 0026284 107.4758 252.9348 15.12089395 37524", + "source": "Satellite team" }, "start": 1639300332000, "end": 1639386732000