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 [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 (VAppTemplate): Image 0%   (0/1)0%   (0/61)0%   (0/9)
withParent (ReferenceType): ImageForVCloudExpressVAppTemplate 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.trmk.vcloud_0_8.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.trmk.vcloud_0_8.domain.ReferenceType;
31import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
32 
33import com.google.common.base.Function;
34 
35/**
36 * @author Adrian Cole
37 */
38public class ImageForVCloudExpressVAppTemplate implements Function<VAppTemplate, 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(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      builder.operatingSystem(osParser.apply(from.getName()));
67      builder.defaultCredentials(credentialsProvider.execute(from));
68      return builder.build();
69   }
70}

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