RestEndpointsAccessibilityTest

RestEndpointsAccessibilityTest.groovy
def checkAllEndRestPoints(String basicUrlPart) {
    if (!syncRequest) {
        def urls = [
            basicUrlPart,
            basicUrlPart + "/rest/issuehub/1.0/nodeinfo/self",
/*            basicUrlPart + "/rest/issuehub/1.0/syncrequests",
            basicUrlPart + "/rest/issuehub/1.0/blobrequests",
            basicUrlPart + "/rest/issuehub/1.0/blobresponses",
            basicUrlPart + "/rest/issuehub/1.0/bloberrorresponses",
            basicUrlPart + "/rest/issuehub/1.0/syncresponses",
            basicUrlPart + "/rest/issuehub/1.0/errorresponses",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/syncresponses/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncevents/syncrequests/search",
            basicUrlPart + "/rest/issuehub/4.1/poll//syncevents/blobrequests/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/errorresponses/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/blobresponses/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/bloberrorresponses/search"
*/
        ]
        def checkEndRestPoint = {String errors, String url ->
            HttpURLConnection httpConnection
            int responseCode
            String responseMessage
            try {
                httpConnection = (HttpURLConnection) new URL(url).openConnection()
                responseCode = httpConnection.getResponseCode()
                responseMessage = httpConnection.getResponseMessage()
                httpConnection.disconnect()
                if (![ 200, 201, 202, 203, 204 ].contains(responseCode))
                    errors + " <br><br> Request to " + url + " results: " +
                    " <br> Response Code: " + responseCode + " Response Message: " + responseMessage
                else
                    errors
            } catch (Exception e) {
                errors + """
                <br> <br> Request to <b>${url}</b> results in an exception<br> 
                <b>${e.class.name}</b> with message '${e.getMessage()}'""".stripIndent() 
            }
        }
        def errorMessage = urls.inject("", checkEndRestPoint)
        if (errorMessage != "")
            debug.error("<br>Connection assessment for <span style='color:red'>${basicUrlPart}</span></br>${errorMessage}")
        else
            debug.error("<br>Connection to <span style='color:green'>${basicUrlPart}</span> is <span style='color:green'><b>OK</b></span>")
    }
}
checkAllEndRestPoints("https://www.google.com")
RestEndpointsAccessibilityTest.groovy
def checkAllEndRestPoints(String basicUrlPart) {
    if (!syncRequest) {
        def urls = [
            basicUrlPart,
            basicUrlPart + "/rest/issuehub/1.0/nodeinfo/self",
/*            basicUrlPart + "/rest/issuehub/1.0/syncrequests",
            basicUrlPart + "/rest/issuehub/1.0/blobrequests",
            basicUrlPart + "/rest/issuehub/1.0/blobresponses",
            basicUrlPart + "/rest/issuehub/1.0/bloberrorresponses",
            basicUrlPart + "/rest/issuehub/1.0/syncresponses",
            basicUrlPart + "/rest/issuehub/1.0/errorresponses",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/syncresponses/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncevents/syncrequests/search",
            basicUrlPart + "/rest/issuehub/4.1/poll//syncevents/blobrequests/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/errorresponses/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/blobresponses/search",
            basicUrlPart + "/rest/issuehub/4.1/poll/syncrequests/bloberrorresponses/search"
*/
        ]
        def checkEndRestPoint = {String errors, String url ->
            HttpURLConnection httpConnection
            int responseCode
            String responseMessage
            try {
                httpConnection = (HttpURLConnection) new URL(url).openConnection()
                responseCode = httpConnection.getResponseCode()
                responseMessage = httpConnection.getResponseMessage()
                httpConnection.disconnect()
                if (![ 200, 201, 202, 203, 204 ].contains(responseCode))
                    errors + " <br><br> Request to " + url + " results: " +
                    " <br> Response Code: " + responseCode + " Response Message: " + responseMessage
                else
                    errors
            } catch (Exception e) {
                errors + """
                <br> <br> Request to <b>${url}</b> results in an exception<br> 
                <b>${e.class.name}</b> with message '${e.getMessage()}'""".stripIndent() 
            }
        }
        def errorMessage = urls.inject("", checkEndRestPoint)
        if (errorMessage != "")
            debug.error("<br>Connection assessment for <span style='color:red'>${basicUrlPart}</span></br>${errorMessage}")
        else
            debug.error("<br>Connection to <span style='color:green'>${basicUrlPart}</span> is <span style='color:green'><b>OK</b></span>")
    }
}
checkAllEndRestPoints("https://www.google.com")