Skip to content

Commit

Permalink
Test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
ytsejam78 committed Sep 27, 2024
1 parent 68bab55 commit c7a09c8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,30 @@ PetOrdersRESTfulControllerTest >> testOverlyComplexOrderCreation [
assert: order date equals: '2018-10-24T18:05:46.418Z'
]

{ #category : 'tests - orders' }
PetOrdersRESTfulControllerTest >> testOverlyComplexOrderCreationWithoutSpecifyingStatusUsesDefaultValue [

| response order |

response := resourceController
createOrderBasedOn: ( self requestToPOSTAsOverlyComplexOrder:
'{"date":"2018-10-24T18:05:46.418Z","pet":{"alternativeName":"Fido","itsType":"Dog"}}' )
within: self newHttpRequestContext.

self
assert: response isSuccess;
assert: response status equals: 201;
assertUrl: response location equals: 'https://petstore.example.com/orders/1';
assert: response hasEntity;
assert: orderRepository count equals: 1.
order := orderRepository findAll first.
self
assert: order pet name equals: 'Fido';
assert: order pet type equals: 'Dog';
assert: order pet status equals: 'UNKNOWN';
assert: order date equals: '2018-10-24T18:05:46.418Z'
]

{ #category : 'tests' }
PetOrdersRESTfulControllerTest >> testRoutes [

Expand Down
3 changes: 2 additions & 1 deletion source/Stargate-Examples/PetOrdersRESTfulController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ PetOrdersRESTfulController >> configureOverlyComplexOrderDecodingOn: reader [
mapProperty: #theStatus as: #Status.
mapping
mapCreationSending: #named:ofType:withStatus:
withArguments: { #alternativeName. #itsType. #theStatus }
withArguments: { #alternativeName. #itsType. #theStatus };
argumentNamed: #theStatus defaultingTo: 'UNKNOWN'
].
reader for: PetOrder createInstanceUsing: [ :mapping |
mapping
Expand Down

0 comments on commit c7a09c8

Please sign in to comment.