How to use dispatch method of com.consol.citrus.validation.json.report.GraciousProcessingReport class

Best Citrus code snippet using com.consol.citrus.validation.json.report.GraciousProcessingReport.dispatch

Source:GraciousProcessingReport.java Github

copy

Full Screen

...74 return exceptionThreshold;75 }76 @Override77 public void debug(ProcessingMessage message) throws ProcessingException {78 dispatch(message.setLogLevel(LogLevel.DEBUG));79 }80 @Override81 public void info(ProcessingMessage message) throws ProcessingException {82 dispatch(message.setLogLevel(LogLevel.INFO));83 }84 @Override85 public void warn(ProcessingMessage message) throws ProcessingException {86 dispatch(message.setLogLevel(LogLevel.WARNING));87 }88 @Override89 public void error(ProcessingMessage message) throws ProcessingException {90 dispatch(message.setLogLevel(LogLevel.ERROR));91 }92 @Override93 public void fatal(ProcessingMessage message) throws ProcessingException {94 dispatch(message.setLogLevel(LogLevel.FATAL));95 }96 public boolean isSuccess() {97 return success;98 }99 public List<ProcessingMessage> getMessages() {100 return messages;101 }102 @Override103 @Nonnull104 public Iterator<ProcessingMessage> iterator() {105 return Iterators.unmodifiableIterator(messages.iterator());106 }107 /**108 * Main dispatch method109 *110 * All messages logged go through this method. According to the report111 * configuration, the message will either be ignored, logged or raise an112 * exception.113 *114 * @param message the message to log115 * @throws ProcessingException the message's level and report configuration116 * require that an exception be thrown117 */118 private void dispatch(final ProcessingMessage message) throws ProcessingException {119 final LogLevel level = message.getLogLevel();120 if (level.compareTo(exceptionThreshold) >= 0)121 throw message.asException();122 if (level.compareTo(currentLevel) > 0)123 currentLevel = level;124 if (level.compareTo(logLevel) >= 0)125 log(message);126 }127 public void log(final ProcessingMessage message) {128 messages.add(message);129 }130}...

Full Screen

Full Screen

dispatch

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.builder.ReceiveMessageBuilder2import com.consol.citrus.dsl.builder.SendMessageBuilder3import com.consol.citrus.dsl.runner.TestRunner4import com.consol.citrus.dsl.runner.TestRunnerSupport5import com.consol.citrus.dsl.runner.TestRunnerSupport.TestRunnerSupportBuilder6import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner7import com.consol.citrus.message.MessageType8import com.consol.citrus.validation.json.JsonMessageValidationContext9import com.consol.citrus.validation.matcher.ValidationMatcherUtils10import com.consol.citrus.validation.script.GroovyJsonMessageValidationContext11import com.consol.citrus.validation.xml.XmlMessageValidationContext12import com.consol.citrus.xml.namespace.NamespaceContextBuilder13import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport14import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder15import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.*16import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl17import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.*18import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.NamespaceContextBuilderSupportBuilderImplImpl19import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.NamespaceContextBuilderSupportBuilderImplImpl.*20import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.NamespaceContextBuilderSupportBuilderImplImpl.NamespaceContextBuilderSupportBuilderImplImplImpl21import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.NamespaceContextBuilderSupportBuilderImplImpl.NamespaceContextBuilderSupportBuilderImplImplImpl.*22import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.NamespaceContextBuilderSupportBuilderImplImpl.NamespaceContextBuilderSupportBuilderImplImplImpl.NamespaceContextBuilderSupportBuilderImplImplImplImpl23import com.consol.citrus.xml.namespace.NamespaceContextBuilderSupport.NamespaceContextBuilderSupportBuilder.NamespaceContextBuilderSupportBuilderImpl.NamespaceContextBuilderSupportBuilder

Full Screen

Full Screen

dispatch

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.validation.json.JsonMessageValidationContext;2import com.consol.citrus.validation.json.JsonMessageValidator;3import com.consol.citrus.validation.json.report.GraciousProcessingReport;4import com.fasterxml.jackson.databind.JsonNode;5import com.fasterxml.jackson.databind.ObjectMapper;6import com.fasterxml.jackson.databind.node.ObjectNode;7import com.github.fge.jsonschema.core.report.ProcessingReport;8import com.github.fge.jsonschema.main.JsonSchema;9import com.github.fge.jsonschema.main.JsonSchemaFactory;10import org.slf4j.Logger;11import org.slf4j.LoggerFactory;12import org.springframework.util.StringUtils;13import java.io.IOException;14public class GraciousJsonMessageValidator extends JsonMessageValidator {15 private static final Logger LOG = LoggerFactory.getLogger(GraciousJsonMessageValidator.class);16 public void validateMessagePayload(String messagePayload, String controlPayload, JsonMessageValidationContext validationContext) {17 ObjectMapper objectMapper = new ObjectMapper();18 try {19 JsonNode messageNode = objectMapper.readTree(messagePayload);20 JsonNode controlNode = objectMapper.readTree(controlPayload);21 JsonSchemaFactory factory = JsonSchemaFactory.byDefault();22 JsonSchema schema = factory.getJsonSchema(controlNode);23 ProcessingReport report = schema.validate(messageNode, true);24 if (!report.isSuccess()) {25 GraciousProcessingReport graciousProcessingReport = new GraciousProcessingReport();26 report.forEach(graciousProcessingReport::dispatch);27 ObjectNode reportNode = (ObjectNode) objectMapper.readTree(report.toString());28 reportNode.put("message", graciousProcessingReport.getErrorMessage());29 report = schema.validate(messageNode, reportNode);30 }31 if (!report.isSuccess()) {32 String errorMessage = String.format("JSON message validation failed:%n%s", report);33 if (validationContext.isIgnoreErrors()) {34 LOG.warn(errorMessage);35 } else {36 throw new JsonMessageValidationException(errorMessage);37 }38 }39 } catch (IOException e) {40 throw new JsonMessageValidationException("Failed to parse JSON message", e);41 }42 }43}44import com.github.fge.jsonschema.core.report.LogLevel;

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