use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable 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())));
});
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable in project cloudbreak by hortonworks.
the class AwsPlatformResources method noSqlTables.
@Override
public CloudNoSqlTables noSqlTables(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters) {
List<CloudNoSqlTable> noSqlTables = new ArrayList<>();
AmazonDynamoDBClient dynamoDbClient = getAmazonDynamoDBClient(cloudCredential, region);
ListTablesRequest listTablesRequest = new ListTablesRequest();
ListTablesResult listTablesResult = null;
boolean first = true;
while (first || !isNullOrEmpty(listTablesResult.getLastEvaluatedTableName())) {
first = false;
listTablesRequest.setExclusiveStartTableName(listTablesResult == null ? null : listTablesResult.getLastEvaluatedTableName());
listTablesResult = dynamoDbClient.listTables(listTablesRequest);
List<String> partialTableNames = listTablesResult.getTableNames();
List<CloudNoSqlTable> partialResult = partialTableNames.stream().map(CloudNoSqlTable::new).collect(Collectors.toList());
noSqlTables.addAll(partialResult);
}
return new CloudNoSqlTables(noSqlTables);
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable 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);
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTable 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")));
}
Aggregations