Delete devlok-databases/src/test/java/de/weapie/devlok/database/test directory
This commit is contained in:
parent
4bff42661d
commit
fc261d6efa
@ -1,56 +0,0 @@
|
||||
package de.weapie.devlok.database.test;
|
||||
|
||||
import de.weapie.devlok.database.Database;
|
||||
import de.weapie.devlok.database.config.DatabaseType;
|
||||
import de.weapie.devlok.database.mongodb.MongoDBDatabase;
|
||||
import de.weapie.devlok.database.mysql.MySQLDatabase;
|
||||
import de.weapie.devlok.utils.data.Pair;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestDatabase {
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void handle() {
|
||||
// Initialize & Create connection
|
||||
Database.initialize("./config/");
|
||||
|
||||
// Create table in database
|
||||
Database.getDatabase().getService().table("players", new Document("uuid", "VARCHAR(100)").append("coins", "INT"));
|
||||
|
||||
// Insert entry in database
|
||||
String uid = UUID.randomUUID().toString();
|
||||
Database.getDatabase().getService().insert("players", new Document("uuid", uid).append("coins", 0));
|
||||
|
||||
System.out.println("Count: " + Database.getDatabase().getService().count("players"));
|
||||
|
||||
Document findFirst = Database.getDatabase().getService().findFirst("players");
|
||||
String uuid = findFirst.getString("uuid");
|
||||
int coins = findFirst.getInteger("coins");
|
||||
|
||||
System.out.println("Exists: " + Database.getDatabase().getService().exist("players", new Document("uuid", uuid)));
|
||||
|
||||
System.out.println("Position: " + Database.getDatabase().getService().position("players", new Pair<>("uuid", uuid), "coins"));
|
||||
System.out.println("Position (1): " + Database.getDatabase().getService().position("players", new Pair<>("uuid", "e90c4f55-262c-4608-9347-8440ba0f3896"), "coins"));
|
||||
System.out.println("Position (2): " + Database.getDatabase().getService().position("players", new Pair<>("uuid", "23840167-672f-426a-be74-4ae790b9c2aa"), "coins"));
|
||||
|
||||
// Update entry in database with complete document
|
||||
Database.getDatabase().getService().replace("players", new Document("uuid", uuid), new Document("uuid", uuid).append("coins", coins + 1));
|
||||
|
||||
// Find entry in database
|
||||
Document document = Database.getDatabase().getService().findOne("players", new Document("uuid", uuid));
|
||||
System.out.println("Json: " + document.toJson());
|
||||
|
||||
// Delete entry from database
|
||||
//Database.getDatabase().getService().deleteOne("players", new Document("uuid", uuid));
|
||||
|
||||
// Delete all entry from database
|
||||
//Database.getDatabase().getService().deleteAll("players");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user