public static void enforceNoLazyInitialization(ContentEntity content) {
   content.setCategory(
       content.getCategory() != null ? new CategoryEntity(content.getCategory()) : null);
   content.setAssignee(
       content.getAssignee() != null ? new UserEntity(content.getAssignee()) : null);
   content.setAssigner(
       content.getAssigner() != null ? new UserEntity(content.getAssigner()) : null);
   content.setOwner(content.getOwner() != null ? new UserEntity(content.getOwner()) : null);
   content.setLanguage(
       content.getLanguage() != null ? new LanguageEntity(content.getLanguage()) : null);
   content.setDraftVersion(
       content.getDraftVersion() != null
           ? new ContentVersionEntity(content.getDraftVersion())
           : null);
   content.setMainVersion(
       content.getMainVersion() != null
           ? new ContentVersionEntity(content.getMainVersion())
           : null);
 }
  @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());
  }