Search in sources :

Example 1 with UserInfo

use of com.djrapitops.plan.gathering.domain.UserInfo in project Plan by plan-player-analytics.

the class UserInfoQueriesTest method userInfoTableStoresCorrectUserInformation.

@Test
default void userInfoTableStoresCorrectUserInformation() {
    assertFalse(db().query(BaseUserQueries.fetchBaseUserOfPlayer(playerUUID)).isPresent());
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    Set<UserInfo> userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
    Set<UserInfo> expected = Collections.singleton(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false));
    assertEquals(expected, userInfo);
}
Also used : UserInfo(com.djrapitops.plan.gathering.domain.UserInfo) Test(org.junit.jupiter.api.Test)

Example 2 with UserInfo

use of com.djrapitops.plan.gathering.domain.UserInfo in project Plan by plan-player-analytics.

the class UserInfoQueriesTest method joinAddressIsUpdatedUponSecondLogin.

@Test
default void joinAddressIsUpdatedUponSecondLogin() {
    assertFalse(db().query(BaseUserQueries.fetchBaseUserOfPlayer(playerUUID)).isPresent());
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), () -> null));
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    Set<UserInfo> userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
    Set<UserInfo> expected = Collections.singleton(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false));
    assertEquals(expected, userInfo);
}
Also used : UserInfo(com.djrapitops.plan.gathering.domain.UserInfo) Test(org.junit.jupiter.api.Test)

Example 3 with UserInfo

use of com.djrapitops.plan.gathering.domain.UserInfo in project Plan by plan-player-analytics.

the class UserInfoQueriesTest method userInfoTableUpdatesBanStatus.

@Test
default void userInfoTableUpdatesBanStatus() {
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    db().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID(), () -> true));
    Set<UserInfo> userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
    Set<UserInfo> expected = Collections.singleton(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, TestConstants.GET_PLAYER_HOSTNAME.get(), true));
    assertEquals(expected, userInfo);
}
Also used : UserInfo(com.djrapitops.plan.gathering.domain.UserInfo) Test(org.junit.jupiter.api.Test)

Example 4 with UserInfo

use of com.djrapitops.plan.gathering.domain.UserInfo in project Plan by plan-player-analytics.

the class UserInfoQueriesTest method cleanRemovesOnlyDuplicatedUserInfo.

@Test
default void cleanRemovesOnlyDuplicatedUserInfo() throws ExecutionException, InterruptedException {
    // Store one duplicate
    db().executeTransaction(new Transaction() {

        @Override
        protected void performOperations() {
            execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
            execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
            execute(DataStoreQueries.registerUserInfo(player2UUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
        }
    }).get();
    db().executeTransaction(new RemoveDuplicateUserInfoTransaction());
    Set<UserInfo> found = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
    assertEquals(Collections.singleton(new UserInfo(playerUUID, serverUUID(), 0, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false)), found);
    Set<UserInfo> found2 = db().query(UserInfoQueries.fetchUserInformationOfUser(player2UUID));
    assertEquals(Collections.singleton(new UserInfo(player2UUID, serverUUID(), 0, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false)), found2);
}
Also used : Transaction(com.djrapitops.plan.storage.database.transactions.Transaction) RemoveDuplicateUserInfoTransaction(com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) RemoveDuplicateUserInfoTransaction(com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction) UserInfo(com.djrapitops.plan.gathering.domain.UserInfo) Test(org.junit.jupiter.api.Test)

Example 5 with UserInfo

use of com.djrapitops.plan.gathering.domain.UserInfo in project Plan by plan-player-analytics.

the class UserInfoQueriesTest method joinAddressCanBeNull.

@Test
default void joinAddressCanBeNull() {
    assertFalse(db().query(BaseUserQueries.fetchBaseUserOfPlayer(playerUUID)).isPresent());
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), () -> null));
    Set<UserInfo> userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
    Set<UserInfo> expected = Collections.singleton(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, null, false));
    assertEquals(expected, userInfo);
}
Also used : UserInfo(com.djrapitops.plan.gathering.domain.UserInfo) Test(org.junit.jupiter.api.Test)

Aggregations

UserInfo (com.djrapitops.plan.gathering.domain.UserInfo)10 Test (org.junit.jupiter.api.Test)7 ServerUUID (com.djrapitops.plan.identification.ServerUUID)3 ResultSet (java.sql.ResultSet)3 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)2 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)2 PreparedStatement (java.sql.PreparedStatement)2 Server (com.djrapitops.plan.identification.Server)1 QueryAllStatement (com.djrapitops.plan.storage.database.queries.QueryAllStatement)1 Transaction (com.djrapitops.plan.storage.database.transactions.Transaction)1 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)1 RemoveDuplicateUserInfoTransaction (com.djrapitops.plan.storage.database.transactions.init.RemoveDuplicateUserInfoTransaction)1 Lists (com.djrapitops.plan.utilities.java.Lists)1