Search in sources :

Example 1 with ContainsAssertionProperties

use of io.irontest.models.assertion.ContainsAssertionProperties in project irontest by zheng-wang.

the class ContainsAssertionVerifier method _verify.

/**
 * @param assertion
 * @param input the String that the assertion is verified against
 * @return
 */
@Override
public AssertionVerificationResult _verify(Assertion assertion, Object input) throws Exception {
    AssertionVerificationResult result = new AssertionVerificationResult();
    ContainsAssertionProperties otherProperties = (ContainsAssertionProperties) assertion.getOtherProperties();
    // validate other properties
    if ("".equals(StringUtils.trimToEmpty(otherProperties.getContains()))) {
        throw new IllegalArgumentException("Contains not specified");
    }
    String inputStr = (String) input;
    result.setResult(inputStr.contains(otherProperties.getContains()) ? TestResult.PASSED : TestResult.FAILED);
    return result;
}
Also used : AssertionVerificationResult(io.irontest.models.assertion.AssertionVerificationResult) ContainsAssertionProperties(io.irontest.models.assertion.ContainsAssertionProperties)

Aggregations

AssertionVerificationResult (io.irontest.models.assertion.AssertionVerificationResult)1 ContainsAssertionProperties (io.irontest.models.assertion.ContainsAssertionProperties)1