Skip to content

Commit

Permalink
fix(vpc): add data annotation to vpc (#4534)
Browse files Browse the repository at this point in the history
Annotate VPC as a data class to address VPC attributes always being null.
  • Loading branch information
dmart authored Sep 22, 2023
1 parent 8523343 commit 9a1fa51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ static SecurityGroup findById(MortService mortService, String securityGroupId) {
}
}

@Data
class VPC {
String id;
String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import retrofit.converter.JacksonConverter
import retrofit.mime.TypedInput
import spock.lang.Specification
import spock.lang.Unroll
import com.netflix.spinnaker.orca.jackson.OrcaObjectMapper

import static com.netflix.spinnaker.orca.clouddriver.MortService.SecurityGroup.SecurityGroupIngress
import static com.netflix.spinnaker.orca.clouddriver.MortService.SecurityGroup.applyMappings
Expand Down Expand Up @@ -254,6 +255,28 @@ class MortServiceSpec extends Specification {
)
}

def "should correctly map VPC properties from JSON response"() {
given:
def objectMapper = OrcaObjectMapper.newInstance()
def vpcResponse = """
{
"account": "test",
"id": "vpc-12345",
"name": "vpc1",
"region": "us-west-1"
}
"""

when:
def vpc = objectMapper.readValue(vpcResponse, MortService.VPC.class)

then:
vpc.account == "test"
vpc.id == "vpc-12345"
vpc.region == "us-west-1"
vpc.name == "vpc1"
}

static class MockTypedInput implements TypedInput {
private final Converter converter
private final Object body
Expand Down

0 comments on commit 9a1fa51

Please sign in to comment.