EMMA Coverage Report (generated Fri Aug 26 14:14:05 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)71%  (98/139)64%  (16/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BYONComputeServiceAdapter100% (1/1)27%  (3/11)68%  (89/130)61%  (14/23)
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/17)0%   (0/2)
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% (59/59)100% (8/8)
listNodes (): Iterable 100% (1/1)100% (9/9)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 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
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.collect.ImmutableSet;
46import com.google.common.collect.Iterables;
47import com.google.common.collect.ImmutableSet.Builder;
48 
49/**
50 * 
51 * @author Adrian Cole
52 */
53@Singleton
54public class BYONComputeServiceAdapter implements JCloudsNativeComputeServiceAdapter {
55   private final Supplier<Map<String, Node>> nodes;
56   private final NodeToNodeMetadata converter;
57   private final JustProvider locationSupplier;
58 
59   @Inject
60   public BYONComputeServiceAdapter(Supplier<Map<String, Node>> nodes, NodeToNodeMetadata converter,
61            JustProvider locationSupplier) {
62      this.nodes = checkNotNull(nodes, "nodes");
63      this.converter = checkNotNull(converter, "converter");
64      this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier");
65   }
66 
67   @Override
68   public NodeMetadata createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name,
69            Template template, Map<String, Credentials> credentialStore) {
70      throw new UnsupportedOperationException();
71   }
72 
73   @Override
74   public Iterable<Hardware> listHardwareProfiles() {
75      return ImmutableSet.<Hardware> of();
76   }
77 
78   @Override
79   public Iterable<Image> listImages() {
80      return ImmutableSet.<Image> of();
81   }
82 
83   @Override
84   public Iterable<NodeMetadata> listNodes() {
85      return Iterables.transform(nodes.get().values(), converter);
86   }
87 
88   @Override
89   public Iterable<Location> listLocations() {
90      Builder<Location> locations = ImmutableSet.builder();
91      Location provider = Iterables.getOnlyElement(locationSupplier.get());
92      Set<String> zones = ImmutableSet.copyOf(Iterables.filter(Iterables.transform(nodes.get().values(),
93               new Function<Node, String>() {
94 
95                  @Override
96                  public String apply(Node arg0) {
97                     return arg0.getLocationId();
98                  }
99               }), Predicates.notNull()));
100      if (zones.size() == 0)
101         return locations.add(provider).build();
102      else
103         for (String zone : zones) {
104            locations.add(new LocationBuilder().scope(LocationScope.ZONE).id(zone).description(zone).parent(provider)
105                     .build());
106         }
107      return locations.build();
108   }
109 
110   @Override
111   public NodeMetadata getNode(String id) {
112      Node node = nodes.get().get(id);
113      return node != null ? converter.apply(node) : null;
114   }
115 
116   @Override
117   public void destroyNode(final String id) {
118      throw new UnsupportedOperationException();
119   }
120 
121   @Override
122   public void rebootNode(String id) {
123      throw new UnsupportedOperationException();
124   }
125 
126   @Override
127   public void resumeNode(String id) {
128      throw new UnsupportedOperationException();
129   }
130 
131   @Override
132   public void suspendNode(String id) {
133      throw new UnsupportedOperationException();
134   }
135}

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