Skip to content

Commit ab36cb0

Browse files
authored
Merge pull request #29 from jupiter-tools/fix-partial-matching
partial matching
2 parents da5c8c7 + 08187e3 commit ab36cb0

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/ActiveMqSmartDataSetTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages;
66
import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest;
7+
import com.jupiter.tools.spring.test.activemq.extension.expected.Bar;
78
import com.jupiter.tools.spring.test.activemq.extension.expected.Foo;
89
import com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar;
910
import org.junit.jupiter.api.Test;
@@ -54,6 +55,28 @@ void testExpectedWithDate() {
5455
jmsTemplate.convertAndSend("test-queue", fooWithBar);
5556
}
5657

58+
@Test
59+
@ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_partial.json")
60+
void testExpectedPartialFields() {
61+
62+
Foo childFoo = new Foo("child foo");
63+
Bar childBar = new Bar("child bar", 1);
64+
FooWithBar child = FooWithBar.builder()
65+
.foo(childFoo)
66+
.bar(childBar)
67+
.build();
68+
69+
Foo foo = new Foo("parent foo");
70+
Bar bar = new Bar("parent bar", 2);
71+
FooWithBar fooWithBar = FooWithBar.builder()
72+
.foo(foo)
73+
.bar(bar)
74+
.child(child)
75+
.build();
76+
77+
jmsTemplate.convertAndSend("test-queue", fooWithBar);
78+
}
79+
5780
@TestConfiguration
5881
public static class TestConfig {
5982
@Bean
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar": [
3+
{
4+
"foo": {
5+
"value": "parent foo"
6+
},
7+
"bar": {
8+
"name": "parent bar"
9+
},
10+
"child": {
11+
"foo": {
12+
"value": "child foo"
13+
}
14+
}
15+
}
16+
]
17+
}

spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/ExpectedMessagesExtensionTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ void testSendObjectWithNested() {
7676
amqpTemplate.convertAndSend("test-queue", fooWithBar);
7777
}
7878

79+
@Test
80+
@ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_partial.json")
81+
void testExpectedPartialFields() {
82+
83+
Foo childFoo = new Foo("child foo");
84+
Bar childBar = new Bar("child bar", 1);
85+
FooWithBar child = FooWithBar.builder()
86+
.foo(childFoo)
87+
.bar(childBar)
88+
.build();
89+
90+
Foo foo = new Foo("parent foo");
91+
Bar bar = new Bar("parent bar", 2);
92+
FooWithBar fooWithBar = FooWithBar.builder()
93+
.foo(foo)
94+
.bar(bar)
95+
.child(child)
96+
.build();
97+
98+
amqpTemplate.convertAndSend("test-queue", fooWithBar);
99+
}
100+
79101
@Test
80102
@ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_js.json")
81103
void testExpectedDataSetWithJavaScript() {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"com.jupiter.tools.spring.test.rabbitmq.extension.pojo.FooWithBar": [
3+
{
4+
"foo": {
5+
"value": "parent foo"
6+
},
7+
"bar": {
8+
"name": "parent bar"
9+
},
10+
"child": {
11+
"foo": {
12+
"value": "child foo"
13+
}
14+
}
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)