|
2 | 2 | private class NebulaAdapter_Test { |
3 | 3 | // Mock that implements HttpCalloutMock and uses HttpCalloutMockFactory for response generation |
4 | 4 | public class RequestCapturingMock implements HttpCalloutMock { |
5 | | - public static HttpRequest lastRequest; |
| 5 | + public HttpRequest lastRequest; |
6 | 6 | private HttpResponse mockResponse; |
7 | 7 |
|
8 | 8 | @SuppressWarnings('PMD.ExcessiveParameterList') |
@@ -59,16 +59,16 @@ private class NebulaAdapter_Test { |
59 | 59 | System.assert(res.getBody().contains('"ok":true'), 'Response body should contain ok:true'); |
60 | 60 |
|
61 | 61 | // Assert — request captured by mock |
62 | | - System.assertEquals('POST', RequestCapturingMock.lastRequest.getMethod(), 'Should use POST method'); |
63 | | - System.assert(RequestCapturingMock.lastRequest.getEndpoint().startsWith('callout:'), |
| 62 | + System.assertEquals('POST', mock.lastRequest.getMethod(), 'Should use POST method'); |
| 63 | + System.assert(mock.lastRequest.getEndpoint().startsWith('callout:'), |
64 | 64 | 'Endpoint should use callout:NamedCredential...'); |
65 | | - System.assertEquals('{"hello":"world"}', RequestCapturingMock.lastRequest.getBody(), 'Should have correct body'); |
66 | | - System.assertEquals('application/json', RequestCapturingMock.lastRequest.getHeader('Content-Type'), 'Should have correct Content-Type'); |
67 | | - System.assertEquals('abc123', RequestCapturingMock.lastRequest.getHeader('X-Custom'), 'Should have correct X-Custom header'); |
| 65 | + System.assertEquals('{"hello":"world"}', mock.lastRequest.getBody(), 'Should have correct body'); |
| 66 | + System.assertEquals('application/json', mock.lastRequest.getHeader('Content-Type'), 'Should have correct Content-Type'); |
| 67 | + System.assertEquals('abc123', mock.lastRequest.getHeader('X-Custom'), 'Should have correct X-Custom header'); |
68 | 68 |
|
69 | 69 | // Nebula adapter should safely no-op (no exception thrown) |
70 | 70 | NebulaAdapter.info('Just a test log', a); |
71 | | - NebulaAdapter.logHttpRequest('Req', RequestCapturingMock.lastRequest, new List<String>{'X-Custom'}, a); |
| 71 | + NebulaAdapter.logHttpRequest('Req', mock.lastRequest, new List<String>{'X-Custom'}, a); |
72 | 72 | NebulaAdapter.logHttpResponse('Res', res, a); |
73 | 73 | // If Nebula isn't installed, the above calls should silently do nothing. |
74 | 74 | } |
@@ -105,9 +105,9 @@ private class NebulaAdapter_Test { |
105 | 105 | System.assertEquals(200, res.getStatusCode(), 'Should get 200 OK'); |
106 | 106 |
|
107 | 107 | // Assert — request |
108 | | - System.assertEquals('DELETE', RequestCapturingMock.lastRequest.getMethod(), 'DEL should map to DELETE'); |
109 | | - System.assertEquals('application/json', RequestCapturingMock.lastRequest.getHeader('Accept'), 'Should have correct Accept header'); |
110 | | - System.assertEquals(null, RequestCapturingMock.lastRequest.getBody(), 'DELETE should not have a body by default'); |
| 108 | + System.assertEquals('DELETE', mock.lastRequest.getMethod(), 'DEL should map to DELETE'); |
| 109 | + System.assertEquals('application/json', mock.lastRequest.getHeader('Accept'), 'Should have correct Accept header'); |
| 110 | + System.assertEquals(null, mock.lastRequest.getBody(), 'DELETE should not have a body by default'); |
111 | 111 |
|
112 | 112 | // Nebula adapter no-ops again |
113 | 113 | NebulaAdapter.debug('Another test log', a); |
|
0 commit comments