001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Antoine Taillefer 016 */ 017 018package org.nuxeo.ecm.diff.test; 019 020import java.io.Serializable; 021 022import org.nuxeo.ecm.core.api.Blobs; 023import org.nuxeo.ecm.core.api.CoreSession; 024import org.nuxeo.ecm.core.api.DocumentModel; 025 026/** 027 * Inits the repository for a document diff test case with 2 documents that are not of the same type. 028 * 029 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a> 030 */ 031public class DocumentDiffNotSameTypeRepositoryInit extends DocumentDiffRepositoryInit { 032 033 /** 034 * Creates the left doc. 035 * 036 * @param session the session 037 * @return the document model 038 */ 039 protected DocumentModel createLeftDoc(CoreSession session) { 040 041 DocumentModel doc = session.createDocumentModel("/", "leftDoc", "SampleType"); 042 043 // ----------------------- 044 // dublincore 045 // ----------------------- 046 doc.setPropertyValue("dc:title", "My first sample, of type SampleType."); 047 doc.setPropertyValue("dc:description", "description"); 048 049 // ----------------------- 050 // file 051 // ----------------------- 052 doc.setPropertyValue("file:filename", "joe.doc"); 053 doc.setPropertyValue("file:content", (Serializable) Blobs.createBlob("Joe is bask.")); 054 055 // ----------------------- 056 // simpletypes 057 // ----------------------- 058 doc.setPropertyValue("st:string", "a string property"); 059 doc.setPropertyValue("st:boolean", true); 060 061 return session.createDocument(doc); 062 } 063 064 /** 065 * Creates the right doc. 066 * 067 * @param session the session 068 * @return the document model 069 */ 070 protected DocumentModel createRightDoc(CoreSession session) { 071 072 DocumentModel doc = session.createDocumentModel("/", "rightDoc", "OtherSampleType"); 073 074 // ----------------------- 075 // dublincore 076 // ----------------------- 077 doc.setPropertyValue("dc:title", "My second sample, of type OtherSampleType."); 078 doc.setPropertyValue("dc:description", "Description is different."); 079 080 // ----------------------- 081 // note 082 // ----------------------- 083 doc.setPropertyValue("note:note", "The note content."); 084 085 // ----------------------- 086 // simpletypes 087 // ----------------------- 088 doc.setPropertyValue("st:string", "a different string property"); 089 doc.setPropertyValue("st:boolean", false); 090 091 return session.createDocument(doc); 092 } 093}