EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8.compute.functions]

COVERAGE SUMMARY FOR SOURCE FILE [HardwareForVCloudExpressVApp.java]

nameclass, %method, %block, %line, %
HardwareForVCloudExpressVApp.java0%   (0/1)0%   (0/2)0%   (0/71)0%   (0/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HardwareForVCloudExpressVApp0%   (0/1)0%   (0/2)0%   (0/71)0%   (0/13)
HardwareForVCloudExpressVApp (Function, HardwareBuilderFromResourceAllocation... 0%   (0/1)0%   (0/18)0%   (0/5)
apply (VApp): Hardware 0%   (0/1)0%   (0/53)0%   (0/8)

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.trmk.vcloud_0_8.compute.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.NoSuchElementException;
24 
25import javax.annotation.Resource;
26import javax.inject.Inject;
27 
28import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations;
29import org.jclouds.compute.domain.Hardware;
30import org.jclouds.compute.domain.HardwareBuilder;
31import org.jclouds.compute.predicates.ImagePredicates;
32import org.jclouds.domain.Location;
33import org.jclouds.logging.Logger;
34import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
35import org.jclouds.trmk.vcloud_0_8.domain.VApp;
36 
37import com.google.common.base.Function;
38 
39/**
40 * @author Adrian Cole
41 */
42public class HardwareForVCloudExpressVApp implements Function<VApp, Hardware> {
43 
44   @Resource
45   protected Logger logger = Logger.NULL;
46 
47   private final Function<ReferenceType, Location> findLocationForResource;
48   private final HardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
49 
50   @Inject
51   protected HardwareForVCloudExpressVApp(Function<ReferenceType, Location> findLocationForResource,
52         HardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
53      this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
54      this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
55   }
56 
57   @Override
58   public Hardware apply(VApp from) {
59      checkNotNull(from, "VApp");
60      try {
61         HardwareBuilder builder = rasdToHardwareBuilder.apply(from.getResourceAllocations());
62         builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
63         builder.ids(from.getHref().toASCIIString()).name(from.getName())
64               .supportsImage(ImagePredicates.idEquals(from.getHref().toASCIIString()));
65         return builder.build();
66      } catch (NoSuchElementException e) {
67         logger.debug("incomplete data to form vApp %s", from.getHref());
68         return null;
69      }
70   }
71}

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