Search in sources :

Example 1 with CsarUploadResult

use of alien4cloud.rest.csar.CsarUploadResult in project alien4cloud by alien4cloud.

the class UploadCSARSStepDefinition method iThereShouldBeAParsingErrorLevelAndCode.

@And("^I there should be a parsing error level \"([^\"]*)\" and code \"([^\"]*)\"$")
public void iThereShouldBeAParsingErrorLevelAndCode(ParsingErrorLevel errorLevel, ErrorCode expectedCode) throws Throwable {
    RestResponse<CsarUploadResult> result = JsonUtil.read(Context.getInstance().getRestResponse(), CsarUploadResult.class);
    Assert.assertFalse("There must have messages after parsing the csar", result.getData().getErrors().isEmpty());
    int errorCount = 0;
    boolean found = false;
    for (List<ParsingError> errors : result.getData().getErrors().values()) {
        for (ParsingError error : errors) {
            if (Objects.equals(error.getErrorCode(), expectedCode) && Objects.equals(error.getErrorLevel(), errorLevel)) {
                found = true;
                break;
            }
        }
        if (found) {
            break;
        }
    }
    Assert.assertTrue(found);
}
Also used : ParsingError(alien4cloud.tosca.parser.ParsingError) CsarUploadResult(alien4cloud.rest.csar.CsarUploadResult) And(cucumber.api.java.en.And)

Example 2 with CsarUploadResult

use of alien4cloud.rest.csar.CsarUploadResult in project alien4cloud by alien4cloud.

the class UploadCSARSStepDefinition method I_should_receive_a_RestResponse_with_compilation_alerts_in_file_s.

@Then("^I should receive a RestResponse with (\\d+) alerts in (\\d+) files : (\\d+) errors (\\d+) warnings and (\\d+) infos$")
public void I_should_receive_a_RestResponse_with_compilation_alerts_in_file_s(int expectedAlertCount, int errornousFiles, int exptectedErrorCount, int exptectedWarningCount, int exptectedInfoCount) throws Throwable {
    RestResponse<CsarUploadResult> result = JsonUtil.read(Context.getInstance().getRestResponse(), CsarUploadResult.class);
    Assert.assertFalse("We should have alerts", result.getData().getErrors().isEmpty());
    Assert.assertEquals(errornousFiles, result.getData().getErrors().size());
    int alertCount = 0;
    int errorCount = 0;
    int warningCount = 0;
    int infoCount = 0;
    for (Map.Entry<String, List<ParsingError>> errorEntry : result.getData().getErrors().entrySet()) {
        alertCount += errorEntry.getValue().size();
        for (ParsingError pe : errorEntry.getValue()) {
            switch(pe.getErrorLevel()) {
                case ERROR:
                    errorCount++;
                    break;
                case WARNING:
                    warningCount++;
                    break;
                case INFO:
                    infoCount++;
                    break;
            }
        }
    }
    Assert.assertEquals(expectedAlertCount, alertCount);
    Assert.assertEquals(exptectedErrorCount, errorCount);
    Assert.assertEquals(exptectedWarningCount, warningCount);
    Assert.assertEquals(exptectedInfoCount, infoCount);
}
Also used : ParsingError(alien4cloud.tosca.parser.ParsingError) CsarUploadResult(alien4cloud.rest.csar.CsarUploadResult) List(java.util.List) Map(java.util.Map) Then(cucumber.api.java.en.Then)

Aggregations

CsarUploadResult (alien4cloud.rest.csar.CsarUploadResult)2 ParsingError (alien4cloud.tosca.parser.ParsingError)2 And (cucumber.api.java.en.And)1 Then (cucumber.api.java.en.Then)1 List (java.util.List)1 Map (java.util.Map)1