com.amazonaws.services.elasticsearch.model.DomainInfo Java Examples

The following examples show how to use com.amazonaws.services.elasticsearch.model.DomainInfo. 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: ESInventoryUtilTest.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
 * Fetch ES info test.
 *
 * @throws Exception the exception
 */
@SuppressWarnings("static-access")
@Test
public void fetchESInfoTest() throws Exception {
    
    mockStatic(AWSElasticsearchClientBuilder.class);
    AWSElasticsearch awsEsClient = PowerMockito.mock(AWSElasticsearch.class);
    AWSElasticsearchClientBuilder awsElasticsearchClientBuilder = PowerMockito.mock(AWSElasticsearchClientBuilder.class);
    AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class);
    PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider);
    when(awsElasticsearchClientBuilder.standard()).thenReturn(awsElasticsearchClientBuilder);
    when(awsElasticsearchClientBuilder.withCredentials(anyObject())).thenReturn(awsElasticsearchClientBuilder);
    when(awsElasticsearchClientBuilder.withRegion(anyString())).thenReturn(awsElasticsearchClientBuilder);
    when(awsElasticsearchClientBuilder.build()).thenReturn(awsEsClient);
    
    ListDomainNamesResult listDomainResult = new ListDomainNamesResult();
    List<DomainInfo> domainNames = new ArrayList<>();
    DomainInfo domainInfo = new DomainInfo();
    domainInfo.setDomainName("domain");
    domainNames.add(domainInfo);
    listDomainResult.setDomainNames(domainNames);
    when(awsEsClient.listDomainNames(anyObject())).thenReturn(listDomainResult);
    
    DescribeElasticsearchDomainsResult  describeResult = new DescribeElasticsearchDomainsResult() ;
    List<ElasticsearchDomainStatus> domainStatusList = new ArrayList<>();
    ElasticsearchDomainStatus domainStatus = new ElasticsearchDomainStatus();
    domainStatus.setARN("arn");
    domainStatusList.add(domainStatus);
    describeResult.setDomainStatusList(domainStatusList);
    when(awsEsClient.describeElasticsearchDomains(anyObject())).thenReturn(describeResult);
    ListTagsResult listTagsResult = new ListTagsResult();
    listTagsResult.setTagList(new ArrayList<Tag>());
    when(awsEsClient.listTags(anyObject())).thenReturn(listTagsResult);
    
    assertThat(esInventoryUtil.fetchESInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), 
            "skipRegions", "account","accountName").size(), is(1));
}