Skip to content

Commit 6e23963

Browse files
committed
GH-1419: Increase New Code Test Coverage
1 parent 82c69d5 commit 6e23963

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/NodeLocatorTests.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,62 @@ public Map<String, Object> restCall(Object client, String baseUri, String vhost,
5858
return Map.of("node", "a@b");
5959
}
6060
}
61+
62+
});
63+
ConnectionFactory factory = nodeLocator.locate(new String[] { "http://foo", "http://bar" },
64+
Map.of("a@b", "baz"), null, "q", null, null, (q, n, u) -> {
65+
return null;
66+
});
67+
verify(nodeLocator, times(2)).restCall(any(), any(), any(), any());
68+
}
69+
70+
@Test
71+
@DisplayName("rest returned null")
72+
void nullInfo() throws URISyntaxException {
73+
74+
NodeLocator<Object> nodeLocator = spy(new NodeLocator<Object>() {
75+
76+
@Override
77+
public Object createClient(String userName, String password) {
78+
return null;
79+
}
80+
81+
@Override
82+
@Nullable
83+
public Map<String, Object> restCall(Object client, String baseUri, String vhost, String queue) {
84+
if (baseUri.contains("foo")) {
85+
return null;
86+
}
87+
else {
88+
return Map.of("node", "a@b");
89+
}
90+
}
91+
92+
});
93+
ConnectionFactory factory = nodeLocator.locate(new String[] { "http://foo", "http://bar" },
94+
Map.of("a@b", "baz"), null, "q", null, null, (q, n, u) -> {
95+
return null;
96+
});
97+
verify(nodeLocator, times(2)).restCall(any(), any(), any(), any());
98+
}
99+
100+
@Test
101+
@DisplayName("queue not found")
102+
void notFound() throws URISyntaxException {
103+
104+
NodeLocator<Object> nodeLocator = spy(new NodeLocator<Object>() {
105+
106+
@Override
107+
public Object createClient(String userName, String password) {
108+
return null;
109+
}
110+
111+
@Override
112+
@Nullable
113+
public Map<String, Object> restCall(Object client, String baseUri, String vhost, String queue) {
114+
return null;
115+
}
116+
61117
});
62118
ConnectionFactory factory = nodeLocator.locate(new String[] { "http://foo", "http://bar" },
63119
Map.of("a@b", "baz"), null, "q", null, null, (q, n, u) -> {

0 commit comments

Comments
 (0)