-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating ResourcePolicy create and update handlers to support stack tags #87
base: main
Are you sure you want to change the base?
Conversation
static Set<Tag> convertResourcePolicyTagToOrganizationTag(final Set<software.amazon.organizations.resourcepolicy.Tag> tags) { | ||
final Set<Tag> tagsToReturn = new HashSet<>(); | ||
if (tags == null) return tagsToReturn; | ||
for (software.amazon.organizations.resourcepolicy.Tag inputTag : tags) { | ||
Tag tag = Tag.builder() | ||
.key(inputTag.getKey()) | ||
.value(inputTag.getValue()) | ||
.build(); | ||
tagsToReturn.add(tag); | ||
} | ||
return tagsToReturn; | ||
} | ||
|
||
static Set<String> getTagKeysToRemove( | ||
Set<Tag> oldTags, Set<Tag> newTags) { | ||
final Set<String> oldTagKeys = getTagKeySet(oldTags); | ||
final Set<String> newTagKeys = getTagKeySet(newTags); | ||
return Sets.difference(oldTagKeys, newTagKeys); | ||
} | ||
|
||
static Set<Tag> getTagsToAddOrUpdate( | ||
Set<Tag> oldTags, Set<Tag> newTags) { | ||
return Sets.difference(newTags, oldTags); | ||
} | ||
|
||
static Set<String> getTagKeySet(Set<Tag> oldTags) { | ||
return oldTags.stream().map(Tag::key).collect(Collectors.toSet()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these to TagsHelper
@@ -86,10 +87,11 @@ public void handleRequest_NoTags_SimpleSuccess() { | |||
|
|||
@Test | |||
public void handleRequest_WithTags_SimpleSuccess() { | |||
final ResourceModel model = generateInitialResourceModel(false, TEST_RESOURCEPOLICY_CONTENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and few others had incorrectly set the hasTags
to false, have updated them to true
assertThat(TagTestResourceHelper.tagsEqual(response.getResourceModel().getTags(), TagTestResourceHelper.updatedTags)); | ||
assertThat(TagTestResourceHelper.correctTagsInTagAndUntagRequests(tagsToAddOrUpdate, tagKeysToRemove)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were missing isTrue()
and thus were never getting tested
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.