1 package org.nuiton.version;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.google.common.collect.Lists;
26 import org.junit.Assert;
27 import org.junit.Test;
28
29
30
31
32
33
34
35 public class VersionTest {
36
37 @Test
38 public void testEquals() {
39
40
41 assertEquals(Versions.valueOf("1.1-rc"), Versions.valueOf("1.1-Rc"));
42
43
44 assertEquals(Versions.valueOf("1.1"), VersionBuilder.create(Lists.<Comparable>newArrayList(1, 1)).setJoinSeparator(' ').build());
45
46 }
47
48 protected void buildVersion(Version version,
49 String stringRepresentation,
50 int nbComponants,
51 boolean snapshot,
52 Comparable... componants) {
53
54 Assert.assertEquals("Bad string represetion", stringRepresentation, version.getVersion());
55 Assert.assertEquals("Bad number of componants", nbComponants, version.getComponantCount());
56 Assert.assertEquals("Bad snapshot value", snapshot, version.isSnapshot());
57 for (int i = 0; i < componants.length; i++) {
58 Comparable componant = componants[i];
59 Assert.assertEquals("Bad componant value at index " + i, componant, version.getComponant(i).getValue());
60 }
61
62 }
63
64 protected void assertEquals(Version v1, Version v2) {
65 Assert.assertEquals(v1 + " equals to " + v2, v1, v2);
66 }
67
68 }