Search in sources :

Example 1 with PlatformNoSqlTablesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse in project cloudbreak by hortonworks.

the class CredentialPlatformResourceController method getNoSqlTables.

@Override
@CustomPermissionCheck
public PlatformNoSqlTablesResponse getNoSqlTables(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone) {
    customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
    String accountId = getAccountId();
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone);
    LOGGER.info("Get /platform_resources/nosql_tables, request: {}", request);
    CloudNoSqlTables noSqlTables = platformParameterService.getNoSqlTables(request);
    PlatformNoSqlTablesResponse response = cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter.convert(noSqlTables);
    LOGGER.info("Resp /platform_resources/nosql_tables, request: {}, noSqlTables: {}, response: {}", request, noSqlTables, response);
    return response;
}
Also used : CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) PlatformNoSqlTablesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck)

Example 2 with PlatformNoSqlTablesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse in project cloudbreak by hortonworks.

the class EnvironmentPlatformResourceController method getNoSqlTables.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformNoSqlTablesResponse getNoSqlTables(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
    LOGGER.info("Get /platform_resources/nosql_tables, request: {}", request);
    CloudNoSqlTables noSqlTables = platformParameterService.getNoSqlTables(request);
    PlatformNoSqlTablesResponse response = cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter.convert(noSqlTables);
    LOGGER.info("Resp /platform_resources/nosql_tables, request: {}, noSqlTables: {}, response: {}", request, noSqlTables, response);
    return response;
}
Also used : CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) PlatformNoSqlTablesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 3 with PlatformNoSqlTablesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse in project cloudbreak by hortonworks.

the class CloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverterTest method convert.

@Test
void convert() {
    List<CloudNoSqlTable> tables = List.of(new CloudNoSqlTable("a"), new CloudNoSqlTable("b"));
    CloudNoSqlTables source = new CloudNoSqlTables(tables);
    PlatformNoSqlTablesResponse result = underTest.convert(source);
    List<PlatformNoSqlTableResponse> noSqlTables = result.getNoSqlTables();
    assertNotNull(noSqlTables);
    assertEquals(tables.size(), noSqlTables.size());
    tables.forEach(t -> {
        assertTrue(noSqlTables.stream().anyMatch(s -> t.getName().equals(s.getName())));
    });
}
Also used : Test(org.junit.jupiter.api.Test) PlatformNoSqlTableResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTableResponse) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) List(java.util.List) CloudNoSqlTable(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PlatformNoSqlTablesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse) CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) CloudNoSqlTable(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable) PlatformNoSqlTablesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse) PlatformNoSqlTableResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTableResponse) Test(org.junit.jupiter.api.Test)

Example 4 with PlatformNoSqlTablesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse in project cloudbreak by hortonworks.

the class CredentialPlatformResourceControllerTest method getNoSqlTables.

@Test
void getNoSqlTables() {
    CloudNoSqlTables noSqlTables = new CloudNoSqlTables();
    PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
    PlatformNoSqlTablesResponse response = new PlatformNoSqlTablesResponse();
    when(platformParameterService.getPlatformResourceRequest(any(), any(), any(), any(), any(), any())).thenReturn(platformResourceRequest);
    when(platformParameterService.getNoSqlTables(any(PlatformResourceRequest.class))).thenReturn(noSqlTables);
    when(cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter.convert(noSqlTables)).thenReturn(response);
    doNothing().when(commonPermissionCheckingUtils).checkPermissionForUserOnResource(any(), any(), any());
    PlatformNoSqlTablesResponse result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getNoSqlTables(null, CREDENTIAL_CRN, "region", "aws", "az"));
    verify(platformParameterService).getNoSqlTables(platformResourceRequest);
    verify(cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter).convert(noSqlTables);
    assertEquals(response, result);
}
Also used : CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) PlatformNoSqlTablesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse) Test(org.junit.jupiter.api.Test)

Aggregations

CloudNoSqlTables (com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables)4 PlatformNoSqlTablesResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse)4 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)3 Test (org.junit.jupiter.api.Test)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 CloudNoSqlTable (com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable)1 PlatformNoSqlTableResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTableResponse)1 List (java.util.List)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1