Skip to content

Commit 645b0d3

Browse files
committed
fix test class
1 parent e8aada8 commit 645b0d3

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

dotCMS/src/main/java/com/dotcms/rest/ContentResource.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,13 +1585,20 @@ private void processFile(final Contentlet contentlet,
15851585

15861586
/**
15871587
* This method has been deprecated in favor of {@link com.dotcms.rest.api.v1.workflow.WorkflowResource#fireActionDefault(HttpServletRequest, HttpServletResponse, String, String, long, SystemAction, FireActionForm)}
1588-
* @param request
1589-
* @param response
1590-
* @param params
1588+
*
1589+
* Note: The requestBody parameter is for OpenAPI documentation only and is not used in the implementation.
1590+
* The actual request body is processed from request.getInputStream() in the singlePUTandPOST method.
1591+
* The @RequestBody annotation uses required=false to maintain backward compatibility with clients
1592+
* that may not send a request body, as per OpenAPI 3.0.3 specification (default is false).
1593+
*
1594+
* @param request HTTP servlet request
1595+
* @param response HTTP servlet response
1596+
* @param params URL parameters for content update
1597+
* @param requestBody Request body parameter for OpenAPI documentation only (not used in implementation)
15911598
* @deprecated
15921599
* @see {@link com.dotcms.rest.api.v1.workflow.WorkflowResource#fireActionDefault(HttpServletRequest, HttpServletResponse, String, String, long, SystemAction, FireActionForm)}
1593-
* @return
1594-
* @throws URISyntaxException
1600+
* @return Response containing the operation result
1601+
* @throws URISyntaxException if URL parameters are malformed
15951602
*/
15961603
@Operation(
15971604
summary = "Update content with JSON/XML/form data (deprecated)",
@@ -1619,7 +1626,7 @@ public Response singlePUT(@Context HttpServletRequest request,
16191626
@Context HttpServletResponse response,
16201627
@Parameter(description = "URL parameters for content update", required = true)
16211628
@PathParam("params") String params,
1622-
@RequestBody(description = "Content data in JSON, XML, or form format", required = true,
1629+
@RequestBody(description = "Content data in JSON, XML, or form format", required = false,
16231630
content = {@Content(mediaType = "application/json"),
16241631
@Content(mediaType = "application/xml"),
16251632
@Content(mediaType = "application/x-www-form-urlencoded")})
@@ -1630,14 +1637,21 @@ public Response singlePUT(@Context HttpServletRequest request,
16301637

16311638
/**
16321639
* This method has been deprecated in favor of {@link com.dotcms.rest.api.v1.workflow.WorkflowResource#fireActionDefault(HttpServletRequest, HttpServletResponse, String, String, long, SystemAction, FireActionForm)}
1633-
* @param request
1634-
* @param response
1635-
* @param params
1640+
*
1641+
* Note: The requestBody parameter is for OpenAPI documentation only and is not used in the implementation.
1642+
* The actual request body is processed from request.getInputStream() in the singlePUTandPOST method.
1643+
* The @RequestBody annotation uses required=false to maintain backward compatibility with clients
1644+
* that may not send a request body, as per OpenAPI 3.0.3 specification (default is false).
1645+
*
1646+
* @param request HTTP servlet request
1647+
* @param response HTTP servlet response
1648+
* @param params URL parameters for content creation
1649+
* @param requestBody Request body parameter for OpenAPI documentation only (not used in implementation)
16361650
* @deprecated
16371651
* @see {@link com.dotcms.rest.api.v1.workflow.WorkflowResource#fireActionDefault(HttpServletRequest, HttpServletResponse, String, String, long, SystemAction, FireActionForm)}
16381652
*
1639-
* @return
1640-
* @throws URISyntaxException
1653+
* @return Response containing the operation result
1654+
* @throws URISyntaxException if URL parameters are malformed
16411655
*/
16421656
@Operation(
16431657
summary = "Create content with JSON/XML/form data (deprecated)",
@@ -1665,7 +1679,7 @@ public Response singlePOST(@Context HttpServletRequest request,
16651679
@Context HttpServletResponse response,
16661680
@Parameter(description = "URL parameters for content creation", required = true)
16671681
@PathParam("params") String params,
1668-
@RequestBody(description = "Content data in JSON, XML, or form format", required = true,
1682+
@RequestBody(description = "Content data in JSON, XML, or form format", required = false,
16691683
content = {@Content(mediaType = "application/json"),
16701684
@Content(mediaType = "application/xml"),
16711685
@Content(mediaType = "application/x-www-form-urlencoded")})

dotCMS/src/main/webapp/WEB-INF/openapi/openapi.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,6 @@ paths:
10001000
schema:
10011001
type: string
10021002
description: "Content data in JSON, XML, or form format"
1003-
required: true
10041003
responses:
10051004
"200":
10061005
content:
@@ -1043,7 +1042,6 @@ paths:
10431042
schema:
10441043
type: string
10451044
description: "Content data in JSON, XML, or form format"
1046-
required: true
10471045
responses:
10481046
"200":
10491047
content:

dotcms-integration/src/test/java/com/dotcms/contenttype/test/ContentResourceTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ public void Test_Save_Action_Remove_Image_Then_Verify_Fields_Were_Cleared_Issue_
11421142
final String jsonPayload1 = String.format(payLoadTemplate,contentType.inode(),"0","lol");
11431143
final HttpServletRequest request1 = createHttpRequest(jsonPayload1);
11441144
final HttpServletResponse response1 = mock(HttpServletResponse.class);
1145-
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1");
1145+
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1", jsonPayload1);
11461146
assertEquals(Status.OK.getStatusCode(), endpointResponse1.getStatus());
11471147
assertNotNull(endpointResponse1.getHeaders().get("inode"));
11481148
assertEquals(endpointResponse1.getHeaders().get("inode").size(), 1);
@@ -1163,7 +1163,7 @@ public void Test_Save_Action_Remove_Image_Then_Verify_Fields_Were_Cleared_Issue_
11631163
final String jsonPayload2 = String.format(payLoadTemplate2,contentType.inode(),inode1,"1");
11641164
final HttpServletRequest request2 = createHttpRequest(jsonPayload2);
11651165
final HttpServletResponse response2 = mock(HttpServletResponse.class);
1166-
final Response endpointResponse2 = contentResource.singlePOST(request2, response2, "/save/1");
1166+
final Response endpointResponse2 = contentResource.singlePOST(request2, response2, "/save/1", jsonPayload2);
11671167
assertEquals(Status.OK.getStatusCode(), endpointResponse2.getStatus());
11681168
assertNotNull(endpointResponse2.getHeaders().get("inode"));
11691169
assertEquals(endpointResponse2.getHeaders().get("inode").size(), 1);
@@ -1214,7 +1214,7 @@ public void Test_Save_Action_Send_Fields_SubSet_Issue_15340() throws Exception {
12141214
final String jsonPayload1 = String.format(payLoadTemplate,contentType.inode(),"0","lol");
12151215
final HttpServletRequest request1 = createHttpRequest(jsonPayload1);
12161216
final HttpServletResponse response1 = mock(HttpServletResponse.class);
1217-
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1");
1217+
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1", jsonPayload1);
12181218
assertEquals(Status.OK.getStatusCode(), endpointResponse1.getStatus());
12191219
assertNotNull(endpointResponse1.getHeaders().get("inode"));
12201220
assertEquals(endpointResponse1.getHeaders().get("inode").size(), 1);
@@ -1234,7 +1234,7 @@ public void Test_Save_Action_Send_Fields_SubSet_Issue_15340() throws Exception {
12341234
final String jsonPayload2 = String.format(payLoadTemplate2, contentType.inode(), inode1);
12351235
final HttpServletRequest request2 = createHttpRequest(jsonPayload2);
12361236
final HttpServletResponse response2 = mock(HttpServletResponse.class);
1237-
final Response endpointResponse2 = contentResource.singlePOST(request2, response2, "/save/1");
1237+
final Response endpointResponse2 = contentResource.singlePOST(request2, response2, "/save/1", jsonPayload2);
12381238
assertEquals(Status.BAD_REQUEST.getStatusCode(), endpointResponse2.getStatus());
12391239

12401240
//The Endpoint can only handle the entire set of fields.. You can not use this endpoint to only update 1 field.
@@ -1265,7 +1265,7 @@ public void Test_Save_Action_Set_Words_To_Required_NumericField_Issue_15340() th
12651265
final String jsonPayload1 = String.format(payLoadTemplate,contentType.inode(),"This isn't a numeric value","imageName");
12661266
final HttpServletRequest request1 = createHttpRequest(jsonPayload1);
12671267
final HttpServletResponse response1 = mock(HttpServletResponse.class);
1268-
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1");
1268+
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1", jsonPayload1);
12691269
assertEquals(Status.BAD_REQUEST.getStatusCode(), endpointResponse1.getStatus());
12701270
final String message = (String)((Map)endpointResponse1.getEntity()).get("message");
12711271
assertEquals("Unable to set string value 'This isn't a numeric value' as a Long for the field: numeric", message);
@@ -1296,7 +1296,7 @@ public void Test_Save_Action_Set_Null_To_Required_NumericField_Issue_15340() thr
12961296
final String jsonPayload1 = String.format(payLoadTemplate,contentType.inode(),"imageName");
12971297
final HttpServletRequest request1 = createHttpRequest(jsonPayload1);
12981298
final HttpServletResponse response1 = mock(HttpServletResponse.class);
1299-
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1");
1299+
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1", jsonPayload1);
13001300
assertEquals(Status.BAD_REQUEST.getStatusCode(), endpointResponse1.getStatus());
13011301
/// No Detailed Message is shown here. Explaining that the field is required
13021302
}finally {
@@ -1346,7 +1346,7 @@ public void testSinglePOST_InvalidParamsShouldReturn400(final Tuple2<String, Res
13461346
//Create an instance of the CT
13471347
final HttpServletRequest request1 = createHttpRequest(testCase._1);
13481348
final HttpServletResponse response1 = mock(HttpServletResponse.class);
1349-
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1");
1349+
final Response endpointResponse1 = contentResource.singlePOST(request1, response1, "/save/1", testCase._1);
13501350
assertEquals(Status.BAD_REQUEST.getStatusCode(), endpointResponse1.getStatus());
13511351
}finally {
13521352
if(null != contentType){

0 commit comments

Comments
 (0)