Search in sources :

Example 1 with MissingParameterException

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());
    }
}
Also used : MockContext(com.walmartlabs.concord.sdk.MockContext) MissingParameterException(com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException) ApiException(com.walmartlabs.concord.plugins.puppet.model.exception.ApiException) CertificateException(java.security.cert.CertificateException) MissingParameterException(com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException) Test(org.junit.Test)

Example 2 with MissingParameterException

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());
    }
}
Also used : MockContext(com.walmartlabs.concord.sdk.MockContext) MissingParameterException(com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException) ApiException(com.walmartlabs.concord.plugins.puppet.model.exception.ApiException) CertificateException(java.security.cert.CertificateException) MissingParameterException(com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException) Test(org.junit.Test)

Aggregations

ApiException (com.walmartlabs.concord.plugins.puppet.model.exception.ApiException)2 MissingParameterException (com.walmartlabs.concord.plugins.puppet.model.exception.MissingParameterException)2 MockContext (com.walmartlabs.concord.sdk.MockContext)2 CertificateException (java.security.cert.CertificateException)2 Test (org.junit.Test)2