EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.vcloud.compute.functions]

COVERAGE SUMMARY FOR SOURCE FILE [ImageForVCloudExpressVAppTemplate.java]

nameclass, %method, %block, %line, %
ImageForVCloudExpressVAppTemplate.java0%   (0/1)0%   (0/3)0%   (0/84)0%   (0/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ImageForVCloudExpressVAppTemplate0%   (0/1)0%   (0/3)0%   (0/84)0%   (0/16)
ImageForVCloudExpressVAppTemplate (FindLocationForResource, PopulateDefaultLo... 0%   (0/1)0%   (0/18)0%   (0/5)
apply (VCloudExpressVAppTemplate): Image 0%   (0/1)0%   (0/61)0%   (0/9)
withParent (ReferenceType): ImageForVCloudExpressVAppTemplate 0%   (0/1)0%   (0/5)0%   (0/2)

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.vcloud.compute.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23 
24import javax.inject.Inject;
25 
26import org.jclouds.compute.domain.Image;
27import org.jclouds.compute.domain.ImageBuilder;
28import org.jclouds.compute.domain.OperatingSystem;
29import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
30import org.jclouds.vcloud.domain.ReferenceType;
31import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
32 
33import com.google.common.base.Function;
34 
35/**
36 * @author Adrian Cole
37 */
38public class ImageForVCloudExpressVAppTemplate implements Function<VCloudExpressVAppTemplate, Image> {
39   private final FindLocationForResource findLocationForResource;
40   private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
41   private final Function<String, OperatingSystem> osParser;
42 
43   private ReferenceType parent;
44 
45   @Inject
46   protected ImageForVCloudExpressVAppTemplate(FindLocationForResource findLocationForResource,
47            PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, Function<String, OperatingSystem> osParser) {
48      this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
49      this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
50      this.osParser = osParser;
51   }
52 
53   public ImageForVCloudExpressVAppTemplate withParent(ReferenceType parent) {
54      this.parent = parent;
55      return this;
56   }
57 
58   @Override
59   public Image apply(VCloudExpressVAppTemplate 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      builder.operatingSystem(osParser.apply(from.getName()));
67      builder.defaultCredentials(credentialsProvider.execute(from));
68      return builder.build();
69   }
70}

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