Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. @RunWith(AndroidJUnit4.class)
  2. public class JsonParserTest {
  3.  
  4. private JsonParser jsonParser = new JsonParser();
  5. //many values
  6. @Test
  7. public void parseJsonNotificationsData_1() throws Exception {
  8.  
  9. String data = "{\"notifications\":[{\"tresc\":\"W tatrach panuja zle warunki pogodowe\",\"data\":\"2019-01-09\",\"kategoria\":\"Informacje pogodowe\",\"status\":\"aktywny\",\"nrKsiazeczki\":\"1\",\"powiadomienieId\":\"1\"},{\"tresc\":\"W karpatach panuja zle warunki pogodowe\",\"data\":\"2019-01-01\",\"kategoria\":\"Informacje pogodowe\",\"status\":\"aktywny\",\"nrKsiazeczki\":\"1\",\"powiadomienieId\":\"2\"},{\"tresc\":\"Zmiana w regulaminie\",\"data\":\"2019-01-09\",\"kategoria\":\"Zmiana w regulaminie\",\"status\":\"aktywny\",\"nrKsiazeczki\":\"1\",\"powiadomienieId\":\"3\"}],\"seccess\":1}";
  10.  
  11. List<Notification> notifications = new ArrayList<>();
  12. notifications.add(new Notification("W tatrach panuja zle warunki pogodowe", "2019.01.09", "Informacje pogodowe", "aktywny", 1, 1));
  13. notifications.add(new Notification("W karpatach panuja zle warunki pogodowe", "2019.01.01", "Informacje pogodowe", "aktywny", 1, 2));
  14. notifications.add(new Notification("Zmiana w regulaminie", "2019.01.09", "Zmiana w regulaminie", "aktywny", 1, 3));
  15.  
  16. assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
  17. }
  18.  
  19. //one
  20. @Test
  21. public void parseJsonNotificationsData_2() throws Exception {
  22.  
  23. String data = "{\"notifications\":[{\"tresc\":\"W tatrach panuja zle warunki pogodowe\",\"data\":\"2019-01-09\",\"kategoria\":\"Informacje pogodowe\",\"status\":\"aktywny\",\"nrKsiazeczki\":\"1\",\"powiadomienieId\":\"1\"}],\"seccess\":1}";
  24.  
  25. List<Notification> notifications = new ArrayList<>();
  26. notifications.add(new Notification("W tatrach panuja zle warunki pogodowe", "2019.01.09", "Informacje pogodowe", "aktywny", 1, 1));
  27.  
  28. assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
  29. }
  30.  
  31. //zero
  32. @Test
  33. public void parseJsonNotificationsData_3() throws Exception {
  34. String data = "{\"notifications\":[]}";
  35. List<Notification> notifications = new ArrayList<>();
  36. assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
  37. }
  38.  
  39. //Incorrect data
  40. @Test
  41. public void parseJsonNotificationsData_4() throws Exception {
  42. String data = "incorrect data,incorrect data";
  43. List<Notification> notifications = new ArrayList<>();
  44. assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement