@@ -1573,9 +1573,10 @@ void testDefaultTable() {
15731573 table .addColumnDefinition ("input2" , ColumnType .INPUT );
15741574 table .addColumnDefinition ("output1" , ColumnType .ENDPOINT );
15751575 table .addRawRow ("000" , "900" , "VALUE:000-900" );
1576+ table .addRawRow ("000" , "*" , "VALUE:000-*" );
15761577 table .addRawRow ("001" , "901" , "VALUE:001-901" );
1578+ table .addRawRow ("001" , "*" , "VALUE:001-*" );
15771579 table .addRawRow ("002" , "902" , "VALUE:001-901" );
1578- table .addRawRow ("*" , "*" , "VALUE:Other" );
15791580 provider .addTable (table );
15801581
15811582 StagingSchema schema = new StagingSchema ("test_default_table" );
@@ -1594,6 +1595,7 @@ void testDefaultTable() {
15941595
15951596 DecisionEngine engine = new DecisionEngine (provider );
15961597
1598+ // test a case where the default_table make a successful lookup
15971599 Map <String , String > context = new HashMap <>();
15981600 context .put ("input1" , "000" );
15991601 Result result = engine .process ("test_default_table" , context );
@@ -1602,6 +1604,37 @@ void testDefaultTable() {
16021604 assertFalse (result .hasErrors ());
16031605 assertEquals (1 , result .getContext ().size ());
16041606 assertEquals ("000-900" , result .getContext ().get ("output1" ));
1607+
1608+ // test a case where there was a fallthrough match in the default table
1609+ context = new HashMap <>();
1610+ context .put ("input1" , "002" );
1611+ result = engine .process ("test_default_table" , context );
1612+
1613+ assertEquals (Type .STAGED , result .getType ());
1614+ assertFalse (result .hasErrors ());
1615+ assertEquals (1 , result .getContext ().size ());
1616+
1617+ // test a case where the default_table did not exist
1618+ schema .getInputs ().stream ().filter (i -> i .getDefaultTable () != null ).forEach (i -> i .setDefaultTable ("does_not_exist" ));
1619+ context = new HashMap <>();
1620+ context .put ("input1" , "000" );
1621+ result = engine .process ("test_default_table" , context );
1622+ assertEquals (Type .STAGED , result .getType ());
1623+ assertEquals (1 , result .getErrors ().size ());
1624+ assertEquals ("input2" , result .getErrors ().get (0 ).getKey ());
1625+ assertEquals ("Default table does not exist: does_not_exist" , result .getErrors ().get (0 ).getMessage ());
1626+
1627+ // test a case where the default table did not find a match
1628+ schema .getInputs ().stream ().filter (i -> i .getDefaultTable () != null ).forEach (i -> i .setDefaultTable ("table_input2_default" ));
1629+ provider .getTable ("table_input2_default" ).setRawRows (new ArrayList <>());
1630+ provider .initTable (provider .getTable ("table_input2_default" ));
1631+ context = new HashMap <>();
1632+ context .put ("input1" , "001" );
1633+ result = engine .process ("test_default_table" , context );
1634+ assertEquals (Type .STAGED , result .getType ());
1635+ assertEquals (1 , result .getErrors ().size ());
1636+ assertEquals ("input2" , result .getErrors ().get (0 ).getKey ());
1637+ assertEquals ("Default table table_input2_default did not find a match" , result .getErrors ().get (0 ).getMessage ());
16051638 }
16061639
16071640}
0 commit comments