EMMA Coverage Report (generated Fri Aug 26 14:14:05 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8.binders]

COVERAGE SUMMARY FOR SOURCE FILE [BindCreateKeyToXmlPayload.java]

nameclass, %method, %block, %line, %
BindCreateKeyToXmlPayload.java0%   (0/1)0%   (0/3)0%   (0/49)0%   (0/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BindCreateKeyToXmlPayload0%   (0/1)0%   (0/3)0%   (0/49)0%   (0/10)
BindCreateKeyToXmlPayload (String, String, BindToStringPayload): void 0%   (0/1)0%   (0/12)0%   (0/5)
bindToRequest (HttpRequest, Map): HttpRequest 0%   (0/1)0%   (0/32)0%   (0/4)
bindToRequest (HttpRequest, Object): HttpRequest 0%   (0/1)0%   (0/5)0%   (0/1)

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.trmk.vcloud_0_8.binders;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
23 
24import java.util.Map;
25 
26import javax.inject.Inject;
27import javax.inject.Named;
28import javax.inject.Singleton;
29 
30import org.jclouds.http.HttpRequest;
31import org.jclouds.rest.MapBinder;
32import org.jclouds.rest.binders.BindToStringPayload;
33import org.jclouds.util.Strings2;
34 
35import com.google.common.collect.ImmutableMap;
36 
37/**
38 * 
39 * @author Adrian Cole
40 * 
41 */
42@Singleton
43public class BindCreateKeyToXmlPayload implements MapBinder {
44 
45   private final String xmlTemplate;
46   private final BindToStringPayload stringBinder;
47   private final String ns;
48 
49   @Inject
50   BindCreateKeyToXmlPayload(@Named(PROPERTY_TERREMARK_EXTENSION_NS) String ns, @Named("CreateKey") String xmlTemplate,
51         BindToStringPayload stringBinder) {
52      this.ns = ns;
53      this.xmlTemplate = xmlTemplate;
54      this.stringBinder = stringBinder;
55   }
56 
57   @Override
58   public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
59      String name = checkNotNull(postParams.get("name"), "name parameter not present");
60      String isDefault = checkNotNull(postParams.get("isDefault"), "isDefault parameter not present");
61 
62      String payload = Strings2.replaceTokens(xmlTemplate,
63            ImmutableMap.of("name", name, "isDefault", isDefault, "ns", ns));
64      return stringBinder.bindToRequest(request, payload);
65   }
66 
67   @Override
68   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
69      throw new IllegalStateException("CreateKey needs parameters");
70   }
71 
72}

[all classes][org.jclouds.trmk.vcloud_0_8.binders]
EMMA 2.0.5312 (C) Vladimir Roubtsov