Skip to content

Commit

Permalink
GH-1419: Increase New Code Test Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
garyrussell committed Oct 14, 2022
1 parent 82c69d5 commit 6e23963
Showing 1 changed file with 56 additions and 0 deletions.
Expand Up @@ -58,6 +58,62 @@ public Map<String, Object> restCall(Object client, String baseUri, String vhost,
return Map.of("node", "a@b");
}
}

});
ConnectionFactory factory = nodeLocator.locate(new String[] { "http://foo", "http://bar" },
Map.of("a@b", "baz"), null, "q", null, null, (q, n, u) -> {
return null;
});
verify(nodeLocator, times(2)).restCall(any(), any(), any(), any());
}

@Test
@DisplayName("rest returned null")
void nullInfo() throws URISyntaxException {

NodeLocator<Object> nodeLocator = spy(new NodeLocator<Object>() {

@Override
public Object createClient(String userName, String password) {
return null;
}

@Override
@Nullable
public Map<String, Object> restCall(Object client, String baseUri, String vhost, String queue) {
if (baseUri.contains("foo")) {
return null;
}
else {
return Map.of("node", "a@b");
}
}

});
ConnectionFactory factory = nodeLocator.locate(new String[] { "http://foo", "http://bar" },
Map.of("a@b", "baz"), null, "q", null, null, (q, n, u) -> {
return null;
});
verify(nodeLocator, times(2)).restCall(any(), any(), any(), any());
}

@Test
@DisplayName("queue not found")
void notFound() throws URISyntaxException {

NodeLocator<Object> nodeLocator = spy(new NodeLocator<Object>() {

@Override
public Object createClient(String userName, String password) {
return null;
}

@Override
@Nullable
public Map<String, Object> restCall(Object client, String baseUri, String vhost, String queue) {
return null;
}

});
ConnectionFactory factory = nodeLocator.locate(new String[] { "http://foo", "http://bar" },
Map.of("a@b", "baz"), null, "q", null, null, (q, n, u) -> {
Expand Down

0 comments on commit 6e23963

Please sign in to comment.