@Test public void testFromJSON() throws IOException { // Json representation of an UserStory object, which equals userstory String jsonString = "{\"id\":0,\"title\":\"Story1\",\"description\":\"An userstory\",\"tasks\":[{\"id\":0,\"title\":\"Task1\",\"priority\":\"HIGH\",\"status\":\"TODO\",\"description\":\"\",\"inCharge\":\"\"},{\"id\":1,\"title\":\"Task2\",\"priority\":\"HIGH\",\"status\":\"TODO\",\"description\":\"\",\"inCharge\":\"\"},{\"id\":2,\"title\":\"Task3\",\"priority\":\"MIDDLE\",\"status\":\"TODO\",\"description\":\"\",\"inCharge\":\"\"},{\"id\":3,\"title\":\"Task4\",\"priority\":\"LOW\",\"status\":\"TODO\",\"description\":\"\",\"inCharge\":\"\"},{\"id\":4,\"title\":\"Task5\",\"priority\":\"VERY_LOW\",\"status\":\"TODO\",\"description\":\"\",\"inCharge\":\"\"}],\"priority\":\"HIGH\"}"; UserStory userstoryFromJson = UserStory.fromJson(jsonString); assertTrue(userstory.equals(userstoryFromJson)); }
@Test public void testEquals() throws IOException { List<Task> tasks = new ArrayList<>(); tasks.add(new Task(0, "Task1", Priority.HIGH)); tasks.add(new Task(1, "Task2", Priority.HIGH)); tasks.add(new Task(2, "Task3", Priority.MIDDLE)); tasks.add(new Task(3, "Task4", Priority.LOW)); UserStory userstory2 = new UserStory(0, "Story1", Priority.HIGH, tasks, "An userstory"); assertFalse(userstory.equals(userstory2)); userstory2.addTask(new Task(4, "Task5", Priority.VERY_LOW)); assertTrue(userstory.equals(userstory2)); userstory2.setTitle("Story2"); assertFalse(userstory.equals(userstory2)); assertTrue(userstory.equals(userstory)); }