EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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