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

COVERAGE SUMMARY FOR SOURCE FILE [RimuHostingHardwareSupplier.java]

nameclass, %method, %block, %line, %
RimuHostingHardwareSupplier.java0%   (0/2)0%   (0/4)0%   (0/127)0%   (0/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RimuHostingHardwareSupplier0%   (0/1)0%   (0/2)0%   (0/110)0%   (0/15)
RimuHostingHardwareSupplier (RimuHostingClient, Supplier): void 0%   (0/1)0%   (0/12)0%   (0/5)
get (): Set 0%   (0/1)0%   (0/98)0%   (0/10)
     
class RimuHostingHardwareSupplier$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/2)
RimuHostingHardwareSupplier$1 (RimuHostingHardwareSupplier, PricingPlan): void 0%   (0/1)0%   (0/9)0%   (0/1)
apply (Location): boolean 0%   (0/1)0%   (0/8)0%   (0/1)

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.rimuhosting.miro.compute.suppliers;
20 
21import java.util.Set;
22 
23import javax.annotation.Resource;
24import javax.inject.Inject;
25import javax.inject.Named;
26import javax.inject.Singleton;
27 
28import org.jclouds.collect.Memoized;
29import org.jclouds.compute.domain.Hardware;
30import org.jclouds.compute.domain.HardwareBuilder;
31import org.jclouds.compute.domain.Processor;
32import org.jclouds.compute.domain.Volume;
33import org.jclouds.compute.domain.internal.VolumeImpl;
34import org.jclouds.compute.reference.ComputeServiceConstants;
35import org.jclouds.domain.Location;
36import org.jclouds.logging.Logger;
37import org.jclouds.rimuhosting.miro.RimuHostingClient;
38import org.jclouds.rimuhosting.miro.domain.PricingPlan;
39 
40import com.google.common.base.Predicate;
41import com.google.common.base.Supplier;
42import com.google.common.collect.ImmutableList;
43import com.google.common.collect.Iterables;
44import com.google.common.collect.Sets;
45 
46/**
47 * 
48 * @author Adrian Cole
49 */
50@Singleton
51public class RimuHostingHardwareSupplier implements Supplier<Set<? extends Hardware>> {
52 
53   @Resource
54   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
55   protected Logger logger = Logger.NULL;
56 
57   private final RimuHostingClient sync;
58   private final Supplier<Set<? extends Location>> locations;
59 
60   @Inject
61   RimuHostingHardwareSupplier(RimuHostingClient sync, @Memoized Supplier<Set<? extends Location>> locations) {
62      this.sync = sync;
63      this.locations = locations;
64   }
65 
66   @Override
67   public Set<? extends Hardware> get() {
68      final Set<Hardware> sizes = Sets.newHashSet();
69      logger.debug(">> providing sizes");
70      for (final PricingPlan from : sync.getPricingPlanList()) {
71         try {
72 
73            final Location location = Iterables.find(locations.get(), new Predicate<Location>() {
74 
75               @Override
76               public boolean apply(Location input) {
77                  return input.getId().equals(from.getDataCenter().getId());
78               }
79 
80            });
81            sizes.add(new HardwareBuilder().ids(from.getId()).location(location).processors(
82                     ImmutableList.of(new Processor(1, 1.0))).ram(from.getRam()).volumes(
83                     ImmutableList.<Volume> of(new VolumeImpl((float) from.getDiskSize(), true, true))).build());
84         } catch (NullPointerException e) {
85            logger.warn("datacenter not present in " + from.getId());
86         }
87      }
88      logger.debug("<< sizes(%d)", sizes.size());
89      return sizes;
90   }
91}

[all classes][org.jclouds.rimuhosting.miro.compute.suppliers]
EMMA 2.0.5312 (C) Vladimir Roubtsov