52 |
52 |
private static final String SUITE = "suite";
|
53 |
53 |
private static final String TEST = "test";
|
54 |
54 |
private static final String EMPTY = "empty";
|
|
55 |
private static final String DISPLAYNAME = "displayName";
|
|
56 |
private static final String TESTCLASS = "testClass";
|
|
57 |
private static final String CLASSNAME = "className";
|
55 |
58 |
private static final String METHOD_NAME = "methodName";
|
56 |
59 |
private static final String CHILDREN = "children";
|
57 |
60 |
private static final String EXCEPTION = "exception";
|
... | ... | |
134 |
137 |
if (m == null) {
|
135 |
138 |
m = new HashMap<String, Object>();
|
136 |
139 |
}
|
|
140 |
m.put(DISPLAYNAME, description.getDisplayName());
|
|
141 |
m.put(TESTCLASS, description.getTestClass());
|
|
142 |
m.put(CLASSNAME, description.getClassName());
|
137 |
143 |
m.put(SUITE, description.isSuite());
|
138 |
144 |
m.put(TEST, description.isTest());
|
139 |
145 |
m.put(EMPTY, description.isEmpty());
|
140 |
|
|
141 |
|
m.put(METHOD_NAME, description.getMethodName());
|
|
146 |
m.put(METHOD_NAME, description.getMethodName());
|
|
147 |
|
142 |
148 |
List<Map<String, Object>> children = new LinkedList<Map<String, Object>>();
|
143 |
149 |
for (Description d : description.getChildren()) {
|
144 |
150 |
children.add(serialize(d, null));
|
... | ... | |
152 |
158 |
// as we care only about order and children.
|
153 |
159 |
//
|
154 |
160 |
public static Description deSerializeDescription(JsonNode e, Class<?> clz) {
|
|
161 |
String displayName = e.get(DISPLAYNAME).getTextValue();
|
155 |
|
boolean suite = e.get(SUITE).getBooleanValue();
|
|
162 |
boolean suite = e.get(SUITE).getBooleanValue();
|
156 |
|
boolean empty = e.get(EMPTY).getBooleanValue();
|
|
163 |
boolean empty = e.get(EMPTY).getBooleanValue();
|
157 |
|
boolean test = e.get(TEST).getBooleanValue();
|
|
164 |
boolean test = e.get(TEST).getBooleanValue();
|
|
165 |
String methodName = e.get(METHOD_NAME).getTextValue();
|
158 |
166 |
Description d;
|
159 |
167 |
if (suite) {
|
160 |
|
d = Description.createSuiteDescription(clz);
|
161 |
|
} else
|
162 |
|
if (empty) {
|
|
168 |
d = Description.createSuiteDescription(displayName, clz.getAnnotations());
|
|
169 |
} else if (empty) {
|
163 |
170 |
d = Description.EMPTY;
|
164 |
|
} else
|
165 |
|
if (test) {
|
166 |
|
d = Description.createTestDescription(clz,e.get(METHOD_NAME).getTextValue());
|
|
171 |
} else if (test) {
|
|
172 |
d = Description.createTestDescription(clz,methodName, clz.getAnnotations());
|
167 |
173 |
} else {
|
168 |
174 |
throw new IllegalArgumentException("Don't know what kind of description "+e+" is");
|
169 |
175 |
}
|
... | ... | |
171 |
177 |
if (children!=null && children.isArray()) {
|
172 |
178 |
Iterator<JsonNode> i = children.getElements();
|
173 |
179 |
while (i.hasNext()) {
|
174 |
|
d.addChild(deSerializeDescription(i.next(),clz));
|
|
180 |
try {
|
|
181 |
JsonNode c = i.next();
|
|
182 |
String testClass = c.get(TESTCLASS).getTextValue();
|
|
183 |
String className = c.get(CLASSNAME).getTextValue();
|
|
184 |
if (testClass != null) {
|
|
185 |
Class<?> tClz = clz.getClassLoader().loadClass(testClass);
|
|
186 |
d.addChild(deSerializeDescription(c,tClz));
|
|
187 |
} else if (className != null) {
|
|
188 |
Class<?> cClz = clz.getClassLoader().loadClass(className);
|
|
189 |
d.addChild(deSerializeDescription(c,cClz));
|
|
190 |
}
|
|
191 |
} catch (Exception e1) {
|
|
192 |
throw new RuntimeException(e1);
|
|
193 |
}
|
175 |
194 |
}
|
176 |
195 |
}
|
177 |
196 |
return d;
|