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

COVERAGE SUMMARY FOR SOURCE FILE [RimuHostingComputeServiceDependenciesModule.java]

nameclass, %method, %block, %line, %
RimuHostingComputeServiceDependenciesModule.java88%  (7/8)75%  (9/12)84%  (103/122)77%  (10/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RimuHostingComputeServiceDependenciesModule$ServerToPublicAddresses0%   (0/1)0%   (0/2)0%   (0/17)0%   (0/2)
RimuHostingComputeServiceDependenciesModule$ServerToPublicAddresses (): void 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Server): Iterable 0%   (0/1)0%   (0/14)0%   (0/1)
     
class RimuHostingComputeServiceDependenciesModule100% (1/1)75%  (3/4)97%  (67/69)89%  (8/9)
provideServerToNodeState (): Map 0%   (0/1)0%   (0/2)0%   (0/1)
<static initializer> 100% (1/1)100% (19/19)100% (1/1)
RimuHostingComputeServiceDependenciesModule (): void 100% (1/1)100% (3/3)100% (2/2)
configure (): void 100% (1/1)100% (45/45)100% (5/5)
     
class RimuHostingComputeServiceDependenciesModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
RimuHostingComputeServiceDependenciesModule$1 (RimuHostingComputeServiceDepen... 100% (1/1)100% (6/6)100% (1/1)
     
class RimuHostingComputeServiceDependenciesModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
RimuHostingComputeServiceDependenciesModule$2 (RimuHostingComputeServiceDepen... 100% (1/1)100% (6/6)100% (1/1)
     
class RimuHostingComputeServiceDependenciesModule$3100% (1/1)100% (1/1)100% (6/6)100% (1/1)
RimuHostingComputeServiceDependenciesModule$3 (RimuHostingComputeServiceDepen... 100% (1/1)100% (6/6)100% (1/1)
     
class RimuHostingComputeServiceDependenciesModule$4100% (1/1)100% (1/1)100% (6/6)100% (1/1)
RimuHostingComputeServiceDependenciesModule$4 (RimuHostingComputeServiceDepen... 100% (1/1)100% (6/6)100% (1/1)
     
class RimuHostingComputeServiceDependenciesModule$5100% (1/1)100% (1/1)100% (6/6)100% (1/1)
RimuHostingComputeServiceDependenciesModule$5 (RimuHostingComputeServiceDepen... 100% (1/1)100% (6/6)100% (1/1)
     
class RimuHostingComputeServiceDependenciesModule$6100% (1/1)100% (1/1)100% (6/6)100% (1/1)
RimuHostingComputeServiceDependenciesModule$6 (RimuHostingComputeServiceDepen... 100% (1/1)100% (6/6)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.rimuhosting.miro.compute.config;
20 
21import java.util.Map;
22 
23import javax.inject.Singleton;
24 
25import org.jclouds.compute.ComputeServiceContext;
26import org.jclouds.compute.domain.NodeMetadata;
27import org.jclouds.compute.domain.NodeState;
28import org.jclouds.compute.internal.ComputeServiceContextImpl;
29import org.jclouds.rest.RestContext;
30import org.jclouds.rest.internal.RestContextImpl;
31import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient;
32import org.jclouds.rimuhosting.miro.RimuHostingClient;
33import org.jclouds.rimuhosting.miro.compute.functions.ServerToNodeMetadata;
34import org.jclouds.rimuhosting.miro.domain.Server;
35import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
36 
37import com.google.common.annotations.VisibleForTesting;
38import com.google.common.base.Function;
39import com.google.common.collect.ImmutableList;
40import com.google.common.collect.ImmutableMap;
41import com.google.common.collect.ImmutableSet;
42import com.google.common.collect.Iterables;
43import com.google.inject.AbstractModule;
44import com.google.inject.Provides;
45import com.google.inject.Scopes;
46import com.google.inject.TypeLiteral;
47 
48/**
49 * Configures the {@link RimuHostingComputeServiceContext}; requires
50 * {@link RimuHostingComputeService} bound.
51 * 
52 * @author Adrian Cole
53 */
54public class RimuHostingComputeServiceDependenciesModule extends AbstractModule {
55 
56   @Override
57   protected void configure() {
58      bind(new TypeLiteral<Function<Server, NodeMetadata>>() {
59      }).to(ServerToNodeMetadata.class);
60      bind(new TypeLiteral<ComputeServiceContext>() {
61      }).to(new TypeLiteral<ComputeServiceContextImpl<RimuHostingClient, RimuHostingAsyncClient>>() {
62      }).in(Scopes.SINGLETON);
63      bind(new TypeLiteral<RestContext<RimuHostingClient, RimuHostingAsyncClient>>() {
64      }).to(new TypeLiteral<RestContextImpl<RimuHostingClient, RimuHostingAsyncClient>>() {
65      }).in(Scopes.SINGLETON);
66      bind(new TypeLiteral<Function<Server, Iterable<String>>>() {
67      }).to(ServerToPublicAddresses.class);
68 
69   }
70 
71   @VisibleForTesting
72   static final Map<RunningState, NodeState> runningStateToNodeState = ImmutableMap.<RunningState, NodeState> builder()
73            .put(RunningState.RUNNING, NodeState.RUNNING)//
74            .put(RunningState.NOTRUNNING, NodeState.SUSPENDED)//
75            .put(RunningState.POWERCYCLING, NodeState.PENDING)//
76            .put(RunningState.RESTARTING, NodeState.PENDING)//
77            .put(RunningState.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
78            .build();
79 
80   @Singleton
81   @Provides
82   Map<RunningState, NodeState> provideServerToNodeState() {
83      return runningStateToNodeState;
84   }
85 
86   @Singleton
87   private static class ServerToPublicAddresses implements Function<Server, Iterable<String>> {
88      @Override
89      public Iterable<String> apply(Server server) {
90         return server.getIpAddresses() == null ? ImmutableSet.<String> of() : Iterables.concat(ImmutableList.of(server
91                  .getIpAddresses().getPrimaryIp()), server.getIpAddresses().getSecondaryIps());
92      }
93   }
94}

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