| 6914 |
dpurdie |
1 |
package com.erggroup.buildtool.utf;
|
|
|
2 |
|
|
|
3 |
import static org.junit.Assert.assertFalse;
|
|
|
4 |
import static org.junit.Assert.assertTrue;
|
|
|
5 |
|
|
|
6 |
import org.junit.Test;
|
|
|
7 |
|
|
|
8 |
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
|
|
|
9 |
import com.erggroup.buildtool.ripple.ReportingData;
|
|
|
10 |
|
|
|
11 |
public class ReportingDataTest
|
|
|
12 |
{
|
|
|
13 |
|
|
|
14 |
@Test
|
|
|
15 |
public void testToBoolNull()
|
|
|
16 |
{
|
|
|
17 |
assertFalse("Test for NULL", ReportingData.toBool(null) );
|
|
|
18 |
}
|
|
|
19 |
@Test
|
|
|
20 |
public void testToBoolNullText()
|
|
|
21 |
{
|
|
|
22 |
assertFalse("Test for NULL String", ReportingData.toBool("null") );
|
|
|
23 |
}
|
|
|
24 |
@Test
|
|
|
25 |
public void testToBool0()
|
|
|
26 |
{ assertFalse("Test for 0", ReportingData.toBool("0") );
|
|
|
27 |
}
|
|
|
28 |
@Test
|
|
|
29 |
public void testToBoolno()
|
|
|
30 |
{ assertFalse("Test for no", ReportingData.toBool("no") );
|
|
|
31 |
}
|
|
|
32 |
@Test
|
|
|
33 |
public void testToBoolNo()
|
|
|
34 |
{ assertFalse("Test for No", ReportingData.toBool("No") );
|
|
|
35 |
}
|
|
|
36 |
@Test
|
|
|
37 |
public void testToBoolFalse()
|
|
|
38 |
{ assertFalse("Test for False", ReportingData.toBool("False") );
|
|
|
39 |
}
|
|
|
40 |
@Test
|
|
|
41 |
public void testToBoolfalse()
|
|
|
42 |
{ assertFalse("Test for false", ReportingData.toBool("false") );
|
|
|
43 |
}
|
|
|
44 |
@Test
|
|
|
45 |
public void testToBool1()
|
|
|
46 |
{ assertTrue("Test for 1", ReportingData.toBool("1") );
|
|
|
47 |
}
|
|
|
48 |
@Test
|
|
|
49 |
public void testToBoolyes()
|
|
|
50 |
{ assertTrue("Test for yes", ReportingData.toBool("yes") );
|
|
|
51 |
}
|
|
|
52 |
@Test
|
|
|
53 |
public void testToBoolYes()
|
|
|
54 |
{ assertTrue("Test for Yes", ReportingData.toBool("Yes") );
|
|
|
55 |
}
|
|
|
56 |
@Test
|
|
|
57 |
public void testToBooltrue()
|
|
|
58 |
{ assertTrue("Test for true", ReportingData.toBool("true") );
|
|
|
59 |
}
|
|
|
60 |
@Test
|
|
|
61 |
public void testToBoolTrue()
|
|
|
62 |
{ assertTrue("Test for True", ReportingData.toBool("True") );
|
|
|
63 |
}
|
|
|
64 |
@Test
|
|
|
65 |
public void testToBoolNumber()
|
|
|
66 |
{ assertTrue("Test for number", ReportingData.toBool("123456") );
|
|
|
67 |
}
|
|
|
68 |
@Test
|
|
|
69 |
public void testToBoolNegNumber()
|
|
|
70 |
{ assertTrue("Test for number", ReportingData.toBool("-123456") );
|
|
|
71 |
}
|
|
|
72 |
@Test
|
|
|
73 |
public void testToBoolNan1()
|
|
|
74 |
{ assertFalse("Test for non-number", ReportingData.toBool("-123456a") );
|
|
|
75 |
}
|
|
|
76 |
@Test
|
|
|
77 |
public void testToBoolNan2()
|
|
|
78 |
{ assertFalse("Test for non-number", ReportingData.toBool("12-123456a") );
|
|
|
79 |
}
|
|
|
80 |
@Test
|
|
|
81 |
public void testToBoolText()
|
|
|
82 |
{ assertFalse("Test for non-number", ReportingData.toBool("Data") );
|
|
|
83 |
}
|
|
|
84 |
@Test
|
|
|
85 |
public void testToBoolEmptyString()
|
|
|
86 |
{ assertFalse("Test for Empty String", ReportingData.toBool("") );
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
//
|
|
|
90 |
// Testing String to Integer conversion
|
|
|
91 |
@Test
|
|
|
92 |
public void testToStringEmptyString()
|
|
|
93 |
{ assertTrue("Test for Empty String", ReportingData.toInt("",1) == 1 );
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
@Test
|
|
|
97 |
public void testToStringNan()
|
|
|
98 |
{ assertTrue("Test for Non Numeric", ReportingData.toInt("12-12",1) == 1 );
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
@Test
|
|
|
102 |
public void testToStringNumber()
|
|
|
103 |
{ assertTrue("Test for Numeric", ReportingData.toInt("1212",1) == 1212 );
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
@Test
|
|
|
107 |
public void testToStringNumberWithSpace()
|
|
|
108 |
{ assertTrue("Test for Number with spaces", ReportingData.toInt(" 1212 ",1) == 1212 );
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
@Test
|
|
|
112 |
public void toToBuildReason()
|
|
|
113 |
{
|
|
|
114 |
BuildReason br = BuildReason.NewVersion;
|
|
|
115 |
assertTrue("Test for BuildReason New", ReportingData.toBuildReason(br + "") == BuildReason.NewVersion );
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
@Test
|
|
|
119 |
public void toToBuildReasonNull()
|
|
|
120 |
{
|
|
|
121 |
assertTrue("Test for BuildReason Null", ReportingData.toBuildReason(null) == null );
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
@Test
|
|
|
125 |
public void toToBuildReasonInvalid()
|
|
|
126 |
{
|
|
|
127 |
assertTrue("Test for Invalid BuildReason", ReportingData.toBuildReason("K") == null );
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
}
|
|
|
131 |
|