use of com.instaclustr.esop.impl.DatabaseEntities in project esop by instaclustr.
the class CassandraDataTest method testCassandraDataForRenamingEntities.
@Test
public // --entities=ks1.tb1,ks1.tb2 --rename=ks1.tb2=ks1.tb1 -> invalid as "to" is in entities
void testCassandraDataForRenamingEntities() {
CassandraData parsed = new CassandraData(tableIdsMap, paths);
parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse("ks1.tb1, ks1.tb3, ks2.tb3, ks2.tb4"));
parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {
{
put("ks1.tb1", "ks1.tb2");
put("ks2.tb3", "ks2.tb2");
}
}));
DatabaseEntities databaseEntitiesToProcessForRestore = parsed.getDatabaseEntitiesToProcessForRestore();
assertTrue(databaseEntitiesToProcessForRestore.contains("ks1", "tb2"));
assertTrue(databaseEntitiesToProcessForRestore.contains("ks2", "tb2"));
assertTrue(databaseEntitiesToProcessForRestore.contains("ks1", "tb3"));
assertTrue(databaseEntitiesToProcessForRestore.contains("ks2", "tb4"));
assertFalse(databaseEntitiesToProcessForRestore.contains("ks1", "tb1"));
assertFalse(databaseEntitiesToProcessForRestore.contains("ks2", "tb3"));
assertEquals(2, databaseEntitiesToProcessForRestore.getKeyspaces().size());
assertEquals(4, databaseEntitiesToProcessForRestore.getKeyspacesAndTables().size());
}
use of com.instaclustr.esop.impl.DatabaseEntities in project esop by instaclustr.
the class CassandraDataTest method testDatabaseEntitiesOnSpacesOnly.
@Test
public void testDatabaseEntitiesOnSpacesOnly() throws Exception {
for (String entity : Stream.of(" ks1 .tb1 ks3. tb3 ", "ks1.tb1 ks3.tb3", " ks1 .tb1 ks3.tb3 ", " ks1.tb1 ks3.tb3, ", " ks1.tb1,ks3.tb3", ",,,ks1.tb1,,,ks3.tb3,,,").collect(Collectors.toList())) {
DatabaseEntities parsed = DatabaseEntities.parse(entity);
Assert.assertTrue(parsed.getKeyspacesAndTables().containsEntry("ks1", "tb1"), entity);
Assert.assertTrue(parsed.getKeyspacesAndTables().containsEntry("ks3", "tb3"), entity);
Assert.assertEquals(parsed.getKeyspacesAndTables().size(), 2, entity);
}
for (String entity : Stream.of(" ks1 ks3 ", "ks1 ks3", " ks1,ks3, ,", ",,,ks1,ks3,,,").collect(Collectors.toList())) {
DatabaseEntities parsed = DatabaseEntities.parse(entity);
Assert.assertTrue(parsed.getKeyspaces().contains("ks1"), entity);
Assert.assertTrue(parsed.getKeyspaces().contains("ks3"), entity);
Assert.assertEquals(parsed.getKeyspaces().size(), 2, entity);
}
}
use of com.instaclustr.esop.impl.DatabaseEntities 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.DatabaseEntities in project esop by instaclustr.
the class KeyspaceTablesTest method testMissingKeyspaces.
@Test
public void testMissingKeyspaces() {
KeyspaceTables keyspaceTables = new KeyspaceTables();
keyspaceTables.add("ks1", "t1");
keyspaceTables.add("ks2", "t2");
keyspaceTables.add("ks3", "t3");
keyspaceTables.add("ks4", "t4");
// ks5 and ks6 are missing
DatabaseEntities entities = DatabaseEntities.parse("ks1,ks5,ks6");
Optional<Pair<List<String>, Multimap<String, String>>> result = keyspaceTables.filterNotPresent(entities);
Assert.assertTrue(result.isPresent());
Pair<List<String>, Multimap<String, String>> pair = result.get();
Assert.assertEquals(2, pair.getLeft().size());
Assert.assertTrue(pair.getLeft().contains("ks5"));
Assert.assertTrue(pair.getLeft().contains("ks6"));
}
use of com.instaclustr.esop.impl.DatabaseEntities in project esop by instaclustr.
the class KeyspaceTablesTest method testEmpty.
@Test
public void testEmpty() {
KeyspaceTables keyspaceTables = new KeyspaceTables();
keyspaceTables.add("ks1", "t1");
keyspaceTables.add("ks2", "t2");
keyspaceTables.add("ks3", "t3");
keyspaceTables.add("ks4", "t4");
DatabaseEntities entities = DatabaseEntities.parse("");
Optional<Pair<List<String>, Multimap<String, String>>> result = keyspaceTables.filterNotPresent(entities);
Assert.assertFalse(result.isPresent());
}
Aggregations