Search in sources :

Example 6 with CloudNoSqlTables

use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.

the class CloudParameterServiceTest method getNoSqlTables.

@Test
void getNoSqlTables() {
    CloudNoSqlTables expected = new CloudNoSqlTables(List.of(new CloudNoSqlTable("a"), new CloudNoSqlTable("b")));
    GetPlatformNoSqlTablesResult response = new GetPlatformNoSqlTablesResult(1L, expected);
    doAnswer(invocation -> {
        Event<GetPlatformNoSqlTablesRequest> ev = invocation.getArgument(1);
        ev.getData().getResult().onNext(response);
        return null;
    }).when(eventBus).notify(anyString(), any(Event.class));
    CloudNoSqlTables noSqlTables = underTest.getNoSqlTables(new ExtendedCloudCredential(new CloudCredential("id", "name", "acc"), "aws", "desc", "crn", "account", new ArrayList<>()), "region", "aws", null);
    assertEquals(expected, noSqlTables);
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformNoSqlTablesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesResult) GetPlatformNoSqlTablesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesRequest) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) ArrayList(java.util.ArrayList) Event(reactor.bus.Event) CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) CloudNoSqlTable(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable) Test(org.junit.jupiter.api.Test)

Example 7 with CloudNoSqlTables

use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables 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)

Example 8 with CloudNoSqlTables

use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method noSqlTables.

@Test
public void noSqlTables() {
    when(awsClient.createDynamoDbClient(any(AwsCredentialView.class), anyString())).thenReturn(amazonDynamoDB);
    when(amazonDynamoDB.listTables(any(ListTablesRequest.class))).thenReturn(new ListTablesResult().withTableNames("a", "b").withLastEvaluatedTableName("b"), new ListTablesResult().withTableNames("c", "d"));
    CloudNoSqlTables cloudNoSqlTables = underTest.noSqlTables(cloudCredential, region("region"), null);
    assertThat(cloudNoSqlTables.getCloudNoSqlTables()).hasSameElementsAs(List.of(new CloudNoSqlTable("a"), new CloudNoSqlTable("b"), new CloudNoSqlTable("c"), new CloudNoSqlTable("d")));
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) ListTablesResult(com.amazonaws.services.dynamodbv2.model.ListTablesResult) ListTablesRequest(com.amazonaws.services.dynamodbv2.model.ListTablesRequest) CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) CloudNoSqlTable(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable) Test(org.junit.jupiter.api.Test)

Aggregations

CloudNoSqlTables (com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables)8 CloudNoSqlTable (com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable)4 PlatformNoSqlTablesResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNoSqlTablesResponse)4 Test (org.junit.jupiter.api.Test)4 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)3 ListTablesRequest (com.amazonaws.services.dynamodbv2.model.ListTablesRequest)2 ListTablesResult (com.amazonaws.services.dynamodbv2.model.ListTablesResult)2 GetPlatformNoSqlTablesRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesRequest)2 GetPlatformNoSqlTablesResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesResult)2 ArrayList (java.util.ArrayList)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 AmazonDynamoDBClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonDynamoDBClient)1 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)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