Example usage for java.lang ArrayIndexOutOfBoundsException getCause

List of usage examples for java.lang ArrayIndexOutOfBoundsException getCause

Introduction

In this page you can find the example usage for java.lang ArrayIndexOutOfBoundsException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImplTest.java

/**
 * Test method for/*from  w w w.j ava  2  s.com*/
 * {@link com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImpl#getQueryResponse(java.lang.String)}
 * .
 */
@Ignore
@Test
public void testGetQueryResponse() {
    logger.debug("RUNNING TEST FOR BASIC QUERY RESPONSE");
    jiraDataFactory = new JiraDataFactoryImpl(properties.getProperty("jira.credentials"),
            properties.getProperty("jira.base.url"), properties.getProperty("jira.query.endpoint"));
    jiraDataFactory.buildBasicQuery(query);
    try {
        JSONArray rs = jiraDataFactory.getQueryResponse();

        /*
         * Testing actual JSON for values
         */
        JSONArray dataMainArry = new JSONArray();
        JSONObject dataMainObj = new JSONObject();
        dataMainArry = (JSONArray) rs.get(0);
        dataMainObj = (JSONObject) dataMainArry.get(0);

        logger.info("Basic query response: " + dataMainObj.get("fields").toString());
        // fields
        assertTrue("No valid Number was found", dataMainObj.get("fields").toString().length() >= 1);
    } catch (NullPointerException npe) {
        fail("There was a problem with an object used to connect to Jira during the test\n" + npe.getMessage()
                + " caused by: " + npe.getCause());
    } catch (ArrayIndexOutOfBoundsException aioobe) {
        fail("The object returned from Jira had no JSONObjects in it during the test; try increasing the scope of your test case query and try again\n"
                + aioobe.getMessage() + " caused by: " + aioobe.getCause());
    } catch (IndexOutOfBoundsException ioobe) {
        logger.info("JSON artifact may be empty - re-running test to prove this out...");
        JSONArray rs = jiraDataFactory.getQueryResponse();

        /*
         * Testing actual JSON for values
         */
        String strRs = new String();
        strRs = rs.toString();

        logger.info("Basic query response: " + strRs);
        assertEquals("There was nothing returned from Jira that is consistent with a valid response.", "[[]]",
                strRs);
    } catch (Exception e) {
        fail("There was an unexpected problem while connecting to Jira during the test\n" + e.getMessage()
                + " caused by: " + e.getCause());
    }
}

From source file:com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImplTest.java

/**
 * Test method for// w ww. j  a  v  a2 s. c  o  m
 * {@link com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImpl#getPagingQueryResponse()}
 * .
 */
@Ignore
@Test
public void testGetPagingQueryResponse() {
    logger.debug("RUNNING TEST FOR PAGING QUERY RESPONSE");
    jiraDataFactory = new JiraDataFactoryImpl(1, properties.getProperty("jira.credentials"),
            properties.getProperty("jira.base.url"), properties.getProperty("jira.query.endpoint"));
    jiraDataFactory.buildBasicQuery(query);
    jiraDataFactory.buildPagingQuery(0);
    try {
        JSONArray rs = jiraDataFactory.getPagingQueryResponse();

        /*
         * Testing actual JSON for values
         */
        JSONArray dataMainArry = new JSONArray();
        JSONObject dataMainObj = new JSONObject();
        dataMainArry = (JSONArray) rs.get(0);
        dataMainObj = (JSONObject) dataMainArry.get(0);

        logger.info("Paging query response: " + dataMainObj.get("fields").toString());
        // fields
        assertTrue("No valid Number was found", dataMainObj.get("fields").toString().length() >= 1);
    } catch (NullPointerException npe) {
        fail("There was a problem with an object used to connect to Jira during the test:\n" + npe.getMessage()
                + " caused by: " + npe.getCause());
    } catch (ArrayIndexOutOfBoundsException aioobe) {
        fail("The object returned from Jira had no JSONObjects in it during the test; try increasing the scope of your test case query and try again.\n"
                + aioobe.getMessage() + " caused by: " + aioobe.getCause());
    } catch (IndexOutOfBoundsException ioobe) {
        logger.info("JSON artifact may be empty - re-running test to prove this out...");

        JSONArray rs = jiraDataFactory.getPagingQueryResponse();

        /*
         * Testing actual JSON for values
         */
        String strRs = new String();
        strRs = rs.toString();

        logger.info("Paging query response: " + strRs);
        assertEquals("There was nothing returned from Jira that is consistent with a valid response.", "[[]]",
                strRs);
    } catch (Exception e) {
        fail("There was an unexpected problem while connecting to Jira during the test:\n" + e.getMessage()
                + " caused by: " + e.getCause());
    }
}