1919import com .djrapitops .plan .PlanSystem ;
2020import com .djrapitops .plan .delivery .domain .ServerIdentifier ;
2121import com .djrapitops .plan .gathering .domain .*;
22+ import com .djrapitops .plan .gathering .domain .builders .TPSBuilder ;
23+ import com .djrapitops .plan .identification .Server ;
2224import com .djrapitops .plan .identification .ServerUUID ;
2325import com .djrapitops .plan .storage .database .Database ;
26+ import com .djrapitops .plan .storage .database .transactions .StoreServerInformationTransaction ;
2427import com .djrapitops .plan .storage .database .transactions .events .StoreServerPlayerTransaction ;
2528import com .djrapitops .plan .storage .database .transactions .events .StoreSessionTransaction ;
2629import com .djrapitops .plan .storage .database .transactions .events .StoreWorldNameTransaction ;
30+ import com .djrapitops .plan .storage .database .transactions .events .TPSStoreTransaction ;
2731import org .junit .jupiter .api .*;
2832import org .junit .jupiter .api .io .TempDir ;
33+ import utilities .DBPreparer ;
2934import utilities .RandomData ;
3035import utilities .TestConstants ;
3136import utilities .dagger .PlanPluginComponent ;
@@ -235,4 +240,62 @@ private void storeKillers() throws ExecutionException, InterruptedException {
235240 .get ();
236241 }
237242 }
243+
244+ @ Test
245+ void networkPlayersOnlineGraphDisplaysDataSingleProxy () {
246+ Database database = component .system ().getDatabaseSystem ().getDatabase ();
247+ database .executeTransaction (new StoreServerInformationTransaction (new Server (-1 , TestConstants .SERVER_UUID , TestConstants .SERVER_NAME , "" , false , TestConstants .VERSION )));
248+ database .executeTransaction (new StoreServerInformationTransaction (new Server (-1 , TestConstants .SERVER_TWO_UUID , TestConstants .SERVER_TWO_NAME , "" , true , TestConstants .VERSION )));
249+ database .executeTransaction (new TPSStoreTransaction (TestConstants .SERVER_UUID , TPSBuilder .get ()
250+ .playersOnline (1 )
251+ .date (System .currentTimeMillis ())
252+ .toTPS ()));
253+ database .executeTransaction (new TPSStoreTransaction (TestConstants .SERVER_TWO_UUID , TPSBuilder .get ()
254+ .playersOnline (2 )
255+ .date (System .currentTimeMillis ())
256+ .toTPS ()));
257+
258+ DBPreparer .awaitUntilTransactionsComplete (database );
259+ String value = underTest .onPlaceholderRequest (TestConstants .PLAYER_ONE_UUID , "network_players_online" , List .of ());
260+ assertEquals ("2" , value );
261+ }
262+
263+ @ Test
264+ void networkPlayersOnlineGraphDisplaysDataTwoProxies () {
265+ Database database = component .system ().getDatabaseSystem ().getDatabase ();
266+ database .executeTransaction (new StoreServerInformationTransaction (new Server (-1 , TestConstants .SERVER_UUID , TestConstants .SERVER_NAME , "" , true , TestConstants .VERSION )));
267+ database .executeTransaction (new StoreServerInformationTransaction (new Server (-1 , TestConstants .SERVER_TWO_UUID , TestConstants .SERVER_TWO_NAME , "" , true , TestConstants .VERSION )));
268+ database .executeTransaction (new TPSStoreTransaction (TestConstants .SERVER_UUID , TPSBuilder .get ()
269+ .playersOnline (1 )
270+ .date (System .currentTimeMillis ())
271+ .toTPS ()));
272+ database .executeTransaction (new TPSStoreTransaction (TestConstants .SERVER_TWO_UUID , TPSBuilder .get ()
273+ .playersOnline (2 )
274+ .date (System .currentTimeMillis ())
275+ .toTPS ()));
276+
277+ DBPreparer .awaitUntilTransactionsComplete (database );
278+
279+ String value = underTest .onPlaceholderRequest (TestConstants .PLAYER_ONE_UUID , "network_players_online" , List .of ());
280+ assertEquals ("3" , value );
281+ }
282+
283+ @ Test
284+ void networkPlayersOnlineGraphDisplaysDataNoProxies () {
285+ Database database = component .system ().getDatabaseSystem ().getDatabase ();
286+ database .executeTransaction (new StoreServerInformationTransaction (new Server (-1 , TestConstants .SERVER_UUID , TestConstants .SERVER_NAME , "" , false , TestConstants .VERSION )));
287+ database .executeTransaction (new StoreServerInformationTransaction (new Server (-1 , TestConstants .SERVER_TWO_UUID , TestConstants .SERVER_TWO_NAME , "" , false , TestConstants .VERSION )));
288+ database .executeTransaction (new TPSStoreTransaction (TestConstants .SERVER_UUID , TPSBuilder .get ()
289+ .playersOnline (1 )
290+ .date (System .currentTimeMillis ())
291+ .toTPS ()));
292+ database .executeTransaction (new TPSStoreTransaction (TestConstants .SERVER_TWO_UUID , TPSBuilder .get ()
293+ .playersOnline (2 )
294+ .date (System .currentTimeMillis ())
295+ .toTPS ()));
296+ DBPreparer .awaitUntilTransactionsComplete (database );
297+
298+ String value = underTest .onPlaceholderRequest (TestConstants .PLAYER_ONE_UUID , "network_players_online" , List .of ());
299+ assertEquals ("3" , value );
300+ }
238301}
0 commit comments