Skip to content

Commit

Permalink
Merge branch 'master' into 28337-binary-field-information-of-assets-n…
Browse files Browse the repository at this point in the history
…eeds-be-refreshed-after-any-change
  • Loading branch information
zJaaal authored Aug 12, 2024
2 parents cb606fa + 1e6c9c3 commit 55755ef
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public final Response saveNew(@Context final HttpServletRequest request,
final DotPortlet newPortlet = DotPortlet.builder()
.portletId(portletId)
.portletClass(contentPortlet.getPortletClass())

.putAllInitParams(contentPortlet.getInitParams()) // add view-action from base content portlet
.putInitParam("name", formData.portletName)
.putInitParam("baseTypes", formData.baseTypes)
.putInitParam("contentTypes", formData.contentTypes)
Expand Down Expand Up @@ -166,6 +166,7 @@ public final Response updatePortlet(@Context final HttpServletRequest request, f
final DotPortlet updatedPortlet = DotPortlet.builder()
.portletId(portletId)
.portletClass(contentPortlet.getPortletClass())
.putAllInitParams(contentPortlet.getInitParams()) // add view-action from base content portlet
.putInitParam("name", formData.portletName)
.putInitParam("baseTypes", formData.baseTypes)
.putInitParam("contentTypes", formData.contentTypes)
Expand Down
130 changes: 123 additions & 7 deletions dotcms-postman/src/main/resources/postman/PortletResource.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"info": {
"_postman_id": "643ee95c-85a5-40d7-9479-0f04474a0d8f",
"_postman_id": "b501b27f-67ea-42a8-850b-7e9b9ac56e2c",
"name": "PortletResource",
"description": "This folder contains a comprehensive set of API requests related to the `PortletResource` API endpoints. These requests cover various operations such as creating, retrieving and updating Portlets. The folder is organized to help developers and testers efficiently validate and interact with the exposed resource endpoints.\n\nThis test suite verifies that Portlets can be created, retrieved, updated, and deleted correctly. It verifies that such Portlets can be added to the main menu layout, and checks access permission for Users. Also, it correctly validates non-existing Portlets and Menu Layouts.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "5403727"
"_exporter_id": "20130511"
},
"item": [
{
Expand Down Expand Up @@ -67,14 +67,44 @@
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code should be 200\", function () {",
"pm.test(\"Response status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response is valid JSON\", function () {",
" pm.response.to.be.json;",
"});",
"",
"pm.test(\"Check the structure of the response\", function () {",
" var jsonData = pm.response.json();",
" console.log(jsonData);",
"",
" pm.expect(jsonData.entity.response.portletId).to.eql(\"c_myCustom\");",
" pm.expect(jsonData.entity.response.initParams.dataViewMode).to.eql(\"card\");",
" pm.expect(jsonData).to.have.property(\"entity\");",
" pm.expect(jsonData.entity).to.have.property(\"response\");",
" pm.expect(jsonData.entity.response).to.be.an(\"object\");",
"});",
"",
"pm.test(\"Check response 'portletId' value\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.entity.response).to.have.property(\"portletId\", \"c_myCustom\");",
"});",
"",
"pm.test(\"Check response 'dataViewMode' value\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"dataViewMode\", \"card\");",
"});",
"",
"pm.test(\"Additional checks for 'initParams'\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"baseTypes\", \"CONTENT\");",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"name\", \"myCustom\");",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"portletSource\", \"db\");",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"view-action\", \"/ext/contentlet/view_contentlets\");",
"});",
"",
"pm.test(\"Verify 'companyId' is 'dotcms.org'\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.entity.response.primaryKey).to.have.property(\"companyId\", \"dotcms.org\");",
"});"
],
"type": "text/javascript",
Expand Down Expand Up @@ -483,18 +513,56 @@
"listen": "test",
"script": {
"exec": [
"// Test to check if the status code is 200",
"pm.test(\"Status code should be 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Portlet exists\", function () {",
"// Test to verify that the portlet exists and validate its properties",
"pm.test(\"Portlet exists and has correct properties\", function () {",
"",
" var jsonData = pm.response.json();",
" let portletId = pm.collectionVariables.get(\"portletId\");",
"",
" // Check if the portletId matches the expected value",
" pm.expect(jsonData.entity.response.portletId).to.eql(portletId);",
"",
" // Check if the dataViewMode is set to 'card'",
" pm.expect(jsonData.entity.response.initParams.dataViewMode).to.eql(\"card\");",
"",
" // Check if the 'view-action' property is correct",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"view-action\", \"/ext/contentlet/view_contentlets\");",
"",
" // Check if the contentTypes is set to 'webPageContent'",
" pm.expect(jsonData.entity.response.initParams.contentTypes).to.eql(\"webPageContent\");",
"});",
"",
"// Additional checks for key fields",
"pm.test(\"Verify additional portlet properties\", function () {",
" var jsonData = pm.response.json();",
"",
" // Check if the companyId is 'dotcms.org'",
" pm.expect(jsonData.entity.response.companyId).to.eql(\"dotcms.org\");",
"",
" // Check if the portletSource is 'db'",
" pm.expect(jsonData.entity.response.initParams.portletSource).to.eql(\"db\");",
"",
" // Check if the portletClass is 'com.liferay.portlet.StrutsPortlet'",
" pm.expect(jsonData.entity.response.portletClass).to.eql(\"com.liferay.portlet.StrutsPortlet\");",
"});",
"",
"// Verify the primaryKey object",
"pm.test(\"Verify primaryKey properties\", function () {",
" var jsonData = pm.response.json();",
"",
" // Check if primaryKey contains the expected companyId",
" pm.expect(jsonData.entity.response.primaryKey.companyId).to.eql(\"dotcms.org\");",
"",
" // Check if primaryKey contains the expected groupId",
" pm.expect(jsonData.entity.response.primaryKey.groupId).to.eql(\"\");",
"",
" // Check if primaryKey contains the expected portletId",
" pm.expect(jsonData.entity.response.primaryKey.portletId).to.eql(pm.collectionVariables.get(\"portletId\"));",
"});"
],
"type": "text/javascript",
Expand Down Expand Up @@ -574,18 +642,56 @@
"listen": "test",
"script": {
"exec": [
"// Test to check if the status code is 200",
"pm.test(\"Status code should be 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Portlet exists\", function () {",
"// Test to verify that the portlet exists and validate its properties",
"pm.test(\"Portlet exists and has correct properties\", function () {",
"",
" var jsonData = pm.response.json();",
" let portletId = pm.collectionVariables.get(\"portletId\");",
"",
" // Check if the portletId matches the expected value",
" pm.expect(jsonData.entity.response.portletId).to.eql(portletId);",
"",
" // Check if the dataViewMode is set to 'list'",
" pm.expect(jsonData.entity.response.initParams.dataViewMode).to.eql(\"list\");",
"",
" // Check if the contentTypes is an empty string",
" pm.expect(jsonData.entity.response.initParams.contentTypes).to.eql(\"\");",
"});",
"",
"// Additional checks for key fields",
"pm.test(\"Verify additional portlet properties\", function () {",
" var jsonData = pm.response.json();",
"",
" // Check if the companyId is 'dotcms.org'",
" pm.expect(jsonData.entity.response.companyId).to.eql(\"dotcms.org\");",
"",
" // Check if the portletSource is 'db'",
" pm.expect(jsonData.entity.response.initParams.portletSource).to.eql(\"db\");",
"",
" // Check if the 'view-action' property is correct",
" pm.expect(jsonData.entity.response.initParams).to.have.property(\"view-action\", \"/ext/contentlet/view_contentlets\");",
"",
" // Check if the portletClass is 'com.liferay.portlet.StrutsPortlet'",
" pm.expect(jsonData.entity.response.portletClass).to.eql(\"com.liferay.portlet.StrutsPortlet\");",
"});",
"",
"// Verify the primaryKey object",
"pm.test(\"Verify primaryKey properties\", function () {",
" var jsonData = pm.response.json();",
"",
" // Check if primaryKey contains the expected companyId",
" pm.expect(jsonData.entity.response.primaryKey.companyId).to.eql(\"dotcms.org\");",
"",
" // Check if primaryKey contains the expected groupId",
" pm.expect(jsonData.entity.response.primaryKey.groupId).to.eql(\"\");",
"",
" // Check if primaryKey contains the expected portletId",
" pm.expect(jsonData.entity.response.primaryKey.portletId).to.eql(pm.collectionVariables.get(\"portletId\"));",
"});"
],
"type": "text/javascript",
Expand Down Expand Up @@ -1022,5 +1128,15 @@
]
}
}
],
"variable": [
{
"key": "timeMilis",
"value": ""
},
{
"key": "portletId",
"value": ""
}
]
}

0 comments on commit 55755ef

Please sign in to comment.