EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.ec2.compute.config]

COVERAGE SUMMARY FOR SOURCE FILE [EC2ComputeServiceDependenciesModule.java]

nameclass, %method, %block, %line, %
EC2ComputeServiceDependenciesModule.java91%  (10/11)63%  (12/19)81%  (172/212)68%  (15/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EC2ComputeServiceDependenciesModule$100%   (0/1)0%   (0/2)0%   (0/23)0%   (0/3)
EC2ComputeServiceDependenciesModule$10 (EC2ComputeServiceDependenciesModule):... 0%   (0/1)0%   (0/11)0%   (0/2)
get (): String 0%   (0/1)0%   (0/12)0%   (0/1)
     
class EC2ComputeServiceDependenciesModule100% (1/1)38%  (3/8)87%  (118/135)72%  (13/18)
credentialsMap (Function): Map 0%   (0/1)0%   (0/2)0%   (0/1)
provideImageMap (Function): Map 0%   (0/1)0%   (0/6)0%   (0/1)
provideServerToNodeState (): Map 0%   (0/1)0%   (0/2)0%   (0/1)
provideSuffix (): Supplier 0%   (0/1)0%   (0/5)0%   (0/1)
securityGroupMap (Function): Map 0%   (0/1)0%   (0/2)0%   (0/1)
<static initializer> 100% (1/1)100% (25/25)100% (1/1)
EC2ComputeServiceDependenciesModule (): void 100% (1/1)100% (3/3)100% (1/1)
configure (): void 100% (1/1)100% (90/90)100% (11/11)
     
class EC2ComputeServiceDependenciesModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$1 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$2 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$3100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$3 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$4100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$4 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$5100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$5 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$6100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$6 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$7100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$7 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$8100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$8 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)100% (1/1)
     
class EC2ComputeServiceDependenciesModule$9100% (1/1)100% (1/1)100% (6/6)100% (1/1)
EC2ComputeServiceDependenciesModule$9 (EC2ComputeServiceDependenciesModule): ... 100% (1/1)100% (6/6)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.ec2.compute.config;
20 
21import static com.google.common.collect.Maps.newLinkedHashMap;
22 
23import java.security.SecureRandom;
24import java.util.Map;
25 
26import javax.inject.Named;
27import javax.inject.Singleton;
28 
29import org.jclouds.compute.ComputeService;
30import org.jclouds.compute.ComputeServiceContext;
31import org.jclouds.compute.domain.Image;
32import org.jclouds.compute.domain.NodeMetadata;
33import org.jclouds.compute.domain.NodeState;
34import org.jclouds.compute.domain.TemplateBuilder;
35import org.jclouds.compute.internal.ComputeServiceContextImpl;
36import org.jclouds.compute.options.TemplateOptions;
37import org.jclouds.domain.Credentials;
38import org.jclouds.ec2.EC2AsyncClient;
39import org.jclouds.ec2.EC2Client;
40import org.jclouds.ec2.compute.EC2ComputeService;
41import org.jclouds.ec2.compute.domain.RegionAndName;
42import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
43import org.jclouds.ec2.compute.functions.CreateSecurityGroupIfNeeded;
44import org.jclouds.ec2.compute.functions.CreateUniqueKeyPair;
45import org.jclouds.ec2.compute.functions.CredentialsForInstance;
46import org.jclouds.ec2.compute.functions.RegionAndIdToImage;
47import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
48import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
49import org.jclouds.ec2.compute.options.EC2TemplateOptions;
50import org.jclouds.ec2.domain.InstanceState;
51import org.jclouds.ec2.domain.KeyPair;
52import org.jclouds.ec2.domain.RunningInstance;
53import org.jclouds.rest.RestContext;
54import org.jclouds.rest.internal.RestContextImpl;
55 
56import com.google.common.base.Function;
57import com.google.common.base.Supplier;
58import com.google.common.collect.ImmutableMap;
59import com.google.common.collect.MapMaker;
60import com.google.inject.AbstractModule;
61import com.google.inject.Provides;
62import com.google.inject.Scopes;
63import com.google.inject.TypeLiteral;
64 
65/**
66 * 
67 * @author Adrian Cole
68 */
69public class EC2ComputeServiceDependenciesModule extends AbstractModule {
70 
71   public static final Map<InstanceState, NodeState> instanceToNodeState = ImmutableMap
72            .<InstanceState, NodeState> builder().put(InstanceState.PENDING, NodeState.PENDING).put(
73                     InstanceState.RUNNING, NodeState.RUNNING).put(InstanceState.SHUTTING_DOWN, NodeState.PENDING).put(
74                     InstanceState.TERMINATED, NodeState.TERMINATED).put(InstanceState.STOPPING, NodeState.PENDING)
75            .put(InstanceState.STOPPED, NodeState.SUSPENDED).put(InstanceState.UNRECOGNIZED, NodeState.UNRECOGNIZED)
76            .build();
77 
78   @Singleton
79   @Provides
80   Map<InstanceState, NodeState> provideServerToNodeState() {
81      return instanceToNodeState;
82   }
83 
84   @Override
85   protected void configure() {
86      bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
87      bind(TemplateOptions.class).to(EC2TemplateOptions.class);
88      bind(ComputeService.class).to(EC2ComputeService.class);
89      bind(new TypeLiteral<Function<RunningInstance, NodeMetadata>>() {
90      }).to(RunningInstanceToNodeMetadata.class);
91      bind(new TypeLiteral<Function<RunningInstance, Credentials>>() {
92      }).to(CredentialsForInstance.class);
93      bind(new TypeLiteral<Function<RegionNameAndIngressRules, String>>() {
94      }).to(CreateSecurityGroupIfNeeded.class);
95      bind(new TypeLiteral<Function<RegionAndName, KeyPair>>() {
96      }).to(CreateUniqueKeyPair.class);
97      bind(new TypeLiteral<Function<RegionAndName, Image>>() {
98      }).to(RegionAndIdToImage.class);
99      bind(new TypeLiteral<ComputeServiceContext>() {
100      }).to(new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
101      }).in(Scopes.SINGLETON);
102      bind(new TypeLiteral<RestContext<EC2Client, EC2AsyncClient>>() {
103      }).to(new TypeLiteral<RestContextImpl<EC2Client, EC2AsyncClient>>() {
104      }).in(Scopes.SINGLETON);
105   }
106 
107   @Provides
108   @Singleton
109   Supplier<String> provideSuffix() {
110      return new Supplier<String>() {
111         final SecureRandom random = new SecureRandom();
112 
113         @Override
114         public String get() {
115            return random.nextInt(100) + "";
116         }
117      };
118 
119   }
120 
121   @Provides
122   @Singleton
123   protected final Map<RegionAndName, KeyPair> credentialsMap(Function<RegionAndName, KeyPair> in) {
124      // doesn't seem to clear when someone issues remove(key)
125      // return new MapMaker().makeComputingMap(in);
126      return newLinkedHashMap();
127   }
128 
129   @Provides
130   @Singleton
131   @Named("SECURITY")
132   protected final Map<RegionAndName, String> securityGroupMap(Function<RegionNameAndIngressRules, String> in) {
133      // doesn't seem to clear when someone issues remove(key)
134      // return new MapMaker().makeComputingMap(in);
135      return newLinkedHashMap();
136   }
137   
138   @Provides
139   @Singleton
140   protected Map<RegionAndName, Image> provideImageMap(Function<RegionAndName, Image> regionAndIdToImage) {
141      return new MapMaker().makeComputingMap(regionAndIdToImage);
142   }
143 
144}

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