@Test public void testCheckInstanceIsTheAmbariServerOrNotMethodWhenTypeIsGatewayThenException() { expectedException.expect(BadRequestException.class); expectedException.expectMessage(CLUSTER_MANAGER_SERVER_HOST_EXCEPTION_MESSAGE); underTest.checkInstanceIsTheClusterManagerServerOrNot(INSTANCE_PUBLIC_IP, GATEWAY); }
public void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType) { if (GATEWAY.equals(metadataType) || GATEWAY_PRIMARY.equals(metadataType)) { String additionalIpPartForTemplate = ""; String messageTemplate = "Downscale for the given node%s is prohibited because it " + "serves as a host the Cluster Manager server"; if (StringUtils.isNotEmpty(instancePublicIp)) { additionalIpPartForTemplate = " [public IP: " + instancePublicIp + "]"; } throw new BadRequestException(String.format(messageTemplate, additionalIpPartForTemplate)); } }
StackDownscaleValidatorService { public void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType) { if (GATEWAY.equals(metadataType) || GATEWAY_PRIMARY.equals(metadataType)) { String additionalIpPartForTemplate = ""; String messageTemplate = "Downscale for the given node%s is prohibited because it " + "serves as a host the Cluster Manager server"; if (StringUtils.isNotEmpty(instancePublicIp)) { additionalIpPartForTemplate = " [public IP: " + instancePublicIp + "]"; } throw new BadRequestException(String.format(messageTemplate, additionalIpPartForTemplate)); } } }
StackDownscaleValidatorService { public void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType) { if (GATEWAY.equals(metadataType) || GATEWAY_PRIMARY.equals(metadataType)) { String additionalIpPartForTemplate = ""; String messageTemplate = "Downscale for the given node%s is prohibited because it " + "serves as a host the Cluster Manager server"; if (StringUtils.isNotEmpty(instancePublicIp)) { additionalIpPartForTemplate = " [public IP: " + instancePublicIp + "]"; } throw new BadRequestException(String.format(messageTemplate, additionalIpPartForTemplate)); } }  }
StackDownscaleValidatorService { public void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType) { if (GATEWAY.equals(metadataType) || GATEWAY_PRIMARY.equals(metadataType)) { String additionalIpPartForTemplate = ""; String messageTemplate = "Downscale for the given node%s is prohibited because it " + "serves as a host the Cluster Manager server"; if (StringUtils.isNotEmpty(instancePublicIp)) { additionalIpPartForTemplate = " [public IP: " + instancePublicIp + "]"; } throw new BadRequestException(String.format(messageTemplate, additionalIpPartForTemplate)); } }  void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType); void checkUserHasRightToTerminateInstance(String owner, String userId, Long stackId); void checkClusterInValidStatus(Cluster cluster); }
StackDownscaleValidatorService { public void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType) { if (GATEWAY.equals(metadataType) || GATEWAY_PRIMARY.equals(metadataType)) { String additionalIpPartForTemplate = ""; String messageTemplate = "Downscale for the given node%s is prohibited because it " + "serves as a host the Cluster Manager server"; if (StringUtils.isNotEmpty(instancePublicIp)) { additionalIpPartForTemplate = " [public IP: " + instancePublicIp + "]"; } throw new BadRequestException(String.format(messageTemplate, additionalIpPartForTemplate)); } }  void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType); void checkUserHasRightToTerminateInstance(String owner, String userId, Long stackId); void checkClusterInValidStatus(Cluster cluster);  }