EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8.domain]

COVERAGE SUMMARY FOR SOURCE FILE [VAppConfiguration.java]

nameclass, %method, %block, %line, %
VAppConfiguration.java100% (2/2)71%  (12/17)74%  (116/156)78%  (29.5/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VAppConfiguration$Builder100% (1/1)17%  (1/6)19%  (8/43)18%  (2/11)
VAppConfiguration$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
addDisk (long): VAppConfiguration 0%   (0/1)0%   (0/8)0%   (0/2)
changeMemoryTo (long): VAppConfiguration 0%   (0/1)0%   (0/8)0%   (0/2)
changeProcessorCountTo (int): VAppConfiguration 0%   (0/1)0%   (0/8)0%   (0/2)
deleteDiskWithAddressOnParent (int): VAppConfiguration 0%   (0/1)0%   (0/8)0%   (0/2)
changeNameTo (String): VAppConfiguration 100% (1/1)100% (8/8)100% (2/2)
     
class VAppConfiguration100% (1/1)100% (11/11)96%  (108/113)99%  (27.7/28)
addDisk (long): VAppConfiguration 100% (1/1)93%  (26/28)97%  (3.9/4)
changeProcessorCountTo (int): VAppConfiguration 100% (1/1)93%  (13/14)97%  (2.9/3)
changeMemoryTo (long): VAppConfiguration 100% (1/1)93%  (14/15)98%  (2.9/3)
deleteDiskWithAddressOnParent (int): VAppConfiguration 100% (1/1)93%  (14/15)98%  (2.9/3)
VAppConfiguration (): void 100% (1/1)100% (18/18)100% (7/7)
changeNameTo (String): VAppConfiguration 100% (1/1)100% (8/8)100% (3/3)
getDisks (): List 100% (1/1)100% (3/3)100% (1/1)
getDisksToDelete (): List 100% (1/1)100% (3/3)100% (1/1)
getMemory (): Long 100% (1/1)100% (3/3)100% (1/1)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
getProcessorCount (): Integer 100% (1/1)100% (3/3)100% (1/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.domain;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import java.util.List;
24 
25import org.jclouds.util.Preconditions2;
26 
27import com.google.common.collect.Lists;
28 
29/**
30 * 
31 * @author Adrian Cole
32 * 
33 */
34public class VAppConfiguration {
35   private String name = null;
36   private Integer processorCount = null;
37   private Long memory = null;
38   private List<Long> disks = Lists.newArrayList();
39   private List<Integer> disksToDelete = Lists.newArrayList();
40 
41   /**
42    * The vApp name
43    * 
44    */
45   public VAppConfiguration changeNameTo(String name) {
46      Preconditions2.checkNotEmpty(name, "name must be specified");
47      this.name = name;
48      return this;
49   }
50 
51   /**
52    * the number of virtual CPUs.
53    */
54   public VAppConfiguration changeProcessorCountTo(int cpus) {
55      checkArgument(cpus >= 1, "cpu count must be positive");
56      this.processorCount = cpus;
57      return this;
58   }
59 
60   /**
61    * number of MB of memory.
62    */
63   public VAppConfiguration changeMemoryTo(long megabytes) {
64      checkArgument(megabytes >= 1, "megabytes must be positive");
65      this.memory = megabytes;
66      return this;
67   }
68 
69   /**
70    * To define a new disk, all you need to define is the size of the disk. The allowed values are a
71    * multiple of 1048576.
72    */
73   public VAppConfiguration addDisk(long kilobytes) {
74      checkArgument(kilobytes > 0, "kilobytes must be positive");
75      checkArgument(kilobytes % 1048576 == 0, "disk must be an interval of 1048576");
76      this.disks.add(kilobytes);
77      return this;
78   }
79 
80   /**
81    * To remove a disk, you specify its addressOnParent.
82    * 
83    * Ex.
84    * 
85    * <pre>
86    * Set&lt;ResourceAllocation&gt; disks = Sets.newLinkedHashSet(vApp.getResourceAllocationByType().get(
87    *          ResourceType.DISK_DRIVE));
88    * ResourceAllocation lastDisk = disks.last();
89    * VAppConfiguration config = deleteDiskWithAddressOnParent(lastDisk.getAddressOnParent());
90    * </pre>
91    */
92   public VAppConfiguration deleteDiskWithAddressOnParent(int addressOnParent) {
93      checkArgument(addressOnParent > 0, "you cannot delete the system disk");
94      disksToDelete.add(addressOnParent);
95      return this;
96   }
97 
98   public static class Builder {
99 
100      /**
101       * @see VAppConfiguration#changeNameTo(String)
102       */
103      public static VAppConfiguration changeNameTo(String name) {
104         VAppConfiguration options = new VAppConfiguration();
105         return options.changeNameTo(name);
106      }
107 
108      /**
109       * @see VAppConfiguration#changeProcessorCountTo(int)
110       */
111      public static VAppConfiguration changeProcessorCountTo(int cpus) {
112         VAppConfiguration options = new VAppConfiguration();
113         return options.changeProcessorCountTo(cpus);
114      }
115 
116      /**
117       * @see VAppConfiguration#changeMemoryTo(long)
118       */
119      public static VAppConfiguration changeMemoryTo(long megabytes) {
120         VAppConfiguration options = new VAppConfiguration();
121         return options.changeMemoryTo(megabytes);
122      }
123 
124      /**
125       * @see VAppConfiguration#addDisk(long)
126       */
127      public static VAppConfiguration addDisk(long kilobytes) {
128         VAppConfiguration options = new VAppConfiguration();
129         return options.addDisk(kilobytes);
130      }
131 
132      /**
133       * @see VAppConfiguration#deleteDiskWithAddressOnParent(int)
134       */
135      public static VAppConfiguration deleteDiskWithAddressOnParent(int addressOnParent) {
136         VAppConfiguration options = new VAppConfiguration();
137         return options.deleteDiskWithAddressOnParent(addressOnParent);
138      }
139 
140   }
141 
142   public Integer getProcessorCount() {
143      return processorCount;
144   }
145 
146   public Long getMemory() {
147      return memory;
148   }
149 
150   public List<Long> getDisks() {
151      return disks;
152   }
153 
154   public String getName() {
155      return name;
156   }
157 
158   public List<Integer> getDisksToDelete() {
159      return disksToDelete;
160   }
161}

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