Search in sources :

Example 1 with OperationFilter

use of org.apache.connect.mongo.replicator.OperationFilter in project rocketmq-externals by apache.

the class FilterTest method testAsterisk.

@Test
public void testAsterisk() {
    List<String> collections = new ArrayList<>();
    collections.add("*");
    insterest.put("test", collections);
    sourceTaskConfig.setInterestDbAndCollection(JSONObject.toJSONString(insterest));
    OperationFilter operationFilter = new OperationFilter(sourceTaskConfig);
    Assert.assertTrue(operationFilter.filterMeta(new CollectionMeta("test", "testsad")));
    Assert.assertTrue(operationFilter.filterMeta(new CollectionMeta("test", "tests032")));
}
Also used : OperationFilter(org.apache.connect.mongo.replicator.OperationFilter) ArrayList(java.util.ArrayList) CollectionMeta(org.apache.connect.mongo.initsync.CollectionMeta) Test(org.junit.Test)

Example 2 with OperationFilter

use of org.apache.connect.mongo.replicator.OperationFilter in project rocketmq-externals by apache.

the class FilterTest method testBlankDb.

@Test
public void testBlankDb() {
    OperationFilter operationFilter = new OperationFilter(sourceTaskConfig);
    Assert.assertTrue(operationFilter.filterMeta(new CollectionMeta("test", "test")));
    Assert.assertTrue(operationFilter.filterMeta(new CollectionMeta("test1", "test01")));
}
Also used : OperationFilter(org.apache.connect.mongo.replicator.OperationFilter) CollectionMeta(org.apache.connect.mongo.initsync.CollectionMeta) Test(org.junit.Test)

Example 3 with OperationFilter

use of org.apache.connect.mongo.replicator.OperationFilter in project rocketmq-externals by apache.

the class FilterTest method testFilterEvent.

@Test
public void testFilterEvent() {
    OperationFilter operationFilter = new OperationFilter(sourceTaskConfig);
    ReplicationEvent replicationEvent = new ReplicationEvent();
    replicationEvent.setOperationType(OperationType.NOOP);
    Assert.assertFalse(operationFilter.filterEvent(replicationEvent));
    replicationEvent.setOperationType(OperationType.DB_COMMAND);
    Assert.assertTrue(operationFilter.filterEvent(replicationEvent));
}
Also used : OperationFilter(org.apache.connect.mongo.replicator.OperationFilter) ReplicationEvent(org.apache.connect.mongo.replicator.event.ReplicationEvent) Test(org.junit.Test)

Example 4 with OperationFilter

use of org.apache.connect.mongo.replicator.OperationFilter in project rocketmq-externals by apache.

the class FilterTest method testSpecialDb.

@Test
public void testSpecialDb() {
    List<String> collections = new ArrayList<>();
    collections.add("person");
    insterest.put("test", collections);
    sourceTaskConfig.setInterestDbAndCollection(JSONObject.toJSONString(insterest));
    OperationFilter operationFilter = new OperationFilter(sourceTaskConfig);
    Assert.assertTrue(operationFilter.filterMeta(new CollectionMeta("test", "person")));
    Assert.assertFalse(operationFilter.filterMeta(new CollectionMeta("test", "person01")));
}
Also used : OperationFilter(org.apache.connect.mongo.replicator.OperationFilter) ArrayList(java.util.ArrayList) CollectionMeta(org.apache.connect.mongo.initsync.CollectionMeta) Test(org.junit.Test)

Aggregations

OperationFilter (org.apache.connect.mongo.replicator.OperationFilter)4 Test (org.junit.Test)4 CollectionMeta (org.apache.connect.mongo.initsync.CollectionMeta)3 ArrayList (java.util.ArrayList)2 ReplicationEvent (org.apache.connect.mongo.replicator.event.ReplicationEvent)1