use of com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException in project concord-plugins by walmartlabs.
the class PuppetTaskTest method testBadUrl.
@Test
public void testBadUrl() {
MockContext ctx = new MockContext(buildDbQueryConfig());
UtilsTest.injectVariable(task, "action", "pql");
ctx.setVariable("queryString", "inventory[certname]{ limit 10 }");
// Empty URL
ctx.setVariable("databaseUrl", "");
try {
task.execute(ctx);
fail("Bad url should cause an exception");
} catch (MissingParameterException expected) {
assert (expected.getMessage().contains("Cannot find value for databaseUrl"));
} catch (Exception e) {
fail("Unexpected exception with bad URL: " + e.getMessage());
}
// Invalid URL
ctx.setVariable("databaseUrl", "notaurl");
try {
task.execute(ctx);
fail("Bad url should cause an exception");
} catch (IllegalArgumentException expected) {
assert (expected.getMessage().contains("Invalid URL"));
} catch (Exception e) {
fail("Unexpected exception with bad URL: " + e.getMessage());
}
}
use of com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException in project concord-plugins by walmartlabs.
the class PuppetTaskTest method testMissingAction.
@Test
public void testMissingAction() {
MockContext ctx = new MockContext(buildDbQueryConfig());
try {
UtilsTest.injectVariable(task, "action", null);
task.execute(ctx);
fail("Missing action value should cause exception");
} catch (MissingParameterException expected) {
// ok
assertTrue(expected.getMessage().contains("action"));
} catch (Exception e) {
fail("Unexpected exception: " + e.getMessage());
}
}
Aggregations