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

COVERAGE SUMMARY FOR SOURCE FILE [TerremarkVCloudComputeServiceContextModule.java]

nameclass, %method, %block, %line, %
TerremarkVCloudComputeServiceContextModule.java8%   (1/12)5%   (1/20)10%  (25/240)4%   (1/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TerremarkVCloudComputeServiceContextModule$10%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$1 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$100%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$10 (TerremarkVCloudComputeServiceC... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$110%   (0/1)0%   (0/2)0%   (0/21)0%   (0/2)
TerremarkVCloudComputeServiceContextModule$11 (TerremarkVCloudComputeServiceC... 0%   (0/1)0%   (0/9)0%   (0/1)
get (): String 0%   (0/1)0%   (0/12)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$20%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$2 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$30%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$3 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$40%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$4 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$50%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$5 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$60%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$6 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$70%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$7 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$80%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$8 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule$90%   (0/1)0%   (0/1)0%   (0/6)0%   (0/1)
TerremarkVCloudComputeServiceContextModule$9 (TerremarkVCloudComputeServiceCo... 0%   (0/1)0%   (0/6)0%   (0/1)
     
class TerremarkVCloudComputeServiceContextModule100% (1/1)12%  (1/8)16%  (25/159)5%   (1/22)
TerremarkVCloudComputeServiceContextModule (): void 0%   (0/1)0%   (0/3)0%   (0/1)
bindVAppConverter (): void 0%   (0/1)0%   (0/10)0%   (0/2)
configure (): void 0%   (0/1)0%   (0/99)0%   (0/14)
credentialsMap (): ConcurrentMap 0%   (0/1)0%   (0/4)0%   (0/1)
providePassword (SecureRandom): String 0%   (0/1)0%   (0/10)0%   (0/1)
provideSuffix (SecureRandom): Supplier 0%   (0/1)0%   (0/6)0%   (0/1)
provideVAppStatusToNodeState (): Map 0%   (0/1)0%   (0/2)0%   (0/1)
<static initializer> 100% (1/1)100% (25/25)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.trmk.vcloud_0_8.compute.config;
20 
21import java.security.SecureRandom;
22import java.util.Map;
23import java.util.concurrent.ConcurrentHashMap;
24import java.util.concurrent.ConcurrentMap;
25 
26import javax.inject.Named;
27import javax.inject.Singleton;
28 
29import org.jclouds.compute.ComputeService;
30import org.jclouds.compute.ComputeServiceContext;
31import org.jclouds.compute.config.BaseComputeServiceContextModule;
32import org.jclouds.compute.domain.Image;
33import org.jclouds.compute.domain.NodeMetadata;
34import org.jclouds.compute.domain.NodeState;
35import org.jclouds.compute.domain.OperatingSystem;
36import org.jclouds.compute.internal.ComputeServiceContextImpl;
37import org.jclouds.compute.options.TemplateOptions;
38import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
39import org.jclouds.rest.RestContext;
40import org.jclouds.rest.internal.RestContextImpl;
41import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
42import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
43import org.jclouds.trmk.vcloud_0_8.compute.TerremarkVCloudComputeService;
44import org.jclouds.trmk.vcloud_0_8.compute.domain.KeyPairCredentials;
45import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
46import org.jclouds.trmk.vcloud_0_8.compute.functions.ImagesInVCloudExpressOrg;
47import org.jclouds.trmk.vcloud_0_8.compute.functions.NodeMetadataToOrgAndName;
48import org.jclouds.trmk.vcloud_0_8.compute.functions.ParseOsFromVAppTemplateName;
49import org.jclouds.trmk.vcloud_0_8.compute.functions.VAppToNodeMetadata;
50import org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions;
51import org.jclouds.trmk.vcloud_0_8.compute.strategy.ParseVAppTemplateDescriptionToGetDefaultLoginCredentials;
52import org.jclouds.trmk.vcloud_0_8.domain.Org;
53import org.jclouds.trmk.vcloud_0_8.domain.Status;
54import org.jclouds.trmk.vcloud_0_8.domain.VApp;
55 
56import com.google.common.annotations.VisibleForTesting;
57import com.google.common.base.Function;
58import com.google.common.base.Supplier;
59import com.google.common.collect.ImmutableMap;
60import com.google.inject.Provides;
61import com.google.inject.Scopes;
62import com.google.inject.TypeLiteral;
63 
64/**
65 * Configures the {@link TerremarkVCloudComputeServiceContext}; requires
66 * {@link TerremarkVCloudComputeClientImpl} bound.
67 * 
68 * @author Adrian Cole
69 */
70public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
71 
72   @VisibleForTesting
73   public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder()
74         .put(Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING)
75         .put(Status.RESOLVED, NodeState.PENDING).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)
76         .put(Status.DEPLOYED, NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED)
77         .put(Status.UNRESOLVED, NodeState.PENDING).build();
78 
79   @Singleton
80   @Provides
81   protected Map<Status, NodeState> provideVAppStatusToNodeState() {
82      return VAPPSTATUS_TO_NODESTATE;
83   }
84 
85   @Override
86   protected void configure() {
87      super.configure();
88      bind(new TypeLiteral<Function<NodeMetadata, OrgAndName>>() {
89      }).to(new TypeLiteral<NodeMetadataToOrgAndName>() {
90      });
91      bind(TemplateOptions.class).to(TerremarkVCloudTemplateOptions.class);
92      bind(ComputeService.class).to(TerremarkVCloudComputeService.class);
93      bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(
94            ParseVAppTemplateDescriptionToGetDefaultLoginCredentials.class);
95      bind(SecureRandom.class).toInstance(new SecureRandom());
96      install(new TerremarkBindComputeStrategiesByClass());
97      install(new TerremarkBindComputeSuppliersByClass());
98      bindVAppConverter();
99      bind(new TypeLiteral<ComputeServiceContext>() {
100      }).to(new TypeLiteral<ComputeServiceContextImpl<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
101      }).in(Scopes.SINGLETON);
102      bind(new TypeLiteral<RestContext<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
103      }).to(new TypeLiteral<RestContextImpl<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
104      }).in(Scopes.SINGLETON);
105      bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() {
106      }).to(new TypeLiteral<ImagesInVCloudExpressOrg>() {
107      });
108      bind(new TypeLiteral<Function<String, OperatingSystem>>() {
109      }).to(ParseOsFromVAppTemplateName.class);
110   }
111 
112   protected void bindVAppConverter() {
113      bind(new TypeLiteral<Function<VApp, NodeMetadata>>() {
114      }).to(VAppToNodeMetadata.class);
115   }
116 
117   @Provides
118   @Singleton
119   Supplier<String> provideSuffix(final SecureRandom random) {
120      return new Supplier<String>() {
121         @Override
122         public String get() {
123            return random.nextInt(4096) + "";
124         }
125      };
126 
127   }
128 
129   @Provides
130   @Singleton
131   ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap() {
132      return new ConcurrentHashMap<OrgAndName, KeyPairCredentials>();
133   }
134 
135   @Named("PASSWORD")
136   @Provides
137   String providePassword(SecureRandom random) {
138      return random.nextLong() + "";
139   }
140 
141}

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