package org.xapek.yvesf.classifieds import groovy.transform.CompileStatic import org.junit.Test import org.xapek.yvesf.classifieds.util.Success @CompileStatic 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.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', 'mem_id' : '0', 'description': 'value=description', 'photo1' : 'asd', 'photo2' : 0, 'photo3' : 0, 'photo4' : 0, 'date' : 'Apr 01, 99', 'rooms' : '1', ])) 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") } }