> + public void testCreateSecurityGroupFail() throws IOException,
> InterruptedException, URISyntaxException {
> + MockWebServer server = mockOpenStackServer();
> + server.enqueue(addCommonHeaders(new
> MockResponse().setBody(stringFromResource("/access.json"))));
> + server.enqueue(addCommonHeaders(
> + new MockResponse().setResponseCode(404)));
> +
> + try {
> + NeutronApi neutronApi = api(server.getUrl("/").toString(),
> "openstack-neutron", overrides);
> + SecurityGroupApi api =
> neutronApi.getSecurityGroupApi("RegionOne").get();
> +
> + SecurityGroup.CreateOptions createSecurityGroup =
> SecurityGroup.createOptions().name("new-webservers")
> + .description("security group for webservers")
> + .build();
> +
> + SecurityGroup securityGroup = api.create(createSecurityGroup);
> + fail("Should have failed with not found exception");
Well, I tend to prefer having the tests complete, but that's just a personal
feeling.
In an hypothetical scenario where we had to disable the create OK test, because
the deserialization of the response was broken, we wouldn't have any assertion
that the request is being properly generated, even when there are other tests
that call the *create* method.
That's unlikely to happen, so being pragmatic the test would be ok as-is, but
for completeness, I tend to prefer adding all relevant assertions to make sure
everything has gone as expected.
It's perhaps just a matter of taste, and I'd be OK if the test remains as-is.
Up to you!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/132/files#r16761538