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

COVERAGE SUMMARY FOR SOURCE FILE [BYONComputeServiceAdapter.java]

nameclass, %method, %block, %line, %
BYONComputeServiceAdapter.java100% (2/2)38%  (5/13)69%  (100/145)57%  (16/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BYONComputeServiceAdapter100% (1/1)27%  (3/11)67%  (91/136)54%  (14/26)
createNodeWithGroupEncodedIntoNameThenStoreCredentials (String, String, Templ... 0%   (0/1)0%   (0/4)0%   (0/1)
destroyNode (String): void 0%   (0/1)0%   (0/4)0%   (0/1)
getNode (String): NodeMetadata 0%   (0/1)0%   (0/21)0%   (0/5)
listHardwareProfiles (): Iterable 0%   (0/1)0%   (0/2)0%   (0/1)
listImages (): Iterable 0%   (0/1)0%   (0/2)0%   (0/1)
rebootNode (String): void 0%   (0/1)0%   (0/4)0%   (0/1)
resumeNode (String): void 0%   (0/1)0%   (0/4)0%   (0/1)
suspendNode (String): void 0%   (0/1)0%   (0/4)0%   (0/1)
BYONComputeServiceAdapter (Supplier, NodeToNodeMetadata, JustProvider): void 100% (1/1)100% (21/21)100% (5/5)
listLocations (): Iterable 100% (1/1)100% (60/60)100% (8/8)
listNodes (): Iterable 100% (1/1)100% (10/10)100% (1/1)
     
class BYONComputeServiceAdapter$1100% (1/1)100% (2/2)100% (9/9)100% (2/2)
BYONComputeServiceAdapter$1 (BYONComputeServiceAdapter): void 100% (1/1)100% (6/6)100% (1/1)
apply (Node): String 100% (1/1)100% (3/3)100% (1/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.byon.internal;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Map;
24import java.util.Set;
25 
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.byon.Node;
30import org.jclouds.byon.functions.NodeToNodeMetadata;
31import org.jclouds.compute.JCloudsNativeComputeServiceAdapter;
32import org.jclouds.compute.domain.Hardware;
33import org.jclouds.compute.domain.Image;
34import org.jclouds.compute.domain.NodeMetadata;
35import org.jclouds.compute.domain.Template;
36import org.jclouds.domain.Credentials;
37import org.jclouds.domain.Location;
38import org.jclouds.domain.LocationBuilder;
39import org.jclouds.domain.LocationScope;
40import org.jclouds.location.suppliers.JustProvider;
41 
42import com.google.common.base.Function;
43import com.google.common.base.Predicates;
44import com.google.common.base.Supplier;
45import com.google.common.cache.Cache;
46import com.google.common.collect.ImmutableSet;
47import com.google.common.collect.ImmutableSet.Builder;
48import com.google.common.collect.Iterables;
49import com.google.common.util.concurrent.UncheckedExecutionException;
50 
51/**
52 * 
53 * @author Adrian Cole
54 */
55@Singleton
56public class BYONComputeServiceAdapter implements JCloudsNativeComputeServiceAdapter {
57   private final Supplier<Cache<String, Node>> nodes;
58   private final NodeToNodeMetadata converter;
59   private final JustProvider locationSupplier;
60 
61   @Inject
62   public BYONComputeServiceAdapter(Supplier<Cache<String, Node>> nodes, NodeToNodeMetadata converter,
63            JustProvider locationSupplier) {
64      this.nodes = checkNotNull(nodes, "nodes");
65      this.converter = checkNotNull(converter, "converter");
66      this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier");
67   }
68 
69   @Override
70   public NodeMetadata createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name,
71            Template template, Map<String, Credentials> credentialStore) {
72      throw new UnsupportedOperationException();
73   }
74 
75   @Override
76   public Iterable<Hardware> listHardwareProfiles() {
77      return ImmutableSet.<Hardware> of();
78   }
79 
80   @Override
81   public Iterable<Image> listImages() {
82      return ImmutableSet.<Image> of();
83   }
84 
85   @Override
86   public Iterable<NodeMetadata> listNodes() {
87      return Iterables.transform(nodes.get().asMap().values(), converter);
88   }
89 
90   @Override
91   public Iterable<Location> listLocations() {
92      Builder<Location> locations = ImmutableSet.builder();
93      Location provider = Iterables.getOnlyElement(locationSupplier.get());
94      Set<String> zones = ImmutableSet.copyOf(Iterables.filter(Iterables.transform(nodes.get().asMap().values(),
95               new Function<Node, String>() {
96 
97                  @Override
98                  public String apply(Node arg0) {
99                     return arg0.getLocationId();
100                  }
101               }), Predicates.notNull()));
102      if (zones.size() == 0)
103         return locations.add(provider).build();
104      else
105         for (String zone : zones) {
106            locations.add(new LocationBuilder().scope(LocationScope.ZONE).id(zone).description(zone).parent(provider)
107                     .build());
108         }
109      return locations.build();
110   }
111 
112   @Override
113   public NodeMetadata getNode(String id) {
114      
115      Node node = null;
116      try {
117         node = nodes.get().getUnchecked(id);
118      } catch (UncheckedExecutionException e) {
119 
120      }
121      return node != null ? converter.apply(node) : null;
122   }
123 
124   @Override
125   public void destroyNode(final String id) {
126      throw new UnsupportedOperationException();
127   }
128 
129   @Override
130   public void rebootNode(String id) {
131      throw new UnsupportedOperationException();
132   }
133 
134   @Override
135   public void resumeNode(String id) {
136      throw new UnsupportedOperationException();
137   }
138 
139   @Override
140   public void suspendNode(String id) {
141      throw new UnsupportedOperationException();
142   }
143}

[all classes][org.jclouds.byon.internal]
EMMA 2.0.5312 (C) Vladimir Roubtsov