EC2Context { public Map<String, String> getAutoScalingGroupTags(String autoScalingGroupName) { Preconditions.checkArgument(autoScalingGroupName != null && !autoScalingGroupName.isEmpty()); AutoScalingGroup group = this.getAutoScalingGroup(autoScalingGroupName); Map<String, String> tags = new HashMap<>(); for (TagDescription tagDescription : group.getTags()) { tags.put(tagDescription.getKey(), tagDescription.getValue()); } return tags; }  String getInstanceId(); Map<String, String> getInstanceTags(); String getAutoScalingGroup(); List<String> getAutoScalingMembers(String autoScalingGroupName); List<String> getPrivateAutoScalingMemberIPs(String autoScalingGroupName); AutoScalingGroup getAutoScalingGroup(String autoScalingGroupName); Map<String, String> getAutoScalingGroupTags(String autoScalingGroupName); Instance getInstance();  }
@Test public void getServerGroupTags() { try { this.context.getAutoScalingGroupTags(null); Assert.fail("Null check failed"); } catch (Exception e) { Assert.assertEquals(IllegalArgumentException.class, e.getClass()); } try { this.context.getAutoScalingGroupTags(""); Assert.fail("Empty check failed"); } catch (Exception e) { Assert.assertEquals(IllegalArgumentException.class, e.getClass()); } String tagName = "foo"; String tagValue = "bar"; AutoScalingGroup grp = new AutoScalingGroup(); grp.setAutoScalingGroupName("awsGroup"); grp.withTags(new TagDescription().withKey(tagName).withValue(tagValue)); DescribeAutoScalingGroupsResult res = new DescribeAutoScalingGroupsResult(); res.setAutoScalingGroups(Collections.singleton(grp)); Mockito.when(this.asgMock.describeAutoScalingGroups(Mockito.any(DescribeAutoScalingGroupsRequest.class))).thenReturn(res); Map<String, String> tags = this.context.getAutoScalingGroupTags("awsGroup"); Assert.assertEquals(1, tags.size()); Assert.assertTrue(tags.containsKey(tagName)); Assert.assertEquals(tagValue, tags.get(tagName)); }