Search in sources :

Example 1 with TestPagedList

use of com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList in project cloudbreak by hortonworks.

the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZonesNotConnectedToNetworkWhenNoZonesFound.

@Test
void testPrivateDnsZonesNotConnectedToNetworkWhenNoZonesFound() {
    ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder();
    PagedList<PrivateZone> privateDnsZoneList = new TestPagedList<>();
    ValidationResult result = underTest.privateDnsZonesNotConnectedToNetwork(azureClient, NETWORK_NAME, A_RESOURCE_GROUP_NAME, ZONE_NAME_POSTGRES, resultBuilder, privateDnsZoneList);
    assertFalse(result.hasError());
    verify(azureClient, never()).getNetworkLinkByPrivateDnsZone(anyString(), anyString(), anyString());
}
Also used : ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) TestPagedList(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with TestPagedList

use of com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList in project cloudbreak by hortonworks.

the class AzurePrivateDnsZoneValidatorServiceTest method getNetworkLinks.

private PagedList<VirtualNetworkLinkInner> getNetworkLinks(List<String> foundNetworkIds) {
    PagedList<VirtualNetworkLinkInner> virtualNetworkLinks = new TestPagedList<>();
    foundNetworkIds.stream().map(id -> new VirtualNetworkLinkInner().withVirtualNetwork(new SubResource().withId(id))).forEach(virtualNetworkLinks::add);
    return virtualNetworkLinks;
}
Also used : SubResource(com.microsoft.azure.SubResource) AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) Mock(org.mockito.Mock) StringUtils(org.apache.commons.lang3.StringUtils) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) SUBSCRIPTION_ID(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsView.SUBSCRIPTION_ID) Network(com.microsoft.azure.management.network.Network) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner) TestPagedList(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList) ZONE_NAME_POSTGRES(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.ZONE_NAME_POSTGRES) PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) PagedList(com.microsoft.azure.PagedList) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) A_RESOURCE_GROUP_NAME(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.A_RESOURCE_GROUP_NAME) SINGLE_RESOURCE_GROUP_NAME(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.SINGLE_RESOURCE_GROUP_NAME) MethodSource(org.junit.jupiter.params.provider.MethodSource) ProvisioningState(com.microsoft.azure.management.privatedns.v2018_09_01.ProvisioningState) InjectMocks(org.mockito.InjectMocks) NETWORK_RESOURCE_ID(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_RESOURCE_ID) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) NETWORK_NAME(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_NAME) Mockito.verify(org.mockito.Mockito.verify) NETWORK_RESOURCE_GROUP_NAME(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_RESOURCE_GROUP_NAME) Test(org.junit.jupiter.api.Test) Mockito.never(org.mockito.Mockito.never) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ValidationTestUtil(com.sequenceiq.cloudbreak.cloud.azure.validator.ValidationTestUtil) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) SubResource(com.microsoft.azure.SubResource) TestPagedList(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner)

Example 3 with TestPagedList

use of com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList in project cloudbreak by hortonworks.

the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZoneExistsWhenZoneExists.

@Test
void testPrivateDnsZoneExistsWhenZoneExists() {
    ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder();
    PagedList<PrivateZone> privateZones = new TestPagedList<>();
    privateZones.add(getPrivateDnsZone(null, ZONE_NAME_POSTGRES, null));
    when(azureClient.getPrivateDnsZonesByResourceGroup(SUBSCRIPTION_ID, SINGLE_RESOURCE_GROUP_NAME)).thenReturn(privateZones);
    resultBuilder = underTest.privateDnsZoneExists(azureClient, getPrivateDnsZoneResourceId(), resultBuilder);
    ValidationResult result = resultBuilder.build();
    assertFalse(result.hasError());
}
Also used : ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) TestPagedList(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

PrivateZone (com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)3 TestPagedList (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList)3 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 PagedList (com.microsoft.azure.PagedList)1 SubResource (com.microsoft.azure.SubResource)1 Network (com.microsoft.azure.management.network.Network)1 ProvisioningState (com.microsoft.azure.management.privatedns.v2018_09_01.ProvisioningState)1 VirtualNetworkLinkInner (com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner)1 AzurePrivateDnsZoneServiceEnum (com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum)1 AzureClient (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient)1 ValidationTestUtil (com.sequenceiq.cloudbreak.cloud.azure.validator.ValidationTestUtil)1 A_RESOURCE_GROUP_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.A_RESOURCE_GROUP_NAME)1 NETWORK_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_NAME)1 NETWORK_RESOURCE_GROUP_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_RESOURCE_GROUP_NAME)1 NETWORK_RESOURCE_ID (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_RESOURCE_ID)1 SINGLE_RESOURCE_GROUP_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.SINGLE_RESOURCE_GROUP_NAME)1 ZONE_NAME_POSTGRES (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.ZONE_NAME_POSTGRES)1 PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId)1