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

COVERAGE SUMMARY FOR SOURCE FILE [VCloudLifeCycleStrategy.java]

nameclass, %method, %block, %line, %
VCloudLifeCycleStrategy.java0%   (0/1)0%   (0/5)0%   (0/70)0%   (0/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VCloudLifeCycleStrategy0%   (0/1)0%   (0/5)0%   (0/70)0%   (0/14)
VCloudLifeCycleStrategy (VCloudClient, Predicate, GetNodeMetadataStrategy): void 0%   (0/1)0%   (0/12)0%   (0/5)
rebootNode (String): NodeMetadata 0%   (0/1)0%   (0/17)0%   (0/3)
resumeNode (String): NodeMetadata 0%   (0/1)0%   (0/15)0%   (0/2)
returnWhenTaskCompletes (String, Task): NodeMetadata 0%   (0/1)0%   (0/11)0%   (0/2)
suspendNode (String): NodeMetadata 0%   (0/1)0%   (0/15)0%   (0/2)

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.vcloud.compute.strategy;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24 
25import javax.annotation.Resource;
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.compute.domain.NodeMetadata;
30import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
31import org.jclouds.compute.strategy.RebootNodeStrategy;
32import org.jclouds.compute.strategy.ResumeNodeStrategy;
33import org.jclouds.compute.strategy.SuspendNodeStrategy;
34import org.jclouds.vcloud.VCloudClient;
35import org.jclouds.vcloud.domain.Task;
36 
37import com.google.common.base.Predicate;
38 
39/**
40 * @author Adrian Cole
41 */
42@Singleton
43public class VCloudLifeCycleStrategy implements RebootNodeStrategy, ResumeNodeStrategy, SuspendNodeStrategy {
44   @Resource
45   private final VCloudClient client;
46   protected final Predicate<URI> taskTester;
47   protected final GetNodeMetadataStrategy getNode;
48 
49   @Inject
50   protected VCloudLifeCycleStrategy(VCloudClient client, Predicate<URI> taskTester,
51            GetNodeMetadataStrategy getNode) {
52      this.client = client;
53      this.taskTester = taskTester;
54      this.getNode = getNode;
55   }
56 
57   @Override
58   public NodeMetadata rebootNode(String in) {
59      URI id = URI.create(checkNotNull(in, "node.id"));
60      Task task = client.getVAppClient().resetVApp(id);
61      return returnWhenTaskCompletes(in, task);
62   }
63 
64   private NodeMetadata returnWhenTaskCompletes(String in, Task task) {
65      taskTester.apply(task.getHref());
66      return getNode.getNode(in);
67   }
68 
69   @Override
70   public NodeMetadata resumeNode(String in) {
71      Task task = client.getVAppClient().powerOnVApp(URI.create(checkNotNull(in, "node.id")));
72      return returnWhenTaskCompletes(in, task);
73   }
74 
75   @Override
76   public NodeMetadata suspendNode(String in) {
77      Task task = client.getVAppClient().powerOffVApp(URI.create(checkNotNull(in, "node.id")));
78      return returnWhenTaskCompletes(in, task);
79   }
80}

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