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

COVERAGE SUMMARY FOR SOURCE FILE [BindServerToPlainTextString.java]

nameclass, %method, %block, %line, %
BindServerToPlainTextString.java100% (1/1)100% (2/2)100% (38/38)100% (10/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BindServerToPlainTextString100% (1/1)100% (2/2)100% (38/38)100% (10/10)
BindServerToPlainTextString (Function, ListOfMapsToListOfKeyValuesDelimitedBy... 100% (1/1)100% (9/9)100% (4/4)
bindToRequest (HttpRequest, Object): HttpRequest 100% (1/1)100% (29/29)100% (6/6)

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.elasticstack.binders;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import java.util.Map;
24 
25import javax.inject.Inject;
26import javax.inject.Singleton;
27import javax.ws.rs.core.MediaType;
28 
29import org.jclouds.elasticstack.domain.Server;
30import org.jclouds.elasticstack.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
31import org.jclouds.http.HttpRequest;
32import org.jclouds.rest.Binder;
33 
34import com.google.common.base.Function;
35import com.google.common.collect.ImmutableSet;
36 
37/**
38 * 
39 * @author Adrian Cole
40 */
41@Singleton
42public class BindServerToPlainTextString implements Binder {
43   private final Function<Server, Map<String, String>> createServerRequestToMap;
44   private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines;
45 
46   @Inject
47   public BindServerToPlainTextString(Function<Server, Map<String, String>> createServerRequestToMap,
48         ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) {
49      this.createServerRequestToMap = createServerRequestToMap;
50      this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines;
51   }
52   @Override
53   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
54      checkArgument(payload instanceof Server, "this binder is only valid for Server!");
55      Server create = Server.class.cast(payload);
56      Map<String, String> map = createServerRequestToMap.apply(create);
57      request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
58      request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
59      return request;
60   }
61}

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