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

COVERAGE SUMMARY FOR SOURCE FILE [PreinstalledDiskToImage.java]

nameclass, %method, %block, %line, %
PreinstalledDiskToImage.java0%   (0/1)0%   (0/2)0%   (0/109)0%   (0/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PreinstalledDiskToImage0%   (0/1)0%   (0/2)0%   (0/109)0%   (0/11)
PreinstalledDiskToImage (Supplier, Function): void 0%   (0/1)0%   (0/9)0%   (0/4)
apply (DriveInfo): Image 0%   (0/1)0%   (0/100)0%   (0/7)

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.cloudsigma.compute.functions;
20 
21import javax.inject.Inject;
22import javax.inject.Singleton;
23 
24import org.jclouds.cloudsigma.domain.DriveInfo;
25import org.jclouds.compute.domain.Image;
26import org.jclouds.compute.domain.ImageBuilder;
27import org.jclouds.compute.domain.OperatingSystem;
28import org.jclouds.compute.domain.OsFamilyVersion64Bit;
29import org.jclouds.compute.domain.OperatingSystem.Builder;
30import org.jclouds.domain.Credentials;
31import org.jclouds.domain.Location;
32 
33import com.google.common.base.Function;
34import com.google.common.base.Supplier;
35import com.google.common.collect.ImmutableMap;
36 
37/**
38 * @author Adrian Cole
39 */
40@Singleton
41public class PreinstalledDiskToImage implements Function<DriveInfo, Image> {
42   private final Supplier<Location> locationSupplier;
43   private final Function<String, OsFamilyVersion64Bit> imageParser;
44 
45   @Inject
46   public PreinstalledDiskToImage(Supplier<Location> locationSupplier,
47            Function<String, OsFamilyVersion64Bit> imageParser) {
48      this.locationSupplier = locationSupplier;
49      this.imageParser = imageParser;
50   }
51 
52   @Override
53   public Image apply(DriveInfo drive) {
54      if (drive.getName() == null)
55         return null;
56      String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
57      Builder builder = OperatingSystem.builder();
58      OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName());
59      builder.name(drive.getName()).description(description)
60            .is64Bit(drive.getBits() != null ? drive.getBits() == 64 : parsed.is64Bit).version(parsed.version)
61            .family(parsed.family);
62      return new ImageBuilder().ids(drive.getUuid()).adminPassword("cloudsigma").userMetadata(
63               ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + "")).defaultCredentials(
64               new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get()).name(drive.getName())
65               .description(description).operatingSystem(builder.build()).version("").build();
66   }
67}

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