summaryrefslogtreecommitdiff
path: root/src/test/groovy
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-01-26 00:59:23 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-01-26 00:59:23 +0100
commit7b83533249d6cbb20e5491a3f11f0305c645ec20 (patch)
treece498921b74553e64aff254fa6202b681d9cfb4b /src/test/groovy
parent08b882f4cf284bed3f8f80f6e47d37037753a22b (diff)
downloadglocals-classifieds-7b83533249d6cbb20e5491a3f11f0305c645ec20.tar.gz
glocals-classifieds-7b83533249d6cbb20e5491a3f11f0305c645ec20.zip
cleanup
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