summaryrefslogtreecommitdiff
path: root/src/test/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/groovy')
-rw-r--r--src/test/groovy/org/xapek/yvesf/classifieds/UnitTest.groovy47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/groovy/org/xapek/yvesf/classifieds/UnitTest.groovy b/src/test/groovy/org/xapek/yvesf/classifieds/UnitTest.groovy
new file mode 100644
index 0000000..7c477b4
--- /dev/null
+++ b/src/test/groovy/org/xapek/yvesf/classifieds/UnitTest.groovy
@@ -0,0 +1,47 @@
+package org.xapek.yvesf.classifieds
+
+import org.junit.Test
+import org.xapek.yvesf.classifieds.util.Success
+
+class UnitTest {
+ @Test
+ void testRead() {
+ final data = Main.readInputStream(UnitTest.getResourceAsStream('test.json'))
+ assert data instanceof Map
+ }
+
+ @Test
+ void testParse() {
+ final data = Main.handleData(Main.readInputStream(UnitTest.getResourceAsStream('test.json')))
+ assert data instanceof Success
+ assert data.success
+ assert !data.error
+ assert data.value instanceof Model.ClassifiedsList
+ assert data.value.totalCount > 0
+ assert data.value.size() > 0
+ }
+
+ @Test
+ void testDump() {
+ final os = new ByteArrayOutputStream()
+ final list = new Model.ClassifiedsList(totalCount: 100)
+ list.add(new Model.Classified([
+ 'available' : 'value=available',
+ 'location' : 'value=location',
+ 'city' : 'value=city',
+ 'type' : 'value=type',
+ 'price' : 'value=price',
+ 'currency' : 'value=currency',
+ 'views' : 'value=views',
+ 'title' : 'value=title',
+ 'id' : 'value=id',
+ 'mem_name' : 'value=mem_name',
+ 'description': 'value=description',
+ ]))
+ Dumper.dump(list, new PrintWriter(os))
+ final output = os.toString()
+ assert output.contains("value=city")
+ assert output.contains("value=title")
+ assert output.contains("value=description")
+ }
+} \ No newline at end of file