Search in sources :

Example 1 with KeyspaceTables

use of com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables in project esop by instaclustr.

the class KeyspaceTablesTest method testMissingTables.

@Test
public void testMissingTables() {
    KeyspaceTables keyspaceTables = new KeyspaceTables();
    keyspaceTables.add("ks1", "t1");
    keyspaceTables.add("ks2", "t2");
    keyspaceTables.add("ks3", "t3");
    keyspaceTables.add("ks4", "t4");
    // ks5.t5 and ks6.t6 are missing
    DatabaseEntities entities = DatabaseEntities.parse("ks1.t1,ks2.t2,ks5.t5,ks6.t6");
    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.getRight().size());
    Assert.assertTrue(pair.getRight().containsEntry("ks5", "t5"));
    Assert.assertTrue(pair.getRight().containsEntry("ks6", "t6"));
}
Also used : DatabaseEntities(com.instaclustr.esop.impl.DatabaseEntities) Multimap(com.google.common.collect.Multimap) KeyspaceTables(com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.testng.annotations.Test)

Example 2 with KeyspaceTables

use of com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables 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"));
}
Also used : DatabaseEntities(com.instaclustr.esop.impl.DatabaseEntities) Multimap(com.google.common.collect.Multimap) KeyspaceTables(com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.testng.annotations.Test)

Example 3 with KeyspaceTables

use of com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables 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());
}
Also used : DatabaseEntities(com.instaclustr.esop.impl.DatabaseEntities) KeyspaceTables(com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.testng.annotations.Test)

Aggregations

DatabaseEntities (com.instaclustr.esop.impl.DatabaseEntities)3 KeyspaceTables (com.instaclustr.esop.impl.KeyspaceTable.KeyspaceTables)3 Pair (org.apache.commons.lang3.tuple.Pair)3 Test (org.testng.annotations.Test)3 Multimap (com.google.common.collect.Multimap)2 List (java.util.List)2