mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-02 22:47:37 +01:00
parent
7de29e72f9
commit
a884e056a6
@ -17,11 +17,13 @@
|
|||||||
"hong kong": "HKG",
|
"hong kong": "HKG",
|
||||||
"armenia": "ARM",
|
"armenia": "ARM",
|
||||||
"vietnam": "VNM",
|
"vietnam": "VNM",
|
||||||
|
"vatican city": "VAT",
|
||||||
"australia": "AUS",
|
"australia": "AUS",
|
||||||
"laos": "LAO",
|
"laos": "LAO",
|
||||||
"aruba": "ABW",
|
"aruba": "ABW",
|
||||||
"solomon islands": "SLB",
|
"solomon islands": "SLB",
|
||||||
"turkey": "TUR",
|
"turkey": "TUR",
|
||||||
|
"türkiye": "TUR",
|
||||||
"ukraine": "UKR",
|
"ukraine": "UKR",
|
||||||
"austria": "AUT",
|
"austria": "AUT",
|
||||||
"united states": "USA",
|
"united states": "USA",
|
||||||
@ -33,7 +35,8 @@
|
|||||||
"greece": "GRC",
|
"greece": "GRC",
|
||||||
"paraguay": "PRY",
|
"paraguay": "PRY",
|
||||||
"palau": "PLW",
|
"palau": "PLW",
|
||||||
"congo, republic of the": "COG",
|
"congo republic": "COD",
|
||||||
|
"dr congo": "COG",
|
||||||
"vanuatu": "VUT",
|
"vanuatu": "VUT",
|
||||||
"cyprus": "CYP",
|
"cyprus": "CYP",
|
||||||
"colombia": "COL",
|
"colombia": "COL",
|
||||||
@ -93,6 +96,7 @@
|
|||||||
"zimbabwe": "ZWE",
|
"zimbabwe": "ZWE",
|
||||||
"el salvador": "SLV",
|
"el salvador": "SLV",
|
||||||
"macedonia": "MKD",
|
"macedonia": "MKD",
|
||||||
|
"north macedonia": "MKD",
|
||||||
"saint lucia": "LCA",
|
"saint lucia": "LCA",
|
||||||
"bolivia": "BOL",
|
"bolivia": "BOL",
|
||||||
"china": "CHN",
|
"china": "CHN",
|
||||||
@ -187,6 +191,7 @@
|
|||||||
"tanzania": "TZA",
|
"tanzania": "TZA",
|
||||||
"grenada": "GRD",
|
"grenada": "GRD",
|
||||||
"netherlands": "NLD",
|
"netherlands": "NLD",
|
||||||
|
"the netherlands": "NLD",
|
||||||
"sao tome and principe": "STP",
|
"sao tome and principe": "STP",
|
||||||
"guam": "GUM",
|
"guam": "GUM",
|
||||||
"eritrea": "ERI",
|
"eritrea": "ERI",
|
||||||
@ -221,5 +226,30 @@
|
|||||||
"saint vincent and the grenadines": "VCT",
|
"saint vincent and the grenadines": "VCT",
|
||||||
"tonga": "TON",
|
"tonga": "TON",
|
||||||
"barbados": "BRB",
|
"barbados": "BRB",
|
||||||
"new caledonia": "NCL"
|
"new caledonia": "NCL",
|
||||||
|
"réunion": "REU",
|
||||||
|
"mayotte": "MYT",
|
||||||
|
"martinique": "MTQ",
|
||||||
|
"guadeloupe": "GLP",
|
||||||
|
"french guiana": "GUF",
|
||||||
|
"eswatini": "SWZ",
|
||||||
|
"cocos (keeling) islands": "CCK",
|
||||||
|
"macao": "MAC",
|
||||||
|
"st kitts and nevis": "KNA",
|
||||||
|
"saint barthélemy": "BLM",
|
||||||
|
"st vincent and grenadines": "VCT",
|
||||||
|
"bahamas": "BHS",
|
||||||
|
"myanmar": "MMR",
|
||||||
|
"tokelau": "TKL",
|
||||||
|
"wallis and futuna": "WLF",
|
||||||
|
"ivory coast": "CIV",
|
||||||
|
"côte d'ivoire": "CIV",
|
||||||
|
"gambia": "GMB",
|
||||||
|
"nauru": "NRU",
|
||||||
|
"federated states of micronesia": "FSM",
|
||||||
|
"curaçao": "CUW",
|
||||||
|
"são tomé and príncipe": "STP",
|
||||||
|
"turks and caicos islands": "TCA",
|
||||||
|
"norfolk island": "NFK",
|
||||||
|
"pitcairn islands": "PCN"
|
||||||
}
|
}
|
||||||
|
@ -17,28 +17,34 @@
|
|||||||
package com.djrapitops.plan.gathering.geolocation;
|
package com.djrapitops.plan.gathering.geolocation;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanSystem;
|
import com.djrapitops.plan.PlanSystem;
|
||||||
|
import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||||
import com.djrapitops.plan.processing.Processing;
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.settings.ConfigSystem;
|
import com.djrapitops.plan.settings.ConfigSystem;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
import extension.FullSystemExtension;
|
import extension.FullSystemExtension;
|
||||||
import net.playeranalytics.plugin.server.PluginLogger;
|
import net.playeranalytics.plugin.server.PluginLogger;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.*;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import utilities.TestErrorLogger;
|
import utilities.TestErrorLogger;
|
||||||
import utilities.TestPluginLogger;
|
import utilities.TestPluginLogger;
|
||||||
|
import utilities.TestResources;
|
||||||
import utilities.mocks.TestProcessing;
|
import utilities.mocks.TestProcessing;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.HashMap;
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@ -118,4 +124,38 @@ class GeolocationTest {
|
|||||||
assertEquals(expIp, countryThirdCall);
|
assertEquals(expIp, countryThirdCall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test utility for reading https://cable.ayra.ch/ip/data/countries.json for getting first IP of each country
|
||||||
|
// Have to manually remove 3 first ones and the IPv6 addresses at the end.
|
||||||
|
public static void main(String[] args) throws URISyntaxException, IOException {
|
||||||
|
File testResourceFile = TestResources.getTestResourceFile("countries.json", GeolocationTest.class);
|
||||||
|
String read = Files.readString(testResourceFile.toPath());
|
||||||
|
Map<String, Map<String, List<String>>> contents = new Gson().fromJson(new StringReader(read), new TypeToken<>() {}.getType());
|
||||||
|
List<String> singleIpPerCountry = contents.values().stream()
|
||||||
|
.map(Map::values)
|
||||||
|
.map(set -> set.stream().findFirst())
|
||||||
|
.filter(Optional::isPresent)
|
||||||
|
.map(Optional::get)
|
||||||
|
.map(list -> list.get(0))
|
||||||
|
.map(string -> string.split("/")[0])
|
||||||
|
.toList();
|
||||||
|
Path write = new File("src/test/resources/countries-reduced.txt").toPath();
|
||||||
|
Files.write(write, singleIpPerCountry, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestFactory
|
||||||
|
@DisplayName("Country has geocode")
|
||||||
|
Collection<DynamicTest> everyCountryHasCodeInGeocodesJson(Graphs graphs) throws URISyntaxException, IOException {
|
||||||
|
Map<String, String> geocodes = graphs.special().getGeocodes();
|
||||||
|
File testResourceFile = TestResources.getTestResourceFile("countries-reduced.txt", GeolocationTest.class);
|
||||||
|
try (Stream<String> lines = Files.lines(testResourceFile.toPath())) {
|
||||||
|
return lines
|
||||||
|
.map(underTest::getCountry)
|
||||||
|
.distinct()
|
||||||
|
.map(country -> DynamicTest.dynamicTest(country, () -> {
|
||||||
|
assertTrue(geocodes.containsKey(country.toLowerCase()),
|
||||||
|
() -> "Country '" + country + "' had no geocode associated with it.");
|
||||||
|
})).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.commands.PlanCommand;
|
|||||||
import com.djrapitops.plan.delivery.DeliveryUtilities;
|
import com.djrapitops.plan.delivery.DeliveryUtilities;
|
||||||
import com.djrapitops.plan.delivery.export.Exporter;
|
import com.djrapitops.plan.delivery.export.Exporter;
|
||||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||||
|
import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||||
import com.djrapitops.plan.identification.ServerUUID;
|
import com.djrapitops.plan.identification.ServerUUID;
|
||||||
import com.djrapitops.plan.settings.ConfigSystem;
|
import com.djrapitops.plan.settings.ConfigSystem;
|
||||||
@ -89,6 +90,7 @@ public class FullSystemExtension implements ParameterResolver, BeforeAllCallback
|
|||||||
.put(PublicHtmlFiles.class, () -> planSystem.getDeliveryUtilities().getPublicHtmlFiles())
|
.put(PublicHtmlFiles.class, () -> planSystem.getDeliveryUtilities().getPublicHtmlFiles())
|
||||||
.put(Webserver.class, () -> planSystem.getWebServerSystem().getWebServer())
|
.put(Webserver.class, () -> planSystem.getWebServerSystem().getWebServer())
|
||||||
.put(Exporter.class, () -> planSystem.getExportSystem().getExporter())
|
.put(Exporter.class, () -> planSystem.getExportSystem().getExporter())
|
||||||
|
.put(Graphs.class, () -> planSystem.getDeliveryUtilities().getGraphs())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
240
Plan/common/src/test/resources/countries-reduced.txt
Normal file
240
Plan/common/src/test/resources/countries-reduced.txt
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
1.0.16.0
|
||||||
|
1.0.128.0
|
||||||
|
1.6.0.0
|
||||||
|
1.9.0.0
|
||||||
|
1.11.0.0
|
||||||
|
1.21.224.0
|
||||||
|
1.32.192.0
|
||||||
|
1.32.208.0
|
||||||
|
1.32.232.0
|
||||||
|
1.32.252.0
|
||||||
|
1.37.0.0
|
||||||
|
1.52.0.0
|
||||||
|
1.178.32.0
|
||||||
|
1.178.48.0
|
||||||
|
1.178.0.0
|
||||||
|
1.178.224.0
|
||||||
|
1.179.112.0
|
||||||
|
1.186.0.0
|
||||||
|
2.16.1.0
|
||||||
|
2.16.2.0
|
||||||
|
2.16.0.0
|
||||||
|
2.16.6.0
|
||||||
|
2.16.12.0
|
||||||
|
2.16.16.0
|
||||||
|
2.16.17.0
|
||||||
|
2.16.19.0
|
||||||
|
2.16.20.0
|
||||||
|
2.16.23.0
|
||||||
|
2.16.36.0
|
||||||
|
2.16.44.0
|
||||||
|
2.16.57.0
|
||||||
|
2.16.63.0
|
||||||
|
2.16.65.0
|
||||||
|
2.16.77.0
|
||||||
|
2.16.109.0
|
||||||
|
2.16.134.0
|
||||||
|
2.16.150.0
|
||||||
|
2.16.171.0
|
||||||
|
2.16.172.0
|
||||||
|
2.17.24.0
|
||||||
|
2.17.116.0
|
||||||
|
2.17.161.0
|
||||||
|
2.17.172.0
|
||||||
|
2.17.248.0
|
||||||
|
2.17.249.0
|
||||||
|
2.17.250.0
|
||||||
|
2.18.11.0
|
||||||
|
2.18.172.0
|
||||||
|
2.18.250.0
|
||||||
|
2.20.45.0
|
||||||
|
2.20.52.0
|
||||||
|
2.21.89.0
|
||||||
|
2.21.128.0
|
||||||
|
2.22.72.0
|
||||||
|
2.23.168.0
|
||||||
|
2.56.0.0
|
||||||
|
2.56.10.0
|
||||||
|
2.56.36.0
|
||||||
|
2.56.112.0
|
||||||
|
2.56.141.0
|
||||||
|
2.56.228.0
|
||||||
|
2.56.243.0
|
||||||
|
2.56.253.0
|
||||||
|
2.57.3.0
|
||||||
|
2.57.60.0
|
||||||
|
2.57.64.0
|
||||||
|
2.57.96.0
|
||||||
|
2.57.236.0
|
||||||
|
2.57.241.0
|
||||||
|
2.58.32.0
|
||||||
|
2.58.76.0
|
||||||
|
2.58.171.0
|
||||||
|
2.59.52.0
|
||||||
|
2.59.131.0
|
||||||
|
2.109.72.0
|
||||||
|
3.2.56.0
|
||||||
|
3.5.36.0
|
||||||
|
5.0.0.0
|
||||||
|
5.8.128.0
|
||||||
|
5.10.250.0
|
||||||
|
5.11.12.0
|
||||||
|
5.22.160.0
|
||||||
|
5.32.136.0
|
||||||
|
5.32.176.0
|
||||||
|
5.34.248.0
|
||||||
|
5.35.160.0
|
||||||
|
5.43.64.0
|
||||||
|
5.44.32.0
|
||||||
|
5.53.0.0
|
||||||
|
5.57.8.0
|
||||||
|
5.57.96.0
|
||||||
|
5.62.82.0
|
||||||
|
5.62.84.0
|
||||||
|
5.62.92.0
|
||||||
|
5.63.0.0
|
||||||
|
5.83.210.0
|
||||||
|
5.100.160.0
|
||||||
|
5.100.192.0
|
||||||
|
5.101.221.0
|
||||||
|
5.102.72.0
|
||||||
|
5.102.73.0
|
||||||
|
5.102.74.0
|
||||||
|
5.102.77.0
|
||||||
|
5.102.79.0
|
||||||
|
5.157.88.0
|
||||||
|
5.175.76.0
|
||||||
|
5.175.77.0
|
||||||
|
5.182.132.0
|
||||||
|
5.182.185.0
|
||||||
|
5.182.196.0
|
||||||
|
5.182.197.0
|
||||||
|
5.252.112.0
|
||||||
|
5.253.184.0
|
||||||
|
8.3.112.0
|
||||||
|
8.3.127.0
|
||||||
|
8.10.6.0
|
||||||
|
8.35.57.0
|
||||||
|
8.51.10.0
|
||||||
|
8.51.52.0
|
||||||
|
8.242.196.0
|
||||||
|
12.24.141.0
|
||||||
|
12.144.82.0
|
||||||
|
12.174.244.0
|
||||||
|
14.0.59.0
|
||||||
|
14.1.69.0
|
||||||
|
14.1.70.0
|
||||||
|
14.1.71.0
|
||||||
|
14.1.77.0
|
||||||
|
14.1.91.0
|
||||||
|
14.1.104.0
|
||||||
|
14.137.32.0
|
||||||
|
14.137.34.0
|
||||||
|
14.137.38.0
|
||||||
|
14.137.40.0
|
||||||
|
14.137.50.0
|
||||||
|
14.137.53.0
|
||||||
|
17.91.136.0
|
||||||
|
17.118.52.0
|
||||||
|
17.118.108.0
|
||||||
|
17.118.208.0
|
||||||
|
23.3.72.0
|
||||||
|
23.26.124.0
|
||||||
|
23.88.192.0
|
||||||
|
23.130.168.0
|
||||||
|
23.130.224.0
|
||||||
|
23.131.208.0
|
||||||
|
23.132.144.0
|
||||||
|
23.135.232.0
|
||||||
|
23.170.80.0
|
||||||
|
23.185.48.0
|
||||||
|
23.186.240.0
|
||||||
|
23.188.0.0
|
||||||
|
23.199.72.0
|
||||||
|
23.205.124.0
|
||||||
|
23.230.33.0
|
||||||
|
23.230.49.0
|
||||||
|
23.236.0.0
|
||||||
|
24.92.144.0
|
||||||
|
24.152.40.0
|
||||||
|
24.152.52.0
|
||||||
|
24.155.28.0
|
||||||
|
27.96.24.0
|
||||||
|
27.114.128.0
|
||||||
|
27.122.0.0
|
||||||
|
27.125.192.0
|
||||||
|
31.6.16.0
|
||||||
|
31.193.32.0
|
||||||
|
31.217.248.0
|
||||||
|
31.220.0.0
|
||||||
|
34.99.136.0
|
||||||
|
34.99.172.0
|
||||||
|
37.18.44.0
|
||||||
|
37.98.152.0
|
||||||
|
37.120.252.0
|
||||||
|
38.7.12.0
|
||||||
|
38.44.64.0
|
||||||
|
38.51.240.0
|
||||||
|
38.182.69.0
|
||||||
|
38.182.88.0
|
||||||
|
38.199.128.0
|
||||||
|
41.57.64.0
|
||||||
|
41.57.80.0
|
||||||
|
41.62.0.0
|
||||||
|
41.63.128.0
|
||||||
|
41.63.160.0
|
||||||
|
41.63.192.0
|
||||||
|
41.67.0.0
|
||||||
|
41.70.0.0
|
||||||
|
41.74.0.0
|
||||||
|
41.74.160.0
|
||||||
|
41.75.64.0
|
||||||
|
41.76.8.0
|
||||||
|
41.76.16.0
|
||||||
|
41.76.40.0
|
||||||
|
41.77.184.0
|
||||||
|
41.78.48.0
|
||||||
|
41.78.72.0
|
||||||
|
41.78.84.0
|
||||||
|
41.78.116.0
|
||||||
|
41.78.120.0
|
||||||
|
41.78.136.0
|
||||||
|
41.78.240.0
|
||||||
|
41.79.48.0
|
||||||
|
41.82.0.0
|
||||||
|
41.96.0.0
|
||||||
|
41.109.117.0
|
||||||
|
41.138.128.0
|
||||||
|
41.189.224.0
|
||||||
|
41.194.32.0
|
||||||
|
41.194.34.0
|
||||||
|
41.218.0.0
|
||||||
|
43.230.6.0
|
||||||
|
43.248.156.0
|
||||||
|
43.249.176.0
|
||||||
|
45.11.242.0
|
||||||
|
45.11.243.0
|
||||||
|
45.42.144.0
|
||||||
|
45.68.20.0
|
||||||
|
45.71.156.0
|
||||||
|
49.156.48.0
|
||||||
|
57.70.176.0
|
||||||
|
57.70.178.0
|
||||||
|
57.70.184.0
|
||||||
|
57.73.214.0
|
||||||
|
57.74.102.0
|
||||||
|
57.74.110.0
|
||||||
|
57.82.64.0
|
||||||
|
57.82.118.0
|
||||||
|
57.82.120.0
|
||||||
|
57.82.162.0
|
||||||
|
57.90.150.0
|
||||||
|
62.208.74.0
|
||||||
|
64.110.148.0
|
||||||
|
65.255.48.0
|
||||||
|
72.252.8.0
|
||||||
|
80.78.16.0
|
||||||
|
103.43.204.0
|
||||||
|
103.208.84.0
|
||||||
|
104.255.176.0
|
||||||
|
206.83.126.0
|
Loading…
Reference in New Issue
Block a user