1 17 package org.alfresco.repo.version.common.versionlabel; 18 19 import java.io.Serializable ; 20 import java.util.HashMap ; 21 22 import junit.framework.TestCase; 23 24 import org.alfresco.model.ContentModel; 25 import org.alfresco.repo.version.VersionModel; 26 import org.alfresco.repo.version.common.VersionImpl; 27 import org.alfresco.service.cmr.repository.NodeRef; 28 import org.alfresco.service.cmr.repository.StoreRef; 29 import org.alfresco.service.cmr.version.Version; 30 import org.alfresco.service.cmr.version.VersionType; 31 32 37 public class SerialVersionLabelPolicyTest extends TestCase 38 { 39 42 public void testGetVersionLabelValue() 43 { 44 SerialVersionLabelPolicy policy = new SerialVersionLabelPolicy(); 45 46 NodeRef dummyNodeRef = new NodeRef(new StoreRef("", ""), ""); 47 48 HashMap <String , Serializable > versionProp1 = new HashMap <String , Serializable >(); 49 versionProp1.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); 50 51 String initialVersion = policy.calculateVersionLabel( 52 ContentModel.TYPE_CMOBJECT, 53 null, 54 0, 55 versionProp1); 56 assertEquals("1.0", initialVersion); 57 58 HashMap <String , Serializable > versionProp2 = new HashMap <String , Serializable >(); 59 versionProp2.put(VersionModel.PROP_VERSION_LABEL, "1.0"); 60 Version version1 = new VersionImpl(versionProp2, dummyNodeRef); 61 62 String verisonLabel1 = policy.calculateVersionLabel( 63 ContentModel.TYPE_CMOBJECT, 64 version1, 65 1, 66 versionProp1); 67 assertEquals("1.1", verisonLabel1); 68 69 HashMap <String , Serializable > versionProp3 = new HashMap <String , Serializable >(); 70 versionProp3.put(VersionModel.PROP_VERSION_LABEL, "1.1"); 71 Version version2 = new VersionImpl(versionProp3, dummyNodeRef); 72 73 HashMap <String , Serializable > versionProp4 = new HashMap <String , Serializable >(); 74 versionProp4.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); 75 76 String verisonLabel2 = policy.calculateVersionLabel( 77 ContentModel.TYPE_CMOBJECT, 78 version2, 79 1, 80 versionProp4); 81 assertEquals("2.0", verisonLabel2); 82 } 83 84 } 85 | Popular Tags |