com.amazonaws.services.redshift.AmazonRedshiftClientBuilder Java Examples

The following examples show how to use com.amazonaws.services.redshift.AmazonRedshiftClientBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InventoryUtilTest.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch redshift info test.
 *
 * @throws Exception the exception
 */
@SuppressWarnings("static-access")
@Test
public void fetchRedshiftInfoTest() throws Exception {
    
    mockStatic(AmazonRedshiftClientBuilder.class);
    AmazonRedshift redshiftClient = PowerMockito.mock(AmazonRedshift.class);
    AmazonRedshiftClientBuilder amazonRedshiftClientBuilder = PowerMockito.mock(AmazonRedshiftClientBuilder.class);
    AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class);
    PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider);
    when(amazonRedshiftClientBuilder.standard()).thenReturn(amazonRedshiftClientBuilder);
    when(amazonRedshiftClientBuilder.withCredentials(anyObject())).thenReturn(amazonRedshiftClientBuilder);
    when(amazonRedshiftClientBuilder.withRegion(anyString())).thenReturn(amazonRedshiftClientBuilder);
    when(amazonRedshiftClientBuilder.build()).thenReturn(redshiftClient);
    
    DescribeClustersResult describeClustersResult = new DescribeClustersResult();
    List<com.amazonaws.services.redshift.model.Cluster> redshiftList = new ArrayList<>();
    redshiftList.add(new com.amazonaws.services.redshift.model.Cluster());
    describeClustersResult.setClusters(redshiftList);
    when(redshiftClient.describeClusters(anyObject())).thenReturn(describeClustersResult);
    assertThat(inventoryUtil.fetchRedshiftInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), 
            "skipRegions", "account","accountName").size(), is(1));
}
 
Example #2
Source File: CreateAndModifyCluster.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {

        // Default client using the {@link com.amazonaws.auth.DefaultAWSCredentialsProviderChain}
        client = AmazonRedshiftClientBuilder.defaultClient();

        try {
            createCluster();
            waitForClusterReady();
            describeClusters();
            modifyCluster();
            describeClusters();

        } catch (Exception e) {
            System.err.println("Operation failed: " + e.getMessage());
        }
    }
 
Example #3
Source File: AmazonDockerClientsHolder.java    From spring-localstack with Apache License 2.0 5 votes vote down vote up
@Override
public AmazonRedshift amazonRedshift() {
    return decorateWithConfigsAndBuild(
        AmazonRedshiftClientBuilder.standard(),
        LocalstackDocker::getEndpointRedshift
    );
}