EMMA Coverage Report (generated Wed Jun 22 19:47:49 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 *
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.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