mirror of https://github.com/apache/jclouds.git
NodePredicates gained static predicate SUSPENDED
Replaced hard-coded Strings in toString methods of static predicates with their enum.toString counterparts Added test 'testNodeRunningFailsOnSuspended' Revert "Added test 'testNodeRunningFailsOnSuspended'" This reverts commit 2a543bfe20540bb4f10ef4f86e845a63bdbe90e3. Removed test 'testNodeRunningFailsOnSuspended'. Added test 'testNodeSuspendedReturnsTrueWhenSuspended'. Renamed ' Revert "Renamed '" This reverts commit 061e9292a812066562ab47ba5eea15337fc13c3d. Renamed 'AtomicNodeSuspended.nodeRunning' to 'AtomicNodeSuspended.nodeSuspended'.\nWhere applicable combined all calls to 'replay(Object...)' instead of the old 'replay(node);replay(computeService);'
This commit is contained in:
parent
cb53eee8aa
commit
9d7a857383
|
@ -254,7 +254,7 @@ public class NodePredicates {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RUNNING";
|
||||
return Status.RUNNING.toString();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -269,7 +269,22 @@ public class NodePredicates {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TERMINATED";
|
||||
return Status.TERMINATED.toString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Match nodes with State == SUSPENDED
|
||||
*/
|
||||
public static final Predicate<NodeMetadata> SUSPENDED = new Predicate<NodeMetadata>() {
|
||||
@Override
|
||||
public boolean apply(NodeMetadata nodeMetadata) {
|
||||
return nodeMetadata.getStatus() == Status.SUSPENDED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Status.SUSPENDED.toString();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -135,21 +135,31 @@ public class AtomicNodePredicatesTest {
|
|||
public void testNodeRunningReturnsTrueWhenRunning() {
|
||||
expect(node.getStatus()).andReturn(Status.RUNNING).atLeastOnce();
|
||||
expect(node.getBackendStatus()).andReturn(null).atLeastOnce();
|
||||
replay(node);
|
||||
replay(computeService);
|
||||
replay(node, computeService);
|
||||
|
||||
AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
|
||||
AtomicReference<NodeMetadata> reference = Atomics.newReference(node);
|
||||
Assert.assertTrue(nodeRunning.apply(reference));
|
||||
Assert.assertEquals(reference.get(), node);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeSuspendedReturnsTrueWhenSuspended() {
|
||||
expect(node.getStatus()).andReturn(Status.SUSPENDED).atLeastOnce();
|
||||
expect(node.getBackendStatus()).andReturn(null).atLeastOnce();
|
||||
replay(node, computeService);
|
||||
|
||||
AtomicNodeSuspended nodeSuspended = new AtomicNodeSuspended(computeService);
|
||||
AtomicReference<NodeMetadata> reference = Atomics.newReference(node);
|
||||
Assert.assertTrue(nodeSuspended.apply(reference));
|
||||
Assert.assertEquals(reference.get(), node);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testNodeRunningFailsOnTerminated() {
|
||||
expect(node.getStatus()).andReturn(Status.TERMINATED).atLeastOnce();
|
||||
expect(node.getBackendStatus()).andReturn(null).atLeastOnce();
|
||||
replay(node);
|
||||
replay(computeService);
|
||||
replay(node, computeService);
|
||||
|
||||
AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
|
||||
AtomicReference<NodeMetadata> reference = Atomics.newReference(node);
|
||||
|
@ -161,8 +171,7 @@ public class AtomicNodePredicatesTest {
|
|||
public void testNodeRunningFailsOnError() {
|
||||
expect(node.getStatus()).andReturn(Status.ERROR).atLeastOnce();
|
||||
expect(node.getBackendStatus()).andReturn(null).atLeastOnce();
|
||||
replay(node);
|
||||
replay(computeService);
|
||||
replay(node, computeService);
|
||||
|
||||
AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
|
||||
AtomicReference<NodeMetadata> reference = Atomics.newReference(node);
|
||||
|
|
Loading…
Reference in New Issue