com.amazonaws.services.rds.model.ListTagsForResourceResult Java Examples
The following examples show how to use
com.amazonaws.services.rds.model.ListTagsForResourceResult.
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 | 5 votes |
/** * Fetch RDS cluster info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchRDSClusterInfoTest() throws Exception { mockStatic(AmazonRDSClientBuilder.class); AmazonRDS rdsClient = PowerMockito.mock(AmazonRDS.class); AmazonRDSClientBuilder amazonRDSClientBuilder = PowerMockito.mock(AmazonRDSClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonRDSClientBuilder.standard()).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.withCredentials(anyObject())).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.withRegion(anyString())).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.build()).thenReturn(rdsClient); DescribeDBClustersResult describeDBClustersResult = new DescribeDBClustersResult(); List<DBCluster> rdsList = new ArrayList<>(); DBCluster dBCluster = new DBCluster(); dBCluster.setDBClusterArn("dBClusterArn");; rdsList.add(dBCluster); describeDBClustersResult.setDBClusters(rdsList); when(rdsClient.describeDBClusters(anyObject())).thenReturn(describeDBClustersResult); ListTagsForResourceResult listTagsForResourceResult = new ListTagsForResourceResult(); listTagsForResourceResult.setTagList(new ArrayList<>()); when(rdsClient.listTagsForResource(anyObject())).thenReturn(listTagsForResourceResult); assertThat(inventoryUtil.fetchRDSClusterInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #2
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch RDS instance info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchRDSInstanceInfoTest() throws Exception { mockStatic(AmazonRDSClientBuilder.class); AmazonRDS rdsClient = PowerMockito.mock(AmazonRDS.class); AmazonRDSClientBuilder amazonRDSClientBuilder = PowerMockito.mock(AmazonRDSClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonRDSClientBuilder.standard()).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.withCredentials(anyObject())).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.withRegion(anyString())).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.build()).thenReturn(rdsClient); DescribeDBInstancesResult describeDBInstancesResult = new DescribeDBInstancesResult(); List<DBInstance> rdsList = new ArrayList<>(); DBInstance dBInstance = new DBInstance(); dBInstance.setDBInstanceArn("dBInstanceArn"); rdsList.add(dBInstance); describeDBInstancesResult.setDBInstances(rdsList); when(rdsClient.describeDBInstances(anyObject())).thenReturn(describeDBInstancesResult); ListTagsForResourceResult listTagsForResourceResult = new ListTagsForResourceResult(); listTagsForResourceResult.setTagList(new ArrayList<>()); when(rdsClient.listTagsForResource(anyObject())).thenReturn(listTagsForResourceResult); assertThat(inventoryUtil.fetchRDSInstanceInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #3
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch cloud front info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchCloudFrontInfoTest() throws Exception { mockStatic(AmazonCloudFrontClientBuilder.class); AmazonCloudFront amazonCloudFront = PowerMockito.mock(AmazonCloudFront.class); AmazonCloudFrontClientBuilder amazonCloudFrontClientBuilder = PowerMockito.mock(AmazonCloudFrontClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonCloudFrontClientBuilder.standard()).thenReturn(amazonCloudFrontClientBuilder); when(amazonCloudFrontClientBuilder.withCredentials(anyObject())).thenReturn(amazonCloudFrontClientBuilder); when(amazonCloudFrontClientBuilder.withRegion(anyString())).thenReturn(amazonCloudFrontClientBuilder); when(amazonCloudFrontClientBuilder.build()).thenReturn(amazonCloudFront); ListDistributionsResult listDistributionsResult = new ListDistributionsResult(); List<DistributionSummary> distributionSummaries = new ArrayList<>(); DistributionSummary distributionSummary = new DistributionSummary(); distributionSummary.setARN("aRN"); distributionSummaries.add(distributionSummary); DistributionList distributionList = new DistributionList(); distributionList.setItems(distributionSummaries); listDistributionsResult.setDistributionList(distributionList); when(amazonCloudFront.listDistributions(anyObject())).thenReturn(listDistributionsResult); com.amazonaws.services.cloudfront.model.ListTagsForResourceResult listTagsForResourceResult = new com.amazonaws.services.cloudfront.model.ListTagsForResourceResult(); Tags tags = new Tags(); tags.setItems(new ArrayList<>()); listTagsForResourceResult.setTags(tags ); when(amazonCloudFront.listTagsForResource(anyObject())).thenReturn(listTagsForResourceResult ); assertThat(inventoryUtil.fetchCloudFrontInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "account","accountName").size(), is(1)); }
Example #4
Source File: AmazonRdsDataSourceUserTagsFactoryBean.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Override protected Map<String, String> createInstance() throws Exception { LinkedHashMap<String, String> userTags = new LinkedHashMap<>(); ListTagsForResourceResult tagsForResource = this.amazonRds .listTagsForResource(new ListTagsForResourceRequest() .withResourceName(getDbInstanceResourceName())); for (Tag tag : tagsForResource.getTagList()) { userTags.put(tag.getKey(), tag.getValue()); } return userTags; }
Example #5
Source File: AmazonRdsDataSourceUserTagsFactoryBeanTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void getObject_instanceWithTagsConfiguredWithCustomResourceResolverAndCustomRegion_mapWithTagsReturned() throws Exception { // Arrange AmazonRDS amazonRds = mock(AmazonRDS.class); ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class); AmazonIdentityManagement amazonIdentityManagement = mock( AmazonIdentityManagement.class); AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean( amazonRds, "test", amazonIdentityManagement); factoryBean.setResourceIdResolver(resourceIdResolver); factoryBean.setRegion(Region.getRegion(Regions.EU_WEST_1)); when(resourceIdResolver.resolveToPhysicalResourceId("test")) .thenReturn("stack-test"); when(amazonIdentityManagement.getUser()).thenReturn( new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date()))); when(amazonRds.listTagsForResource(new ListTagsForResourceRequest() .withResourceName("arn:aws:rds:eu-west-1:1234567890:db:stack-test"))) .thenReturn(new ListTagsForResourceResult().withTagList( new Tag().withKey("key1").withValue("value1"), new Tag().withKey("key2").withValue("value2"))); // Act factoryBean.afterPropertiesSet(); Map<String, String> userTagMap = factoryBean.getObject(); // Assert assertThat(userTagMap.get("key1")).isEqualTo("value1"); assertThat(userTagMap.get("key2")).isEqualTo("value2"); }
Example #6
Source File: AmazonRdsDataSourceUserTagsFactoryBeanTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void getObject_instanceWithOutTags_emptyMapReturned() throws Exception { // Arrange AmazonRDS amazonRds = mock(AmazonRDS.class); ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class); AmazonIdentityManagement amazonIdentityManagement = mock( AmazonIdentityManagement.class); AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean( amazonRds, "test", amazonIdentityManagement); factoryBean.setResourceIdResolver(resourceIdResolver); factoryBean.setResourceIdResolver(resourceIdResolver); factoryBean.setRegion(Region.getRegion(Regions.EU_WEST_1)); when(resourceIdResolver.resolveToPhysicalResourceId("test")) .thenReturn("stack-test"); when(amazonIdentityManagement.getUser()).thenReturn( new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date()))); when(amazonRds.listTagsForResource(new ListTagsForResourceRequest() .withResourceName("arn:aws:rds:eu-west-1:1234567890:db:stack-test"))) .thenReturn(new ListTagsForResourceResult()); // Act factoryBean.afterPropertiesSet(); Map<String, String> userTagMap = factoryBean.getObject(); // Assert assertThat(userTagMap.isEmpty()).isTrue(); }
Example #7
Source File: AmazonRdsDataSourceUserTagsFactoryBeanTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void getObject_instanceWithTagsAndNoResourceIdResolverAndDefaultRegion_mapWithTagsReturned() throws Exception { // Arrange AmazonRDS amazonRds = mock(AmazonRDS.class); AmazonIdentityManagement amazonIdentityManagement = mock( AmazonIdentityManagement.class); AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean( amazonRds, "test", amazonIdentityManagement); when(amazonIdentityManagement.getUser()).thenReturn( new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date()))); when(amazonRds.listTagsForResource(new ListTagsForResourceRequest() .withResourceName("arn:aws:rds:us-west-2:1234567890:db:test"))) .thenReturn(new ListTagsForResourceResult().withTagList( new Tag().withKey("key1").withValue("value1"), new Tag().withKey("key2").withValue("value2"))); // Act factoryBean.afterPropertiesSet(); Map<String, String> userTagMap = factoryBean.getObject(); // Assert assertThat(userTagMap.get("key1")).isEqualTo("value1"); assertThat(userTagMap.get("key2")).isEqualTo("value2"); }