Search in sources :

Example 6 with ExitThrowable

use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.

the class SastCliSteps method checkReturnCode.

@Then("cxflow should exit with exit code: {}")
public void checkReturnCode(int expectedExitCode) {
    Throwable exception = testContext.getCxFlowExecutionException();
    Assert.assertNotNull("Expected an exception to be thrown.", exception);
    Assert.assertEquals(InvocationTargetException.class, exception.getClass());
    Throwable targetException = ((InvocationTargetException) exception).getTargetException();
    Assert.assertTrue(targetException instanceof ExitThrowable);
    int actualExitCode = ((ExitThrowable) targetException).getExitCode();
    Assert.assertEquals("The expected exist code did not match", expectedExitCode, actualExitCode);
}
Also used : ExitThrowable(com.checkmarx.flow.exception.ExitThrowable) ExitThrowable(com.checkmarx.flow.exception.ExitThrowable) InvocationTargetException(java.lang.reflect.InvocationTargetException) Then(io.cucumber.java.en.Then)

Example 7 with ExitThrowable

use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.

the class ScaCliSteps method validateExitCode.

@Then("run should exit with exit code {}")
public void validateExitCode(int expectedExitCode) {
    Assert.assertNotNull("Expected an exception to be thrown.", cxFlowExecutionException);
    Assert.assertEquals(InvocationTargetException.class, cxFlowExecutionException.getClass());
    Throwable targetException = ((InvocationTargetException) cxFlowExecutionException).getTargetException();
    Assert.assertTrue(targetException instanceof ExitThrowable);
    int actualExitCode = ((ExitThrowable) targetException).getExitCode();
    Assert.assertEquals("The expected exit code did not match", expectedExitCode, actualExitCode);
}
Also used : ExitThrowable(com.checkmarx.flow.exception.ExitThrowable) ExitThrowable(com.checkmarx.flow.exception.ExitThrowable) InvocationTargetException(java.lang.reflect.InvocationTargetException) Then(io.cucumber.java.en.Then)

Example 8 with ExitThrowable

use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.

the class PublishingSteps method publishingTheReport.

@When("^publishing (?:the|a SAST) report$")
public void publishingTheReport() throws Exception, ExitThrowable {
    ScanRequest request = prepareScanRequest();
    String sastReportPath = Paths.get(Constants.SAMPLE_SAST_RESULTS_DIR, sastReportFilename).toString();
    File sastReport = TestUtils.getFileFromResource(sastReportPath);
    try {
        sastScanner.cxParseResults(request, sastReport);
    } catch (Throwable e) {
        if (expectingException) {
            lastCxFlowException = e;
        } else {
            throw e;
        }
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ExitThrowable(com.checkmarx.flow.exception.ExitThrowable) File(java.io.File) When(io.cucumber.java.en.When)

Aggregations

ExitThrowable (com.checkmarx.flow.exception.ExitThrowable)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 Then (io.cucumber.java.en.Then)6 ScanRequest (com.checkmarx.flow.dto.ScanRequest)1 When (io.cucumber.java.en.When)1 File (java.io.File)1 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)1