Search in sources :

Example 1 with TestTypeField

use of clients.model.TestTypeField in project cvs-auto-svc by dvsa.

the class TestTypeSteps method validateData.

@Step
public void validateData(TestTypeById testTypeById, List<TestTypeField> testTypeFields) {
    int expectedResponseSize = 1;
    response.then().body("id", equalTo(testTypeById.getId()));
    if (testTypeFields != null) {
        expectedResponseSize = expectedResponseSize + testTypeFields.size();
        for (TestTypeField testTypeField : testTypeFields) {
            switch(testTypeField) {
                case DEFAULT_TEST_CODE:
                    response.then().body(testTypeField.getField(), equalTo(testTypeById.getDefaultTestCode()));
                    break;
                case TEST_TYPE_CLASSIFICATION:
                    response.then().body(testTypeField.getField(), equalTo(testTypeById.getTestTypeClassification()));
                    break;
                case LINKED_TEST_CODE:
                    response.then().body(testTypeField.getField(), equalTo(testTypeById.getLinkedTestCode()));
                    break;
                case INVALID:
                    response.then().body("$", not(hasKey(testTypeField.getField())));
                    expectedResponseSize--;
                    break;
                default:
                    throw new AutomationException("Field is" + testTypeField.getField() + " not present in automation please update step");
            }
        }
    }
    response.then().body("size()", equalTo(expectedResponseSize));
}
Also used : TestTypeField(clients.model.TestTypeField) AutomationException(exceptions.AutomationException) Step(net.thucydides.core.annotations.Step)

Aggregations

TestTypeField (clients.model.TestTypeField)1 AutomationException (exceptions.AutomationException)1 Step (net.thucydides.core.annotations.Step)1