Skip to content

Commit

Permalink
fix(vpc): add data annotation to vpc (#4534) (#4537)
Browse files Browse the repository at this point in the history
Annotate VPC as a data class to address VPC attributes always being null.

(cherry picked from commit 9a1fa51)

Co-authored-by: David Martin <david.martin@smartthings.com>
  • Loading branch information
mergify[bot] and dmart committed Sep 22, 2023
1 parent e7e0c1b commit 2022134
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Expand Up @@ -190,6 +190,7 @@ static SecurityGroup findById(MortService mortService, String securityGroupId) {
}
}

@Data
class VPC {
String id;
String name;
Expand Down
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 2022134

Please sign in to comment.