EMMA Coverage Report (generated Fri Aug 26 14:14:05 EDT 2011)
[all classes][org.jclouds.openstack.nova.options]

COVERAGE SUMMARY FOR SOURCE FILE [RebuildServerOptions.java]

nameclass, %method, %block, %line, %
RebuildServerOptions.java100% (2/2)67%  (4/6)84%  (46/55)88%  (11.4/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RebuildServerOptions$Builder100% (1/1)50%  (1/2)73%  (8/11)67%  (2/3)
RebuildServerOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
withImage (String): RebuildServerOptions 100% (1/1)100% (8/8)100% (2/2)
     
class RebuildServerOptions100% (1/1)75%  (3/4)86%  (38/44)90%  (9.9/11)
bindToRequest (HttpRequest, Object): HttpRequest 0%   (0/1)0%   (0/5)0%   (0/1)
withImage (String): RebuildServerOptions 100% (1/1)94%  (16/17)98%  (3.9/4)
RebuildServerOptions (): void 100% (1/1)100% (3/3)100% (2/2)
bindToRequest (HttpRequest, Map): HttpRequest 100% (1/1)100% (19/19)100% (4/4)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.openstack.nova.options;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22import static com.google.common.base.Preconditions.checkNotNull;
23 
24import java.util.Map;
25 
26import javax.inject.Inject;
27 
28import org.jclouds.http.HttpRequest;
29import org.jclouds.rest.MapBinder;
30import org.jclouds.rest.binders.BindToJsonPayload;
31 
32import com.google.common.collect.ImmutableMap;
33import com.google.common.collect.Maps;
34 
35/**
36 * 
37 * 
38 * @author Adrian Cole
39 * 
40 */
41public class RebuildServerOptions implements MapBinder {
42   @Inject
43   private BindToJsonPayload jsonBinder;
44   String imageRef;
45 
46   @Override
47   public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
48      Map<String, String> image = Maps.newHashMap();
49      if (imageRef != null)
50         image.put("imageRef", imageRef);
51      return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image));
52   }
53 
54   @Override
55   public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
56      throw new IllegalStateException("RebuildServer is a POST operation");
57   }
58 
59   /**
60    * @param ref
61    *           - reference of the image to rebuild the server with.
62    */
63   public RebuildServerOptions withImage(String ref) {
64      checkNotNull(ref, "image reference should not be null");
65      checkArgument(!ref.isEmpty(), "image reference should not be empty");
66      this.imageRef = ref;
67      return this;
68   }
69 
70   public static class Builder {
71 
72      /**
73       * @see RebuildServerOptions#withImage(String)
74       */
75      public static RebuildServerOptions withImage(String ref) {
76         RebuildServerOptions options = new RebuildServerOptions();
77         return options.withImage(ref);
78      }
79   }
80}

[all classes][org.jclouds.openstack.nova.options]
EMMA 2.0.5312 (C) Vladimir Roubtsov