EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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