public class EC2DestroyNodeStrategyTest {
@SuppressWarnings("unchecked")
@Test
public void testDestroyNodeTerminatesInstanceAndReturnsRefreshedNode() throws Exception {
EC2Client client = createMock(EC2Client.class);
InstanceClient instanceClient = createMock(InstanceClient.class);
GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class);
LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);
NodeMetadata node = createMock(NodeMetadata.class);
expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null);
expect(getNode.getNode("region/i-blah")).andReturn(node);
replay(client);
replay(getNode);