| Tor Norbye | 1aa2e09 | 2014-08-20 17:01:23 -0700 | [diff] [blame] | 1 | import com.google.gson.FieldNamingPolicy; |
| 2 | import com.google.gson.Gson; |
| 3 | import com.google.gson.GsonBuilder; |
| 4 | import org.junit.Before; |
| 5 | import org.junit.Test; |
| 6 | import com.jetbrains.python.edu.StudyUtils; |
| 7 | import com.jetbrains.python.edu.course.Course; |
| 8 | |
| 9 | import java.io.FileInputStream; |
| 10 | import java.io.FileNotFoundException; |
| 11 | import java.io.InputStreamReader; |
| 12 | import java.io.Reader; |
| 13 | |
| 14 | import static org.junit.Assert.assertEquals; |
| 15 | |
| 16 | /** |
| 17 | * author: liana |
| 18 | * data: 7/4/14. |
| 19 | */ |
| 20 | public class JsonParserTest { |
| 21 | private Course myCourse = null; |
| 22 | @Before |
| 23 | public void setUp() throws FileNotFoundException { |
| 24 | Reader reader = new InputStreamReader(new FileInputStream("EDIDE/testData/course.json")); |
| 25 | Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); |
| 26 | myCourse = gson.fromJson(reader, Course.class); |
| 27 | } |
| 28 | |
| 29 | @Test |
| 30 | public void testCourseLevel() { |
| 31 | assertEquals(myCourse.getName(), "Python для начинающих"); |
| 32 | assertEquals(StudyUtils.getFirst(myCourse.getLessons().get(1).getTaskList().get(0).getUserTests()).getInput(), "sum-input.txt"); |
| 33 | assertEquals(myCourse.getLessons().size(), 2); |
| 34 | assertEquals(myCourse.getLessons().get(0).getTaskList().size(), 2); |
| 35 | assertEquals(myCourse.getLessons().get(1).getTaskList().size(), 1); |
| 36 | } |
| 37 | } |