use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class FreeIpaScalingValidationServiceTest method testDownscaleIfInvalidInstancesExistsThenValidationFails.
@Test
public void testDownscaleIfInvalidInstancesExistsThenValidationFails() {
Stack stack = mock(Stack.class);
BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.validateStackForDownscale(createValidImSet(2), stack, null));
assertEquals("Downscaling currently only available for FreeIPA installation with 3 instances", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class FreeIpaScalingValidationServiceTest method testUpscaleIfMoreInstancesExistsThenValidationFails.
@Test
public void testUpscaleIfMoreInstancesExistsThenValidationFails() {
Stack stack = mock(Stack.class);
BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.validateStackForUpscale(createValidImSet(4), stack, null));
assertEquals("Upscaling currently only available for FreeIPA installation with 1 or 2 instances", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class FreeIpaRecommendationServiceTest method testValidateCustomInstanceTypeWhenEntitlementIsNotEnabled.
@Test
public void testValidateCustomInstanceTypeWhenEntitlementIsNotEnabled() {
when(defaultInstanceTypeProvider.getForPlatform(eq("AWS"))).thenReturn("medium");
when(entitlementService.isFreeIpaSelectInstanceTypeEnabled(anyString())).thenReturn(Boolean.FALSE);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.validateCustomInstanceType(createStack("large"), new Credential("AWS", "Cred", null, "crn", "account")));
assertEquals("Custom instance type for FreeIPA is not enabled!", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class FreeIpaScalingServiceTest method testUpscaleIfValidationFailsThenErrorThrown.
@Test
public void testUpscaleIfValidationFailsThenErrorThrown() {
Stack stack = mock(Stack.class);
Set<InstanceMetaData> allInstances = createValidImSet();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
UpscaleRequest request = createUpscaleRequest();
doThrow(new BadRequestException("validation failed")).when(validationService).validateStackForUpscale(allInstances, stack, new ScalingPath(AvailabilityType.TWO_NODE_BASED, AvailabilityType.HA));
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.upscale(ACCOUNT_ID, request));
assertEquals(exception.getMessage(), "validation failed");
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class FreeIpaPasswordValidatorTest method testValidateShouldThrowExceptionWhenThePasswordIsTooLong.
@Test
void testValidateShouldThrowExceptionWhenThePasswordIsTooLong() {
String password = "123456789123456789";
BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.validate(password));
assertEquals("Password must be between minimum 8 and maximum 16 characters.", exception.getMessage());
}
Aggregations