001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Antoine Taillefer 018 */ 019 020package org.nuxeo.ecm.diff.test; 021 022import java.io.Serializable; 023 024import org.nuxeo.ecm.core.api.Blobs; 025import org.nuxeo.ecm.core.api.CoreSession; 026import org.nuxeo.ecm.core.api.DocumentModel; 027 028/** 029 * Inits the repository for a document diff test case with 2 documents that are not of the same type. 030 * 031 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a> 032 */ 033public class DocumentDiffNotSameTypeRepositoryInit extends DocumentDiffRepositoryInit { 034 035 /** 036 * Creates the left doc. 037 * 038 * @param session the session 039 * @return the document model 040 */ 041 protected DocumentModel createLeftDoc(CoreSession session) { 042 043 DocumentModel doc = session.createDocumentModel("/", "leftDoc", "SampleType"); 044 045 // ----------------------- 046 // dublincore 047 // ----------------------- 048 doc.setPropertyValue("dc:title", "My first sample, of type SampleType."); 049 doc.setPropertyValue("dc:description", "description"); 050 051 // ----------------------- 052 // file 053 // ----------------------- 054 doc.setPropertyValue("file:content", 055 (Serializable) Blobs.createBlob("Joe is bask.", "text/plain", "UTF-8", "joe.doc")); 056 057 // ----------------------- 058 // simpletypes 059 // ----------------------- 060 doc.setPropertyValue("st:string", "a string property"); 061 doc.setPropertyValue("st:boolean", true); 062 063 return session.createDocument(doc); 064 } 065 066 /** 067 * Creates the right doc. 068 * 069 * @param session the session 070 * @return the document model 071 */ 072 protected DocumentModel createRightDoc(CoreSession session) { 073 074 DocumentModel doc = session.createDocumentModel("/", "rightDoc", "OtherSampleType"); 075 076 // ----------------------- 077 // dublincore 078 // ----------------------- 079 doc.setPropertyValue("dc:title", "My second sample, of type OtherSampleType."); 080 doc.setPropertyValue("dc:description", "Description is different."); 081 082 // ----------------------- 083 // note 084 // ----------------------- 085 doc.setPropertyValue("note:note", "The note content."); 086 087 // ----------------------- 088 // simpletypes 089 // ----------------------- 090 doc.setPropertyValue("st:string", "a different string property"); 091 doc.setPropertyValue("st:boolean", false); 092 093 return session.createDocument(doc); 094 } 095}