Skip to content

Commit

Permalink
Merge pull request #29 from jupiter-tools/fix-partial-matching
Browse files Browse the repository at this point in the history
partial matching
  • Loading branch information
antkorwin authored Jun 10, 2020
2 parents da5c8c7 + 08187e3 commit ab36cb0
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages;
import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest;
import com.jupiter.tools.spring.test.activemq.extension.expected.Bar;
import com.jupiter.tools.spring.test.activemq.extension.expected.Foo;
import com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -54,6 +55,28 @@ void testExpectedWithDate() {
jmsTemplate.convertAndSend("test-queue", fooWithBar);
}

@Test
@ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_partial.json")
void testExpectedPartialFields() {

Foo childFoo = new Foo("child foo");
Bar childBar = new Bar("child bar", 1);
FooWithBar child = FooWithBar.builder()
.foo(childFoo)
.bar(childBar)
.build();

Foo foo = new Foo("parent foo");
Bar bar = new Bar("parent bar", 2);
FooWithBar fooWithBar = FooWithBar.builder()
.foo(foo)
.bar(bar)
.child(child)
.build();

jmsTemplate.convertAndSend("test-queue", fooWithBar);
}

@TestConfiguration
public static class TestConfig {
@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar": [
{
"foo": {
"value": "parent foo"
},
"bar": {
"name": "parent bar"
},
"child": {
"foo": {
"value": "child foo"
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ void testSendObjectWithNested() {
amqpTemplate.convertAndSend("test-queue", fooWithBar);
}

@Test
@ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_partial.json")
void testExpectedPartialFields() {

Foo childFoo = new Foo("child foo");
Bar childBar = new Bar("child bar", 1);
FooWithBar child = FooWithBar.builder()
.foo(childFoo)
.bar(childBar)
.build();

Foo foo = new Foo("parent foo");
Bar bar = new Bar("parent bar", 2);
FooWithBar fooWithBar = FooWithBar.builder()
.foo(foo)
.bar(bar)
.child(child)
.build();

amqpTemplate.convertAndSend("test-queue", fooWithBar);
}

@Test
@ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_js.json")
void testExpectedDataSetWithJavaScript() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"com.jupiter.tools.spring.test.rabbitmq.extension.pojo.FooWithBar": [
{
"foo": {
"value": "parent foo"
},
"bar": {
"name": "parent bar"
},
"child": {
"foo": {
"value": "child foo"
}
}
}
]
}

0 comments on commit ab36cb0

Please sign in to comment.