-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a testcase for XmlMarshallingValidationProcessor.Builder
- Loading branch information
1 parent
9953169
commit 4ac1678
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...c/test/java/org/citrusframework/validation/xml/XmlMarshallingValidationProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.citrusframework.validation.xml; | ||
|
||
import org.citrusframework.UnitTestSupport; | ||
import org.citrusframework.message.DefaultMessage; | ||
import org.citrusframework.spi.ReferenceResolver; | ||
import org.citrusframework.spi.SimpleReferenceResolver; | ||
import org.citrusframework.validation.GenericValidationProcessor; | ||
import org.citrusframework.xml.Unmarshaller; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
class XmlMarshallingValidationProcessorTest extends UnitTestSupport { | ||
final Unmarshaller unmarshaller = Object::toString; | ||
final GenericValidationProcessor<String> validationProcessor = (payload, headers, context) -> | ||
logger.info("Validating message %s".formatted(payload)); | ||
|
||
@Test | ||
void builderWithoutUnmarshallerTest() { | ||
XmlMarshallingValidationProcessor<String> build = XmlMarshallingValidationProcessor.Builder.validate(validationProcessor) | ||
.unmarshaller(unmarshaller) | ||
.build(); | ||
|
||
build.setReferenceResolver(new SimpleReferenceResolver()); | ||
|
||
assertDoesNotThrow(() -> build.validate(new DefaultMessage().setPayload("hi"), null)); | ||
} | ||
|
||
@Test | ||
void builderWithUnmarshallerTest() { | ||
final ReferenceResolver referenceResolver = new SimpleReferenceResolver(); | ||
referenceResolver.bind("anyName", unmarshaller); | ||
|
||
XmlMarshallingValidationProcessor<String> build = XmlMarshallingValidationProcessor.Builder.validate(validationProcessor) | ||
.withReferenceResolver(referenceResolver) | ||
.build(); | ||
|
||
build.setReferenceResolver(referenceResolver); | ||
|
||
assertDoesNotThrow(() -> build.validate(new DefaultMessage().setPayload("bye"), null)); | ||
} | ||
} |