use of com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto in project cloudbreak by hortonworks.
the class EnvironmentLoadBalancerServiceTest method testNoEnvironmentFound.
@Test
public void testNoEnvironmentFound() {
EnvironmentLoadBalancerDto environmentLbDto = EnvironmentLoadBalancerDto.builder().withEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED).build();
EnvironmentDto environmentDto = EnvironmentDto.builder().withName(ENV_NAME).withResourceCrn(ENV_CRN).build();
String expectedError = String.format("Could not find environment '%s' using crn '%s'", ENV_NAME, ENV_CRN);
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(anyString(), anyString())).thenReturn(Optional.empty());
doNothing().when(loadBalancerEntitlementService).validateNetworkForEndpointGateway(any(), any(), any());
final NotFoundException[] exception = new NotFoundException[1];
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
exception[0] = assertThrows(NotFoundException.class, () -> underTest.updateLoadBalancerInEnvironmentAndStacks(environmentDto, environmentLbDto));
});
assertEquals(expectedError, exception[0].getMessage());
}
use of com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto in project cloudbreak by hortonworks.
the class EnvironmentLoadBalancerServiceTest method testNoEntitlements.
@Test
public void testNoEntitlements() {
EnvironmentLoadBalancerDto environmentLbDto = EnvironmentLoadBalancerDto.builder().withEndpointAccessGateway(PublicEndpointAccessGateway.DISABLED).build();
EnvironmentDto environmentDto = EnvironmentDto.builder().withResourceCrn(ENV_CRN).build();
String expectedError = "Neither Endpoint Gateway nor Data Lake load balancer is enabled. Nothing to do.";
when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(false);
final BadRequestException[] exception = new BadRequestException[1];
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
exception[0] = assertThrows(BadRequestException.class, () -> underTest.updateLoadBalancerInEnvironmentAndStacks(environmentDto, environmentLbDto));
});
assertEquals(expectedError, exception[0].getMessage());
}
use of com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testInitLoadBalancerDto.
@Test
void testInitLoadBalancerDto() {
Set<String> subnetIds = Set.of("id1, id2");
EnvironmentLoadBalancerUpdateRequest request = new EnvironmentLoadBalancerUpdateRequest();
request.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
request.setSubnetIds(subnetIds);
EnvironmentLoadBalancerDto environmentLbDto = underTest.initLoadBalancerDto(request);
assertEquals(PublicEndpointAccessGateway.ENABLED, environmentLbDto.getEndpointAccessGateway());
assertEquals(subnetIds, environmentLbDto.getEndpointGatewaySubnetIds());
}
use of com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto in project cloudbreak by hortonworks.
the class EnvironmentLoadBalancerServiceTest method testDataLakeLoadBalancerEnabled.
@Test
public void testDataLakeLoadBalancerEnabled() {
EnvironmentLoadBalancerDto environmentLbDto = EnvironmentLoadBalancerDto.builder().withEndpointAccessGateway(PublicEndpointAccessGateway.DISABLED).build();
EnvironmentDto environmentDto = EnvironmentDto.builder().withResourceCrn(ENV_CRN).build();
when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(true);
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(anyString(), anyString())).thenReturn(Optional.of(new Environment()));
doNothing().when(loadBalancerEntitlementService).validateNetworkForEndpointGateway(any(), any(), any());
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
underTest.updateLoadBalancerInEnvironmentAndStacks(environmentDto, environmentLbDto);
});
verify(reactorFlowManager, times(1)).triggerLoadBalancerUpdateFlow(any(), any(), any(), any(), any(), any(), anyString());
}
use of com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto in project cloudbreak by hortonworks.
the class EnvironmentLoadBalancerServiceTest method testEndpointGatewayEnabled.
@Test
public void testEndpointGatewayEnabled() {
EnvironmentLoadBalancerDto environmentLbDto = EnvironmentLoadBalancerDto.builder().withEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED).build();
EnvironmentDto environmentDto = EnvironmentDto.builder().withResourceCrn(ENV_CRN).build();
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(anyString(), anyString())).thenReturn(Optional.of(new Environment()));
doNothing().when(loadBalancerEntitlementService).validateNetworkForEndpointGateway(any(), any(), any());
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
underTest.updateLoadBalancerInEnvironmentAndStacks(environmentDto, environmentLbDto);
});
verify(reactorFlowManager, times(1)).triggerLoadBalancerUpdateFlow(any(), any(), any(), any(), any(), any(), anyString());
}
Aggregations