EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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