public void assignContent(AssignContentParams params) { final UserEntity assigner = securityService.getImpersonatedPortalUser(); final UserParser userParser = new UserParser( securityService, userStoreService, userDao, new UserStoreParser(userStoreDao)); final UserEntity assignee = userParser.parseUser(params.assignee); final ContentKey contentToAssignOn = new ContentKey(params.contentKey); AssignContentCommand command = new AssignContentCommand(); command.setContentKey(contentToAssignOn); command.setAssignerKey(assigner.getKey()); command.setAssigneeKey(assignee.getKey()); command.setAssignmentDueDate(params.assignmentDueDate); command.setAssignmentDescription(params.assignmentDescription); contentService.assignContent(command); }
@Test public void testUpdateContentDoNotChangeAssignment() { // exercise: updateContent AssignContentCommand assignContentCommand = new AssignContentCommand(); assignContentCommand.setAssignerKey(fixture.findUserByName("testuser").getKey()); assignContentCommand.setAssigneeKey(fixture.findUserByName("testuser").getKey()); assignContentCommand.setAssignmentDescription("test assignment"); assignContentCommand.setAssignmentDueDate(new DateTime(2010, 6, 6, 10, 0, 0, 0).toDate()); assignContentCommand.setContentKey(contentWithBinaryKey); contentService.assignContent(assignContentCommand); ContentDataInput newContentData = new ContentDataInput("MyContentType"); newContentData.add(new TextInput("myTitle", "changedtitle")); newContentData.add(new BinaryInput("myBinaryfile", dummyBinary, "dummyBinary")); UserEntity runningUser = fixture.findUserByName("testuser"); PortalSecurityHolder.setImpersonatedUser(runningUser.getKey()); UpdateContentParams params = new UpdateContentParams(); params.contentKey = contentWithBinaryKey.toInt(); params.contentData = newContentData; params.publishFrom = new Date(); params.publishTo = null; params.createNewVersion = false; params.status = ContentStatus.STATUS_DRAFT; int contentVersionKey = internalClient.updateContent(params); fixture.flushAndClearHibernateSession(); ContentVersionEntity actualVersion = contentVersionDao.findByKey(new ContentVersionKey(contentVersionKey)); ContentEntity persistedContent = contentDao.findByKey(actualVersion.getContent().getKey()); assertEquals(runningUser, persistedContent.getAssignee()); assertEquals(runningUser, persistedContent.getAssigner()); assertEquals("test assignment", persistedContent.getAssignmentDescription()); assertEquals( new DateTime(2010, 6, 6, 10, 0, 0, 0).toDate(), persistedContent.getAssignmentDueDate()); }