You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Zack Shoylev <no...@github.com> on 2013/11/07 22:29:43 UTC
[jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
You can merge this Pull Request by running:
git pull https://github.com/rackerlabs/jclouds-labs-openstack rackspace-autoscale3
Or you can view, comment on it, or merge it online at:
https://github.com/jclouds/jclouds-labs-openstack/pull/48
-- Commit Summary --
* JCLOUDS-215 - Adds Webhook and Execution support to autoscale
-- File Changes --
M rackspace-autoscale-us/src/main/java/org/jclouds/rackspace/autoscale/us/v1/AutoscaleUSProviderMetadata.java (9)
M rackspace-autoscale-us/src/test/java/org/jclouds/rackspace/autoscale/us/v1/features/AutoscaleUSGroupApiLiveTest.java (2)
M rackspace-autoscale-us/src/test/java/org/jclouds/rackspace/autoscale/us/v1/features/AutoscaleUSScalingPolicyApiLiveTest.java (2)
A rackspace-autoscale-us/src/test/java/org/jclouds/rackspace/autoscale/us/v1/features/AutoscaleUSWebhookApiLiveTest.java (32)
M rackspace-autoscale/pom.xml (12)
M rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/AutoscaleApi.java (10)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhookToJson.java (60)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhookUpdateToJson.java (58)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhooksToJson.java (65)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Webhook.java (136)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/WebhookResponse.java (104)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApi.java (161)
A rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/utils/AutoscaleUtils.java (52)
M rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiExpectTest.java (4)
M rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiLiveTest.java (13)
M rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiLiveTest.java (36)
A rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiExpectTest.java (187)
A rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiLiveTest.java (304)
A rackspace-autoscale/src/test/resources/autoscale_webhook_create_request.json (8)
A rackspace-autoscale/src/test/resources/autoscale_webhook_create_response.json (21)
M rackspace-autoscale/src/test/resources/autoscale_webhook_get_response.json (22)
A rackspace-autoscale/src/test/resources/autoscale_webhook_list_response.json (37)
A rackspace-autoscale/src/test/resources/autoscale_webhooks_create_request.json (11)
A rackspace-autoscale/src/test/resources/autoscale_webhooks_create_response.json (36)
-- Patch Links --
https://github.com/jclouds/jclouds-labs-openstack/pull/48.patch
https://github.com/jclouds/jclouds-labs-openstack/pull/48.diff
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #91](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/91/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28097019
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> + connection.setDoOutput(true);
> + connection.setDoInput(true);
> + connection.setInstanceFollowRedirects(false);
> + connection.setRequestMethod("POST");
> + connection.setUseCaches(false);
> + connection.connect();
> + int code = connection.getResponseCode();
> + connection.disconnect();
> +
> + return code == 202;
> + }
> +
> + public static boolean execute(WebhookResponse webhook) throws IOException {
> + return execute(webhook.getAnonymousExecutionURI());
> + }
Makes perfect sense. Thanks for explaining!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7537633
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> + connection.setDoOutput(true);
> + connection.setDoInput(true);
> + connection.setInstanceFollowRedirects(false);
> + connection.setRequestMethod("POST");
> + connection.setUseCaches(false);
> + connection.connect();
> + int code = connection.getResponseCode();
> + connection.disconnect();
> +
> + return code == 202;
> + }
> +
> + public static boolean execute(WebhookResponse webhook) throws IOException {
> + return execute(webhook.getAnonymousExecutionURI());
> + }
Could the logic in this class be included as part of the `WebhookApi`? Something like:
```java
HttpResponse anonymousExecute(@EndpointParam(parser = ExtractURIFromWebhook.class) Webhook webhook);
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7513307
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
Changes look good to me. Thanks @zack-shoylev!
Just a tip (although it is a matter of preference): when addressing review comments, push the changes in a separate commit. Don't squash until it is ok to merge (or requested). This helps focusing only on the last changes, without having to go through all the files to identify what can have changed.
Thx again!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28095061
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + assertEquals(webhook.getLinks().size(), 2);
> + }
> +
> + public void testGetWebhookFail() {
> + URI endpoint = URI.create("https://dfw.autoscale.api.rackspacecloud.com/v1.0/888888/groups/1234567890/policies/321456/webhooks/5555");
> + WebhookApi api = requestsSendResponses(
> + keystoneAuthWithUsernameAndPasswordAndTenantName,
> + responseWithKeystoneAccess,
> + authenticatedGET().endpoint(endpoint).build(),
> + HttpResponse.builder().statusCode(404).payload(payloadFromResource("/autoscale_webhook_get_response.json")).build()
> + ).getWebhookApiForGroupAndPolicyInZone("1234567890", "321456", "DFW");
> +
> + WebhookResponse webhook = api.get("5555");
> + assertNull(webhook);
> + }
> +}
I'm not sure that is a good idea. If we pospose this refactor, does anyone know when it will be addressed (or if it will just happen)? In my opinion, if we have decided to implement unit tests in a certain way, we should do that directly when we add a new test class. Adding tests to an already existing class is different, but when writing an entire class form scratch, we should do it the right way. My main worries about leaving this out of this PR is that we are introducing more technical debt to the project, and we already have an important an amount of it (trove is part of that technical debt, but IMO that does not justify not implementing tests here the right way).
There are also several open pull requests where we asked to implement the tests using `mockwebserver` (see the Joyen blob store one, for example), and we should be consistent with that in other pull requests.
No offense :) I'm just trying to make this PR follow what we thought was a better way to implement unit tests, but we can discuss that :) If we are asking people to do so, we'd better give them some examples and do it ourselves too.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7520958
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + assertEquals(webhook.getLinks().size(), 2);
> + }
> +
> + public void testGetWebhookFail() {
> + URI endpoint = URI.create("https://dfw.autoscale.api.rackspacecloud.com/v1.0/888888/groups/1234567890/policies/321456/webhooks/5555");
> + WebhookApi api = requestsSendResponses(
> + keystoneAuthWithUsernameAndPasswordAndTenantName,
> + responseWithKeystoneAccess,
> + authenticatedGET().endpoint(endpoint).build(),
> + HttpResponse.builder().statusCode(404).payload(payloadFromResource("/autoscale_webhook_get_response.json")).build()
> + ).getWebhookApiForGroupAndPolicyInZone("1234567890", "321456", "DFW");
> +
> + WebhookResponse webhook = api.get("5555");
> + assertNull(webhook);
> + }
> +}
That said, I'm ok to leave this for a different pull request if we open an issue in JIRA to refactor the whole autoscale and set the fix version to 1.7 (or the versions this PR will be merged to). Just want to make sure we don't forget this and we don't increase our technical debt.
WDYT?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7520995
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> +import com.google.common.base.Objects.ToStringHelper;
> +import com.google.common.collect.ImmutableMap;
> +
> +/**
> + * An Autoscale Webhook for a specific group and policy.
> + *
> + * @see Group
> + * @see ScalingPolicy
> + * @author Zack Shoylev
> + */
> +public class Webhook {
> + private final String name;
> + private final ImmutableMap<String, Object> metadata;
> +
> + @ConstructorProperties({ "name", "metadata" })
> + protected Webhook(String name, Map<String, Object> metadata) {
Mark metadata as `@Nullable`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7512750
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + } else {
> + this.metadata = ImmutableMap.copyOf(metadata);
> + }
> + }
> +
> + /**
> + * @return the name of this Webhook.
> + * @see Webhook.Builder#name(String)
> + */
> + public String getName() {
> + return this.name;
> + }
> +
> + /**
> + * @return the metadata for this Webhook.
> + * @see Webhook.Builder#metadata(String)
Parameter is a `Map`, not a `String`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7512776
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Zack Shoylev <no...@github.com>.
> + assertEquals(webhook.getLinks().size(), 2);
> + }
> +
> + public void testGetWebhookFail() {
> + URI endpoint = URI.create("https://dfw.autoscale.api.rackspacecloud.com/v1.0/888888/groups/1234567890/policies/321456/webhooks/5555");
> + WebhookApi api = requestsSendResponses(
> + keystoneAuthWithUsernameAndPasswordAndTenantName,
> + responseWithKeystoneAccess,
> + authenticatedGET().endpoint(endpoint).build(),
> + HttpResponse.builder().statusCode(404).payload(payloadFromResource("/autoscale_webhook_get_response.json")).build()
> + ).getWebhookApiForGroupAndPolicyInZone("1234567890", "321456", "DFW");
> +
> + WebhookResponse webhook = api.get("5555");
> + assertNull(webhook);
> + }
> +}
Rather refactor the whole autoscale to use mockwebserver later. Separate commit. This also needs to be done for trove too.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7514676
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + assertEquals(webhook.getLinks().size(), 2);
> + }
> +
> + public void testGetWebhookFail() {
> + URI endpoint = URI.create("https://dfw.autoscale.api.rackspacecloud.com/v1.0/888888/groups/1234567890/policies/321456/webhooks/5555");
> + WebhookApi api = requestsSendResponses(
> + keystoneAuthWithUsernameAndPasswordAndTenantName,
> + responseWithKeystoneAccess,
> + authenticatedGET().endpoint(endpoint).build(),
> + HttpResponse.builder().statusCode(404).payload(payloadFromResource("/autoscale_webhook_get_response.json")).build()
> + ).getWebhookApiForGroupAndPolicyInZone("1234567890", "321456", "DFW");
> +
> + WebhookResponse webhook = api.get("5555");
> + assertNull(webhook);
> + }
> +}
Thanks @zack-shoylev !
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7537653
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Zack Shoylev <no...@github.com>.
> + assertEquals(webhook.getLinks().size(), 2);
> + }
> +
> + public void testGetWebhookFail() {
> + URI endpoint = URI.create("https://dfw.autoscale.api.rackspacecloud.com/v1.0/888888/groups/1234567890/policies/321456/webhooks/5555");
> + WebhookApi api = requestsSendResponses(
> + keystoneAuthWithUsernameAndPasswordAndTenantName,
> + responseWithKeystoneAccess,
> + authenticatedGET().endpoint(endpoint).build(),
> + HttpResponse.builder().statusCode(404).payload(payloadFromResource("/autoscale_webhook_get_response.json")).build()
> + ).getWebhookApiForGroupAndPolicyInZone("1234567890", "321456", "DFW");
> +
> + WebhookResponse webhook = api.get("5555");
> + assertNull(webhook);
> + }
> +}
I added JCLOUDS-370 and JCLOUDS-371 specifically to switch to mock webserver. This should also be separate from the other refactoring that needs to be done for autoscale when it is more stable.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7530270
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> +import com.google.common.collect.ImmutableList;
> +
> +/**
> + * Autoscale WebhookResponse. Extends Webhook with id and links.
> + *
> + * @see Webhook#getWebhooks()
> + * @author Zack Shoylev
> + */
> +public class WebhookResponse extends Webhook{
> + private final ImmutableList<Link> links;
> + private final String id;
> +
> + @ConstructorProperties({
> + "name", "metadata", "links", "id"
> + })
> + public WebhookResponse(String name, Map<String, Object> metadata, List<Link> links, String id) {
Mark metadata as `@Nullable` here too?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7512840
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> +import java.net.URI;
> +
> +import javax.ws.rs.core.MediaType;
> +
> +import org.jclouds.http.HttpResponse;
> +import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
> +import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
> +import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiExpectTest;
> +import org.testng.annotations.Test;
> +
> +import com.google.common.collect.FluentIterable;
> +import com.google.common.collect.ImmutableList;
> +import com.google.common.collect.ImmutableMap;
> +
> +/**
> + * Tests GroupApi Guice wiring and parsing
This javadoc does not describe this test class.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7513335
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Zack Shoylev <no...@github.com>.
> + HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> + connection.setDoOutput(true);
> + connection.setDoInput(true);
> + connection.setInstanceFollowRedirects(false);
> + connection.setRequestMethod("POST");
> + connection.setUseCaches(false);
> + connection.connect();
> + int code = connection.getResponseCode();
> + connection.disconnect();
> +
> + return code == 202;
> + }
> +
> + public static boolean execute(WebhookResponse webhook) throws IOException {
> + return execute(webhook.getAnonymousExecutionURI());
> + }
Executing a webhook anonymously should not require context, authentication, or even jclouds. The utils method is mostly for testing/example.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7535573
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Zack Shoylev <no...@github.com>.
I will be merging this in a bit then. Thanks!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28096653
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + * The capability Link for the webhook can be called with a POST request to execute the webhook anonymously.
> + * @return the links to this ScalingPolicy.
> + * @see ScalingPolicyResponse.Builder#links(String)
> + */
> + public ImmutableList<Link> getLinks() {
> + return this.links;
> + }
> +
> + public URI getAnonymousExecutionURI() {
> + // TODO: Add Relation.CAPABILITY to openstack Link
> + for (Link l : this.links) {
> + if (l.getRelation() == Relation.UNRECOGNIZED) {
> + return l.getHref();
> + }
> + }
> + return null;
We try to avoid returning `null` to express absence. Could this method be refactored to return an `Optional<URI>`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7512902
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.rackspace.autoscale.us.v1.features;
> +
> +import org.jclouds.rackspace.autoscale.v1.features.WebhookApiLiveTest;
> +import org.testng.annotations.Test;
> +
> +/**
> + * Tests GroupApi Guice wiring and parsing
Is this javadoc ok?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7537514
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #90](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/90/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28089587
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + public Builder name(String name) {
> + this.name = name;
> + return this;
> + }
> +
> + /**
> + * @param metadata The metadata of this Webhook.
> + * @return The builder object.
> + * @see Webhook#getMetadata()
> + */
> + public Builder metadata(Map<String, Object> metadata) {
> + if (metadata == null) {
> + this.metadata = ImmutableMap.of();
> + } else {
> + this.metadata = ImmutableMap.copyOf(metadata);
> + }
The constructor already does this logic. Could this just be `this.metadata = metadata`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7512803
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> +@RequestFilters(AuthenticateRequest.class)
> +public interface WebhookApi {
> + /**
> + * Create a webhook.
> + * @param name The webhook name. Required.
> + * @param metadata A map of associated metadata. Use String keys. Required.
> + * @return WebhookResponse The webhook created by this call.
> + * @see Webhook
> + * @see WebhookResponse
> + * @see Group
> + * @see ScalingPolicy
> + */
> + @Named("Webhook:create")
> + @POST
> + @Path("/webhooks")
> + @Consumes(MediaType.APPLICATION_JSON)
All methods consume the same MediaType. Move this annotation to the class declaration and remove it from all methods?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7513084
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Zack Shoylev <no...@github.com>.
Updated with fixes
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28089430
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #89](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/89/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28008586
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Zack Shoylev <no...@github.com>.
Very good point, thanks. I was under the impression we want to keep it to one commit at all times... Much better keeping all the commits until merge. Thanks!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48#issuecomment-28096075
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> + assertEquals(webhook.getLinks().size(), 2);
> + }
> +
> + public void testGetWebhookFail() {
> + URI endpoint = URI.create("https://dfw.autoscale.api.rackspacecloud.com/v1.0/888888/groups/1234567890/policies/321456/webhooks/5555");
> + WebhookApi api = requestsSendResponses(
> + keystoneAuthWithUsernameAndPasswordAndTenantName,
> + responseWithKeystoneAccess,
> + authenticatedGET().endpoint(endpoint).build(),
> + HttpResponse.builder().statusCode(404).payload(payloadFromResource("/autoscale_webhook_get_response.json")).build()
> + ).getWebhookApiForGroupAndPolicyInZone("1234567890", "321456", "DFW");
> +
> + WebhookResponse webhook = api.get("5555");
> + assertNull(webhook);
> + }
> +}
We said that the preferred way to unit test the APIs was to use `mockwebserver` instead of the Expect tests. As this is a new test class, could it be refactored to a *MockTest that uses `mockwebserver`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7513413
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> +import org.jclouds.http.HttpResponse;
> +import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
> +import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
> +import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiExpectTest;
> +import org.testng.annotations.Test;
> +
> +import com.google.common.collect.FluentIterable;
> +import com.google.common.collect.ImmutableList;
> +import com.google.common.collect.ImmutableMap;
> +
> +/**
> + * Tests GroupApi Guice wiring and parsing
> + *
> + * @author Zack Shoylev
> + */
> +@Test(groups = "unit", testName = "GroupApiExpectTest")
Test name should be `WebhookApiExpectTest `.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7513353
Re: [jclouds-labs-openstack] JCLOUDS-215 - Adds Webhook and Execution
support to autoscale (#48)
Posted by Ignasi Barrera <no...@github.com>.
> +import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
> +import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
> +import org.jclouds.rest.annotations.Fallback;
> +import org.jclouds.rest.annotations.MapBinder;
> +import org.jclouds.rest.annotations.PayloadParam;
> +import org.jclouds.rest.annotations.RequestFilters;
> +import org.jclouds.rest.annotations.SelectJson;
> +
> +import com.google.common.collect.FluentIterable;
> +
> +/**
> + * The API for controlling autoscale webhooks.
> + * @author Zack Shoylev
> + */
> +@RequestFilters(AuthenticateRequest.class)
> +public interface WebhookApi {
Interface APIs should extend `Closeable`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/48/files#r7513026