EMMA Coverage Report (generated Fri Aug 26 14:14:05 EDT 2011)
[all classes][org.jclouds.elasticstack.compute.functions]

COVERAGE SUMMARY FOR SOURCE FILE [WellKnownImageToImage.java]

nameclass, %method, %block, %line, %
WellKnownImageToImage.java0%   (0/1)0%   (0/2)0%   (0/81)0%   (0/6)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class WellKnownImageToImage0%   (0/1)0%   (0/2)0%   (0/81)0%   (0/6)
WellKnownImageToImage (Supplier, Map): void 0%   (0/1)0%   (0/9)0%   (0/4)
apply (DriveInfo): Image 0%   (0/1)0%   (0/72)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.elasticstack.compute.functions;
20 
21import java.util.Map;
22 
23import javax.inject.Inject;
24import javax.inject.Singleton;
25 
26import org.jclouds.compute.domain.Image;
27import org.jclouds.compute.domain.ImageBuilder;
28import org.jclouds.compute.domain.OperatingSystem;
29import org.jclouds.domain.Credentials;
30import org.jclouds.domain.Location;
31import org.jclouds.elasticstack.domain.DriveInfo;
32import org.jclouds.elasticstack.domain.WellKnownImage;
33 
34import com.google.common.base.Function;
35import com.google.common.base.Supplier;
36import com.google.common.collect.ImmutableMap;
37 
38/**
39 * @author Adrian Cole
40 */
41@Singleton
42public class WellKnownImageToImage implements Function<DriveInfo, Image> {
43   private final Supplier<Location> locationSupplier;
44   private final Map<String, WellKnownImage> preinstalledImages;
45 
46   @Inject
47   public WellKnownImageToImage(Supplier<Location> locationSupplier, Map<String, WellKnownImage> preinstalledImages) {
48      this.locationSupplier = locationSupplier;
49      this.preinstalledImages = preinstalledImages;
50   }
51 
52   @Override
53   public Image apply(DriveInfo drive) {
54      WellKnownImage input = preinstalledImages.get(drive.getUuid());
55      return new ImageBuilder().ids(drive.getUuid()).userMetadata(
56               ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata())
57                        .put("size", input.getSize() + "").build()).defaultCredentials(
58               new Credentials(input.getLoginUser(), null)).location(locationSupplier.get()).name(
59               input.getDescription()).description(drive.getName()).operatingSystem(
60               new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()).name(
61                        input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()).version(
62               "").build();
63   }
64}

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