Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions models/protocol_tests/output/rest-xml.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
},
"Timestamp": {
"shape": "TimestampType"
},
"Blobs": {
"shape": "Blobs"
},
"Timestamps": {
"shape": "Timestamps"
},
"Float64s": {
"shape": "Float64s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add JSONValue to this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed JSONValue as its not yet supported by RESTXML. we can add that in another change.

}
}
},
Expand Down Expand Up @@ -76,6 +85,21 @@
},
"TimestampType": {
"type": "timestamp"
},
"BlobType": {
"type": "blob"
},
"Blobs": {
"type":"list",
"member":{"shape":"BlobType"}
},
"Timestamps":{
"type":"list",
"member":{"shape":"TimestampType"}
},
"Float64s": {
"type":"list",
"member":{"shape":"FloatType"}
}
},
"cases": [
Expand Down Expand Up @@ -136,6 +160,24 @@
},
"body": "<OperationNameResponse><Str></Str><FooNum>123</FooNum><FalseBool>false</FalseBool><TrueBool>true</TrueBool><Float>1.2</Float><Double>1.3</Double><Long>200</Long><Char>a</Char><Timestamp>2015-01-25T08:00:00Z</Timestamp></OperationNameResponse>"
}
},
{
"given": {
"output": {
"shape": "OutputShape"
},
"name": "OperationName"
},
"result": {
"Float64s": [0.1, 0.2],
"Blobs": ["value", "value2"],
"Timestamps": [1422172800, 1422172801]
},
"response": {
"status_code": 200,
"headers": {},
"body": "<OperationNameResponse><Float64s><member>0.1</member><member>0.2</member></Float64s><Blobs><member>dmFsdWU=</member><member>dmFsdWUy</member></Blobs><Timestamps><member>2015-01-25T08:00:00Z</member><member>2015-01-25T08:00:01Z</member></Timestamps></OperationNameResponse>"
}
}
]
},
Expand Down
159 changes: 148 additions & 11 deletions private/protocol/restxml/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ type OutputService1TestCaseOperation1Request struct {
}

// Send marshals and sends the OutputService1TestCaseOperation1 API request.
func (r OutputService1TestCaseOperation1Request) Send() (*OutputService1TestShapeOutputService1TestCaseOperation2Output, error) {
func (r OutputService1TestCaseOperation1Request) Send() (*OutputService1TestShapeOutputService1TestCaseOperation3Output, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}

return r.Request.Data.(*OutputService1TestShapeOutputService1TestCaseOperation2Output), nil
return r.Request.Data.(*OutputService1TestShapeOutputService1TestCaseOperation3Output), nil
}

// OutputService1TestCaseOperation1Request returns a request value for making API operation for
Expand All @@ -129,7 +129,7 @@ func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1Request(inp
input = &OutputService1TestShapeOutputService1TestCaseOperation1Input{}
}

output := &OutputService1TestShapeOutputService1TestCaseOperation2Output{}
output := &OutputService1TestShapeOutputService1TestCaseOperation3Output{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}

Expand All @@ -146,13 +146,13 @@ type OutputService1TestCaseOperation2Request struct {
}

// Send marshals and sends the OutputService1TestCaseOperation2 API request.
func (r OutputService1TestCaseOperation2Request) Send() (*OutputService1TestShapeOutputService1TestCaseOperation2Output, error) {
func (r OutputService1TestCaseOperation2Request) Send() (*OutputService1TestShapeOutputService1TestCaseOperation3Output, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}

return r.Request.Data.(*OutputService1TestShapeOutputService1TestCaseOperation2Output), nil
return r.Request.Data.(*OutputService1TestShapeOutputService1TestCaseOperation3Output), nil
}

// OutputService1TestCaseOperation2Request returns a request value for making API operation for
Expand All @@ -175,13 +175,59 @@ func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation2Request(inp
input = &OutputService1TestShapeOutputService1TestCaseOperation2Input{}
}

output := &OutputService1TestShapeOutputService1TestCaseOperation2Output{}
output := &OutputService1TestShapeOutputService1TestCaseOperation3Output{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}

return OutputService1TestCaseOperation2Request{Request: req, Input: input, Copy: c.OutputService1TestCaseOperation2Request}
}

const opOutputService1TestCaseOperation3 = "OperationName"

// OutputService1TestCaseOperation3Request is a API request type for the OutputService1TestCaseOperation3 API operation.
type OutputService1TestCaseOperation3Request struct {
*aws.Request
Input *OutputService1TestShapeOutputService1TestCaseOperation3Input
Copy func(*OutputService1TestShapeOutputService1TestCaseOperation3Input) OutputService1TestCaseOperation3Request
}

// Send marshals and sends the OutputService1TestCaseOperation3 API request.
func (r OutputService1TestCaseOperation3Request) Send() (*OutputService1TestShapeOutputService1TestCaseOperation3Output, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}

return r.Request.Data.(*OutputService1TestShapeOutputService1TestCaseOperation3Output), nil
}

// OutputService1TestCaseOperation3Request returns a request value for making API operation for
// .
//
// // Example sending a request using the OutputService1TestCaseOperation3Request method.
// req := client.OutputService1TestCaseOperation3Request(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation3Request(input *OutputService1TestShapeOutputService1TestCaseOperation3Input) OutputService1TestCaseOperation3Request {
op := &aws.Operation{
Name: opOutputService1TestCaseOperation3,

HTTPPath: "/",
}

if input == nil {
input = &OutputService1TestShapeOutputService1TestCaseOperation3Input{}
}

output := &OutputService1TestShapeOutputService1TestCaseOperation3Output{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}

return OutputService1TestCaseOperation3Request{Request: req, Input: input, Copy: c.OutputService1TestCaseOperation3Request}
}

type OutputService1TestShapeOutputService1TestCaseOperation1Input struct {
_ struct{} `type:"structure"`
}
Expand All @@ -202,11 +248,23 @@ func (s OutputService1TestShapeOutputService1TestCaseOperation2Input) MarshalFie
return nil
}

type OutputService1TestShapeOutputService1TestCaseOperation2Output struct {
type OutputService1TestShapeOutputService1TestCaseOperation3Input struct {
_ struct{} `type:"structure"`
}

// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s OutputService1TestShapeOutputService1TestCaseOperation3Input) MarshalFields(e protocol.FieldEncoder) error {

return nil
}

type OutputService1TestShapeOutputService1TestCaseOperation3Output struct {
_ struct{} `type:"structure"`

responseMetadata aws.Response

Blobs [][]byte `type:"list"`

Char *string `type:"character"`

Double *float64 `type:"double"`
Expand All @@ -215,6 +273,8 @@ type OutputService1TestShapeOutputService1TestCaseOperation2Output struct {

Float *float64 `type:"float"`

Float64s []float64 `type:"list"`

ImaHeader *string `location:"header" type:"string"`

ImaHeaderLocation *string `location:"header" locationName:"X-Foo" type:"string"`
Expand All @@ -227,16 +287,30 @@ type OutputService1TestShapeOutputService1TestCaseOperation2Output struct {

Timestamp *time.Time `type:"timestamp" timestampFormat:"iso8601"`

Timestamps []time.Time `type:"list"`

TrueBool *bool `type:"boolean"`
}

// SDKResponseMetdata return sthe response metadata for the API.
func (s OutputService1TestShapeOutputService1TestCaseOperation2Output) SDKResponseMetadata() aws.Response {
func (s OutputService1TestShapeOutputService1TestCaseOperation3Output) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}

// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s OutputService1TestShapeOutputService1TestCaseOperation2Output) MarshalFields(e protocol.FieldEncoder) error {
func (s OutputService1TestShapeOutputService1TestCaseOperation3Output) MarshalFields(e protocol.FieldEncoder) error {
if len(s.Blobs) > 0 {
v := s.Blobs

metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "Blobs", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddValue(protocol.BytesValue(v1))
}
ls0.End()

}
if s.Char != nil {
v := *s.Char

Expand All @@ -261,6 +335,18 @@ func (s OutputService1TestShapeOutputService1TestCaseOperation2Output) MarshalFi
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "Float", protocol.Float64Value(v), metadata)
}
if len(s.Float64s) > 0 {
v := s.Float64s

metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "Float64s", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddValue(protocol.Float64Value(v1))
}
ls0.End()

}
if s.Long != nil {
v := *s.Long

Expand All @@ -285,6 +371,18 @@ func (s OutputService1TestShapeOutputService1TestCaseOperation2Output) MarshalFi
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "Timestamp", protocol.TimeValue{V: v, Format: protocol.ISO8601TimeFormat}, metadata)
}
if len(s.Timestamps) > 0 {
v := s.Timestamps

metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "Timestamps", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddValue(protocol.TimeValue{V: v1})
}
ls0.End()

}
if s.TrueBool != nil {
v := *s.TrueBool

Expand Down Expand Up @@ -2325,7 +2423,7 @@ func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
t.Errorf("expect not error, got %v", req.Error)
}

out := req.Data.(*OutputService1TestShapeOutputService1TestCaseOperation2Output)
out := req.Data.(*OutputService1TestShapeOutputService1TestCaseOperation3Output)
// assert response
if out == nil {
t.Errorf("expect not to be nil")
Expand Down Expand Up @@ -2387,7 +2485,7 @@ func TestOutputService1ProtocolTestScalarMembersCase2(t *testing.T) {
t.Errorf("expect not error, got %v", req.Error)
}

out := req.Data.(*OutputService1TestShapeOutputService1TestCaseOperation2Output)
out := req.Data.(*OutputService1TestShapeOutputService1TestCaseOperation3Output)
// assert response
if out == nil {
t.Errorf("expect not to be nil")
Expand Down Expand Up @@ -2428,6 +2526,45 @@ func TestOutputService1ProtocolTestScalarMembersCase2(t *testing.T) {

}

func TestOutputService1ProtocolTestScalarMembersCase3(t *testing.T) {
cfg := unit.Config()
cfg.EndpointResolver = aws.ResolveWithEndpointURL("https://test")

svc := NewOutputService1ProtocolTest(cfg)

buf := bytes.NewReader([]byte("<OperationNameResponse><Float64s><member>0.1</member><member>0.2</member></Float64s><Blobs><member>dmFsdWU=</member><member>dmFsdWUy</member></Blobs><Timestamps><member>2015-01-25T08:00:00Z</member><member>2015-01-25T08:00:01Z</member></Timestamps></OperationNameResponse>"))
req := svc.OutputService1TestCaseOperation3Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}

// set headers

// unmarshal response
restxml.UnmarshalMeta(req.Request)
restxml.Unmarshal(req.Request)
if req.Error != nil {
t.Errorf("expect not error, got %v", req.Error)
}

out := req.Data.(*OutputService1TestShapeOutputService1TestCaseOperation3Output)
// assert response
if out == nil {
t.Errorf("expect not to be nil")
}
if e, a := "value", string(out.Blobs[0]); e != a {
t.Errorf("expect %v, got %v", e, a)
}
if e, a := "value2", string(out.Blobs[1]); e != a {
t.Errorf("expect %v, got %v", e, a)
}
if e, a := time.Unix(1.4221728e+09, 0).UTC().String(), out.Timestamps[0].String(); e != a {
t.Errorf("expect %v, got %v", e, a)
}
if e, a := time.Unix(1.422172801e+09, 0).UTC().String(), out.Timestamps[1].String(); e != a {
t.Errorf("expect %v, got %v", e, a)
}

}

func TestOutputService2ProtocolTestBlobCase1(t *testing.T) {
cfg := unit.Config()
cfg.EndpointResolver = aws.ResolveWithEndpointURL("https://test")
Expand Down
Loading