EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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