EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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