EMMA Coverage Report (generated Mon Dec 09 15:12:29 EST 2013)
[all classes][org.jclouds.glesys.compute.functions]

COVERAGE SUMMARY FOR SOURCE FILE [ServerSpecToHardware.java]

nameclass, %method, %block, %line, %
ServerSpecToHardware.java100% (1/1)67%  (2/3)18%  (15/85)54%  (3.8/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ServerSpecToHardware100% (1/1)67%  (2/3)18%  (15/85)54%  (3.8/7)
apply (ServerSpec): Hardware 0%   (0/1)0%   (0/68)0%   (0/3)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
ServerSpecToHardware (Supplier): void 100% (1/1)100% (9/9)100% (3/3)

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17package org.jclouds.glesys.compute.functions;
18 
19import static com.google.common.base.Preconditions.checkNotNull;
20import static org.jclouds.location.predicates.LocationPredicates.idEquals;
21 
22import java.util.Set;
23 
24import javax.inject.Inject;
25import javax.inject.Singleton;
26 
27import org.jclouds.collect.Memoized;
28import org.jclouds.compute.domain.Hardware;
29import org.jclouds.compute.domain.HardwareBuilder;
30import org.jclouds.compute.domain.Processor;
31import org.jclouds.compute.domain.Volume;
32import org.jclouds.compute.domain.internal.VolumeImpl;
33import org.jclouds.compute.predicates.ImagePredicates;
34import org.jclouds.domain.Location;
35import org.jclouds.glesys.domain.ServerSpec;
36 
37import com.google.common.base.Function;
38import com.google.common.base.Supplier;
39import com.google.common.collect.FluentIterable;
40import com.google.common.collect.ImmutableList;
41 
42/**
43 * 
44 * @author Adrian Cole
45 */
46@Singleton
47public class ServerSpecToHardware implements Function<ServerSpec, Hardware> {
48 
49   private final Supplier<Set<? extends Location>> locations;
50 
51   @Inject
52   ServerSpecToHardware(@Memoized Supplier<Set<? extends Location>> locations) {
53      this.locations = checkNotNull(locations, "locations");
54   }
55 
56   @Override
57   public Hardware apply(ServerSpec spec) {
58      Location location = FluentIterable.from(locations.get()).firstMatch(idEquals(spec.getDatacenter())).orNull();
59      assert location != null : String.format("no location matched ServerSpec %s", spec);
60      return new HardwareBuilder().ids(spec.toString()).ram(spec.getMemorySizeMB()).processors(
61               ImmutableList.of(new Processor(spec.getCpuCores(), 1.0))).volumes(
62               ImmutableList.<Volume> of(new VolumeImpl((float) spec.getDiskSizeGB(), true, true))).hypervisor(
63               spec.getPlatform()).location(location).supportsImage(
64               ImagePredicates.idEquals(spec.getTemplateName())).build();
65   }
66}

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