@Test public void shouldNotRebootMultipleInstancesDueToAnInvalidUser() { // setup setupScatterGather(instanceIds); // act rebootInstanceServiceHelper.rebootInstances("nonOwner", instanceIds, apiApplicationManager); // verify verify(instance123, never()).setRestartRequested(eq(true)); verify(instance456, never()).setRestartRequested(eq(true)); verify(instanceManagerMessageContext, never()) .routePiMessageToApplication( eq(nodeId), eq(EntityMethod.UPDATE), eq(instance123), eq(InstanceManagerApplication.APPLICATION_NAME)); verify(secondMessageContext, never()) .routePiMessageToApplication( eq(nodeId), eq(EntityMethod.UPDATE), eq(instance456), eq(InstanceManagerApplication.APPLICATION_NAME)); }
@Test public void shouldRebootMultipleInstances() { // setup final Collection<String> instanceIds = Arrays.asList(new String[] {"i-123", "i-456"}); when(instance123.getNodeId()).thenReturn(nodeIdStr); when(instance456.getNodeId()).thenReturn(nodeIdStr); when(piIdBuilder.getNodeIdFromNodeId(anyString())).thenReturn(nodeId); setupScatterGather(instanceIds); // act rebootInstanceServiceHelper.rebootInstances(ownerId, instanceIds, apiApplicationManager); // verify verify(instance123).setRestartRequested(eq(true)); verify(instance456).setRestartRequested(eq(true)); verify(instanceManagerMessageContext) .routePiMessageToApplication( eq(nodeId), eq(EntityMethod.UPDATE), eq(instance123), eq(InstanceManagerApplication.APPLICATION_NAME)); verify(secondMessageContext) .routePiMessageToApplication( eq(nodeId), eq(EntityMethod.UPDATE), eq(instance456), eq(InstanceManagerApplication.APPLICATION_NAME)); }
@SuppressWarnings("unchecked") @Test public void shouldRebootSingleInstance() { // setup instanceIds = Arrays.asList(new String[] {"i-123"}); // act rebootInstanceServiceHelper.rebootInstances(ownerId, instanceIds, apiApplicationManager); // assert verify(scatterGatherContinuationRunner, times(1)) .execute(anyCollection(), anyLong(), isA(TimeUnit.class)); }