diff --git a/pom.xml b/pom.xml
index b453aee..8486975 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,6 +92,30 @@
org.sqlite
wtf.casper.storageapi.libs.sqlite
+
+ com.google
+ wtf.casper.storageapi.libs.google
+
+
+ org.bson
+ wtf.casper.storageapi.libs.bson
+
+
+ org.checkerframework
+ wtf.casper.storageapi.libs.checkerframework
+
+
+ org.intellij
+ wtf.casper.storageapi.libs.intellij
+
+
+ org.jetbrains
+ wtf.casper.storageapi.libs.jetbrains
+
+
+ org.slf4j
+ wtf.casper.storageapi.libs.slf4j
+
false
diff --git a/src/main/java/wtf/casper/storageapi/StatelessKVStorage.java b/src/main/java/wtf/casper/storageapi/StatelessKVStorage.java
index 57491d6..a60054d 100644
--- a/src/main/java/wtf/casper/storageapi/StatelessKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/StatelessKVStorage.java
@@ -11,6 +11,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
@@ -155,6 +156,10 @@ default CompletableFuture migrateFrom(Supplier
}, StorageAPIConstants.DB_THREAD_POOL);
}
+ CompletableFuture renameField(String path, String newPath);
+
+ CompletableFuture renameFields(Map pathToNewPath);
+
/**
* @return a future that will complete with a collection of all values in the storage.
*/
diff --git a/src/main/java/wtf/casper/storageapi/impl/kvstorage/JsonKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/kvstorage/JsonKVStorage.java
index 0cb4341..a76f67e 100644
--- a/src/main/java/wtf/casper/storageapi/impl/kvstorage/JsonKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/kvstorage/JsonKVStorage.java
@@ -2,6 +2,7 @@
import com.github.benmanes.caffeine.cache.Caffeine;
+import com.google.gson.JsonObject;
import lombok.SneakyThrows;
import wtf.casper.storageapi.KVStorage;
import wtf.casper.storageapi.cache.Cache;
@@ -13,6 +14,7 @@
import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@@ -197,4 +199,84 @@ public CompletableFuture> allValues() {
return cache.asMap().values();
}, StorageAPIConstants.DB_THREAD_POOL);
}
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ File[] files = dataFolder.listFiles();
+ if (files == null) {
+ return;
+ }
+
+ cache().invalidateAll();
+ for (File file : files) {
+ if (!file.getName().endsWith(".json")) {
+ continue;
+ }
+
+ try {
+ final Reader reader = new FileReader(file);
+ final JsonObject value = StorageAPIConstants.getGson().fromJson(reader, JsonObject.class);
+ reader.close();
+
+ if (value == null) {
+ continue;
+ }
+
+ if (value.has(path)) {
+ value.add(newPath, value.get(path));
+ value.remove(path);
+ }
+
+ final Writer writer = new FileWriter(file);
+ StorageAPIConstants.getGson().toJson(value, writer);
+ writer.close();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ }
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ File[] files = dataFolder.listFiles();
+ if (files == null) {
+ return;
+ }
+
+ cache().invalidateAll();
+ for (File file : files) {
+ if (!file.getName().endsWith(".json")) {
+ continue;
+ }
+
+ try {
+ final Reader reader = new FileReader(file);
+ final JsonObject value = StorageAPIConstants.getGson().fromJson(reader, JsonObject.class);
+ reader.close();
+
+ if (value == null) {
+ continue;
+ }
+
+ for (Map.Entry entry : pathToNewPath.entrySet()) {
+ if (value.has(entry.getKey())) {
+ value.add(entry.getValue(), value.get(entry.getKey()));
+ value.remove(entry.getKey());
+ }
+ }
+
+ final Writer writer = new FileWriter(file);
+ StorageAPIConstants.getGson().toJson(value, writer);
+ writer.close();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ }
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
diff --git a/src/main/java/wtf/casper/storageapi/impl/kvstorage/MariaDBKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/kvstorage/MariaDBKVStorage.java
index 14b9da2..91dcb30 100644
--- a/src/main/java/wtf/casper/storageapi/impl/kvstorage/MariaDBKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/kvstorage/MariaDBKVStorage.java
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
@@ -159,4 +160,27 @@ public CompletableFuture> allValues() {
}, StorageAPIConstants.DB_THREAD_POOL);
}
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ this.execute("UPDATE " + this.table + " SET data = JSON_SET(data, '$." + newPath + "', JSON_EXTRACT(data, '$." + path + "'))," +
+ " data = JSON_REMOVE(data, '$." + path + "')", statement -> {
+ });
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ pathToNewPath.forEach((path, newPath) -> {
+ this.execute("UPDATE " + this.table + " SET data = JSON_SET(data, '$." + newPath + "', JSON_EXTRACT(data, '$." + path + "'))," +
+ " data = JSON_REMOVE(data, '$." + path + "')", statement -> {
+ });
+ });
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
diff --git a/src/main/java/wtf/casper/storageapi/impl/kvstorage/MongoKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/kvstorage/MongoKVStorage.java
index 04614f9..399b043 100644
--- a/src/main/java/wtf/casper/storageapi/impl/kvstorage/MongoKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/kvstorage/MongoKVStorage.java
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@@ -171,4 +172,30 @@ public CompletableFuture> allValues() {
return collection;
}, StorageAPIConstants.DB_THREAD_POOL);
}
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ for (Map.Entry entry : pathToNewPath.entrySet()) {
+ cache().invalidateAll();
+ getCollection().updateMany(
+ new Document(),
+ new Document("$rename", new Document(entry.getKey(), entry.getValue()))
+ );
+ cache().invalidateAll();
+ }
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ getCollection().updateMany(
+ new Document(),
+ new Document("$rename", new Document(path, newPath))
+ );
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
diff --git a/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLKVStorage.java
index 97d845c..b2a973e 100644
--- a/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLKVStorage.java
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
@@ -155,4 +156,26 @@ public CompletableFuture> allValues() {
return values;
}, StorageAPIConstants.DB_THREAD_POOL);
}
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ for (Map.Entry entry : pathToNewPath.entrySet()) {
+ execute("UPDATE " + this.table + " SET data = JSON_SET(data, '$." + entry.getValue() + "', JSON_EXTRACT(data, '$." + entry.getKey() + "'));");
+ execute("UPDATE " + this.table + " SET data = JSON_REMOVE(data, '$." + entry.getKey() + "');");
+ }
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ execute("UPDATE " + this.table + " SET data = JSON_SET(data, '$." + newPath + "', JSON_EXTRACT(data, '$." + path + "'));");
+ execute("UPDATE " + this.table + " SET data = JSON_REMOVE(data, '$." + path + "');");
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
diff --git a/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLiteKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLiteKVStorage.java
index dac16f9..c164152 100644
--- a/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLiteKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/kvstorage/SQLiteKVStorage.java
@@ -15,10 +15,7 @@
import java.io.File;
import java.lang.reflect.Field;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
@@ -180,4 +177,28 @@ public void createTable() {
execute("CREATE TABLE IF NOT EXISTS " + table() + " (" + idType + ", json TEXT NOT NULL);");
}
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ execute("UPDATE " + this.table + " SET json = JSON_SET(json, '$." + newPath + "', JSON_EXTRACT(json, '$." + path + "'))," +
+ " json = JSON_REMOVE(json, '$." + path + "')", statement -> {
+ });
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ cache().invalidateAll();
+ pathToNewPath.forEach((path, newPath) -> {
+ execute("UPDATE " + this.table + " SET json = JSON_SET(json, '$." + newPath + "', JSON_EXTRACT(json, '$." + path + "'))," +
+ " json = JSON_REMOVE(json, '$." + path + "')", statement -> {
+ });
+ });
+ cache().invalidateAll();
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
diff --git a/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMariaDBKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMariaDBKVStorage.java
index d4b2124..2b173b0 100644
--- a/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMariaDBKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMariaDBKVStorage.java
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Logger;
@@ -112,4 +113,22 @@ public CompletableFuture> allValues() {
return values;
}, StorageAPIConstants.DB_THREAD_POOL);
}
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ execute("UPDATE " + this.table + " SET data = JSON_SET(data, '$." + newPath + "', JSON_EXTRACT(data, '$." + path + "'));");
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ pathToNewPath.forEach((path, newPath) -> {
+ this.execute("UPDATE " + this.table + " SET data = JSON_SET(data, '$." + newPath + "', JSON_EXTRACT(data, '$." + path + "'))," +
+ " data = JSON_REMOVE(data, '$." + path + "')", statement -> {
+ });
+ });
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMongoKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMongoKVStorage.java
index 1e55ba5..0b2be5f 100644
--- a/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMongoKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessMongoKVStorage.java
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
@Log
@@ -145,4 +146,26 @@ public CompletableFuture> allValues() {
return collection;
}, StorageAPIConstants.DB_THREAD_POOL);
}
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ for (Map.Entry entry : pathToNewPath.entrySet()) {
+ getCollection().updateMany(
+ new Document(),
+ new Document("$rename", new Document(entry.getKey(), entry.getValue()))
+ );
+ }
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ getCollection().updateMany(
+ new Document(),
+ new Document("$rename", new Document(path, newPath))
+ );
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
diff --git a/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessSQLKVStorage.java b/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessSQLKVStorage.java
index 255f98a..d1445e1 100644
--- a/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessSQLKVStorage.java
+++ b/src/main/java/wtf/casper/storageapi/impl/statelesskvstorage/StatelessSQLKVStorage.java
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Logger;
@@ -111,4 +112,20 @@ public CompletableFuture> allValues() {
return values;
}, StorageAPIConstants.DB_THREAD_POOL);
}
+
+ @Override
+ public CompletableFuture renameField(String path, String newPath) {
+ return CompletableFuture.runAsync(() -> {
+ execute("ALTER TABLE " + this.table + " CHANGE " + path + " " + newPath + " TEXT;");
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
+
+ @Override
+ public CompletableFuture renameFields(Map pathToNewPath) {
+ return CompletableFuture.runAsync(() -> {
+ for (Map.Entry entry : pathToNewPath.entrySet()) {
+ execute("ALTER TABLE " + this.table + " CHANGE " + entry.getKey() + " " + entry.getValue() + " TEXT;");
+ }
+ }, StorageAPIConstants.DB_THREAD_POOL);
+ }
}
\ No newline at end of file
diff --git a/src/test/java/wtf/casper/storageapi/KVStorageTests.java b/src/test/java/wtf/casper/storageapi/KVStorageTests.java
index 1a75820..8a66784 100644
--- a/src/test/java/wtf/casper/storageapi/KVStorageTests.java
+++ b/src/test/java/wtf/casper/storageapi/KVStorageTests.java
@@ -8,6 +8,7 @@
import java.io.File;
import java.io.InputStream;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.UUID;
@@ -58,11 +59,20 @@ public static void init(Properties properties) {
case MONGODB -> storage = new DirectMongoKVStorage<>(UUID.class, TestObject.class, credentials, TestObject::new);
case SQLITE -> storage = new DirectSQLiteKVStorage<>(UUID.class, TestObject.class, new File("src/test/resources/data.db"), "data", TestObject::new);
case SQL -> storage = new DirectSQLKVStorage<>(UUID.class, TestObject.class, credentials, TestObject::new);
- case MARIADB -> new DirectMariaDBKVStorage<>(UUID.class, TestObject.class, credentials, TestObject::new);
+ case MARIADB -> storage = new DirectMariaDBKVStorage<>(UUID.class, TestObject.class, credentials, TestObject::new);
case JSON -> storage = new DirectJsonKVStorage<>(UUID.class, TestObject.class, new File("./src/test/resources/data"), TestObject::new);
default -> throw new IllegalStateException("Unexpected value: " + type);
}
+ switch (type) {
+ case MONGODB -> storageOther = new DirectMongoKVStorage<>(UUID.class, TestObjectOther.class, credentials, TestObjectOther::new);
+ case SQLITE -> storageOther = new DirectSQLiteKVStorage<>(UUID.class, TestObjectOther.class, new File("src/test/resources/data.db"), "data", TestObjectOther::new);
+ case SQL -> storageOther = new DirectSQLKVStorage<>(UUID.class, TestObjectOther.class, credentials, TestObjectOther::new);
+ case MARIADB -> storageOther = new DirectMariaDBKVStorage<>(UUID.class, TestObjectOther.class, credentials, TestObjectOther::new);
+ case JSON -> storageOther = new DirectJsonKVStorage<>(UUID.class, TestObjectOther.class, new File("./src/test/resources/data"), TestObjectOther::new);
+ default -> throw new IllegalStateException("Unexpected value: " + type);
+ }
+
storage.deleteAll().join();
storage.saveAll(initialData).join();
storage.write().join();
@@ -70,6 +80,7 @@ public static void init(Properties properties) {
private static Credentials credentials;
private static KVStorage storage;
+ private static KVStorage storageOther;
private static final List initialData = List.of(
new TestObject(
@@ -230,4 +241,89 @@ public void testDeleteAll() {
storage.deleteAll().join();
assertEquals(0, storage.allValues().join().size());
}
+
+ @Test
+ public void testChangeFieldName() {
+ TestObject testObject = new TestObject(
+ UUID.fromString("00000000-0000-0000-0000-000000000019"), "Test", 100,
+ new TestObjectData("1234 Test Street", "Test Employer", "test@test", "123-456-7890",
+ 100, new TestObjectBalance(100, "USD")
+ )
+ );
+
+ storage.save(testObject).join();
+
+ storage.renameField("id", "idOther").join();
+ storage.renameField("name", "nameOther").join();
+ storage.renameField("age", "ageOther").join();
+
+ TestObjectOther join;
+ try {
+ join = storageOther.get(UUID.fromString("00000000-0000-0000-0000-000000000019")).join();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ if (join == null) {
+ throw new RuntimeException("Join is null");
+ }
+
+ assertEquals(testObject.getId(), join.getIdOther());
+ assertEquals(testObject.getName(), join.getNameOther());
+ assertEquals(testObject.getAge(), join.getAgeOther());
+ assertEquals(testObject.getData().getAge(), join.getData().getAge());
+
+ storage.renameField("idOther", "id").join();
+ storage.renameField("nameOther", "name").join();
+ storage.renameField("ageOther", "age").join();
+
+ TestObject object = storage.get(testObject.getId()).join();
+ assertEquals(testObject, object);
+
+ storageOther.remove(join).join();
+ }
+
+ @Test
+ public void testChangeFieldNames() {
+ TestObject testObject = new TestObject(
+ UUID.fromString("00000000-0000-0000-0000-000000000019"), "Test", 100,
+ new TestObjectData("1234 Test Street", "Test Employer", "test@test", "123-456-7890",
+ 100, new TestObjectBalance(100, "USD")
+ )
+ );
+
+ storage.save(testObject).join();
+
+ storage.renameFields(Map.of(
+ "id", "idOther",
+ "name", "nameOther",
+ "age", "ageOther"
+ )).join();
+
+ TestObjectOther join;
+ try {
+ join = storageOther.get(UUID.fromString("00000000-0000-0000-0000-000000000019")).join();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ if (join == null) {
+ throw new RuntimeException("Join is null");
+ }
+
+ assertEquals(testObject.getId(), join.getIdOther());
+ assertEquals(testObject.getName(), join.getNameOther());
+ assertEquals(testObject.getAge(), join.getAgeOther());
+ assertEquals(testObject.getData().getAge(), join.getData().getAge());
+
+ storage.renameFields(Map.of(
+ "idOther", "id",
+ "nameOther", "name",
+ "ageOther", "age"
+ )).join();
+
+ TestObject object = storage.get(testObject.getId()).join();
+ assertEquals(testObject, object);
+
+ storage.remove(testObject).join();
+ }
+
}
diff --git a/src/test/java/wtf/casper/storageapi/TestObjectData.java b/src/test/java/wtf/casper/storageapi/TestObjectData.java
index 8aa619a..4176cbd 100644
--- a/src/test/java/wtf/casper/storageapi/TestObjectData.java
+++ b/src/test/java/wtf/casper/storageapi/TestObjectData.java
@@ -40,6 +40,7 @@ public String toString() {
", phone='" + phone + '\'' +
", age=" + age +
", balance=" + balance +
+ ", balanceMap=" + balanceMap +
'}';
}
}
diff --git a/src/test/java/wtf/casper/storageapi/TestObjectOther.java b/src/test/java/wtf/casper/storageapi/TestObjectOther.java
new file mode 100644
index 0000000..12bc07c
--- /dev/null
+++ b/src/test/java/wtf/casper/storageapi/TestObjectOther.java
@@ -0,0 +1,56 @@
+package wtf.casper.storageapi;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import wtf.casper.storageapi.id.Id;
+import wtf.casper.storageapi.id.StorageSerialized;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
+@Getter @EqualsAndHashCode @StorageSerialized
+public class TestObjectOther {
+ @Id
+ private final UUID idOther;
+ private String nameOther;
+ private int ageOther;
+ private TestObjectData data;
+ private List dataList = List.of(
+ new TestObjectData("123 Fake Street", "Walmart", "test@test.com", "123-456-7890", ageOther, new TestObjectBalance(100, "USD")),
+ new TestObjectData("456 Fake Street", "Target", "nope@nope.com", "098-765-4321", ageOther, new TestObjectBalance(200, "USD")),
+ new TestObjectData("789 Fake Street", "Best Buy", "ttt@ttt.com", "111-222-3333", ageOther, new TestObjectBalance(300, "USD"))
+ );
+ private TestObjectData[] dataArray = new TestObjectData[] {
+ new TestObjectData("123 Fake Street", "Walmart", "test@test.com", "123-456-7890", ageOther, new TestObjectBalance(100, "USD")),
+ new TestObjectData("456 Fake Street", "Target", "nope@nope.com", "098-765-4321", ageOther, new TestObjectBalance(200, "USD")),
+ new TestObjectData("789 Fake Street", "Best Buy", "ttt@ttt.com", "111-222-3333", ageOther, new TestObjectBalance(300, "USD"))
+ };
+ private List emptyDataList = List.of();
+ private TestObjectData[] emptyDataArray = new TestObjectData[] {};
+
+ public TestObjectOther(final UUID id) {
+ this.idOther = id;
+ }
+
+ public TestObjectOther(final UUID id, final String name, final int age, final TestObjectData data) {
+ this.idOther = id;
+ this.nameOther = name;
+ this.ageOther = age;
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return "TestObjectOther{" +
+ "idOther=" + idOther +
+ ", nameOther='" + nameOther + '\'' +
+ ", ageOther=" + ageOther +
+ ", data=" + data +
+ ", dataList=" + dataList +
+ ", dataArray=" + Arrays.toString(dataArray) +
+ ", emptyDataList=" + emptyDataList +
+ ", emptyDataArray=" + Arrays.toString(emptyDataArray) +
+ '}';
+ }
+}
diff --git a/src/test/resources/storage.properties b/src/test/resources/storage.properties
index 39a9fbf..abf51c2 100644
--- a/src/test/resources/storage.properties
+++ b/src/test/resources/storage.properties
@@ -1,4 +1,4 @@
-storage.type=MONGODB
+storage.type=JSON
storage.host=127.0.0.1
storage.username=root
storage.password=1212