Skip to content

Commit

Permalink
Use core PopulateProperties in PopulatePropertiesIT
Browse files Browse the repository at this point in the history
  • Loading branch information
patchwork01 committed Nov 1, 2024
1 parent c9398ef commit ab7fe27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import software.amazon.awssdk.regions.providers.AwsRegionProvider;

import sleeper.core.deploy.DeployInstanceConfiguration;
import sleeper.core.deploy.PopulateInstanceProperties;
import sleeper.core.deploy.SleeperScheduleRule;
import sleeper.core.properties.instance.InstanceProperties;
import sleeper.core.properties.validation.LambdaDeployType;
Expand Down Expand Up @@ -67,6 +68,12 @@ private PopulateInstancePropertiesAws(Builder builder) {
tagsProperties = Optional.ofNullable(builder.tagsProperties).orElseGet(properties::getTagsProperties);
}

public static PopulateInstanceProperties.Builder builder(AWSSecurityTokenService sts, AwsRegionProvider regionProvider) {
return PopulateInstanceProperties.builder()
.accountSupplier(sts.getCallerIdentity(new GetCallerIdentityRequest())::getAccount)
.regionIdSupplier(() -> regionProvider.getRegion().id());
}

public static Builder builder() {
return new Builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import software.amazon.awssdk.regions.Region;

import sleeper.core.CommonTestConstants;
import sleeper.core.deploy.PopulateInstanceProperties;
import sleeper.core.properties.instance.InstanceProperties;

import java.util.Map;
Expand Down Expand Up @@ -63,8 +64,7 @@ public class PopulatePropertiesIT {
void shouldPopulateInstancePropertiesCorrectly() {
// Given/When
InstanceProperties properties = populateInstancePropertiesBuilder()
.sts(sts).regionProvider(() -> Region.of(localStackContainer.getRegion()))
.build().populate();
.build().populate(new InstanceProperties());

// Then
InstanceProperties expected = new InstanceProperties();
Expand All @@ -83,8 +83,8 @@ void shouldPopulateInstancePropertiesCorrectly() {
assertThat(properties).isEqualTo(expected);
}

private PopulateInstancePropertiesAws.Builder populateInstancePropertiesBuilder() {
return PopulateInstancePropertiesAws.builder()
private PopulateInstanceProperties.Builder populateInstancePropertiesBuilder() {
return PopulateInstancePropertiesAws.builder(sts, () -> Region.of(localStackContainer.getRegion()))
.instanceId("test-instance").vpcId("some-vpc").subnetIds("some-subnet");
}
}

This file was deleted.

0 comments on commit ab7fe27

Please sign in to comment.