package it.cavallium.strangedb.server.strangedb.tests; import org.junit.After; import org.junit.Before; import org.junit.Test; import it.cavallium.strangedb.server.strangedb.database.Database; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import static org.junit.Assert.assertEquals; public class EnhancedClassUpdate { private Path path1; private Path path2; private Path path3; private Database db; @Before public void setUp() throws Exception { path1 = Files.createTempFile("db-tests-", ".db"); path2 = Files.createTempFile("db-tests-", ".db"); path3 = Files.createTempFile("db-tests-", ".db"); db = new Database(path1, path2, path3); OldClass root = db.loadRoot(OldClass.class, OldClass::new); root.field1 = "Abc"; root.field2 = 12; root.field4 = 13; db.close(); } @Test public void shouldUpdateClass() throws IOException { db = new Database(path1, path2, path3); V2Class root = db.loadRoot(V2Class.class, V2Class::new); assertEquals(root.field4, "Abc"); assertEquals(root.field2, 12); assertEquals(root.field1, 13L); db.close(); } @After public void tearDown() throws Exception { Files.deleteIfExists(path1); Files.deleteIfExists(path2); Files.deleteIfExists(path3); } }