private void checkInstanceState(InstanceHealth instanceState) { checkNotNull(instanceState.getDescription(), "Description cannot be null for InstanceState"); checkNotNull(instanceState.getInstanceId(), "InstanceId cannot be null for InstanceState"); checkNotNull( instanceState.getReasonCode(), "While ReasonCode can be null for InstanceState, its Optional wrapper cannot"); checkNotNull(instanceState.getState(), "State cannot be null for InstanceState"); }
@Test protected void testListInstanceStates() { for (LoadBalancer loadBalancer : api.getLoadBalancerApi().list().concat()) { Set<InstanceHealth> response = api().getHealthOfInstancesOfLoadBalancer(loadBalancer.getName()); for (InstanceHealth instanceState : response) { checkInstanceState(instanceState); } if (response.size() > 0) { InstanceHealth instanceState = response.iterator().next(); Assert.assertEquals( ImmutableSet.of( api() .getHealthOfInstancesOfLoadBalancer( ImmutableSet.of(instanceState.getInstanceId()), loadBalancer.getName())), instanceState); } } }