How to use buildValidationErrorMessage method of com.consol.citrus.ws.validation.AbstractSoapAttachmentValidator class

Best Citrus code snippet using com.consol.citrus.ws.validation.AbstractSoapAttachmentValidator.buildValidationErrorMessage

Source:AbstractSoapAttachmentValidator.java Github

copy

Full Screen

...95 if (!StringUtils.hasText(controlAttachment.getContentId())) { return; }96 97 if (receivedAttachment.getContentId() != null) {98 Assert.isTrue(controlAttachment.getContentId() != null, 99 buildValidationErrorMessage("Values not equal for attachment contentId", 100 null, receivedAttachment.getContentId()));101 Assert.isTrue(receivedAttachment.getContentId().equals(controlAttachment.getContentId()),102 buildValidationErrorMessage("Values not equal for attachment contentId", 103 controlAttachment.getContentId(), receivedAttachment.getContentId()));104 } else {105 Assert.isTrue(controlAttachment.getContentId() == null || controlAttachment.getContentId().length() == 0, 106 buildValidationErrorMessage("Values not equal for attachment contentId", 107 controlAttachment.getContentId(), null));108 }109 110 if (log.isDebugEnabled()) {111 log.debug("Validating attachment contentId: " + receivedAttachment.getContentId() + 112 "='" + controlAttachment.getContentId() + "': OK.");113 }114 }115 116 /**117 * Validating SOAP attachment content type.118 * @param receivedAttachment119 * @param controlAttachment120 */121 protected void validateAttachmentContentType(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) {122 //in case contentType was not set in test case, skip validation123 if (!StringUtils.hasText(controlAttachment.getContentType())) { return; }124 125 if (receivedAttachment.getContentType() != null) {126 Assert.isTrue(controlAttachment.getContentType() != null, 127 buildValidationErrorMessage("Values not equal for attachment contentType", 128 null, receivedAttachment.getContentType()));129 Assert.isTrue(receivedAttachment.getContentType().equals(controlAttachment.getContentType()),130 buildValidationErrorMessage("Values not equal for attachment contentType", 131 controlAttachment.getContentType(), receivedAttachment.getContentType()));132 } else {133 Assert.isTrue(controlAttachment.getContentType() == null || controlAttachment.getContentType().length() == 0, 134 buildValidationErrorMessage("Values not equal for attachment contentType", 135 controlAttachment.getContentType(), null));136 }137 138 if (log.isDebugEnabled()) {139 log.debug("Validating attachment contentType: " + receivedAttachment.getContentType() + 140 "='" + controlAttachment.getContentType() + "': OK.");141 }142 }143 144 /**145 * Constructs proper error message with expected value and actual value.146 * @param message the base error message.147 * @param expectedValue the expected value.148 * @param actualValue the actual value.149 * @return150 */151 private String buildValidationErrorMessage(String message, Object expectedValue, Object actualValue) {152 return message + ", expected '" + expectedValue + "' but was '" + actualValue + "'";153 }154 /**155 * Delegate content body validation to subclasses.156 * @param receivedAttachment157 * @param controlAttachment158 */159 protected abstract void validateAttachmentContent(SoapAttachment receivedAttachment, SoapAttachment controlAttachment);160}...

Full Screen

Full Screen

buildValidationErrorMessage

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.builder.ValidatorBuilder;2import com.consol.citrus.dsl.builder.ValidationBuilder;3import com.consol.citrus.dsl.builder.ValidationContextBuilder;4import com.consol.citrus.dsl.runner.TestRunner;5import com.consol.citrus.dsl.runner.TestRunnerSupport;6import com.consol.citrus.ws.validation.AbstractSoapAttachmentValidator;7import com.consol.citrus.ws.validation.SoapAttachmentValidationContext;8import com.consol.citrus.ws.validation.SoapAttachmentValidationContextBuilder;9import com.consol.citrus.ws.validation.SoapAttachmentValidator;10import org.springframework.util.StringUtils;11import java.util.ArrayList;12import java.util.List;13public class CustomSoapAttachmentValidator extends AbstractSoapAttachmentValidator {14 public List<String> validateAttachment(String controlAttachment, String testAttachment, SoapAttachmentValidationContext validationContext) {15 List<String> validationErrors = new ArrayList<>();16 if (!StringUtils.isEmpty(controlAttachment) && !StringUtils.isEmpty(testAttachment)) {17 if (!controlAttachment.equals(testAttachment)) {18 validationErrors.add(buildValidationErrorMessage("Attachment content", controlAttachment, testAttachment));19 }20 }21 return validationErrors;22 }23 public List<String> validateAttachment(String controlAttachment, String testAttachment, SoapAttachmentValidationContextBuilder validationContextBuilder) {24 return validateAttachment(controlAttachment, testAttachment, validationContextBuilder.build());25 }26 public ValidationContextBuilder<? extends SoapAttachmentValidationContext, ? extends SoapAttachmentValidationContextBuilder> createValidationContextBuilder() {27 return SoapAttachmentValidationContextBuilder.withSoapAttachmentValidator(this);28 }29 public SoapAttachmentValidator getValidator() {30 return this;31 }32 public ValidationBuilder validate() {33 return new ValidationBuilder(getValidator());34 }35 public ValidatorBuilder validate(TestRunner runner) {36 return new ValidatorBuilder(runner, getValidator());37 }38 public ValidatorBuilder validate(TestRunnerSupport runner) {39 return new ValidatorBuilder(runner, getValidator());40 }41}42import com.consol.citrus.dsl.builder.HttpClientActionBuilder;43import com.consol.citrus.dsl.builder.HttpServerActionBuilder;44import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder;45import com.consol.cit

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful