Search in sources :

Example 16 with NodeChannel

use of org.jumpmind.symmetric.model.NodeChannel in project symmetric-ds by JumpMind.

the class ColumnMatchDataRouterTest method testExpressionExternalData.

@Test
public void testExpressionExternalData() {
    ColumnMatchDataRouter router = new ColumnMatchDataRouter();
    SimpleRouterContext routingContext = new SimpleRouterContext();
    HashSet<Node> nodes = new HashSet<Node>();
    nodes.add(new Node("100", "client"));
    nodes.add(new Node("200", "client"));
    nodes.add(new Node("300", "client"));
    TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,NODE_ID,COLUMN2");
    Data data = new Data();
    data.setDataId(1);
    data.setDataEventType(DataEventType.INSERT);
    data.setRowData("1,100,Super Dooper");
    data.setExternalData("100");
    data.setTriggerHistory(triggerHist);
    Table table = new Table();
    NodeChannel nodeChannel = new NodeChannel();
    Router route = new Router();
    route.setRouterExpression("EXTERNAL_DATA = :NODE_ID");
    route.setRouterId("route1");
    DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
    Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
    assertEquals(1, result.size());
    assertEquals(true, result.contains("100"));
}
Also used : Table(org.jumpmind.db.model.Table) Node(org.jumpmind.symmetric.model.Node) Router(org.jumpmind.symmetric.model.Router) Data(org.jumpmind.symmetric.model.Data) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) TriggerHistory(org.jumpmind.symmetric.model.TriggerHistory) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) HashSet(java.util.HashSet) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) Test(org.junit.Test)

Example 17 with NodeChannel

use of org.jumpmind.symmetric.model.NodeChannel in project symmetric-ds by JumpMind.

the class ColumnMatchDataRouterTest method testExpressionNotEqualsNull.

@Test
public void testExpressionNotEqualsNull() {
    ColumnMatchDataRouter router = new ColumnMatchDataRouter();
    SimpleRouterContext routingContext = new SimpleRouterContext();
    HashSet<Node> nodes = new HashSet<Node>();
    nodes.add(new Node("100", "client"));
    nodes.add(new Node("200", "client"));
    TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,NODE_ID,COLUMN2");
    Data data = new Data();
    data.setDataId(1);
    data.setDataEventType(DataEventType.INSERT);
    data.setRowData("1,100,");
    data.setTriggerHistory(triggerHist);
    Table table = new Table();
    NodeChannel nodeChannel = new NodeChannel();
    Router route = new Router();
    route.setRouterExpression("COLUMN2 != NULL");
    route.setRouterId("route1");
    DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
    Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
    assertEquals(0, result.size());
}
Also used : Table(org.jumpmind.db.model.Table) Node(org.jumpmind.symmetric.model.Node) Router(org.jumpmind.symmetric.model.Router) Data(org.jumpmind.symmetric.model.Data) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) TriggerHistory(org.jumpmind.symmetric.model.TriggerHistory) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) HashSet(java.util.HashSet) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) Test(org.junit.Test)

Example 18 with NodeChannel

use of org.jumpmind.symmetric.model.NodeChannel in project symmetric-ds by JumpMind.

the class ColumnMatchDataRouterTest method testExpressionContains.

@Test
public void testExpressionContains() {
    ColumnMatchDataRouter router = new ColumnMatchDataRouter();
    SimpleRouterContext routingContext = new SimpleRouterContext();
    HashSet<Node> nodes = new HashSet<Node>();
    nodes.add(new Node("100", "client"));
    nodes.add(new Node("200", "client"));
    nodes.add(new Node("300", "client"));
    nodes.add(new Node("1000", "client"));
    TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,NODE_ID,COLUMN2");
    Data data = new Data();
    data.setDataId(1);
    data.setDataEventType(DataEventType.INSERT);
    data.setRowData("1,100,Super Dooper");
    data.setExternalData("1000,200");
    data.setTriggerHistory(triggerHist);
    Table table = new Table();
    NodeChannel nodeChannel = new NodeChannel();
    Router route = new Router();
    route.setRouterExpression("EXTERNAL_DATA contains :NODE_ID");
    route.setRouterId("route1");
    DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
    Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
    assertEquals(2, result.size());
    assertEquals(true, result.contains("1000"));
    assertEquals(true, result.contains("200"));
}
Also used : Table(org.jumpmind.db.model.Table) Node(org.jumpmind.symmetric.model.Node) Router(org.jumpmind.symmetric.model.Router) Data(org.jumpmind.symmetric.model.Data) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) TriggerHistory(org.jumpmind.symmetric.model.TriggerHistory) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) HashSet(java.util.HashSet) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) Test(org.junit.Test)

Example 19 with NodeChannel

use of org.jumpmind.symmetric.model.NodeChannel in project symmetric-ds by JumpMind.

the class ColumnMatchDataRouterTest method testExpressionEqualsGroupId.

@Test
public void testExpressionEqualsGroupId() {
    ColumnMatchDataRouter router = new ColumnMatchDataRouter();
    SimpleRouterContext routingContext = new SimpleRouterContext();
    HashSet<Node> nodes = new HashSet<Node>();
    nodes.add(new Node("10", "server"));
    nodes.add(new Node("20", "server"));
    nodes.add(new Node("3", "client"));
    nodes.add(new Node("2", "client"));
    nodes.add(new Node("1", "client"));
    TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,GROUP_ID,COLUMN2");
    Data data = new Data();
    data.setDataId(1);
    data.setDataEventType(DataEventType.INSERT);
    data.setRowData("1,client,Super Dooper");
    data.setTriggerHistory(triggerHist);
    Table table = new Table();
    NodeChannel nodeChannel = new NodeChannel();
    Router route = new Router();
    route.setRouterExpression("GROUP_ID = :NODE_GROUP_ID");
    route.setRouterId("route1");
    DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
    Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
    assertEquals(3, result.size());
    assertEquals(true, result.contains("1"));
    assertEquals(true, result.contains("2"));
    assertEquals(true, result.contains("3"));
}
Also used : Table(org.jumpmind.db.model.Table) Node(org.jumpmind.symmetric.model.Node) Router(org.jumpmind.symmetric.model.Router) Data(org.jumpmind.symmetric.model.Data) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) TriggerHistory(org.jumpmind.symmetric.model.TriggerHistory) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) HashSet(java.util.HashSet) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) Test(org.junit.Test)

Example 20 with NodeChannel

use of org.jumpmind.symmetric.model.NodeChannel in project symmetric-ds by JumpMind.

the class ColumnMatchDataRouterTest method testExpressionEqualsNull.

@Test
public void testExpressionEqualsNull() {
    ColumnMatchDataRouter router = new ColumnMatchDataRouter();
    SimpleRouterContext routingContext = new SimpleRouterContext();
    HashSet<Node> nodes = new HashSet<Node>();
    nodes.add(new Node("100", "client"));
    nodes.add(new Node("200", "client"));
    TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,NODE_ID,COLUMN2");
    Data data = new Data();
    data.setDataId(1);
    data.setDataEventType(DataEventType.INSERT);
    data.setRowData("1,100,");
    data.setTriggerHistory(triggerHist);
    Table table = new Table();
    NodeChannel nodeChannel = new NodeChannel();
    Router route = new Router();
    route.setRouterExpression("COLUMN2 = NULL");
    route.setRouterId("route1");
    DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
    Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
    assertEquals(2, result.size());
    assertEquals(true, result.contains("100"));
    assertEquals(true, result.contains("200"));
}
Also used : Table(org.jumpmind.db.model.Table) Node(org.jumpmind.symmetric.model.Node) Router(org.jumpmind.symmetric.model.Router) Data(org.jumpmind.symmetric.model.Data) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) TriggerHistory(org.jumpmind.symmetric.model.TriggerHistory) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) HashSet(java.util.HashSet) DataMetaData(org.jumpmind.symmetric.model.DataMetaData) Test(org.junit.Test)

Aggregations

NodeChannel (org.jumpmind.symmetric.model.NodeChannel)39 Test (org.junit.Test)15 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)14 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)13 Node (org.jumpmind.symmetric.model.Node)12 HashSet (java.util.HashSet)11 Data (org.jumpmind.symmetric.model.Data)10 Table (org.jumpmind.db.model.Table)9 DataMetaData (org.jumpmind.symmetric.model.DataMetaData)9 Router (org.jumpmind.symmetric.model.Router)9 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)9 Date (java.util.Date)7 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)6 IOutgoingBatchService (org.jumpmind.symmetric.service.IOutgoingBatchService)5 FixMethodOrder (org.junit.FixMethodOrder)5 ArrayList (java.util.ArrayList)4 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)3 BigDecimal (java.math.BigDecimal)2 List (java.util.List)2 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)2