EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.rimuhosting.miro.binder]

COVERAGE SUMMARY FOR SOURCE FILE [CreateServerOptions.java]

nameclass, %method, %block, %line, %
CreateServerOptions.java100% (1/1)50%  (2/4)83%  (50/60)71%  (10/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CreateServerOptions100% (1/1)50%  (2/4)83%  (50/60)71%  (10/14)
withMetaData (List): CreateServerOptions 0%   (0/1)0%   (0/5)0%   (0/2)
withPassword (String): CreateServerOptions 0%   (0/1)0%   (0/5)0%   (0/2)
CreateServerOptions (Json): void 100% (1/1)100% (9/9)100% (3/3)
bindToRequest (HttpRequest, Map): HttpRequest 100% (1/1)100% (41/41)100% (7/7)

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.rimuhosting.miro.binder;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.ArrayList;
24import java.util.List;
25import java.util.Map;
26 
27import javax.inject.Inject;
28 
29import org.jclouds.http.HttpRequest;
30import org.jclouds.json.Json;
31import org.jclouds.rimuhosting.miro.data.CreateOptions;
32import org.jclouds.rimuhosting.miro.data.NewServerData;
33import org.jclouds.rimuhosting.miro.domain.MetaData;
34 
35/**
36 * @author Ivan Meredith
37 */
38public class CreateServerOptions extends RimuHostingJsonBinder {
39   @Inject
40   public CreateServerOptions(Json jsonBinder) {
41      super(jsonBinder);
42   }
43   
44   private String password;
45   private List<MetaData> metaData = new ArrayList<MetaData>();
46 
47   @Override
48   public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
49      String name = checkNotNull(postParams.get("name"));
50      String imageId = checkNotNull(postParams.get("imageId"));
51      String planId = checkNotNull(postParams.get("planId"));
52      // There will be cases when the password is null.
53      String password = this.password;
54      NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
55      newServerData.setMetaData(metaData);
56      return bindToRequest(request, newServerData);
57   }
58 
59   public CreateServerOptions withPassword(String password) {
60      this.password = password;
61      return this;
62   }
63 
64   public CreateServerOptions withMetaData(List<MetaData> metaData) {
65      this.metaData = metaData;
66      return this;
67   }
68}

[all classes][org.jclouds.rimuhosting.miro.binder]
EMMA 2.0.5312 (C) Vladimir Roubtsov