Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith(AndroidJUnit4.class)
- public class JsonParserTest {
- private JsonParser jsonParser = new JsonParser();
- //many values
- @Test
- public void parseJsonNotificationsData_1() throws Exception {
- 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}";
- List<Notification> notifications = new ArrayList<>();
- notifications.add(new Notification("W tatrach panuja zle warunki pogodowe", "2019.01.09", "Informacje pogodowe", "aktywny", 1, 1));
- notifications.add(new Notification("W karpatach panuja zle warunki pogodowe", "2019.01.01", "Informacje pogodowe", "aktywny", 1, 2));
- notifications.add(new Notification("Zmiana w regulaminie", "2019.01.09", "Zmiana w regulaminie", "aktywny", 1, 3));
- assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
- }
- //one
- @Test
- public void parseJsonNotificationsData_2() throws Exception {
- 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}";
- List<Notification> notifications = new ArrayList<>();
- notifications.add(new Notification("W tatrach panuja zle warunki pogodowe", "2019.01.09", "Informacje pogodowe", "aktywny", 1, 1));
- assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
- }
- //zero
- @Test
- public void parseJsonNotificationsData_3() throws Exception {
- String data = "{\"notifications\":[]}";
- List<Notification> notifications = new ArrayList<>();
- assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
- }
- //Incorrect data
- @Test
- public void parseJsonNotificationsData_4() throws Exception {
- String data = "incorrect data,incorrect data";
- List<Notification> notifications = new ArrayList<>();
- assertEquals(true, notifications.equals(jsonParser.parseJsonNotificationsData(data)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement