mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Fixed error in serverPreferencePieValuesAreCorrect test
This commit is contained in:
parent
25e98ef7b5
commit
ae4fb0c98e
@ -746,12 +746,12 @@ public class SessionQueries {
|
||||
String sql = SELECT +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime," +
|
||||
"s." + ServerTable.SERVER_ID + ',' +
|
||||
ServerTable.NAME +
|
||||
"s." + ServerTable.NAME +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
INNER_JOIN + ServerTable.TABLE_NAME + " s on s." + ServerTable.SERVER_UUID + '=' + SessionsTable.TABLE_NAME + '.' + SessionsTable.SERVER_UUID +
|
||||
WHERE + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?" +
|
||||
GROUP_BY + ServerTable.NAME;
|
||||
GROUP_BY + "s." + ServerTable.SERVER_ID;
|
||||
return new QueryStatement<Map<String, Long>>(sql, 100) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.storage.database.transactions.Transaction;
|
||||
import utilities.TestConstants;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public interface DatabaseTestPreparer {
|
||||
|
||||
@ -57,17 +58,25 @@ public interface DatabaseTestPreparer {
|
||||
}
|
||||
|
||||
default void execute(Executable executable) {
|
||||
db().executeTransaction(new Transaction() {
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
execute(executable);
|
||||
}
|
||||
});
|
||||
try {
|
||||
db().executeTransaction(new Transaction() {
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
execute(executable);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
default void executeTransactions(Transaction... transactions) {
|
||||
for (Transaction transaction : transactions) {
|
||||
db().executeTransaction(transaction);
|
||||
try {
|
||||
db().executeTransaction(transaction).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,11 +328,14 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
@Test
|
||||
default void serverPreferencePieValuesAreCorrect() {
|
||||
prepareForSessionSave();
|
||||
List<Session> server1Sessions = RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
server1Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session)));
|
||||
|
||||
UUID serverTwoUuid = TestConstants.SERVER_TWO_UUID;
|
||||
executeTransactions(new StoreServerInformationTransaction(new Server(serverTwoUuid, TestConstants.SERVER_TWO_NAME, "")));
|
||||
List<Session> server1Sessions = RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[1]));
|
||||
List<Session> server2Sessions = RandomData.randomSessions(serverTwoUuid, worlds, playerUUID, player2UUID);
|
||||
server1Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session)));
|
||||
server2Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session)));
|
||||
|
||||
Map<String, Long> expected = Maps.builder(String.class, Long.class)
|
||||
|
Loading…
Reference in New Issue
Block a user