private ContentVersionEntity createDraftVersion(String title) {
   ContentVersionEntity draftVersion =
       factory.createContentVersion("" + ContentStatus.DRAFT.getKey(), "testuser/testuserstore");
   draftVersion.setCreatedAt(new Date());
   draftVersion.setModifiedAt(new Date());
   draftVersion.setModifiedBy(fixture.findUserByName("testuser"));
   draftVersion.setTitle(title);
   return draftVersion;
 }
  private void createUpdateContentWithBinary() {
    UserEntity runningUser = fixture.findUserByName("testuser");

    // prepare: save a new content
    ContentEntity content = new ContentEntity();
    content.setPriority(0);
    content.setAvailableFrom(null);
    content.setAvailableTo(null);
    content.setCategory(fixture.findCategoryByName("MyCategory"));
    content.setLanguage(fixture.findLanguageByCode("en"));
    content.setName("testcontentwithbinary");

    ContentVersionEntity version = new ContentVersionEntity();
    version.setContent(content);
    version.setModifiedBy(runningUser);
    version.setStatus(com.enonic.cms.core.content.ContentStatus.DRAFT);
    version.setContent(content);
    CustomContentData contentData =
        new CustomContentData(
            fixture.findContentTypeByName("MyContentType").getContentTypeConfig());

    TextDataEntryConfig titleConfig =
        (TextDataEntryConfig)
            contentData.getContentTypeConfig().getForm().getInputConfig("myTitle");
    TextDataEntryConfig updateFieldConfig =
        (TextDataEntryConfig)
            contentData.getContentTypeConfig().getForm().getInputConfig("fieldToUpdate");
    BinaryDataEntryConfig binaryConfig =
        (BinaryDataEntryConfig)
            contentData.getContentTypeConfig().getForm().getInputConfig("myBinaryfile");

    contentData.add(new TextDataEntry(titleConfig, "testitle"));
    contentData.add(new TextDataEntry(updateFieldConfig, "foobar"));
    contentData.add(new BinaryDataEntry(binaryConfig, "%0"));

    version.setContentData(contentData);
    version.setTitle(contentData.getTitle());

    CreateContentCommand createContentCommand = new CreateContentCommand();
    createContentCommand.setCreator(runningUser);

    createContentCommand.populateCommandWithContentValues(content);
    createContentCommand.populateCommandWithContentVersionValues(version);

    List<BinaryDataAndBinary> binaryDatas = new ArrayList<BinaryDataAndBinary>();
    binaryDatas.add(factory.createBinaryDataAndBinary("dummyBinary", dummyBinary));

    createContentCommand.setBinaryDatas(binaryDatas);
    createContentCommand.setUseCommandsBinaryDataToAdd(true);

    contentWithBinaryKey = contentService.createContent(createContentCommand);

    fixture.flushAndClearHibernateSession();
  }
  private void createUpdateContent() {
    UserEntity runningUser = fixture.findUserByName("testuser");

    // prepare: save a new content
    ContentEntity content = new ContentEntity();
    content.setPriority(0);
    content.setAvailableFrom(new Date());
    content.setAvailableTo(null);
    content.setCategory(fixture.findCategoryByName("MyCategory"));
    content.setLanguage(fixture.findLanguageByCode("en"));
    content.setName("testcontent");

    ContentVersionEntity version = new ContentVersionEntity();
    version.setContent(content);
    version.setModifiedBy(runningUser);
    version.setStatus(com.enonic.cms.core.content.ContentStatus.APPROVED);
    version.setContent(content);
    CustomContentData contentData =
        new CustomContentData(
            fixture.findContentTypeByName("MyContentType").getContentTypeConfig());

    TextDataEntryConfig titleConfig =
        (TextDataEntryConfig)
            contentData.getContentTypeConfig().getForm().getInputConfig("myTitle");
    TextDataEntryConfig updateFieldConfig =
        (TextDataEntryConfig)
            contentData.getContentTypeConfig().getForm().getInputConfig("fieldToUpdate");
    contentData.add(new TextDataEntry(titleConfig, "testitle"));
    contentData.add(new TextDataEntry(updateFieldConfig, "foobar"));

    version.setContentData(contentData);
    version.setTitle(contentData.getTitle());

    CreateContentCommand createContentCommand = new CreateContentCommand();
    createContentCommand.setCreator(runningUser);
    createContentCommand.setAccessRightsStrategy(AccessRightsStrategy.USE_GIVEN);

    createContentCommand.populateCommandWithContentValues(content);
    createContentCommand.populateCommandWithContentVersionValues(version);

    updateContentKey = contentService.createContent(createContentCommand);

    fixture.flushAndClearHibernateSession();
  }