use of com.djrapitops.plan.storage.database.transactions.patches.Patch in project Plan by plan-player-analytics.
the class DBPatchRegressionTest method assertPatchesHaveBeenApplied.
void assertPatchesHaveBeenApplied(Patch[] patches) {
List<String> failed = new ArrayList<>();
for (Patch patch : patches) {
if (!patch.isApplied()) {
System.out.println("! NOT APPLIED: " + patch.getClass().getSimpleName());
failed.add(patch.getClass().getSimpleName());
} else {
System.out.println(" WAS APPLIED: " + patch.getClass().getSimpleName());
}
}
assertTrue(failed.isEmpty(), "Patches " + failed + " were not applied properly.");
}
use of com.djrapitops.plan.storage.database.transactions.patches.Patch in project Plan by plan-player-analytics.
the class MySQLTest method setUp.
@BeforeEach
void setUp() {
TestErrorLogger.throwErrors(true);
db().executeTransaction(new Patch() {
@Override
public boolean hasBeenApplied() {
return false;
}
@Override
public void applyPatch() {
dropTable("plan_world_times");
dropTable("plan_kills");
dropTable("plan_sessions");
dropTable("plan_worlds");
dropTable("plan_users");
}
});
db().executeTransaction(new CreateTablesTransaction());
db().executeTransaction(new RemoveEverythingTransaction());
db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, "")));
assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
use of com.djrapitops.plan.storage.database.transactions.patches.Patch in project Plan by plan-player-analytics.
the class SQLiteTest method setUp.
@BeforeEach
void setUp() {
TestErrorLogger.throwErrors(true);
db().executeTransaction(new Patch() {
@Override
public boolean hasBeenApplied() {
return false;
}
@Override
public void applyPatch() {
dropTable("plan_world_times");
dropTable("plan_kills");
dropTable("plan_sessions");
dropTable("plan_worlds");
dropTable("plan_users");
}
});
db().executeTransaction(new CreateTablesTransaction());
db().executeTransaction(new RemoveEverythingTransaction());
db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), "ServerName", "")));
assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
use of com.djrapitops.plan.storage.database.transactions.patches.Patch in project Plan by plan-player-analytics.
the class DBPatchMySQLRegressionTest method mysqlPatchesAreApplied.
@Test
void mysqlPatchesAreApplied() {
Patch[] patches = underTest.patches();
for (Patch patch : patches) {
underTest.executeTransaction(patch);
}
assertPatchesHaveBeenApplied(patches);
// Make sure that a fetch works.
PlayerContainer player = underTest.query(ContainerFetchQueries.fetchPlayerContainer(TestConstants.PLAYER_ONE_UUID));
OptionalAssert.equals(1, player.getValue(PlayerKeys.PLAYER_KILL_COUNT));
// Make sure no foreign key checks fail on removal
underTest.executeTransaction(new RemoveEverythingTransaction());
}
use of com.djrapitops.plan.storage.database.transactions.patches.Patch in project Plan by plan-player-analytics.
the class DBPatchSQLiteRegressionTest method sqlitePatchesAreApplied.
@Test
void sqlitePatchesAreApplied() {
Patch[] patches = underTest.patches();
for (Patch patch : patches) {
underTest.executeTransaction(patch);
}
assertPatchesHaveBeenApplied(patches);
// Make sure that a fetch works.
PlayerContainer player = underTest.query(ContainerFetchQueries.fetchPlayerContainer(TestConstants.PLAYER_ONE_UUID));
OptionalAssert.equals(1, player.getValue(PlayerKeys.PLAYER_KILL_COUNT));
// Make sure no foreign key checks fail on removal
underTest.executeTransaction(new RemoveEverythingTransaction());
}
Aggregations