@Test(expectedExceptions = IllegalStateException.class) public void testNodeRunningFailsOnError() { expect(node.getStatus()).andReturn(Status.ERROR).atLeastOnce(); expect(node.getBackendStatus()).andReturn(null).atLeastOnce(); replay(node); replay(computeService); AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService); AtomicReference<NodeMetadata> reference = Atomics.newReference(node); nodeRunning.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); AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService); AtomicReference<NodeMetadata> reference = Atomics.newReference(node); nodeRunning.apply(reference); Assert.assertEquals(reference.get(), node); }
@Test public void testNodeRunningReturnsTrueWhenRunning() { expect(node.getStatus()).andReturn(Status.RUNNING).atLeastOnce(); expect(node.getBackendStatus()).andReturn(null).atLeastOnce(); replay(node); replay(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 public void testNodeRunningReturnsTrueWhenRunning() { expect(node.getStatus()).andReturn(Status.RUNNING).atLeastOnce(); expect(node.getBackendStatus()).andReturn(null).atLeastOnce(); 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(expectedExceptions = IllegalStateException.class) public void testNodeRunningFailsOnError() { expect(node.getStatus()).andReturn(Status.ERROR).atLeastOnce(); expect(node.getBackendStatus()).andReturn(null).atLeastOnce(); replay(node, computeService); AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService); AtomicReference<NodeMetadata> reference = Atomics.newReference(node); nodeRunning.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, computeService); AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService); AtomicReference<NodeMetadata> reference = Atomics.newReference(node); nodeRunning.apply(reference); Assert.assertEquals(reference.get(), node); }
private static void assertNodeEquals(NodeMetadata actual, NodeMetadata expected) { assertEquals(actual, expected); // NodeMetadata equals method does not use all fields in equals. It assumes that same ids in same locations // determine the equivalence assertEquals(actual.getStatus(), expected.getStatus()); assertEquals(actual.getBackendStatus(), expected.getBackendStatus()); assertEquals(actual.getLoginPort(), expected.getLoginPort()); assertEquals(actual.getPublicAddresses(), expected.getPublicAddresses()); assertEquals(actual.getPrivateAddresses(), expected.getPrivateAddresses()); assertEquals(actual.getCredentials(), expected.getCredentials()); assertEquals(actual.getGroup(), expected.getGroup()); assertEquals(actual.getImageId(), expected.getImageId()); assertEquals(actual.getHardware(), expected.getHardware()); assertEquals(actual.getOperatingSystem(), expected.getOperatingSystem()); assertEquals(actual.getHostname(), expected.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }