public void testCreateNodeSet() throws Exception {
{
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertTrue(set.getInclude().isBlank() );
assertNotNull(set.getExclude());
assertTrue(set.getExclude().isBlank());
assertEquals(1,set.getThreadCount());
assertEquals(false,set.isKeepgoing());
}
{
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-K"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertTrue(set.getInclude().isBlank() );
assertNotNull(set.getExclude());
assertTrue(set.getExclude().isBlank());
assertEquals(1,set.getThreadCount());
assertEquals(true,set.isKeepgoing());
}
{
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertTrue(set.getInclude().isBlank() );
assertNotNull(set.getExclude());
assertTrue(set.getExclude().isBlank());
assertEquals(2,set.getThreadCount());
assertEquals(false,set.isKeepgoing());
}
{
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2","-I","ahostname","-X","tags=blaoen","-I","os-family=test","-X","os-version=3"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertFalse(set.getInclude().isBlank() );
assertEquals("ahostname",set.getInclude().getHostname() );
assertEquals("test",set.getInclude().getOsfamily() );
assertNotNull(set.getExclude());
assertFalse(set.getExclude().isBlank());
assertEquals("blaoen",set.getExclude().getTags());
assertEquals("3",set.getExclude().getOsversion());
assertEquals(2,set.getThreadCount());
assertEquals(false,set.isKeepgoing());
}
{
//test precedence setting, Include dominant in first position
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2","-I","ahostname","-X","tags=blaoen"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertFalse(set.getInclude().isBlank() );
assertTrue(set.getInclude().isDominant() );
assertNotNull(set.getExclude());
assertFalse(set.getExclude().isBlank());
assertFalse(set.getExclude().isDominant());
}
{
//test precedence setting, Exclude dominant in first position
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2","-X","ahostname","-I","tags=blaoen"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertFalse(set.getInclude().isBlank() );
assertFalse(set.getInclude().isDominant() );
assertNotNull(set.getExclude());
assertFalse(set.getExclude().isBlank());
assertTrue(set.getExclude().isDominant());
}
{
//test precedence setting, Include dominant explicitly
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"--filter-exclude-precedence","false","-C","2","-X","ahostname","-I","tags=blaoen"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertFalse(set.getInclude().isBlank() );
assertTrue(set.getInclude().isDominant() );
assertNotNull(set.getExclude());
assertFalse(set.getExclude().isBlank());
assertFalse(set.getExclude().isDominant());
}
{
//test precedence setting, Exclude dominant explicitly
final ExecTool main = newExecTool();
main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"--filter-exclude-precedence","true","-C","2","-I","ahostname","-X","tags=blaoen"});
final NodeSet set = main.createFilterNodeSelector();
assertNotNull(set);
assertNotNull(set.getInclude());
assertFalse(set.getInclude().isBlank() );
assertFalse(set.getInclude().isDominant() );
assertNotNull(set.getExclude());
assertFalse(set.getExclude().isBlank());
assertTrue(set.getExclude().isDominant());
}
}