|
1 | 1 | Class { |
2 | | - #name : #APISkeletonHTTPClientErrorExtensionsTest, |
3 | | - #superclass : #TestCase, |
4 | | - #pools : [ |
5 | | - 'JRPCConstantsSharedPool' |
6 | | - ], |
7 | | - #category : #'API-Skeleton-Tests' |
| 2 | + #name : 'APISkeletonHTTPClientErrorExtensionsTest', |
| 3 | + #superclass : 'TestCase', |
| 4 | + #category : 'API-Skeleton-Tests', |
| 5 | + #package : 'API-Skeleton-Tests' |
8 | 6 | } |
9 | 7 |
|
10 | | -{ #category : #tests } |
| 8 | +{ #category : 'tests' } |
11 | 9 | APISkeletonHTTPClientErrorExtensionsTest >> testHTTPClientErrorAsJRPCResponse [ |
12 | 10 |
|
13 | | - self |
14 | | - should: [ HTTPClientError badRequest signal: 'Bad Request' ] |
15 | | - raise: HTTPClientError badRequest |
16 | | - withExceptionDo: [ :error | |
17 | | - | response | |
18 | | - |
19 | | - response := error asJRPCResponse. |
20 | | - self |
21 | | - assert: response isError; |
22 | | - assert: response error code equals: InternalError; |
23 | | - assert: response error message equals: 'Internal JSON-RPC error.'; |
24 | | - assert: (response error data at: 'errorClass') equals: 'HTTPClientError'; |
25 | | - assert: (response error data at: 'messageText') equals: 'Bad Request'; |
26 | | - assert: (response error data at: 'code') equals: '400' |
27 | | - ] |
| 11 | + self |
| 12 | + should: [ HTTPClientError badRequest signal: 'Bad Request' ] |
| 13 | + raise: HTTPClientError badRequest |
| 14 | + withExceptionDo: [ :error | |
| 15 | + | response | |
| 16 | + response := error asJRPCResponse. |
| 17 | + self |
| 18 | + assert: response isError; |
| 19 | + assert: response error code equals: JRPCConstants internalErrorCode; |
| 20 | + assert: response error message equals: 'Internal JSON-RPC error.'; |
| 21 | + assert: ( response error data at: 'errorClass' ) equals: 'HTTPClientError'; |
| 22 | + assert: ( response error data at: 'messageText' ) equals: 'Bad Request'; |
| 23 | + assert: ( response error data at: 'code' ) equals: '400' |
| 24 | + ] |
28 | 25 | ] |
29 | 26 |
|
30 | | -{ #category : #tests } |
| 27 | +{ #category : 'tests' } |
31 | 28 | APISkeletonHTTPClientErrorExtensionsTest >> testUnprocessableEntityAsJRPCResponse [ |
32 | 29 |
|
33 | | - self |
34 | | - should: [ HTTPClientError unprocessableEntity signal: 'Invalid parameter format' ] |
35 | | - raise: HTTPClientError unprocessableEntity |
36 | | - withExceptionDo: [ :error | |
37 | | - | response | |
38 | | - |
39 | | - response := error asJRPCResponse. |
40 | | - self |
41 | | - assert: response isError; |
42 | | - assert: response error code equals: InvalidParams; |
43 | | - assert: response error message equals: 'Invalid parameter format' |
44 | | - ] |
| 30 | + self |
| 31 | + should: [ HTTPClientError unprocessableEntity signal: 'Invalid parameter format' ] |
| 32 | + raise: HTTPClientError unprocessableEntity |
| 33 | + withExceptionDo: [ :error | |
| 34 | + | response | |
| 35 | + response := error asJRPCResponse. |
| 36 | + self |
| 37 | + assert: response isError; |
| 38 | + assert: response error code equals: JRPCConstants invalidParametersErrorCode; |
| 39 | + assert: response error message equals: 'Invalid parameter format' |
| 40 | + ] |
45 | 41 | ] |
0 commit comments