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 [NodeMetadataToOrgAndName.java]

nameclass, %method, %block, %line, %
NodeMetadataToOrgAndName.java100% (1/1)0%   (0/2)0%   (0/58)0%   (0/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NodeMetadataToOrgAndName100% (1/1)0%   (0/2)0%   (0/58)0%   (0/11)
NodeMetadataToOrgAndName (TerremarkVCloudClient, Supplier): void 0%   (0/1)0%   (0/12)0%   (0/5)
apply (NodeMetadata): OrgAndName 0%   (0/1)0%   (0/46)0%   (0/6)

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 java.util.Map;
22 
23import javax.annotation.Resource;
24import javax.inject.Inject;
25import javax.inject.Named;
26import javax.inject.Singleton;
27 
28import org.jclouds.compute.domain.NodeMetadata;
29import org.jclouds.compute.reference.ComputeServiceConstants;
30import org.jclouds.logging.Logger;
31import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
32import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
33import org.jclouds.trmk.vcloud_0_8.domain.Org;
34import org.jclouds.trmk.vcloud_0_8.endpoints.VDC;
35 
36import com.google.common.base.Function;
37import com.google.common.base.Supplier;
38 
39/**
40 * 
41 * @author Adrian Cole
42 * 
43 */
44@Singleton
45public class NodeMetadataToOrgAndName implements Function<NodeMetadata, OrgAndName> {
46 
47   @Resource
48   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
49   protected Logger logger = Logger.NULL;
50 
51   final Supplier<Map<String, String>> vdcToOrg;
52 
53   private final TerremarkVCloudClient client;
54 
55   @Inject
56   NodeMetadataToOrgAndName(TerremarkVCloudClient client, @VDC Supplier<Map<String, String>> vdcToOrg) {
57      this.vdcToOrg = vdcToOrg;
58      this.client = client;
59   }
60 
61   @Override
62   public OrgAndName apply(NodeMetadata from) {
63      if (from.getGroup() != null) {
64         Org org = client.findOrgNamed(vdcToOrg.get().get(from.getLocation().getId()));
65         if (org == null) {
66            logger.warn("did not find an association for vdc %s in %s", from.getLocation().getId(), vdcToOrg);
67         } else {
68            return new OrgAndName(org.getHref(), from.getGroup());
69         }
70      }
71      return null;
72   }
73}

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