KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > version > common > versionlabel > SerialVersionLabelPolicyTest


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.version.common.versionlabel;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.HashMap JavaDoc;
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 /**
33  * Unit test class for SerialVersionLabelPolicy class
34  *
35  * @author Roy Wetherall
36  */

37 public class SerialVersionLabelPolicyTest extends TestCase
38 {
39     /**
40      * Test getVersionLabelValue
41      */

42     public void testGetVersionLabelValue()
43     {
44         SerialVersionLabelPolicy policy = new SerialVersionLabelPolicy();
45         
46         NodeRef dummyNodeRef = new NodeRef(new StoreRef("", ""), "");
47         
48         HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> versionProp1 = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>();
49         versionProp1.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
50         
51         String JavaDoc initialVersion = policy.calculateVersionLabel(
52                 ContentModel.TYPE_CMOBJECT,
53                 null,
54                 0,
55                 versionProp1);
56         assertEquals("1.0", initialVersion);
57         
58         HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> versionProp2 = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>();
59         versionProp2.put(VersionModel.PROP_VERSION_LABEL, "1.0");
60         Version version1 = new VersionImpl(versionProp2, dummyNodeRef);
61         
62         String JavaDoc verisonLabel1 = policy.calculateVersionLabel(
63                 ContentModel.TYPE_CMOBJECT,
64                 version1,
65                 1,
66                 versionProp1);
67         assertEquals("1.1", verisonLabel1);
68         
69         HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> versionProp3 = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>();
70         versionProp3.put(VersionModel.PROP_VERSION_LABEL, "1.1");
71         Version version2 = new VersionImpl(versionProp3, dummyNodeRef);
72         
73         HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> versionProp4 = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>();
74         versionProp4.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
75         
76         String JavaDoc verisonLabel2 = policy.calculateVersionLabel(
77                 ContentModel.TYPE_CMOBJECT,
78                 version2,
79                 1,
80                 versionProp4);
81         assertEquals("2.0", verisonLabel2);
82     }
83
84 }
85
Popular Tags