EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds.cim.functions]

COVERAGE SUMMARY FOR SOURCE FILE [HardwareBuilderFromResourceAllocations.java]

nameclass, %method, %block, %line, %
HardwareBuilderFromResourceAllocations.java0%   (0/3)0%   (0/7)0%   (0/136)0%   (0/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HardwareBuilderFromResourceAllocations0%   (0/1)0%   (0/3)0%   (0/110)0%   (0/7)
HardwareBuilderFromResourceAllocations (): void 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Iterable): HardwareBuilder 0%   (0/1)0%   (0/64)0%   (0/5)
apply (ResourceAllocationSettingData): Volume 0%   (0/1)0%   (0/43)0%   (0/1)
     
class HardwareBuilderFromResourceAllocations$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/2)
HardwareBuilderFromResourceAllocations$1 (HardwareBuilderFromResourceAllocati... 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ResourceAllocationSettingData): Volume 0%   (0/1)0%   (0/5)0%   (0/1)
     
class HardwareBuilderFromResourceAllocations$20%   (0/1)0%   (0/2)0%   (0/15)0%   (0/2)
HardwareBuilderFromResourceAllocations$2 (HardwareBuilderFromResourceAllocati... 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ResourceAllocationSettingData): Processor 0%   (0/1)0%   (0/9)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.cim.functions;
20 
21import static com.google.common.collect.Iterables.filter;
22import static com.google.common.collect.Iterables.find;
23import static com.google.common.collect.Iterables.transform;
24 
25import javax.inject.Singleton;
26 
27import org.jclouds.cim.CIMPredicates;
28import org.jclouds.cim.ResourceAllocationSettingData;
29import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
30import org.jclouds.compute.domain.HardwareBuilder;
31import org.jclouds.compute.domain.Processor;
32import org.jclouds.compute.domain.Volume;
33import org.jclouds.compute.domain.internal.VolumeImpl;
34 
35import com.google.common.base.Function;
36 
37/**
38 * @author Adrian Cole
39 */
40@Singleton
41public class HardwareBuilderFromResourceAllocations implements
42         Function<Iterable<? extends ResourceAllocationSettingData>, HardwareBuilder> {
43   @Override
44   public HardwareBuilder apply(Iterable<? extends ResourceAllocationSettingData> from) {
45      HardwareBuilder builder = new HardwareBuilder();
46      builder.volumes(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE,
47               ResourceType.BASE_PARTITIONABLE_UNIT, ResourceType.PARTITIONABLE_UNIT)),
48               new Function<ResourceAllocationSettingData, Volume>() {
49 
50                  @Override
51                  public Volume apply(ResourceAllocationSettingData from) {
52                     return HardwareBuilderFromResourceAllocations.this.apply(from);
53                  }
54 
55               }));
56 
57      builder.ram((int) find(from, CIMPredicates.resourceTypeIn(ResourceType.MEMORY)).getVirtualQuantity().longValue());
58 
59      builder.processors(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)),
60               new Function<ResourceAllocationSettingData, Processor>() {
61 
62                  @Override
63                  public Processor apply(ResourceAllocationSettingData arg0) {
64                     return new Processor(arg0.getVirtualQuantity(), 1);
65                  }
66               }));
67      return builder;
68   }
69 
70   public Volume apply(ResourceAllocationSettingData from) {
71      return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null
72               : from.getVirtualQuantity() / 1024 / 1024f, null, "0".equals(from.getAddressOnParent())
73               || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true);
74   }
75}

[all classes][org.jclouds.cim.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov