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 [RimuHostingLocationSupplier.java]

nameclass, %method, %block, %line, %
RimuHostingLocationSupplier.java0%   (0/2)0%   (0/4)0%   (0/101)0%   (0/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RimuHostingLocationSupplier0%   (0/1)0%   (0/2)0%   (0/92)0%   (0/16)
RimuHostingLocationSupplier (Set, String, URI, RimuHostingClient, Map): void 0%   (0/1)0%   (0/18)0%   (0/4)
get (): Set 0%   (0/1)0%   (0/74)0%   (0/12)
     
class RimuHostingLocationSupplier$10%   (0/1)0%   (0/2)0%   (0/9)0%   (0/2)
RimuHostingLocationSupplier$1 (RimuHostingLocationSupplier): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (PricingPlan): DataCenter 0%   (0/1)0%   (0/3)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 static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Map;
25import java.util.Set;
26 
27import javax.inject.Inject;
28import javax.inject.Singleton;
29 
30import org.jclouds.domain.Location;
31import org.jclouds.domain.LocationBuilder;
32import org.jclouds.domain.LocationScope;
33import org.jclouds.location.Iso3166;
34import org.jclouds.location.Provider;
35import org.jclouds.location.suppliers.JustProvider;
36import org.jclouds.rimuhosting.miro.RimuHostingClient;
37import org.jclouds.rimuhosting.miro.domain.DataCenter;
38import org.jclouds.rimuhosting.miro.domain.PricingPlan;
39 
40import com.google.common.base.Function;
41import com.google.common.base.Predicates;
42import com.google.common.collect.ImmutableSet;
43import com.google.common.collect.Iterables;
44import com.google.common.collect.ImmutableSet.Builder;
45 
46/**
47 * 
48 * @author Adrian Cole
49 */
50@Singleton
51public class RimuHostingLocationSupplier extends JustProvider {
52 
53   private final RimuHostingClient sync;
54   private final Map<String, Set<String>> isoCodesById;
55 
56   @Inject
57   RimuHostingLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
58            RimuHostingClient sync, @Iso3166 Map<String, Set<String>> isoCodesById) {
59      super(isoCodes, providerName, endpoint);
60      this.sync = checkNotNull(sync, "sync");
61      this.isoCodesById = checkNotNull(isoCodesById, "isoCodesById");
62   }
63 
64   @Override
65   public Set<? extends Location> get() {
66      Builder<Location> locations = ImmutableSet.builder();
67      Iterable<DataCenter> list = Iterables.filter(Iterables.transform(sync.getPricingPlanList(),
68               new Function<PricingPlan, DataCenter>() {
69 
70                  @Override
71                  public DataCenter apply(PricingPlan arg0) {
72                     return arg0.getDataCenter();
73                  }
74 
75               }), Predicates.<DataCenter>notNull());
76      Location provider = Iterables.getOnlyElement(super.get());
77      if (Iterables.size(list) == 0)
78         locations.add(provider);
79      else
80         for (DataCenter from : list) {
81            LocationBuilder builder = new LocationBuilder().scope(LocationScope.ZONE).id(from.getId()).description(
82                     from.getName()).parent(provider);
83            if (isoCodesById.containsKey(from.getId()))
84               builder.iso3166Codes(isoCodesById.get(from.getId()));
85            locations.add(builder.build());
86         }
87      return locations.build();
88   }
89}

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