-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdgeFieldTest.java
More file actions
179 lines (151 loc) · 5.23 KB
/
EdgeFieldTest.java
File metadata and controls
179 lines (151 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Test class that will test the methods in the EdgeField class
*
* @author Brendon Strowe
* @author Brett Phillips
* @author Steven Ricci
* @author Louie Trapani
*
*/
public class EdgeFieldTest {
//Declare the test object
EdgeField testObj;
public EdgeFieldTest() {
try {
setUp();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Set up the test object before running each test
*
* @throws Exception
*/
@Before
public void setUp() throws Exception {
String inputString = Integer.toString(MainTester.num) + "|" + MainTester.test;
testObj = new EdgeField(inputString);
//testObj = new EdgeField("1|testName");
//runner();
}
/**
* Method that will call different mutator and
* accessor methods
*/
/*public void runner() {
testGetNumFigure();
testGetName();
testGetTableID();
testGetFieldBound();
testGetDisallowNull();
testGetIsPrimaryKey();
testGetDefaultValue();
testGetVarcharValue();
testGetDataType();
testGetStrDataType();
testToString();
// testSetTableID();
// testSetTableBound();
// testSetFieldBound();
// testSetDisallowNull();
// testSetIsPrimaryKey();
// testSetDefaultValue();
// testSetVarcharValue();
// testSetDataType();
}*/
//ACCESSORS
@Test
public void testGetNumFigure() {
assertEquals("numFigure was initialized to 1, so it should be 1", 1, testObj.getNumFigure());
}
@Test
public void testGetName() {
assertEquals("name was initialized to testName, so it should be testName", "testName", testObj.getName());
}
@Test
public void testGetTableID() {
assertEquals("tableID was initialized to 0, so it should be 0", 0, testObj.getTableID());
}
@Test
public void testGetTableBound() {
assertEquals("tableBound was initialized to 0, so it should be 0", 0, testObj.getTableBound());
}
@Test
public void testGetFieldBound() {
assertEquals("fieldBound was initialized to 0, so it should be 0", 0, testObj.getFieldBound());
}
@Test
public void testGetDisallowNull() {
assertEquals("disallowNull was initialized to false, so it should be false", false, testObj.getDisallowNull());
}
@Test
public void testGetIsPrimaryKey() {
assertEquals("isPrimaryKey was initialized to false, so it should be false", false, testObj.getIsPrimaryKey());
}
@Test
public void testGetDefaultValue() {
assertEquals("defaultValue was initialized to '', so it should be ''", "", testObj.getDefaultValue());
}
@Test
public void testGetVarcharValue() {
assertEquals("varcharValue was initialized to VARCHAR_DEFAULT_LENGTH, so it should be VARCHAR_DEFAULT_LENGTH", EdgeField.VARCHAR_DEFAULT_LENGTH, testObj.getVarcharValue());
}
@Test
public void testGetDataType() {
assertEquals("dataType was initialized to 0, so it should be 0", 0, testObj.getDataType());
}
@Test
public void testGetStrDataType() {
assertEquals("strDataType was initialized to {\"Varchar\", \"Boolean\", \"Integer\", \"Double\"}, so it should be {\"Varchar\", \"Boolean\", \"Integer\", \"Double\"}", new String[] {"Varchar", "Boolean", "Integer", "Double"}, EdgeField.getStrDataType());
}
//TO STRING
@Test
public void testToString() {
assertEquals("toString should return a string with all of the properties", "1|testName|0|0|0|0|1|false|false|", testObj.toString());
}
//MUTATORS
@Test
public void testSetTableID() {
testObj.setTableID(1);
assertEquals("tableID was set to 1, so it should be 1", 1, testObj.getTableID());
}
@Test
public void testSetTableBound() {
testObj.setTableBound(1);
assertEquals("tableBound was set to 1, so it should be 1", 1, testObj.getTableBound());
}
@Test
public void testSetFieldBound() {
testObj.setFieldBound(1);
assertEquals("tableBound was set to 1, so it should be 1", 1, testObj.getFieldBound());
}
@Test
public void testSetIsPrimaryKey() {
testObj.setIsPrimaryKey(true);
assertEquals("isPrimaryKey was set to true, so it should be true", true, testObj.getIsPrimaryKey());
}
@Test
public void testSetDisallowNull() {
testObj.setDisallowNull(true);
assertEquals("disallowNull was set to true, so it should be true", true, testObj.getDisallowNull());
}
@Test
public void testSetDefaultValue() {
testObj.setDefaultValue("default");
assertEquals("defaultValue was set to 'default', so it should be 'default'", "default", testObj.getDefaultValue());
}
@Test
public void testSetVarcharValue() {
testObj.setVarcharValue(2);
assertEquals("varcharValue was set to 2, so it should be 2", 2, testObj.getVarcharValue());
}
@Test
public void testSetDataType() {
testObj.setDataType(1);
assertEquals("dataType was set to 1, so it should be 1", 1, testObj.getDataType());
}
}