Skip to content

Commit 5264375

Browse files
authored
Cleanup (#7)
* remove debugs * add cleanup
1 parent 663a8ac commit 5264375

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/classes/RESTControllerTest.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public with sharing class RESTControllerTest {
4646
@IsTest
4747
public static void testPost() {
4848
RestRequest req = new RestRequest();
49+
req.requestBody = Blob.valueOf(
50+
'{"data":{"firstName":"max", "lastName":"testcase"}}'
51+
);
4952
req.requestURI = '/services/apexrest/tests/12345';
5053
req.httpMethod = 'POST';
5154
req.addHeader('Content-Type', 'application/json');
@@ -59,7 +62,7 @@ public with sharing class RESTControllerTest {
5962
TestResponseEnvelope envelope = getResponseEnvelope(response);
6063
System.assert(envelope.errors.isEmpty(), 'there should be no errors');
6164
System.assert(envelope.messages.isEmpty(), 'there should be no messages');
62-
System.assertEquals('post records', envelope.data);
65+
System.assertEquals('max testcase', envelope.data);
6366
}
6467

6568
@IsTest

src/classes/TestRESTController.cls

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ global class TestRESTController extends RESTController {
3737
}
3838

3939
protected override void postRecords() {
40-
envelope.setData('post records');
40+
RequestEnvelope requestEnvelope = new RequestEnvelope(request.requestBody.toString());
41+
42+
String responseString = requestEnvelope.data.firstName + ' ' + requestEnvelope.data.lastName;
43+
envelope.setData(responseString);
4144

4245
response.addHeader('Content-Type', 'application/json');
4346
response.responseBody = envelope.asBlob();
@@ -49,8 +52,6 @@ global class TestRESTController extends RESTController {
4952
response.responseBody = envelope.asBlob();
5053
}
5154
protected override void getRecords() {
52-
System.debug(request);
53-
System.debug(request.params.get('Type'));
5455
String requestType = request.params.get('Type');
5556
if (requestType == 'error') {
5657
envelope.addError('error');

0 commit comments

Comments
 (0)