rename null classes to dummy classes
This commit is contained in:
@@ -3,7 +3,7 @@ package jef.main;
|
|||||||
import jef.model.DbContext;
|
import jef.model.DbContext;
|
||||||
import jef.model.ModelBuilder;
|
import jef.model.ModelBuilder;
|
||||||
import jef.model.migration.creator.MigrationCreator;
|
import jef.model.migration.creator.MigrationCreator;
|
||||||
import jef.platform.nul.NullPlatform;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.util.Util;
|
import jef.util.Util;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -124,7 +124,7 @@ public class MigrationCommandHandler {
|
|||||||
var targetFolderFile = new File(targetFolder);
|
var targetFolderFile = new File(targetFolder);
|
||||||
targetFolderFile.mkdirs();
|
targetFolderFile.mkdirs();
|
||||||
migrationPackage = findMigrationPackageName(targetFolder);
|
migrationPackage = findMigrationPackageName(targetFolder);
|
||||||
var sqlPlatform = new NullPlatform();//TODO find out from migrations or -p param
|
var sqlPlatform = new DummyPlatform();//TODO find out from migrations or -p param
|
||||||
|
|
||||||
//find data
|
//find data
|
||||||
var currentSnapshotFile = new File(targetFolderFile, "CurrentSnapshot.java");
|
var currentSnapshotFile = new File(targetFolderFile, "CurrentSnapshot.java");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package jef.platform.nul;
|
package jef.platform.dummy;
|
||||||
|
|
||||||
import jef.MigrationException;
|
import jef.MigrationException;
|
||||||
import jef.platform.base.Database;
|
import jef.platform.base.Database;
|
||||||
|
|
||||||
public class NullDatabase extends Database {
|
public class DummyDatabase extends Database {
|
||||||
public NullDatabase() {
|
public DummyDatabase() {
|
||||||
super(null, null);
|
super(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,30 +1,30 @@
|
|||||||
package jef.platform.nul;
|
package jef.platform.dummy;
|
||||||
|
|
||||||
import jef.platform.SqlPlatform;
|
import jef.platform.SqlPlatform;
|
||||||
import jef.platform.base.DatabaseOptions;
|
import jef.platform.base.DatabaseOptions;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.base.SqlTypeMapper;
|
||||||
import jef.platform.base.migration.MigrationApplier;
|
import jef.platform.base.migration.MigrationApplier;
|
||||||
import jef.platform.base.migration.MigrationOperationTranslator;
|
import jef.platform.base.migration.MigrationOperationTranslator;
|
||||||
import jef.platform.nul.migration.NullMigrationApplier;
|
import jef.platform.dummy.migration.DummyMigrationApplier;
|
||||||
import jef.platform.nul.migration.NullMigrationOperationTranslator;
|
import jef.platform.dummy.migration.DummyMigrationOperationTranslator;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
|
||||||
public class NullPlatform implements SqlPlatform {
|
public class DummyPlatform implements SqlPlatform {
|
||||||
public static final NullPlatform INSTANCE = new NullPlatform();
|
public static final DummyPlatform INSTANCE = new DummyPlatform();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MigrationOperationTranslator getTranslator() {
|
public MigrationOperationTranslator getTranslator() {
|
||||||
return NullMigrationOperationTranslator.INSTANCE;
|
return DummyMigrationOperationTranslator.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqlTypeMapper getTypeMapper() {
|
public SqlTypeMapper getTypeMapper() {
|
||||||
return NullTypeMapper.INSTANCE;
|
return DummyTypeMapper.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MigrationApplier getMigrationApplier(Connection connection, DatabaseOptions options) {
|
public MigrationApplier getMigrationApplier(Connection connection, DatabaseOptions options) {
|
||||||
return NullMigrationApplier.INSTANCE;
|
return DummyMigrationApplier.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package jef.platform.nul;
|
package jef.platform.dummy;
|
||||||
|
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.base.SqlTypeMapper;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
@@ -7,8 +7,8 @@ import lombok.NoArgsConstructor;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class NullTypeMapper extends SqlTypeMapper {
|
public class DummyTypeMapper extends SqlTypeMapper {
|
||||||
public static final NullTypeMapper INSTANCE = new NullTypeMapper();
|
public static final DummyTypeMapper INSTANCE = new DummyTypeMapper();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> map(String typeName) {
|
public Optional<String> map(String typeName) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package jef.platform.nul.migration;
|
package jef.platform.dummy.migration;
|
||||||
|
|
||||||
import jef.MigrationException;
|
import jef.MigrationException;
|
||||||
import jef.model.migration.Migration;
|
import jef.model.migration.Migration;
|
||||||
@@ -7,10 +7,10 @@ import jef.platform.base.migration.MigrationApplier;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NullMigrationApplier extends MigrationApplier {
|
public class DummyMigrationApplier extends MigrationApplier {
|
||||||
public static final NullMigrationApplier INSTANCE = new NullMigrationApplier();
|
public static final DummyMigrationApplier INSTANCE = new DummyMigrationApplier();
|
||||||
|
|
||||||
private NullMigrationApplier() {
|
private DummyMigrationApplier() {
|
||||||
super(null, null, null);
|
super(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package jef.platform.nul.migration;
|
package jef.platform.dummy.migration;
|
||||||
|
|
||||||
import jef.model.migration.operation.MigrationOperation;
|
import jef.model.migration.operation.MigrationOperation;
|
||||||
import jef.platform.base.migration.MigrationOperationTranslator;
|
import jef.platform.base.migration.MigrationOperationTranslator;
|
||||||
@@ -10,8 +10,8 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class NullMigrationOperationTranslator implements MigrationOperationTranslator {
|
public class DummyMigrationOperationTranslator implements MigrationOperationTranslator {
|
||||||
public static final NullMigrationOperationTranslator INSTANCE = new NullMigrationOperationTranslator();
|
public static final DummyMigrationOperationTranslator INSTANCE = new DummyMigrationOperationTranslator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement translate(Connection connection, MigrationOperation op) throws SQLException {
|
public PreparedStatement translate(Connection connection, MigrationOperation op) throws SQLException {
|
||||||
12
core/src/test/java/jef/platform/dummy/DummyDatabaseTest.java
Normal file
12
core/src/test/java/jef/platform/dummy/DummyDatabaseTest.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package jef.platform.dummy;
|
||||||
|
|
||||||
|
import jef.MigrationException;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class DummyDatabaseTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void migrate() throws MigrationException {
|
||||||
|
new DummyDatabase().migrate();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
core/src/test/java/jef/platform/dummy/DummyPlatformTest.java
Normal file
29
core/src/test/java/jef/platform/dummy/DummyPlatformTest.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package jef.platform.dummy;
|
||||||
|
|
||||||
|
import jef.platform.dummy.migration.DummyMigrationApplier;
|
||||||
|
import jef.platform.dummy.migration.DummyMigrationOperationTranslator;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
|
||||||
|
class DummyPlatformTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getTranslator() {
|
||||||
|
//test
|
||||||
|
var translator = new DummyPlatform().getTranslator();
|
||||||
|
|
||||||
|
//assert
|
||||||
|
assertSame(DummyMigrationOperationTranslator.INSTANCE, translator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getTypeMapper() {
|
||||||
|
assertSame(DummyTypeMapper.INSTANCE, new DummyPlatform().getTypeMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getMigrationApplier() {
|
||||||
|
assertSame(DummyMigrationApplier.INSTANCE, DummyPlatform.INSTANCE.getMigrationApplier(null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package jef.platform.nul;
|
package jef.platform.dummy;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -8,14 +8,14 @@ import java.util.UUID;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
class NullTypeMapperTest {
|
class DummyTypeMapperTest {
|
||||||
@Test
|
@Test
|
||||||
void map() {
|
void map() {
|
||||||
//setup
|
//setup
|
||||||
var type = UUID.randomUUID().toString();
|
var type = UUID.randomUUID().toString();
|
||||||
|
|
||||||
//test
|
//test
|
||||||
Optional<String> opt = NullTypeMapper.INSTANCE.map(type);
|
Optional<String> opt = DummyTypeMapper.INSTANCE.map(type);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
assertTrue(opt.isPresent());
|
assertTrue(opt.isPresent());
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package jef.platform.nul;
|
|
||||||
|
|
||||||
import jef.MigrationException;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class NullDatabaseTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void migrate() throws MigrationException {
|
|
||||||
new NullDatabase().migrate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package jef.platform.nul;
|
|
||||||
|
|
||||||
import jef.platform.nul.migration.NullMigrationApplier;
|
|
||||||
import jef.platform.nul.migration.NullMigrationOperationTranslator;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
|
||||||
|
|
||||||
class NullPlatformTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getTranslator() {
|
|
||||||
//test
|
|
||||||
var translator = new NullPlatform().getTranslator();
|
|
||||||
|
|
||||||
//assert
|
|
||||||
assertSame(NullMigrationOperationTranslator.INSTANCE, translator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getTypeMapper() {
|
|
||||||
assertSame(NullTypeMapper.INSTANCE, new NullPlatform().getTypeMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getMigrationApplier() {
|
|
||||||
assertSame(NullMigrationApplier.INSTANCE, NullPlatform.INSTANCE.getMigrationApplier(null, null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package jef.platform.nul.migration;
|
package jef.platform.dummy.migration;
|
||||||
|
|
||||||
import jef.MigrationException;
|
import jef.MigrationException;
|
||||||
import jef.model.migration.Migration;
|
import jef.model.migration.Migration;
|
||||||
@@ -11,11 +11,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
class NullMigrationApplierTest {
|
class DummyMigrationApplierTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void migrate() throws MigrationException {
|
void migrate() throws MigrationException {
|
||||||
NullMigrationApplier.INSTANCE.migrate();
|
DummyMigrationApplier.INSTANCE.migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -24,14 +24,14 @@ class NullMigrationApplierTest {
|
|||||||
Migration migration = mock(Migration.class);
|
Migration migration = mock(Migration.class);
|
||||||
|
|
||||||
//test
|
//test
|
||||||
NullMigrationApplier.INSTANCE.applyMigration(migration);
|
DummyMigrationApplier.INSTANCE.applyMigration(migration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findMigrations() throws MigrationException {
|
void findMigrations() throws MigrationException {
|
||||||
var foundMethodOverride = new Throwable();
|
var foundMethodOverride = new Throwable();
|
||||||
try {
|
try {
|
||||||
NullMigrationApplier.class.getDeclaredMethod("findMigrations", String.class);//throws NoSuchMethodException, i.e. not overriden
|
DummyMigrationApplier.class.getDeclaredMethod("findMigrations", String.class);//throws NoSuchMethodException, i.e. not overriden
|
||||||
throw foundMethodOverride;
|
throw foundMethodOverride;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertNotSame(foundMethodOverride, t);
|
assertNotSame(foundMethodOverride, t);
|
||||||
@@ -40,17 +40,17 @@ class NullMigrationApplierTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void migrationsTableExists() throws SQLException {
|
void migrationsTableExists() throws SQLException {
|
||||||
assertFalse(NullMigrationApplier.INSTANCE.migrationsTableExists());
|
assertFalse(DummyMigrationApplier.INSTANCE.migrationsTableExists());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createMigrationsTable() throws MigrationException {
|
void createMigrationsTable() throws MigrationException {
|
||||||
NullMigrationApplier.INSTANCE.createMigrationsTable();
|
DummyMigrationApplier.INSTANCE.createMigrationsTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAppliedMigrations() throws SQLException {
|
void getAppliedMigrations() throws SQLException {
|
||||||
assertEquals(0, NullMigrationApplier.INSTANCE.getAppliedMigrations().size());
|
assertEquals(0, DummyMigrationApplier.INSTANCE.getAppliedMigrations().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -59,6 +59,6 @@ class NullMigrationApplierTest {
|
|||||||
Migration migration = mock(Migration.class);
|
Migration migration = mock(Migration.class);
|
||||||
|
|
||||||
//test
|
//test
|
||||||
NullMigrationApplier.INSTANCE.insertMigrationLog(migration);
|
DummyMigrationApplier.INSTANCE.insertMigrationLog(migration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package jef.platform.nul.migration;
|
package jef.platform.dummy.migration;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -6,9 +6,9 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
class NullMigrationOperationTranslatorTest {
|
class DummyMigrationOperationTranslatorTest {
|
||||||
@Test
|
@Test
|
||||||
void translate() throws SQLException {
|
void translate() throws SQLException {
|
||||||
assertNull(NullMigrationOperationTranslator.INSTANCE.translate(null, null));
|
assertNull(DummyMigrationOperationTranslator.INSTANCE.translate(null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,10 @@ import jef.model.annotations.Id;
|
|||||||
import jef.model.constraints.ForeignKeyConstraint;
|
import jef.model.constraints.ForeignKeyConstraint;
|
||||||
import jef.model.constraints.PrimaryKeyConstraint;
|
import jef.model.constraints.PrimaryKeyConstraint;
|
||||||
import jef.model.migration.operation.AddForeignKeyOperation;
|
import jef.model.migration.operation.AddForeignKeyOperation;
|
||||||
import jef.model.migration.operation.AddPrimaryKeyOperation;
|
|
||||||
import jef.model.migration.operation.AddTableOperation;
|
import jef.model.migration.operation.AddTableOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.model.migration.operation.DropTableOperation;
|
import jef.model.migration.operation.DropTableOperation;
|
||||||
import jef.platform.nul.NullPlatform;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -31,7 +30,7 @@ public class MigrationCreatorAddEntityTest extends MigrationCreatorTestBase {
|
|||||||
ent.field("addedField", int.class.getName());
|
ent.field("addedField", int.class.getName());
|
||||||
to.getEntity("AddedEntity").setPrimaryKey(new PrimaryKeyConstraint(to.getEntity("AddedEntity"), List.of(to.getEntity("AddedEntity").getField("id"))));
|
to.getEntity("AddedEntity").setPrimaryKey(new PrimaryKeyConstraint(to.getEntity("AddedEntity"), List.of(to.getEntity("AddedEntity").getField("id"))));
|
||||||
to.getEntity("AddedEntity").addForeignKey(new ForeignKeyConstraint(to.getEntity("AddedEntity"), List.of(to.getEntity("AddedEntity").getField("addedField")), to.getEntity("AddedEntity"), List.of(to.getEntity("AddedEntity").getField("id")), ForeignKeyConstraint.Action.CASCADE, ForeignKeyConstraint.Action.CASCADE));
|
to.getEntity("AddedEntity").addForeignKey(new ForeignKeyConstraint(to.getEntity("AddedEntity"), List.of(to.getEntity("AddedEntity").getField("addedField")), to.getEntity("AddedEntity"), List.of(to.getEntity("AddedEntity").getField("id")), ForeignKeyConstraint.Action.CASCADE, ForeignKeyConstraint.Action.CASCADE));
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import jef.model.migration.operation.AddFieldOperation;
|
|||||||
import jef.model.migration.operation.AddForeignKeyOperation;
|
import jef.model.migration.operation.AddForeignKeyOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.model.migration.operation.DropFieldOperation;
|
import jef.model.migration.operation.DropFieldOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -28,7 +27,7 @@ public class MigrationCreatorAddFieldTest extends MigrationCreatorTestBase {
|
|||||||
var ent = to.getEntity(TestClass2.class);
|
var ent = to.getEntity(TestClass2.class);
|
||||||
ent.getOrCreateField("addedField", int.class.getName());
|
ent.getOrCreateField("addedField", int.class.getName());
|
||||||
ent.addForeignKey(new ForeignKeyConstraint(ent, List.of(ent.getField("addedField")), ent, List.of(ent.getField("i")), ForeignKeyConstraint.Action.CASCADE, ForeignKeyConstraint.Action.CASCADE));
|
ent.addForeignKey(new ForeignKeyConstraint(ent, List.of(ent.getField("addedField")), ent, List.of(ent.getField("i")), ForeignKeyConstraint.Action.CASCADE, ForeignKeyConstraint.Action.CASCADE));
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import jef.model.annotations.Id;
|
|||||||
import jef.model.constraints.ForeignKeyConstraint;
|
import jef.model.constraints.ForeignKeyConstraint;
|
||||||
import jef.model.migration.operation.AddForeignKeyOperation;
|
import jef.model.migration.operation.AddForeignKeyOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -25,7 +24,7 @@ public class MigrationCreatorAddForeignKeyTest extends MigrationCreatorTestBase
|
|||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var ent = to.getEntity(TestClass.class);
|
var ent = to.getEntity(TestClass.class);
|
||||||
ent.addForeignKey(new ForeignKeyConstraint(ent, List.of(ent.getField("i2")), ent, List.of(ent.getField("i")), ForeignKeyConstraint.Action.CASCADE, ForeignKeyConstraint.Action.CASCADE));
|
ent.addForeignKey(new ForeignKeyConstraint(ent, List.of(ent.getField("i2")), ent, List.of(ent.getField("i")), ForeignKeyConstraint.Action.CASCADE, ForeignKeyConstraint.Action.CASCADE));
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import jef.model.annotations.Clazz;
|
|||||||
import jef.model.annotations.Id;
|
import jef.model.annotations.Id;
|
||||||
import jef.model.migration.operation.AddIndexOperation;
|
import jef.model.migration.operation.AddIndexOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -24,7 +23,7 @@ public class MigrationCreatorAddIndexTest extends MigrationCreatorTestBase {
|
|||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var ent = to.entity(TestClass.class);
|
var ent = to.entity(TestClass.class);
|
||||||
ent.field("d", double.class.getName()).isIndex(true);
|
ent.field("d", double.class.getName()).isIndex(true);
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import jef.model.annotations.Clazz;
|
|||||||
import jef.model.annotations.Id;
|
import jef.model.annotations.Id;
|
||||||
import jef.model.migration.operation.AddKeyOperation;
|
import jef.model.migration.operation.AddKeyOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -24,7 +23,7 @@ public class MigrationCreatorAddKeyTest extends MigrationCreatorTestBase {
|
|||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var ent = to.entity(TestClass.class);
|
var ent = to.entity(TestClass.class);
|
||||||
ent.field("d", double.class.getName()).isKey(true);
|
ent.field("d", double.class.getName()).isKey(true);
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import jef.model.annotations.Clazz;
|
|||||||
import jef.model.annotations.Id;
|
import jef.model.annotations.Id;
|
||||||
import jef.model.migration.operation.AddUniqueKeyOperation;
|
import jef.model.migration.operation.AddUniqueKeyOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -24,7 +23,7 @@ public class MigrationCreatorAddUniqueTest extends MigrationCreatorTestBase {
|
|||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var ent = to.entity(TestClass.class);
|
var ent = to.entity(TestClass.class);
|
||||||
ent.field("d", double.class.getName()).isUnique(true);
|
ent.field("d", double.class.getName()).isUnique(true);
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import jef.model.annotations.Id;
|
|||||||
import jef.model.annotations.Index;
|
import jef.model.annotations.Index;
|
||||||
import jef.model.annotations.Key;
|
import jef.model.annotations.Key;
|
||||||
import jef.model.annotations.Unique;
|
import jef.model.annotations.Unique;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -23,7 +22,7 @@ public class MigrationCreatorEmptyTest extends MigrationCreatorTestBase {
|
|||||||
public void test() {
|
public void test() {
|
||||||
var from = ModelBuilder.from(Ctx.class);
|
var from = ModelBuilder.from(Ctx.class);
|
||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "EmptyMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "EmptyMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import jef.model.migration.operation.AddForeignKeyOperation;
|
|||||||
import jef.model.migration.operation.AddTableOperation;
|
import jef.model.migration.operation.AddTableOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.model.migration.operation.DropTableOperation;
|
import jef.model.migration.operation.DropTableOperation;
|
||||||
import jef.platform.nul.NullPlatform;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -23,7 +23,7 @@ public class MigrationCreatorInitialMigrationTest extends MigrationCreatorTestBa
|
|||||||
public void test() {
|
public void test() {
|
||||||
var from = new ModelBuilder(List.of());
|
var from = new ModelBuilder(List.of());
|
||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "InitialMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "InitialMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import jef.model.migration.operation.AddForeignKeyOperation;
|
|||||||
import jef.model.migration.operation.AddPrimaryKeyOperation;
|
import jef.model.migration.operation.AddPrimaryKeyOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.model.migration.operation.RenameTableOperation;
|
import jef.model.migration.operation.RenameTableOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -26,7 +25,7 @@ public class MigrationCreatorRenameEntityTest extends MigrationCreatorTestBase {
|
|||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var ent = to.entity(TestClass.class);
|
var ent = to.entity(TestClass.class);
|
||||||
ent.name("d2");
|
ent.name("d2");
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import jef.model.migration.operation.AddPrimaryKeyOperation;
|
|||||||
import jef.model.migration.operation.AddUniqueKeyOperation;
|
import jef.model.migration.operation.AddUniqueKeyOperation;
|
||||||
import jef.model.migration.operation.DropConstraintOperation;
|
import jef.model.migration.operation.DropConstraintOperation;
|
||||||
import jef.model.migration.operation.RenameFieldOperation;
|
import jef.model.migration.operation.RenameFieldOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -32,7 +31,7 @@ public class MigrationCreatorRenameFieldConstraintsTest extends MigrationCreator
|
|||||||
var from = ModelBuilder.from(Ctx.class);
|
var from = ModelBuilder.from(Ctx.class);
|
||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
to.getEntity(TestClass.class).getField("i").setName("i2");
|
to.getEntity(TestClass.class).getField("i").setName("i2");
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import jef.model.ModelBuilder;
|
|||||||
import jef.model.annotations.Clazz;
|
import jef.model.annotations.Clazz;
|
||||||
import jef.model.annotations.Id;
|
import jef.model.annotations.Id;
|
||||||
import jef.model.migration.operation.RenameFieldOperation;
|
import jef.model.migration.operation.RenameFieldOperation;
|
||||||
import jef.platform.base.SqlTypeMapper;
|
import jef.platform.dummy.DummyPlatform;
|
||||||
import jef.platform.nul.NullPlatform;
|
|
||||||
import jef.serializable.SerializableObject;
|
import jef.serializable.SerializableObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -23,7 +22,7 @@ public class MigrationCreatorRenameFieldTest extends MigrationCreatorTestBase {
|
|||||||
var to = ModelBuilder.from(Ctx.class);
|
var to = ModelBuilder.from(Ctx.class);
|
||||||
var ent = to.entity(TestClass.class);
|
var ent = to.entity(TestClass.class);
|
||||||
ent.field("d", double.class.getName()).name("d2");
|
ent.field("d", double.class.getName()).name("d2");
|
||||||
var platform = new NullPlatform();
|
var platform = new DummyPlatform();
|
||||||
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
var mc = new MigrationCreator(platform, from, to, "SomeMigration", "test",
|
||||||
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
new ModelBuilderGenerator(from, "Current", "test", platform.getTypeMapper()).generate().getJava());
|
||||||
var res = mc.createMigration();
|
var res = mc.createMigration();
|
||||||
|
|||||||
Reference in New Issue
Block a user