use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.
the class CassandraDataTest method testCassandraDataEntitiesEmptyRenameNonEmptySholdFail.
@Test
public // --entities="" --rename=whatever non empty -> invalid
void testCassandraDataEntitiesEmptyRenameNonEmptySholdFail() {
CassandraData parsed = new CassandraData(tableIdsMap, paths);
parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse(""));
parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {
{
put("ks1.tb2", "ks1.tb3");
}
}));
try {
parsed.validate();
fail("setting rename entities but not setting entities should fail");
} catch (final Exception ex) {
// ok
}
}
use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.
the class CassandraDataTest method testRenamedEntitiesWithDatabaseEntities.
@Test
public void testRenamedEntitiesWithDatabaseEntities() {
CassandraData parsed = new CassandraData(tableIdsMap, paths);
DatabaseEntities entities = DatabaseEntities.parse("ks1.tb1,ks1.tb2");
parsed.setDatabaseEntitiesFromRequest(entities);
parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {
{
put("ks1.tb2", "ks1.tb3");
}
});
}
use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.
the class CassandraDataTest method testCassandraDataToInRenamingEntitiesIsPresentInEntitiesShouldFail.
@Test
public // --entities=ks1.tb1,ks1.tb2 --rename=ks1.tb2=ks1.tb1 -> invalid as "to" is in entities
void testCassandraDataToInRenamingEntitiesIsPresentInEntitiesShouldFail() {
CassandraData parsed = new CassandraData(tableIdsMap, paths);
parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse("ks1.tb1, ks1.tb2"));
parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {
{
put("ks1.tb2", "ks1.tb1");
}
}));
try {
parsed.validate();
fail("setting rename entities where 'to' is present in entities should fail");
} catch (final Exception ex) {
// ok
}
}
use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.
the class CassandraDataTest method testRenamedEntities.
@Test
public void testRenamedEntities() throws Exception {
CassandraData parsed = new CassandraData(tableIdsMap, paths);
try {
parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {
{
put("ks3. tb4", "ks1. tb2");
}
});
Assert.fail("should fail on non-existing ks3.tb4");
} catch (Exception ex) {
assertEquals(ex.getMessage(), "There is not keyspace ks3 to rename an entity from!");
}
try {
parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {
{
put("ks1.tb5", "ks1.tb2");
}
});
Assert.fail("should fail on non-existing ks1.tb5");
} catch (Exception ex) {
assertEquals(ex.getMessage(), "There is not table ks1.tb5 to rename an entity from!");
}
try {
parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {
{
put("ks1. tb1", "ks3 . tb1");
}
});
Assert.fail("should fail on non-existing ks3.tb1");
} catch (Exception ex) {
assertEquals(ex.getMessage(), "There is not keyspace ks3 to rename an entity to!");
}
try {
parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {
{
put("ks1 .tb1", "ks2. tb5");
}
});
Assert.fail("should fail on non-existing ks2.tb5");
} catch (Exception ex) {
assertEquals(ex.getMessage(), "There is not table ks2.tb5 to rename an entity to!");
}
}
use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.
the class CassandraDataTest method testCassandraDataKeyspaceEntitiesNotEmptyRenameNonEmptySholdFail.
@Test
public // --entities=ks1 --rename=whatever non empty -> invalid
void testCassandraDataKeyspaceEntitiesNotEmptyRenameNonEmptySholdFail() {
CassandraData parsed = new CassandraData(tableIdsMap, paths);
parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse("ks1"));
parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {
{
put("ks1.tb2", "ks1.tb3");
}
}));
try {
parsed.validate();
fail("setting rename entities with set keyspace entities should fail");
} catch (final Exception ex) {
// ok
}
}
Aggregations