-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#22993 sending the PR again since the previous is having a weird beha… (
#23272) * #22993 sending the PR again since the previous is having a weird behavior on test * #22993 seems to exists a conflict since an unit test and it test have the same name * #22993 seems to exists a conflict since an unit test and it test have the same name * #22993 fixing an unit test issue * #22993 fixing save draft * #22993 adding fixes for curl test * #22993 adding fixes for curl test * #22993 adding fixes for curl test * #22993 adding fixes for curl test
- Loading branch information
Showing
12 changed files
with
259 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...dotmarketing/portlets/workflows/actionlet/SaveContentAsDraftActionletIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.dotmarketing.portlets.workflows.actionlet; | ||
|
||
import com.dotcms.datagen.ContentletDataGen; | ||
import com.dotcms.util.IntegrationTestInitService; | ||
import com.dotmarketing.beans.Permission; | ||
import com.dotmarketing.business.APILocator; | ||
import com.dotmarketing.business.PermissionAPI; | ||
import com.dotmarketing.business.Role; | ||
import com.dotmarketing.exception.DotDataException; | ||
import com.dotmarketing.portlets.contentlet.model.Contentlet; | ||
import com.dotmarketing.portlets.contentlet.model.ContentletDependencies; | ||
import com.dotmarketing.portlets.workflows.business.BaseWorkflowIntegrationTest; | ||
import com.dotmarketing.portlets.workflows.model.WorkflowProcessor; | ||
import com.dotmarketing.util.DateUtil; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Save Draft test | ||
* @author jsanca | ||
*/ | ||
public class SaveContentAsDraftActionletIntegrationTest extends BaseWorkflowIntegrationTest { | ||
|
||
|
||
@BeforeClass | ||
public static void prepare() throws Exception { | ||
//Setting web app environment | ||
|
||
IntegrationTestInitService.getInstance().init(); | ||
|
||
setDebugMode(false); | ||
} | ||
/** | ||
* Method to test: {@link SaveContentAsDraftActionlet#executeAction(WorkflowProcessor, Map)} | ||
* Given Scenario: Adding permissions to the workflow processor | ||
* ExpectedResult: The permissions should be added | ||
*/ | ||
@Test | ||
public void save_draft_with_permissions() throws DotDataException { | ||
|
||
final Contentlet contentlet = new ContentletDataGen("webPageContent") | ||
.host(APILocator.systemHost()) | ||
.setProperty("title", "title-test") | ||
.setProperty("body", "body-test") | ||
.nextPersisted(); | ||
|
||
final Optional<Role> role = APILocator.getRoleAPI().findAllAssignableRoles(true).stream().findAny(); | ||
|
||
Assert.assertTrue(role.isPresent()); | ||
|
||
final List<Permission> permissions = new ArrayList<>(); | ||
permissions.add(new Permission(null, role.get().getId(), PermissionAPI.PERMISSION_READ)); | ||
final ContentletDependencies contentletDependencies = | ||
new ContentletDependencies.Builder() | ||
.modUser(APILocator.systemUser()) | ||
.permissions(permissions) | ||
.build(); | ||
final WorkflowProcessor processor = new WorkflowProcessor(contentlet, APILocator.systemUser()); | ||
processor.setContentletDependencies(contentletDependencies); | ||
new SaveContentAsDraftActionlet().executeAction(processor, null); | ||
DateUtil.sleep(DateUtil.SECOND_MILLIS*2); // we need to wait for the commit listener that saves the permissions | ||
|
||
final List<Permission> permissionsRecovery = APILocator.getPermissionAPI().getPermissions(contentlet); | ||
Assert.assertNotNull(permissionsRecovery); | ||
Assert.assertTrue(!permissionsRecovery.isEmpty()); | ||
Assert.assertTrue(permissionsRecovery.stream().anyMatch(permission -> contentlet.getIdentifier().equals(permission.getInode()) && | ||
role.get().getId().equals(permission.getRoleId()) && PermissionAPI.PERMISSION_READ == permission.getPermission())); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.