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

COVERAGE SUMMARY FOR SOURCE FILE [VCloudComputeServiceContextModule.java]

nameclass, %method, %block, %line, %
VCloudComputeServiceContextModule.java100% (12/12)89%  (16/18)96%  (217/225)92%  (22/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VCloudComputeServiceContextModule100% (1/1)71%  (5/7)95%  (151/159)89%  (17/19)
provideTemplate (Injector, TemplateBuilder): TemplateBuilder 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% (40/40)100% (1/1)
VCloudComputeServiceContextModule (): void 100% (1/1)100% (3/3)100% (1/1)
configure (): void 100% (1/1)100% (100/100)100% (13/13)
defineComputeStrategyModule (): BindComputeStrategiesByClass 100% (1/1)100% (4/4)100% (1/1)
defineComputeSupplierModule (): BindComputeSuppliersByClass 100% (1/1)100% (4/4)100% (1/1)
     
class VCloudComputeServiceContextModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$1 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$10100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$10 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$11100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$11 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$2 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$3100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$3 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$4100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$4 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$5100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$5 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$6100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$6 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$7100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$7 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$8100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$8 (VCloudComputeServiceContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class VCloudComputeServiceContextModule$9100% (1/1)100% (1/1)100% (6/6)100% (1/1)
VCloudComputeServiceContextModule$9 (VCloudComputeServiceContextModule): void 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.vcloud.compute.config;
20 
21 
22import static org.jclouds.compute.domain.OsFamily.UBUNTU;
23 
24import java.util.Map;
25 
26import javax.inject.Singleton;
27 
28import org.jclouds.compute.ComputeServiceContext;
29import org.jclouds.compute.config.BaseComputeServiceContextModule;
30import org.jclouds.compute.config.BindComputeStrategiesByClass;
31import org.jclouds.compute.config.BindComputeSuppliersByClass;
32import org.jclouds.compute.domain.Hardware;
33import org.jclouds.compute.domain.Image;
34import org.jclouds.compute.domain.NodeMetadata;
35import org.jclouds.compute.domain.NodeState;
36import org.jclouds.compute.domain.TemplateBuilder;
37import org.jclouds.compute.internal.ComputeServiceContextImpl;
38import org.jclouds.compute.options.TemplateOptions;
39import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
40import org.jclouds.rest.RestContext;
41import org.jclouds.rest.internal.RestContextImpl;
42import org.jclouds.vcloud.VCloudClient;
43import org.jclouds.vcloud.compute.functions.HardwareForVApp;
44import org.jclouds.vcloud.compute.functions.HardwareInOrg;
45import org.jclouds.vcloud.compute.functions.ImagesInOrg;
46import org.jclouds.vcloud.compute.functions.VAppToNodeMetadata;
47import org.jclouds.vcloud.compute.internal.VCloudTemplateBuilderImpl;
48import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
49import org.jclouds.vcloud.compute.strategy.GetLoginCredentialsFromGuestConfiguration;
50import org.jclouds.vcloud.domain.Org;
51import org.jclouds.vcloud.domain.Status;
52import org.jclouds.vcloud.domain.VApp;
53 
54import com.google.common.annotations.VisibleForTesting;
55import com.google.common.base.Function;
56import com.google.common.collect.ImmutableMap;
57import com.google.inject.Injector;
58import com.google.inject.Provides;
59import com.google.inject.Scopes;
60import com.google.inject.TypeLiteral;
61 
62/**
63 * Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
64 * bound.
65 * 
66 * @author Adrian Cole
67 */
68public class VCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
69 
70   @VisibleForTesting
71   public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder()
72         .put(Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING)
73         .put(Status.RESOLVED, NodeState.PENDING).put(Status.ERROR, NodeState.ERROR)
74         .put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED, NodeState.PENDING)
75         .put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN, NodeState.UNRECOGNIZED)
76         .put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT, NodeState.PENDING)
77         .put(Status.SUSPENDED, NodeState.SUSPENDED).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      install(defineComputeStrategyModule());
89      install(defineComputeSupplierModule());
90      bind(new TypeLiteral<Function<VApp, NodeMetadata>>() {
91      }).to(VAppToNodeMetadata.class);
92      bind(TemplateOptions.class).to(VCloudTemplateOptions.class);
93      bind(TemplateBuilder.class).to(VCloudTemplateBuilderImpl.class);
94      bind(new TypeLiteral<Function<VApp, Hardware>>() {
95      }).to(new TypeLiteral<HardwareForVApp>() {
96      });
97      bind(new TypeLiteral<ComputeServiceContext>() {
98      }).to(new TypeLiteral<ComputeServiceContextImpl<VCloudClient, VCloudClient>>() {
99      }).in(Scopes.SINGLETON);
100      bind(new TypeLiteral<RestContext<VCloudClient, VCloudClient>>() {
101      }).to(new TypeLiteral<RestContextImpl<VCloudClient, VCloudClient>>() {
102      }).in(Scopes.SINGLETON);
103      bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() {
104      }).to(new TypeLiteral<ImagesInOrg>() {
105      });
106      bind(new TypeLiteral<Function<Org, Iterable<? extends Hardware>>>() {
107      }).to(new TypeLiteral<HardwareInOrg>() {
108      });
109      bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(GetLoginCredentialsFromGuestConfiguration.class);
110   }
111   
112   //CIM ostype does not include version info
113   @Override
114   protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
115      return template.osFamily(UBUNTU).os64Bit(true);
116   }
117   
118   public BindComputeStrategiesByClass defineComputeStrategyModule() {
119      return new VCloudBindComputeStrategiesByClass();
120   }
121 
122   public BindComputeSuppliersByClass defineComputeSupplierModule() {
123      return new VCloudBindComputeSuppliersByClass();
124   }
125}

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