rename null classes to dummy classes
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package jef.platform.nul;
|
||||
package jef.platform.dummy;
|
||||
|
||||
import jef.MigrationException;
|
||||
import jef.platform.base.Database;
|
||||
|
||||
public class NullDatabase extends Database {
|
||||
public NullDatabase() {
|
||||
public class DummyDatabase extends Database {
|
||||
public DummyDatabase() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
package jef.platform.nul;
|
||||
package jef.platform.dummy;
|
||||
|
||||
import jef.platform.SqlPlatform;
|
||||
import jef.platform.base.DatabaseOptions;
|
||||
import jef.platform.base.SqlTypeMapper;
|
||||
import jef.platform.base.migration.MigrationApplier;
|
||||
import jef.platform.base.migration.MigrationOperationTranslator;
|
||||
import jef.platform.nul.migration.NullMigrationApplier;
|
||||
import jef.platform.nul.migration.NullMigrationOperationTranslator;
|
||||
import jef.platform.dummy.migration.DummyMigrationApplier;
|
||||
import jef.platform.dummy.migration.DummyMigrationOperationTranslator;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
public class NullPlatform implements SqlPlatform {
|
||||
public static final NullPlatform INSTANCE = new NullPlatform();
|
||||
public class DummyPlatform implements SqlPlatform {
|
||||
public static final DummyPlatform INSTANCE = new DummyPlatform();
|
||||
|
||||
@Override
|
||||
public MigrationOperationTranslator getTranslator() {
|
||||
return NullMigrationOperationTranslator.INSTANCE;
|
||||
return DummyMigrationOperationTranslator.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeMapper getTypeMapper() {
|
||||
return NullTypeMapper.INSTANCE;
|
||||
return DummyTypeMapper.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 lombok.AccessLevel;
|
||||
@@ -7,8 +7,8 @@ import lombok.NoArgsConstructor;
|
||||
import java.util.Optional;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class NullTypeMapper extends SqlTypeMapper {
|
||||
public static final NullTypeMapper INSTANCE = new NullTypeMapper();
|
||||
public class DummyTypeMapper extends SqlTypeMapper {
|
||||
public static final DummyTypeMapper INSTANCE = new DummyTypeMapper();
|
||||
|
||||
@Override
|
||||
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.model.migration.Migration;
|
||||
@@ -7,10 +7,10 @@ import jef.platform.base.migration.MigrationApplier;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public class NullMigrationApplier extends MigrationApplier {
|
||||
public static final NullMigrationApplier INSTANCE = new NullMigrationApplier();
|
||||
public class DummyMigrationApplier extends MigrationApplier {
|
||||
public static final DummyMigrationApplier INSTANCE = new DummyMigrationApplier();
|
||||
|
||||
private NullMigrationApplier() {
|
||||
private DummyMigrationApplier() {
|
||||
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.platform.base.migration.MigrationOperationTranslator;
|
||||
@@ -10,8 +10,8 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class NullMigrationOperationTranslator implements MigrationOperationTranslator {
|
||||
public static final NullMigrationOperationTranslator INSTANCE = new NullMigrationOperationTranslator();
|
||||
public class DummyMigrationOperationTranslator implements MigrationOperationTranslator {
|
||||
public static final DummyMigrationOperationTranslator INSTANCE = new DummyMigrationOperationTranslator();
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
@@ -8,14 +8,14 @@ import java.util.UUID;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class NullTypeMapperTest {
|
||||
class DummyTypeMapperTest {
|
||||
@Test
|
||||
void map() {
|
||||
//setup
|
||||
var type = UUID.randomUUID().toString();
|
||||
|
||||
//test
|
||||
Optional<String> opt = NullTypeMapper.INSTANCE.map(type);
|
||||
Optional<String> opt = DummyTypeMapper.INSTANCE.map(type);
|
||||
|
||||
//assert
|
||||
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.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.mockito.Mockito.mock;
|
||||
|
||||
class NullMigrationApplierTest {
|
||||
class DummyMigrationApplierTest {
|
||||
|
||||
@Test
|
||||
void migrate() throws MigrationException {
|
||||
NullMigrationApplier.INSTANCE.migrate();
|
||||
DummyMigrationApplier.INSTANCE.migrate();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -24,14 +24,14 @@ class NullMigrationApplierTest {
|
||||
Migration migration = mock(Migration.class);
|
||||
|
||||
//test
|
||||
NullMigrationApplier.INSTANCE.applyMigration(migration);
|
||||
DummyMigrationApplier.INSTANCE.applyMigration(migration);
|
||||
}
|
||||
|
||||
@Test
|
||||
void findMigrations() throws MigrationException {
|
||||
var foundMethodOverride = new Throwable();
|
||||
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;
|
||||
} catch (Throwable t) {
|
||||
assertNotSame(foundMethodOverride, t);
|
||||
@@ -40,17 +40,17 @@ class NullMigrationApplierTest {
|
||||
|
||||
@Test
|
||||
void migrationsTableExists() throws SQLException {
|
||||
assertFalse(NullMigrationApplier.INSTANCE.migrationsTableExists());
|
||||
assertFalse(DummyMigrationApplier.INSTANCE.migrationsTableExists());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createMigrationsTable() throws MigrationException {
|
||||
NullMigrationApplier.INSTANCE.createMigrationsTable();
|
||||
DummyMigrationApplier.INSTANCE.createMigrationsTable();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAppliedMigrations() throws SQLException {
|
||||
assertEquals(0, NullMigrationApplier.INSTANCE.getAppliedMigrations().size());
|
||||
assertEquals(0, DummyMigrationApplier.INSTANCE.getAppliedMigrations().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,6 +59,6 @@ class NullMigrationApplierTest {
|
||||
Migration migration = mock(Migration.class);
|
||||
|
||||
//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;
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.sql.SQLException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class NullMigrationOperationTranslatorTest {
|
||||
class DummyMigrationOperationTranslatorTest {
|
||||
@Test
|
||||
void translate() throws SQLException {
|
||||
assertNull(NullMigrationOperationTranslator.INSTANCE.translate(null, null));
|
||||
assertNull(DummyMigrationOperationTranslator.INSTANCE.translate(null, null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user