EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.vcloud.compute.functions]

COVERAGE SUMMARY FOR SOURCE FILE [ImageForVAppTemplate.java]

nameclass, %method, %block, %line, %
ImageForVAppTemplate.java0%   (0/1)0%   (0/3)0%   (0/90)0%   (0/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ImageForVAppTemplate0%   (0/1)0%   (0/3)0%   (0/90)0%   (0/17)
ImageForVAppTemplate (VCloudClient, FindLocationForResource, PopulateDefaultL... 0%   (0/1)0%   (0/21)0%   (0/5)
apply (VAppTemplate): Image 0%   (0/1)0%   (0/64)0%   (0/10)
withParent (ReferenceType): ImageForVAppTemplate 0%   (0/1)0%   (0/5)0%   (0/2)

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.vcloud.compute.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import javax.inject.Inject;
24 
25import org.jclouds.compute.domain.CIMOperatingSystem;
26import org.jclouds.compute.domain.Image;
27import org.jclouds.compute.domain.ImageBuilder;
28import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
29import org.jclouds.ovf.Envelope;
30import org.jclouds.vcloud.VCloudClient;
31import org.jclouds.vcloud.domain.ReferenceType;
32import org.jclouds.vcloud.domain.VAppTemplate;
33 
34import com.google.common.base.Function;
35 
36/**
37 * @author Adrian Cole
38 */
39public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
40   private final VCloudClient client;
41   private final FindLocationForResource findLocationForResource;
42   private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
43   private ReferenceType parent;
44 
45   @Inject
46   protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
47         PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) {
48      this.client = checkNotNull(client, "client");
49      this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
50      this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
51   }
52 
53   public ImageForVAppTemplate withParent(ReferenceType parent) {
54      this.parent = parent;
55      return this;
56   }
57 
58   @Override
59   public Image apply(VAppTemplate from) {
60      ImageBuilder builder = new ImageBuilder();
61      builder.ids(from.getHref().toASCIIString());
62      builder.uri(from.getHref());
63      builder.name(from.getName());
64      builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
65      builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
66      Envelope ovf = client.getVAppTemplateClient().getOvfEnvelopeForVAppTemplate(from.getHref());
67      builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
68      builder.defaultCredentials(credentialsProvider.execute(from));
69      return builder.build();
70   }
71 
72}

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