From 7b83533249d6cbb20e5491a3f11f0305c645ec20 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Tue, 26 Jan 2016 00:59:23 +0100 Subject: cleanup --- .../org/xapek/yvesf/classifieds/UnitTest.groovy | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/test/groovy/org/xapek/yvesf/classifieds/UnitTest.groovy (limited to 'src/test/groovy') 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 -- cgit v1.2.1