forked from github/wulkanowy-mirror
API facade (#27)
*Create API facade * Refactor API tests * Implementation of the facade API and add tests for synchronization
This commit is contained in:

committed by
Rafał Borcz

parent
c876d114e3
commit
1f5a03fba7
@ -7,8 +7,6 @@ public class FixtureHelper {
|
||||
|
||||
public static String getAsString(InputStream inputStream) {
|
||||
Scanner s = new Scanner(inputStream).useDelimiter("\\A");
|
||||
String input = s.hasNext() ? s.next() : "";
|
||||
|
||||
return input;
|
||||
return s.hasNext() ? s.next() : "";
|
||||
}
|
||||
}
|
||||
|
@ -10,23 +10,23 @@ import org.mockito.Mockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.login.LoginErrorException;
|
||||
import io.github.wulkanowy.api.login.NotLoggedInErrorException;
|
||||
|
||||
public class StudentAndParentTest {
|
||||
|
||||
private String fixtureFileName = "OcenyWszystkie-semester.html";
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
String input = FixtureHelper.getAsString(
|
||||
getClass().getResourceAsStream("OcenyWszystkie-semester.html"));
|
||||
Document gradesPageDocument = Jsoup.parse(input);
|
||||
|
||||
snp = Mockito.mock(StudentAndParent.class);
|
||||
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(gradesPageDocument);
|
||||
Mockito.when(snp.getCalculatedID(Mockito.anyString())).thenCallRealMethod();
|
||||
Mockito.when(snp.getExtractedIdFromUrl(Mockito.anyString())).thenCallRealMethod();
|
||||
Mockito.when(snp.getBaseUrl()).thenReturn("https://uonetplus-opiekun.vulcan.net.pl/{symbol}/{ID}/");
|
||||
Mockito.when(snp.getSymbol()).thenReturn("symbol");
|
||||
Mockito.when(snp.getId()).thenReturn("123456");
|
||||
Mockito.when(snp.getSemesters()).thenCallRealMethod();
|
||||
@ -36,20 +36,63 @@ public class StudentAndParentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCalculatedIDStandardTest() throws Exception {
|
||||
Assert.assertEquals("123456", snp.getCalculatedID("https://uonetplus-opiekun"
|
||||
public void snpTest() throws Exception {
|
||||
StudentAndParent snp = new StudentAndParent(new Cookies(), "demo123", "id123");
|
||||
Assert.assertEquals("demo123", snp.getSymbol());
|
||||
Assert.assertEquals("id123", snp.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSnpPageUrlWithIdTest() throws Exception {
|
||||
Mockito.when(snp.getSnpPageUrl()).thenCallRealMethod();
|
||||
Assert.assertEquals("https://uonetplus-opiekun.vulcan.net.pl/symbol/123456/",
|
||||
snp.getSnpPageUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSnpPageUrlWithoutIdTest() throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream("Start.html"));
|
||||
Document startPageDocument = Jsoup.parse(input);
|
||||
|
||||
Mockito.when(snp.getPageByUrl(Mockito.anyString())).thenReturn(startPageDocument);
|
||||
Mockito.when(snp.getStartPageUrl()).thenReturn("http://wulkan.io");
|
||||
Mockito.when(snp.getId()).thenCallRealMethod();
|
||||
|
||||
Mockito.when(snp.getSnpPageUrl()).thenCallRealMethod();
|
||||
Assert.assertEquals("https://uonetplus-opiekun.vulcan.net.pl/symbol/534213/Start/Index/",
|
||||
snp.getSnpPageUrl());
|
||||
}
|
||||
|
||||
@Test(expected = NotLoggedInErrorException.class)
|
||||
public void getSnpPageUrlWithWrongPage() throws Exception {
|
||||
Document wrongPageDocument = Jsoup.parse(
|
||||
FixtureHelper.getAsString(getClass().getResourceAsStream("OcenyWszystkie-semester.html"))
|
||||
);
|
||||
|
||||
Mockito.when(snp.getPageByUrl(Mockito.anyString())).thenReturn(wrongPageDocument);
|
||||
Mockito.when(snp.getStartPageUrl()).thenReturn("http://wulkan.io");
|
||||
Mockito.when(snp.getId()).thenCallRealMethod();
|
||||
|
||||
Mockito.when(snp.getSnpPageUrl()).thenCallRealMethod();
|
||||
|
||||
snp.getSnpPageUrl();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExtractedIDStandardTest() throws Exception {
|
||||
Assert.assertEquals("123456", snp.getExtractedIdFromUrl("https://uonetplus-opiekun"
|
||||
+ ".vulcan.net.pl/powiat/123456/Start/Index/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCalculatedIDDemoTest() throws Exception {
|
||||
Assert.assertEquals("demo12345", snp.getCalculatedID("https://uonetplus-opiekundemo"
|
||||
public void getExtractedIDDemoTest() throws Exception {
|
||||
Assert.assertEquals("demo12345", snp.getExtractedIdFromUrl("https://uonetplus-opiekundemo"
|
||||
+ ".vulcan.net.pl/demoupowiat/demo12345/Start/Index/"));
|
||||
}
|
||||
|
||||
@Test(expected = LoginErrorException.class)
|
||||
public void getCalculatedIDNotLoggedTest() throws Exception {
|
||||
Assert.assertEquals("123", snp.getCalculatedID("https://uonetplus"
|
||||
@Test(expected = NotLoggedInErrorException.class)
|
||||
public void getExtractedIDNotLoggedTest() throws Exception {
|
||||
Assert.assertEquals("123", snp.getExtractedIdFromUrl("https://uonetplus"
|
||||
+ ".vulcan.net.pl/powiat/"));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public abstract class StudentAndParentTestCase {
|
||||
|
||||
protected StudentAndParent getSnp(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document tablePageDocument = Jsoup.parse(input);
|
||||
|
||||
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString()))
|
||||
.thenReturn(tablePageDocument);
|
||||
Mockito.when(snp.getSemesters(Mockito.any(Document.class))).thenCallRealMethod();
|
||||
Mockito.when(snp.getCurrentSemester(Mockito.<Semester>anyList()))
|
||||
.thenCallRealMethod();
|
||||
Mockito.when(snp.getRowDataChildValue(Mockito.any(Element.class),
|
||||
Mockito.anyInt())).thenCallRealMethod();
|
||||
|
||||
return snp;
|
||||
}
|
||||
}
|
124
app/src/test/java/io/github/wulkanowy/api/VulcanTest.java
Normal file
124
app/src/test/java/io/github/wulkanowy/api/VulcanTest.java
Normal file
@ -0,0 +1,124 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import io.github.wulkanowy.api.attendance.AttendanceStatistics;
|
||||
import io.github.wulkanowy.api.attendance.AttendanceTable;
|
||||
import io.github.wulkanowy.api.grades.GradesList;
|
||||
import io.github.wulkanowy.api.grades.SubjectsList;
|
||||
import io.github.wulkanowy.api.login.NotLoggedInErrorException;
|
||||
import io.github.wulkanowy.api.notes.AchievementsList;
|
||||
import io.github.wulkanowy.api.notes.NotesList;
|
||||
import io.github.wulkanowy.api.school.SchoolInfo;
|
||||
import io.github.wulkanowy.api.school.TeachersInfo;
|
||||
import io.github.wulkanowy.api.timetable.Timetable;
|
||||
import io.github.wulkanowy.api.user.BasicInformation;
|
||||
import io.github.wulkanowy.api.user.FamilyInformation;
|
||||
|
||||
public class VulcanTest extends Vulcan {
|
||||
|
||||
private Vulcan vulcan;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
|
||||
vulcan = Mockito.mock(Vulcan.class);
|
||||
Mockito.when(vulcan.getStudentAndParent())
|
||||
.thenReturn(snp);
|
||||
}
|
||||
|
||||
@Test(expected = NotLoggedInErrorException.class)
|
||||
public void getStudentAndParentTest() throws Exception {
|
||||
Mockito.when(vulcan.getStudentAndParent()).thenCallRealMethod();
|
||||
vulcan.getStudentAndParent();
|
||||
}
|
||||
|
||||
@Test(expected = NotLoggedInErrorException.class)
|
||||
public void getAttendanceExceptionText() throws Exception {
|
||||
Mockito.when(vulcan.getAttendanceTable()).thenCallRealMethod();
|
||||
Mockito.when(vulcan.getStudentAndParent()).thenThrow(NotLoggedInErrorException.class);
|
||||
|
||||
vulcan.getAttendanceTable();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAttendanceTest() throws Exception {
|
||||
Mockito.when(vulcan.getAttendanceTable()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getAttendanceTable(),
|
||||
CoreMatchers.instanceOf(AttendanceTable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAttendanceStatisticTest() throws Exception {
|
||||
Mockito.when(vulcan.getAttendanceStatistics()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getAttendanceStatistics(),
|
||||
CoreMatchers.instanceOf(AttendanceStatistics.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getGradesListTest() throws Exception {
|
||||
Mockito.when(vulcan.getGradesList()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getGradesList(),
|
||||
CoreMatchers.instanceOf(GradesList.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSubjectListTest() throws Exception {
|
||||
Mockito.when(vulcan.getSubjectsList()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getSubjectsList(),
|
||||
CoreMatchers.instanceOf(SubjectsList.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAchievementsListTest() throws Exception {
|
||||
Mockito.when(vulcan.getAchievementsList()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getAchievementsList(),
|
||||
CoreMatchers.instanceOf(AchievementsList.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNotesListTest() throws Exception {
|
||||
Mockito.when(vulcan.getNotesList()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getNotesList(),
|
||||
CoreMatchers.instanceOf(NotesList.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSchoolInfoTest() throws Exception {
|
||||
Mockito.when(vulcan.getSchoolInfo()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getSchoolInfo(),
|
||||
CoreMatchers.instanceOf(SchoolInfo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeachersInfoTest() throws Exception {
|
||||
Mockito.when(vulcan.getTeachersInfo()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getTeachersInfo(),
|
||||
CoreMatchers.instanceOf(TeachersInfo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTimetableTest() throws Exception {
|
||||
Mockito.when(vulcan.getTimetable()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getTimetable(),
|
||||
CoreMatchers.instanceOf(Timetable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBasicInformationTest() throws Exception {
|
||||
Mockito.when(vulcan.getBasicInformation()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getBasicInformation(),
|
||||
CoreMatchers.instanceOf(BasicInformation.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFamilyInformationTest() throws Exception {
|
||||
Mockito.when(vulcan.getFamilyInformation()).thenCallRealMethod();
|
||||
Assert.assertThat(vulcan.getFamilyInformation(),
|
||||
CoreMatchers.instanceOf(FamilyInformation.class));
|
||||
}
|
||||
}
|
@ -1,39 +1,23 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class StatisticsTest {
|
||||
public class AttendanceStatisticsTest extends StudentAndParentTestCase {
|
||||
|
||||
private Statistics excellent;
|
||||
private AttendanceStatistics excellent;
|
||||
|
||||
private Statistics full;
|
||||
private AttendanceStatistics full;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.excellent = getSetUpTable("Frekwencja-excellent.html");
|
||||
this.full = getSetUpTable("Frekwencja-full.html");
|
||||
}
|
||||
|
||||
private Statistics getSetUpTable(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document tablePageDocument = Jsoup.parse(input);
|
||||
|
||||
StudentAndParent timetable = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(timetable.getSnPPageDocument(Mockito.anyString()))
|
||||
.thenReturn(tablePageDocument);
|
||||
|
||||
return new Statistics(timetable);
|
||||
this.excellent = new AttendanceStatistics(getSnp("Frekwencja-excellent.html"));
|
||||
this.full = new AttendanceStatistics(getSnp("Frekwencja-full.html"));
|
||||
}
|
||||
|
||||
@Test
|
@ -1,37 +1,21 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class TableTest {
|
||||
public class AttendanceTableTest extends StudentAndParentTestCase {
|
||||
|
||||
private Table excellent;
|
||||
private AttendanceTable excellent;
|
||||
|
||||
private Table full;
|
||||
private AttendanceTable full;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
excellent = getSetUpTable("Frekwencja-excellent.html");
|
||||
full = getSetUpTable("Frekwencja-full.html");
|
||||
}
|
||||
|
||||
public Table getSetUpTable(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document tablePageDocument = Jsoup.parse(input);
|
||||
|
||||
StudentAndParent timetable = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(timetable.getSnPPageDocument(Mockito.anyString()))
|
||||
.thenReturn(tablePageDocument);
|
||||
|
||||
return new Table(timetable);
|
||||
excellent = new AttendanceTable(getSnp("Frekwencja-excellent.html"));
|
||||
full = new AttendanceTable(getSnp("Frekwencja-full.html"));
|
||||
}
|
||||
|
||||
@Test
|
@ -6,66 +6,109 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GradesListTest extends GradesTest {
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
private String fixtureFileName = "OcenyWszystkie-filled.html";
|
||||
public class GradesListTest extends StudentAndParentTestCase {
|
||||
|
||||
private GradesList gradesList;
|
||||
private GradesList filled;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp(fixtureFileName);
|
||||
|
||||
gradesList = new GradesList(snp);
|
||||
filled = new GradesList(getSnp("OcenyWszystkie-filled.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllTest() throws Exception {
|
||||
List<Grade> grades = gradesList.getAll();
|
||||
Assert.assertEquals(6, grades.size()); // 2 items are skipped
|
||||
Assert.assertEquals(6, filled.getAll().size()); // 2 items are skipped
|
||||
}
|
||||
|
||||
Grade grade1 = grades.get(0);
|
||||
Assert.assertEquals("Zajęcia z wychowawcą", grade1.getSubject());
|
||||
Assert.assertEquals("5", grade1.getValue());
|
||||
Assert.assertEquals("000000", grade1.getColor());
|
||||
Assert.assertEquals("A1", grade1.getSymbol());
|
||||
Assert.assertEquals("Dzień Kobiet w naszej klasie", grade1.getDescription());
|
||||
Assert.assertEquals("1,00", grade1.getWeight());
|
||||
Assert.assertEquals("2017-03-21", grade1.getDate());
|
||||
Assert.assertEquals("Patryk Maciejewski", grade1.getTeacher());
|
||||
Assert.assertEquals("7654321", grade1.getSemester());
|
||||
@Test
|
||||
public void getSubjectTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Grade grade2 = grades.get(3);
|
||||
Assert.assertEquals("Język angielski", grade2.getSubject());
|
||||
Assert.assertEquals("5", grade2.getValue());
|
||||
Assert.assertEquals("1289F7", grade2.getColor());
|
||||
Assert.assertEquals("BW3", grade2.getSymbol());
|
||||
Assert.assertEquals("Writing", grade2.getDescription());
|
||||
Assert.assertEquals("3,00", grade2.getWeight());
|
||||
Assert.assertEquals("2017-06-02", grade2.getDate());
|
||||
Assert.assertEquals("Oliwia Woźniak", grade2.getTeacher());
|
||||
Assert.assertEquals("7654321", grade2.getSemester());
|
||||
Assert.assertEquals("Zajęcia z wychowawcą", list.get(0).getSubject());
|
||||
Assert.assertEquals("Język angielski", list.get(3).getSubject());
|
||||
Assert.assertEquals("Wychowanie fizyczne", list.get(4).getSubject());
|
||||
Assert.assertEquals("Język polski", list.get(5).getSubject());
|
||||
}
|
||||
|
||||
Grade grade3 = grades.get(4);
|
||||
Assert.assertEquals("Wychowanie fizyczne", grade3.getSubject());
|
||||
Assert.assertEquals("1", grade3.getValue());
|
||||
Assert.assertEquals("6ECD07", grade3.getColor());
|
||||
Assert.assertEquals("STR", grade3.getSymbol());
|
||||
Assert.assertEquals("", grade3.getDescription());
|
||||
Assert.assertEquals("8,00", grade3.getWeight());
|
||||
Assert.assertEquals("2017-04-02", grade3.getDate());
|
||||
Assert.assertEquals("Klaudia Dziedzic", grade3.getTeacher());
|
||||
Assert.assertEquals("7654321", grade3.getSemester());
|
||||
@Test
|
||||
public void getValueTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Grade grade4 = grades.get(5);
|
||||
Assert.assertEquals("Język polski", grade4.getSubject());
|
||||
Assert.assertEquals("1", grade4.getValue());
|
||||
Assert.assertEquals("6ECD07", grade4.getColor());
|
||||
Assert.assertEquals("K", grade4.getSymbol());
|
||||
Assert.assertEquals("Kordian", grade4.getDescription());
|
||||
Assert.assertEquals("5,00", grade4.getWeight());
|
||||
Assert.assertEquals("2017-02-06", grade4.getDate());
|
||||
Assert.assertEquals("Amelia Stępień", grade4.getTeacher());
|
||||
Assert.assertEquals("7654321", grade4.getSemester());
|
||||
Assert.assertEquals("5", list.get(0).getValue());
|
||||
Assert.assertEquals("5", list.get(3).getValue());
|
||||
Assert.assertEquals("1", list.get(4).getValue());
|
||||
Assert.assertEquals("1", list.get(5).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getColorTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("000000", list.get(0).getColor());
|
||||
Assert.assertEquals("1289F7", list.get(3).getColor());
|
||||
Assert.assertEquals("6ECD07", list.get(4).getColor());
|
||||
Assert.assertEquals("6ECD07", list.get(5).getColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSymbolTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("A1", list.get(0).getSymbol());
|
||||
Assert.assertEquals("BW3", list.get(3).getSymbol());
|
||||
Assert.assertEquals("STR", list.get(4).getSymbol());
|
||||
Assert.assertEquals("K", list.get(5).getSymbol());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDescriptionTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("Dzień Kobiet w naszej klasie", list.get(0).getDescription());
|
||||
Assert.assertEquals("Writing", list.get(3).getDescription());
|
||||
Assert.assertEquals("", list.get(4).getDescription());
|
||||
Assert.assertEquals("Kordian", list.get(5).getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeightTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("1,00", list.get(0).getWeight());
|
||||
Assert.assertEquals("3,00", list.get(3).getWeight());
|
||||
Assert.assertEquals("8,00", list.get(4).getWeight());
|
||||
Assert.assertEquals("5,00", list.get(5).getWeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDateTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("2017-03-21", list.get(0).getDate());
|
||||
Assert.assertEquals("2017-06-02", list.get(3).getDate());
|
||||
Assert.assertEquals("2017-04-02", list.get(4).getDate());
|
||||
Assert.assertEquals("2017-02-06", list.get(5).getDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeacherTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("Patryk Maciejewski", list.get(0).getTeacher());
|
||||
Assert.assertEquals("Oliwia Woźniak", list.get(3).getTeacher());
|
||||
Assert.assertEquals("Klaudia Dziedzic", list.get(4).getTeacher());
|
||||
Assert.assertEquals("Amelia Stępień", list.get(5).getTeacher());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSemesterTest() throws Exception {
|
||||
List<Grade> list = filled.getAll();
|
||||
|
||||
Assert.assertEquals("7654321", list.get(0).getSemester());
|
||||
Assert.assertEquals("7654321", list.get(3).getSemester());
|
||||
Assert.assertEquals("7654321", list.get(4).getSemester());
|
||||
Assert.assertEquals("7654321", list.get(5).getSemester());
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.Semester;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class GradesTest {
|
||||
|
||||
protected StudentAndParent snp;
|
||||
|
||||
public void setUp(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
Document gradesPageDocument = Jsoup.parse(input);
|
||||
|
||||
snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString()))
|
||||
.thenReturn(gradesPageDocument);
|
||||
Mockito.when(snp.getSemesters(Mockito.any(Document.class))).thenCallRealMethod();
|
||||
Mockito.when(snp.getCurrentSemester(Mockito.<Semester>anyList()))
|
||||
.thenCallRealMethod();
|
||||
}
|
||||
}
|
@ -1,83 +1,82 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubjectsListTest extends GradesTest {
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
private String fixtureStdFileName = "OcenyWszystkie-subjects.html";
|
||||
public class SubjectsListTest extends StudentAndParentTestCase {
|
||||
|
||||
private String fixtureAverageFileName = "OcenyWszystkie-subjects-average.html";
|
||||
private SubjectsList std;
|
||||
|
||||
public SubjectsList getSetUpSubjectsList(String fixtureFileName) throws Exception {
|
||||
super.setUp(fixtureFileName);
|
||||
private SubjectsList average;
|
||||
|
||||
return new SubjectsList(snp);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
std = new SubjectsList(getSnp("OcenyWszystkie-subjects.html"));
|
||||
average = new SubjectsList(getSnp("OcenyWszystkie-subjects-average.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllStdTest() throws Exception {
|
||||
List<Subject> list = getSetUpSubjectsList(fixtureStdFileName).getAll();
|
||||
|
||||
Assert.assertEquals(5, list.size());
|
||||
|
||||
Subject subject0 = list.get(0);
|
||||
Assert.assertEquals("Zachowanie", subject0.getName());
|
||||
Assert.assertEquals("bardzo dobre", subject0.getPredictedRating());
|
||||
Assert.assertEquals("bardzo dobre", subject0.getFinalRating());
|
||||
|
||||
Subject subject1 = list.get(1);
|
||||
Assert.assertEquals("Praktyka zawodowa", subject1.getName());
|
||||
Assert.assertEquals("-", subject1.getPredictedRating());
|
||||
Assert.assertEquals("celujący", subject1.getFinalRating());
|
||||
|
||||
Subject subject2 = list.get(2);
|
||||
Assert.assertEquals("Metodologia programowania", subject2.getName());
|
||||
Assert.assertEquals("bardzo dobry", subject2.getPredictedRating());
|
||||
Assert.assertEquals("celujący", subject2.getFinalRating());
|
||||
|
||||
Subject subject3 = list.get(3);
|
||||
Assert.assertEquals("Podstawy przedsiębiorczości", subject3.getName());
|
||||
Assert.assertEquals("3/4", subject3.getPredictedRating());
|
||||
Assert.assertEquals("dostateczny", subject3.getFinalRating());
|
||||
|
||||
Subject subject4 = list.get(4);
|
||||
Assert.assertEquals("Wychowanie do życia w rodzinie", subject4.getName());
|
||||
Assert.assertEquals("-", subject4.getPredictedRating());
|
||||
Assert.assertEquals("-", subject4.getFinalRating());
|
||||
public void getAllTest() throws Exception {
|
||||
Assert.assertEquals(5, std.getAll().size());
|
||||
Assert.assertEquals(5, average.getAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllAverageTest() throws Exception {
|
||||
List<Subject> list = getSetUpSubjectsList(fixtureAverageFileName).getAll();
|
||||
public void getNameTest() throws Exception {
|
||||
List<Subject> stdList = std.getAll();
|
||||
|
||||
Assert.assertEquals(5, list.size());
|
||||
Assert.assertEquals("Zachowanie", stdList.get(0).getName());
|
||||
Assert.assertEquals("Praktyka zawodowa", stdList.get(1).getName());
|
||||
Assert.assertEquals("Metodologia programowania", stdList.get(2).getName());
|
||||
Assert.assertEquals("Podstawy przedsiębiorczości", stdList.get(3).getName());
|
||||
Assert.assertEquals("Wychowanie do życia w rodzinie", stdList.get(4).getName());
|
||||
|
||||
Subject subject0 = list.get(0);
|
||||
Assert.assertEquals("Zachowanie", subject0.getName());
|
||||
Assert.assertEquals("bardzo dobre", subject0.getPredictedRating());
|
||||
Assert.assertEquals("bardzo dobre", subject0.getFinalRating());
|
||||
List<Subject> averageList = average.getAll();
|
||||
Assert.assertEquals("Zachowanie", averageList.get(0).getName());
|
||||
Assert.assertEquals("Język polski", averageList.get(1).getName());
|
||||
Assert.assertEquals("Wychowanie fizyczne", averageList.get(2).getName());
|
||||
Assert.assertEquals("Język angielski", averageList.get(3).getName());
|
||||
Assert.assertEquals("Wiedza o społeczeństwie", averageList.get(4).getName());
|
||||
}
|
||||
|
||||
Subject subject1 = list.get(1);
|
||||
Assert.assertEquals("Język polski", subject1.getName());
|
||||
Assert.assertEquals("-", subject1.getPredictedRating());
|
||||
Assert.assertEquals("dobry", subject1.getFinalRating());
|
||||
@Test
|
||||
public void getPredictedRatingTest() throws Exception {
|
||||
List<Subject> stdList = std.getAll();
|
||||
|
||||
Subject subject2 = list.get(2);
|
||||
Assert.assertEquals("Wychowanie fizyczne", subject2.getName());
|
||||
Assert.assertEquals("bardzo dobry", subject2.getPredictedRating());
|
||||
Assert.assertEquals("celujący", subject2.getFinalRating());
|
||||
Assert.assertEquals("bardzo dobre", stdList.get(0).getPredictedRating());
|
||||
Assert.assertEquals("-", stdList.get(1).getPredictedRating());
|
||||
Assert.assertEquals("bardzo dobry", stdList.get(2).getPredictedRating());
|
||||
Assert.assertEquals("3/4", stdList.get(3).getPredictedRating());
|
||||
Assert.assertEquals("-", stdList.get(4).getPredictedRating());
|
||||
|
||||
Subject subject3 = list.get(3);
|
||||
Assert.assertEquals("Język angielski", subject3.getName());
|
||||
Assert.assertEquals("4/5", subject3.getPredictedRating());
|
||||
Assert.assertEquals("bardzo dobry", subject3.getFinalRating());
|
||||
List<Subject> averageList = average.getAll();
|
||||
Assert.assertEquals("bardzo dobre", averageList.get(0).getPredictedRating());
|
||||
Assert.assertEquals("-", averageList.get(1).getPredictedRating());
|
||||
Assert.assertEquals("bardzo dobry", averageList.get(2).getPredictedRating());
|
||||
Assert.assertEquals("4/5", averageList.get(3).getPredictedRating());
|
||||
Assert.assertEquals("-", averageList.get(4).getPredictedRating());
|
||||
}
|
||||
|
||||
Subject subject4 = list.get(4);
|
||||
Assert.assertEquals("Wiedza o społeczeństwie", subject4.getName());
|
||||
Assert.assertEquals("-", subject4.getPredictedRating());
|
||||
Assert.assertEquals("-", subject4.getFinalRating());
|
||||
@Test
|
||||
public void getFinalRatingTest() throws Exception {
|
||||
List<Subject> stdList = std.getAll();
|
||||
|
||||
Assert.assertEquals("bardzo dobre", stdList.get(0).getFinalRating());
|
||||
Assert.assertEquals("celujący", stdList.get(1).getFinalRating());
|
||||
Assert.assertEquals("celujący", stdList.get(2).getFinalRating());
|
||||
Assert.assertEquals("dostateczny", stdList.get(3).getFinalRating());
|
||||
Assert.assertEquals("-", stdList.get(4).getFinalRating());
|
||||
|
||||
List<Subject> averageList = average.getAll();
|
||||
Assert.assertEquals("bardzo dobre", averageList.get(0).getFinalRating());
|
||||
Assert.assertEquals("dobry", averageList.get(1).getFinalRating());
|
||||
Assert.assertEquals("celujący", averageList.get(2).getFinalRating());
|
||||
Assert.assertEquals("bardzo dobry", averageList.get(3).getFinalRating());
|
||||
Assert.assertEquals("-", averageList.get(4).getFinalRating());
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,36 @@
|
||||
package io.github.wulkanowy.api.notes;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class AchievementsListTest {
|
||||
public class AchievementsListTest extends StudentAndParentTestCase {
|
||||
|
||||
private String fixtureFilledFileName = "UwagiOsiagniecia-filled.html";
|
||||
private AchievementsList filledAchievementsList;
|
||||
|
||||
private String fixtureEmptyFileName = "UwagiOsiagniecia-empty.html";
|
||||
private AchievementsList emptyAchievementsList;
|
||||
|
||||
private AchievementsList getSetUpAchievementsList(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document notesPageDocument = Jsoup.parse(input);
|
||||
|
||||
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(notesPageDocument);
|
||||
|
||||
return new AchievementsList(snp);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
filledAchievementsList = new AchievementsList(getSnp("UwagiOsiagniecia-filled.html"));
|
||||
emptyAchievementsList = new AchievementsList(getSnp("UwagiOsiagniecia-empty.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllAchievementsFilledTest() throws Exception {
|
||||
List<String> list = getSetUpAchievementsList(fixtureFilledFileName).getAllAchievements();
|
||||
|
||||
Assert.assertEquals(2, list.size());
|
||||
Assert.assertEquals("I miejsce w ogólnopolskim konkursie ortograficznym", list.get(0));
|
||||
Assert.assertEquals("III miejsce w ogólnopolskim konkursie plastycznym", list.get(1));
|
||||
public void getAllAchievementsTest() throws Exception {
|
||||
Assert.assertEquals(2, filledAchievementsList.getAllAchievements().size());
|
||||
Assert.assertEquals(0, emptyAchievementsList.getAllAchievements().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllAchievementsEmptyTest() throws Exception {
|
||||
List<String> list = getSetUpAchievementsList(fixtureEmptyFileName).getAllAchievements();
|
||||
public void getAchievements() throws Exception {
|
||||
List<String> filledList = filledAchievementsList.getAllAchievements();
|
||||
|
||||
Assert.assertEquals(0, list.size());
|
||||
Assert.assertEquals("I miejsce w ogólnopolskim konkursie ortograficznym", filledList.get(0));
|
||||
Assert.assertEquals("III miejsce w ogólnopolskim konkursie plastycznym", filledList.get(1));
|
||||
}
|
||||
}
|
||||
|
@ -1,57 +1,60 @@
|
||||
package io.github.wulkanowy.api.notes;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class NotesListTest {
|
||||
public class NotesListTest extends StudentAndParentTestCase {
|
||||
|
||||
private String fixtureFilledFileName = "UwagiOsiagniecia-filled.html";
|
||||
private NotesList filled;
|
||||
|
||||
private String fixtureEmptyFileName = "UwagiOsiagniecia-empty.html";
|
||||
private NotesList empty;
|
||||
|
||||
private NotesList getSetUpNotesList(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document notesPageDocument = Jsoup.parse(input);
|
||||
|
||||
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(notesPageDocument);
|
||||
Mockito.when(snp.getRowDataChildValue(Mockito.any(Element.class),
|
||||
Mockito.anyInt())).thenCallRealMethod();
|
||||
|
||||
return new NotesList(snp);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
filled = new NotesList(getSnp("UwagiOsiagniecia-filled.html"));
|
||||
empty = new NotesList(getSnp("UwagiOsiagniecia-empty.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllNotesFilledTest() throws Exception {
|
||||
List<Note> list = getSetUpNotesList(fixtureFilledFileName).getAllNotes();
|
||||
|
||||
Assert.assertEquals(3, list.size());
|
||||
|
||||
Assert.assertEquals("06.06.2017", list.get(0).getDate());
|
||||
Assert.assertEquals("Jan Kowalski [JK]", list.get(0).getTeacher());
|
||||
Assert.assertEquals("Zaangażowanie społeczne", list.get(0).getCategory());
|
||||
Assert.assertEquals("Pomoc przy pikniku charytatywnym", list.get(0).getContent());
|
||||
|
||||
Assert.assertEquals("01.10.2016", list.get(2).getDate());
|
||||
Assert.assertEquals("Kochański Leszek [KL]", list.get(2).getTeacher());
|
||||
Assert.assertEquals("Zachowanie na lekcji", list.get(2).getCategory());
|
||||
Assert.assertEquals("Przeszkadzanie w prowadzeniu lekcji", list.get(2).getContent());
|
||||
public void getAllNotesTest() throws Exception {
|
||||
Assert.assertEquals(3, filled.getAllNotes().size());
|
||||
Assert.assertEquals(0, empty.getAllNotes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllNotesWhenEmpty() throws Exception {
|
||||
List<Note> list = getSetUpNotesList(fixtureEmptyFileName).getAllNotes();
|
||||
public void getDateTest() throws Exception {
|
||||
List<Note> filledList = filled.getAllNotes();
|
||||
|
||||
Assert.assertEquals(0, list.size());
|
||||
Assert.assertEquals("06.06.2017", filledList.get(0).getDate());
|
||||
Assert.assertEquals("01.10.2016", filledList.get(2).getDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeacherTest() throws Exception {
|
||||
List<Note> filledList = filled.getAllNotes();
|
||||
|
||||
Assert.assertEquals("Jan Kowalski [JK]", filledList.get(0).getTeacher());
|
||||
Assert.assertEquals("Kochański Leszek [KL]", filledList.get(2).getTeacher());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCategoryTest() throws Exception {
|
||||
List<Note> filledList = filled.getAllNotes();
|
||||
|
||||
Assert.assertEquals("Zaangażowanie społeczne", filledList.get(0).getCategory());
|
||||
Assert.assertEquals("Zachowanie na lekcji", filledList.get(2).getCategory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContentTest() throws Exception {
|
||||
List<Note> filledList = filled.getAllNotes();
|
||||
|
||||
Assert.assertEquals("Pomoc przy pikniku charytatywnym", filledList.get(0).getContent());
|
||||
Assert.assertEquals("Przeszkadzanie w prowadzeniu lekcji", filledList.get(2).getContent());
|
||||
}
|
||||
}
|
||||
|
@ -4,30 +4,45 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SchoolInfoTest extends SchoolTest {
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class SchoolInfoTest extends StudentAndParentTestCase {
|
||||
|
||||
private SchoolInfo schoolInfo;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
schoolInfo = new SchoolInfo(snp);
|
||||
schoolInfo = new SchoolInfo(getSnp("Szkola.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSchoolDataTest() throws Exception {
|
||||
SchoolData schoolData = schoolInfo.getSchoolData();
|
||||
public void getNameTest() throws Exception {
|
||||
Assert.assertEquals("Zespół Szkół nr 64", schoolInfo.getSchoolData().getName());
|
||||
}
|
||||
|
||||
Assert.assertEquals("Zespół Szkół nr 64", schoolData.getName());
|
||||
@Test
|
||||
public void getAddressTest() throws Exception {
|
||||
Assert.assertEquals("ul. Wiśniowa 128, 01-234 Rogalowo, Nibylandia",
|
||||
schoolData.getAddress());
|
||||
Assert.assertEquals("55 5555555", schoolData.getPhoneNumber());
|
||||
Assert.assertEquals("Antoni Sobczyk", schoolData.getHeadmaster());
|
||||
schoolInfo.getSchoolData().getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPhoneNumberTest() throws Exception {
|
||||
Assert.assertEquals("55 5555555", schoolInfo.getSchoolData().getPhoneNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeadmasterTest() throws Exception {
|
||||
Assert.assertEquals("Antoni Sobczyk", schoolInfo.getSchoolData().getHeadmaster());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPedagoguesTest() throws Exception {
|
||||
Assert.assertArrayEquals(new String[]{
|
||||
"Zofia Czerwińska [ZC]",
|
||||
"Aleksander Krzemiński [AK]",
|
||||
"Karolina Kowalska [KK]",
|
||||
"Bartek Dąbrowski [BD]"
|
||||
}, schoolData.getPedagogues());
|
||||
}, schoolInfo.getSchoolData().getPedagogues());
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package io.github.wulkanowy.api.school;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.junit.Before;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class SchoolTest {
|
||||
|
||||
protected StudentAndParent snp;
|
||||
private String fixtureFileName = "Szkola.html";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document schoolPageDocument = Jsoup.parse(input);
|
||||
|
||||
snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(schoolPageDocument);
|
||||
Mockito.when(snp.getRowDataChildValue(Mockito.any(Element.class),
|
||||
Mockito.anyInt())).thenCallRealMethod();
|
||||
}
|
||||
}
|
@ -6,35 +6,47 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TeachersInfoTest extends SchoolTest {
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class TeachersInfoTest extends StudentAndParentTestCase {
|
||||
|
||||
private TeachersInfo teachersInfo;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
teachersInfo = new TeachersInfo(snp);
|
||||
teachersInfo = new TeachersInfo(getSnp("Szkola.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeachersDataTest() throws Exception {
|
||||
TeachersData teachersData = teachersInfo.getTeachersData();
|
||||
public void getClassNameTest() throws Exception {
|
||||
Assert.assertEquals("1a", teachersInfo.getTeachersData().getClassName());
|
||||
}
|
||||
|
||||
Assert.assertEquals("1a", teachersData.getClassName());
|
||||
@Test
|
||||
public void getClassTeacherTest() throws Exception {
|
||||
Assert.assertArrayEquals(new String[]{
|
||||
"Karolina Kowalska [AN]",
|
||||
"Antoni Sobczyk [AS]"
|
||||
}, teachersData.getClassTeacher());
|
||||
}, teachersInfo.getTeachersData().getClassTeacher());
|
||||
}
|
||||
|
||||
List<Subject> subjects = teachersData.getSubjects();
|
||||
@Test
|
||||
public void getTeachersDataSubjectsNameTest() throws Exception {
|
||||
List<Subject> subjects = teachersInfo.getTeachersData().getSubjects();
|
||||
|
||||
Assert.assertEquals("Biologia", subjects.get(0).getName());
|
||||
Assert.assertEquals("Język angielski", subjects.get(6).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeachersDataSubjectsTeachersTest() throws Exception {
|
||||
List<Subject> subjects = teachersInfo.getTeachersData().getSubjects();
|
||||
|
||||
Assert.assertArrayEquals(new String[]{"Karolina Kowalska [AN]"},
|
||||
subjects.get(0).getTeachers());
|
||||
Assert.assertEquals("Karolina Kowalska [AN]",
|
||||
subjects.get(0).getTeachers()[0]);
|
||||
|
||||
Assert.assertEquals("Język angielski", subjects.get(6).getName());
|
||||
Assert.assertArrayEquals(new String[]{
|
||||
"Karolina Kowalska [AN]",
|
||||
"Mateusz Kowal [MK]",
|
||||
|
@ -1,222 +0,0 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class TableTest {
|
||||
|
||||
private String fixtureStdFileName = "PlanLekcji-std.html";
|
||||
|
||||
private String fixtureHolidaysFileName = "PlanLekcji-holidays.html";
|
||||
|
||||
private String fixtureFullFileName = "PlanLekcji-full.html";
|
||||
|
||||
private Table getSetUpTable(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document tablePageDocument = Jsoup.parse(input);
|
||||
|
||||
StudentAndParent timetable = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(timetable.getSnPPageDocument(Mockito.anyString()))
|
||||
.thenReturn(tablePageDocument);
|
||||
|
||||
return new Table(timetable);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableStandardTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureStdFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertEquals(5, week.getDays().size());
|
||||
Assert.assertEquals("19.06.2017", week.getStartDayDate());
|
||||
|
||||
Assert.assertEquals("19.06.2017", week.getDay(0).getDate());
|
||||
Assert.assertEquals("23.06.2017", week.getDay(4).getDate());
|
||||
|
||||
Assert.assertFalse(week.getDay(4).isFreeDay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableStandardLessonStartEndEndTest() throws Exception {
|
||||
Table tableStd = getSetUpTable(fixtureStdFileName);
|
||||
Week stdWeek = tableStd.getWeekTable();
|
||||
|
||||
Assert.assertEquals("08:00", stdWeek.getDay(0).getLesson(0).getStartTime());
|
||||
Assert.assertEquals("08:45", stdWeek.getDay(1).getLesson(0).getEndTime());
|
||||
Assert.assertEquals("12:15", stdWeek.getDay(2).getLesson(4).getEndTime());
|
||||
Assert.assertEquals("14:10", stdWeek.getDay(3).getLesson(7).getStartTime());
|
||||
|
||||
Table tableFull = getSetUpTable(fixtureFullFileName);
|
||||
Week fullWeek = tableFull.getWeekTable();
|
||||
|
||||
Assert.assertEquals("07:10", fullWeek.getDay(0).getLesson(0).getStartTime());
|
||||
Assert.assertEquals("07:55", fullWeek.getDay(1).getLesson(0).getEndTime());
|
||||
Assert.assertEquals("12:20", fullWeek.getDay(2).getLesson(6).getStartTime());
|
||||
Assert.assertEquals("19:00", fullWeek.getDay(3).getLesson(13).getEndTime());
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void getWeekTableStandardOutOfBoundsIndex() throws Exception {
|
||||
Table table = getSetUpTable(fixtureStdFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
week.getDay(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableHolidaysTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureHolidaysFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertTrue(week.getDay(1).isFreeDay());
|
||||
|
||||
Assert.assertNotEquals("Wakacje", week.getDay(2).getFreeDayName());
|
||||
|
||||
Assert.assertEquals("Ferie letnie", week.getDay(3).getFreeDayName());
|
||||
Assert.assertEquals("31.07.2017", week.getStartDayDate());
|
||||
Assert.assertEquals(5, week.getDays().size());
|
||||
Assert.assertEquals(14, week.getDay(4).getLessons().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableHolidaysWithEmptyLessonsTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureHolidaysFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertEquals(5, week.getDays().size());
|
||||
|
||||
Assert.assertTrue(week.getDay(0).getLesson(5).isEmpty());
|
||||
Assert.assertTrue(week.getDay(2).getLesson(13).isEmpty());
|
||||
Assert.assertTrue(week.getDay(3).getLesson(0).isEmpty());
|
||||
Assert.assertTrue(week.getDay(4).getLesson(13).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertFalse(week.getDay(1).getLesson(2).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullLessonsGroupsDivisionTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
// class="", span*4
|
||||
Lesson lesson1 = week.getDay(0).getLesson(1);
|
||||
Assert.assertTrue(lesson1.isDivisionIntoGroups());
|
||||
Assert.assertEquals("J1", lesson1.getGroupName());
|
||||
|
||||
// class="", span*3
|
||||
Lesson lesson2 = week.getDay(0).getLesson(7);
|
||||
Assert.assertFalse(lesson2.isDivisionIntoGroups());
|
||||
Assert.assertEquals("", lesson2.getGroupName());
|
||||
|
||||
// div*3 (2), class="x-treelabel-zas", span*4
|
||||
Lesson lesson3 = week.getDay(1).getLesson(2);
|
||||
Assert.assertFalse(lesson3.isDivisionIntoGroups());
|
||||
Assert.assertEquals("", lesson3.getGroupName());
|
||||
|
||||
// div*3 (2), class="x-treelabel-zas", span*5
|
||||
Lesson lesson4 = week.getDay(1).getLesson(3);
|
||||
Assert.assertTrue(lesson4.isDivisionIntoGroups());
|
||||
Assert.assertEquals("wf2", lesson4.getGroupName());
|
||||
|
||||
// class="x-treelabel-ppl", span*3
|
||||
Lesson lesson5 = week.getDay(4).getLesson(0);
|
||||
Assert.assertFalse(lesson5.isDivisionIntoGroups());
|
||||
Assert.assertEquals("", lesson5.getGroupName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullLessonsTypesTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
// class="", span*4
|
||||
Lesson lesson1 = week.getDay(0).getLesson(1);
|
||||
Assert.assertFalse(lesson1.isPlanning());
|
||||
Assert.assertTrue(lesson1.isRealized());
|
||||
Assert.assertFalse(lesson1.isMovedOrCanceled());
|
||||
Assert.assertFalse(lesson1.isNewMovedInOrChanged());
|
||||
|
||||
// class="", span*3
|
||||
Lesson lesson2 = week.getDay(0).getLesson(7);
|
||||
Assert.assertFalse(lesson2.isPlanning());
|
||||
Assert.assertTrue(lesson2.isRealized());
|
||||
Assert.assertTrue(lesson2.isMovedOrCanceled());
|
||||
Assert.assertFalse(lesson2.isNewMovedInOrChanged());
|
||||
|
||||
// div*3 (2), class="x-treelabel-zas", span*4
|
||||
Lesson lesson3 = week.getDay(1).getLesson(2);
|
||||
Assert.assertFalse(lesson3.isPlanning());
|
||||
Assert.assertTrue(lesson3.isRealized());
|
||||
Assert.assertFalse(lesson3.isMovedOrCanceled());
|
||||
Assert.assertTrue(lesson3.isNewMovedInOrChanged());
|
||||
|
||||
// div*3 (2), class="x-treelabel-zas", span*5
|
||||
Lesson lesson4 = week.getDay(1).getLesson(3);
|
||||
Assert.assertFalse(lesson4.isPlanning());
|
||||
Assert.assertTrue(lesson4.isRealized());
|
||||
Assert.assertFalse(lesson4.isMovedOrCanceled());
|
||||
Assert.assertTrue(lesson4.isNewMovedInOrChanged());
|
||||
|
||||
// class="x-treelabel-ppl", span*3
|
||||
Lesson lesson5 = week.getDay(4).getLesson(0);
|
||||
Assert.assertTrue(lesson5.isPlanning());
|
||||
Assert.assertFalse(lesson5.isRealized());
|
||||
Assert.assertFalse(lesson5.isMovedOrCanceled());
|
||||
Assert.assertFalse(lesson5.isNewMovedInOrChanged());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullLessonsBasicInfoTest() throws Exception {
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
// class="", span*4
|
||||
Lesson lesson1 = week.getDay(0).getLesson(1);
|
||||
Assert.assertEquals("Język angielski", lesson1.getSubject());
|
||||
Assert.assertEquals("Kobczyk Iwona", lesson1.getTeacher());
|
||||
Assert.assertEquals("", lesson1.getRoom());
|
||||
Assert.assertEquals("", lesson1.getDescription());
|
||||
|
||||
// class="", span*3
|
||||
Lesson lesson2 = week.getDay(0).getLesson(7);
|
||||
Assert.assertEquals("Fizyka", lesson2.getSubject());
|
||||
Assert.assertEquals("Bączek Grzegorz", lesson2.getTeacher());
|
||||
Assert.assertEquals("33", lesson2.getRoom());
|
||||
Assert.assertEquals("okienko dla uczniów", lesson2.getDescription());
|
||||
|
||||
// div*3 (2), class="x-treelabel-zas", span*4
|
||||
Lesson lesson3 = week.getDay(1).getLesson(2);
|
||||
Assert.assertEquals("Język polski", lesson3.getSubject());
|
||||
Assert.assertEquals("Bocian Natalia", lesson3.getTeacher());
|
||||
Assert.assertEquals("", lesson3.getRoom());
|
||||
Assert.assertEquals("przeniesiona z lekcji 7, 20.06.2017", lesson3.getDescription());
|
||||
|
||||
// div*3 (2), class="x-treelabel-zas", span*5
|
||||
Lesson lesson4 = week.getDay(1).getLesson(3);
|
||||
Assert.assertEquals("Wychowanie fizyczne", lesson4.getSubject());
|
||||
Assert.assertEquals("Nowicka Irena", lesson4.getTeacher());
|
||||
Assert.assertEquals("", lesson4.getRoom());
|
||||
Assert.assertEquals("przeniesiona z lekcji 4, 20.06.2017", lesson4.getDescription());
|
||||
|
||||
// class="x-treelabel-ppl", span*3
|
||||
Lesson lesson5 = week.getDay(4).getLesson(0);
|
||||
Assert.assertEquals("Uroczyste zakończenie roku szkolnego", lesson5.getSubject());
|
||||
Assert.assertEquals("Baran Małgorzata", lesson5.getTeacher());
|
||||
Assert.assertEquals("37", lesson5.getRoom());
|
||||
Assert.assertEquals("", lesson5.getDescription());
|
||||
}
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class TimetableTest extends StudentAndParentTestCase {
|
||||
|
||||
private Timetable std;
|
||||
|
||||
private Timetable full;
|
||||
|
||||
private Timetable holidays;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
std = new Timetable(getSnp("PlanLekcji-std.html"));
|
||||
full = new Timetable(getSnp("PlanLekcji-full.html"));
|
||||
holidays = new Timetable(getSnp("PlanLekcji-holidays.html"));
|
||||
}
|
||||
|
||||
// Week
|
||||
|
||||
@Test
|
||||
public void getWeekTableTest() throws Exception {
|
||||
Assert.assertEquals(5, std.getWeekTable().getDays().size());
|
||||
Assert.assertEquals(5, full.getWeekTable().getDays().size());
|
||||
Assert.assertEquals(5, holidays.getWeekTable().getDays().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStartDayDateTest() throws Exception {
|
||||
Assert.assertEquals("19.06.2017", std.getWeekTable().getStartDayDate());
|
||||
Assert.assertEquals("19.06.2017", full.getWeekTable().getStartDayDate());
|
||||
Assert.assertEquals("31.07.2017", holidays.getWeekTable().getStartDayDate());
|
||||
}
|
||||
|
||||
// Day
|
||||
|
||||
@Test
|
||||
public void getDayDateTest() throws Exception {
|
||||
Assert.assertEquals("19.06.2017", std.getWeekTable().getDay(0).getDate());
|
||||
Assert.assertEquals("23.06.2017", std.getWeekTable().getDay(4).getDate());
|
||||
Assert.assertEquals("20.06.2017", full.getWeekTable().getDay(1).getDate());
|
||||
Assert.assertEquals("22.06.2017", full.getWeekTable().getDay(3).getDate());
|
||||
Assert.assertEquals("02.08.2017", holidays.getWeekTable().getDay(2).getDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDayIsFreeTest() throws Exception {
|
||||
Assert.assertFalse(std.getWeekTable().getDay(0).isFreeDay());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(2).isFreeDay());
|
||||
Assert.assertTrue(holidays.getWeekTable().getDay(4).isFreeDay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDayFreeDayName() throws Exception {
|
||||
Assert.assertNotEquals("Wakacje", std.getWeekTable().getDay(0).getFreeDayName());
|
||||
Assert.assertNotEquals("Ferie letnie", full.getWeekTable().getDay(1).getFreeDayName());
|
||||
Assert.assertNotEquals("Wakacje", holidays.getWeekTable().getDay(2).getFreeDayName());
|
||||
Assert.assertEquals("Ferie letnie", holidays.getWeekTable().getDay(4).getFreeDayName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDayLessonsTest() throws Exception {
|
||||
Assert.assertEquals(8, std.getWeekTable().getDay(0).getLessons().size());
|
||||
Assert.assertEquals(14, full.getWeekTable().getDay(2).getLessons().size());
|
||||
Assert.assertEquals(14, holidays.getWeekTable().getDay(4).getLessons().size());
|
||||
}
|
||||
|
||||
// Lesson
|
||||
|
||||
@Test
|
||||
public void getLessonSubjectTest() throws Exception {
|
||||
Assert.assertEquals("Historia", std.getWeekTable().getDay(0).getLesson(1).getSubject());
|
||||
Assert.assertEquals("Zajęcia techniczne", std.getWeekTable().getDay(2).getLesson(4).getSubject());
|
||||
Assert.assertEquals("Język angielski", full.getWeekTable().getDay(0).getLesson(1).getSubject());
|
||||
Assert.assertEquals("Uroczyste zakończenie roku szkolnego", full.getWeekTable().getDay(4).getLesson(0).getSubject());
|
||||
Assert.assertEquals("", holidays.getWeekTable().getDay(3).getLesson(3).getSubject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonTeacherTest() throws Exception {
|
||||
Assert.assertEquals("Bogatka Katarzyna", std.getWeekTable().getDay(0).getLesson(1).getTeacher());
|
||||
Assert.assertEquals("Chlebowski Stanisław", std.getWeekTable().getDay(2).getLesson(4).getTeacher());
|
||||
Assert.assertEquals("Kobczyk Iwona", full.getWeekTable().getDay(0).getLesson(1).getTeacher());
|
||||
Assert.assertEquals("Bączek Grzegorz", full.getWeekTable().getDay(0).getLesson(7).getTeacher());
|
||||
Assert.assertEquals("Baran Małgorzata", full.getWeekTable().getDay(4).getLesson(0).getTeacher());
|
||||
Assert.assertEquals("", holidays.getWeekTable().getDay(3).getLesson(3).getTeacher());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonRoomTest() throws Exception {
|
||||
Assert.assertEquals("", std.getWeekTable().getDay(3).getLesson(3).getRoom());
|
||||
Assert.assertEquals("33", full.getWeekTable().getDay(0).getLesson(7).getRoom());
|
||||
Assert.assertEquals("32", full.getWeekTable().getDay(1).getLesson(8).getRoom());
|
||||
Assert.assertEquals("37", full.getWeekTable().getDay(4).getLesson(0).getRoom());
|
||||
Assert.assertEquals("", holidays.getWeekTable().getDay(3).getLesson(3).getRoom());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonDescriptionTest() throws Exception {
|
||||
Assert.assertEquals("", std.getWeekTable().getDay(3).getLesson(3).getDescription());
|
||||
Assert.assertEquals("okienko dla uczniów", full.getWeekTable().getDay(0).getLesson(7).getDescription());
|
||||
Assert.assertEquals("przeniesiona z lekcji 7, 20.06.2017", full.getWeekTable().getDay(1).getLesson(2).getDescription());
|
||||
Assert.assertEquals("przeniesiona z lekcji 4, 20.06.2017", full.getWeekTable().getDay(1).getLesson(3).getDescription());
|
||||
Assert.assertEquals("", full.getWeekTable().getDay(4).getLesson(0).getDescription());
|
||||
Assert.assertEquals("", holidays.getWeekTable().getDay(3).getLesson(3).getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonGroupNameTest() throws Exception {
|
||||
Assert.assertEquals("CH", std.getWeekTable().getDay(0).getLesson(2).getGroupName());
|
||||
Assert.assertEquals("JNPW", std.getWeekTable().getDay(4).getLesson(0).getGroupName());
|
||||
Assert.assertEquals("", full.getWeekTable().getDay(0).getLesson(7).getGroupName());
|
||||
Assert.assertEquals("wf2", full.getWeekTable().getDay(1).getLesson(3).getGroupName());
|
||||
Assert.assertEquals("", holidays.getWeekTable().getDay(3).getLesson(3).getGroupName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonStartTimeTest() throws Exception {
|
||||
Assert.assertEquals("08:00", std.getWeekTable().getDay(0).getLesson(0).getStartTime());
|
||||
Assert.assertEquals("14:10", std.getWeekTable().getDay(3).getLesson(7).getStartTime());
|
||||
Assert.assertEquals("07:10", full.getWeekTable().getDay(0).getLesson(0).getStartTime());
|
||||
Assert.assertEquals("12:20", full.getWeekTable().getDay(2).getLesson(6).getStartTime());
|
||||
Assert.assertEquals("12:20", holidays.getWeekTable().getDay(2).getLesson(6).getStartTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonEndTimeTest() throws Exception {
|
||||
Assert.assertEquals("08:45", std.getWeekTable().getDay(1).getLesson(0).getEndTime());
|
||||
Assert.assertEquals("12:15", std.getWeekTable().getDay(2).getLesson(4).getEndTime());
|
||||
Assert.assertEquals("07:55", full.getWeekTable().getDay(1).getLesson(0).getEndTime());
|
||||
Assert.assertEquals("19:00", full.getWeekTable().getDay(3).getLesson(13).getEndTime());
|
||||
Assert.assertEquals("19:00", holidays.getWeekTable().getDay(3).getLesson(13).getEndTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonIsEmptyTest() throws Exception {
|
||||
Assert.assertFalse(std.getWeekTable().getDay(1).getLesson(4).isEmpty());
|
||||
Assert.assertTrue(std.getWeekTable().getDay(3).getLesson(7).isEmpty());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(1).getLesson(2).isEmpty());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(0).getLesson(7).isEmpty());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(2).getLesson(9).isEmpty());
|
||||
Assert.assertTrue(holidays.getWeekTable().getDay(0).getLesson(5).isEmpty());
|
||||
Assert.assertTrue(holidays.getWeekTable().getDay(4).getLesson(13).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonIsDivisionIntoGroupsTest() throws Exception {
|
||||
Assert.assertTrue(std.getWeekTable().getDay(0).getLesson(2).isDivisionIntoGroups());
|
||||
Assert.assertTrue(std.getWeekTable().getDay(4).getLesson(0).isDivisionIntoGroups());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(0).getLesson(7).isDivisionIntoGroups());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(3).isDivisionIntoGroups());
|
||||
Assert.assertFalse(holidays.getWeekTable().getDay(3).getLesson(3).isDivisionIntoGroups());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonIsPlanningTest() throws Exception {
|
||||
Assert.assertFalse(std.getWeekTable().getDay(4).getLesson(4).isPlanning());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(0).getLesson(1).isPlanning());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(1).getLesson(3).isPlanning());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(4).getLesson(0).isPlanning());
|
||||
Assert.assertFalse(holidays.getWeekTable().getDay(3).getLesson(3).isPlanning());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonIsRealizedTest() throws Exception {
|
||||
Assert.assertTrue(std.getWeekTable().getDay(3).getLesson(3).isRealized());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(0).getLesson(1).isRealized());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(3).isRealized());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(0).isRealized());
|
||||
Assert.assertFalse(holidays.getWeekTable().getDay(3).getLesson(3).isRealized());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonIsMovedOrCanceledTest() throws Exception {
|
||||
Assert.assertFalse(std.getWeekTable().getDay(3).getLesson(3).isMovedOrCanceled());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(0).getLesson(7).isMovedOrCanceled());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(1).getLesson(3).isMovedOrCanceled());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(0).isMovedOrCanceled());
|
||||
Assert.assertFalse(holidays.getWeekTable().getDay(3).getLesson(3).isMovedOrCanceled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLessonIsNewMovedInOrChangedTest() throws Exception {
|
||||
Assert.assertFalse(std.getWeekTable().getDay(3).getLesson(3).isNewMovedInOrChanged());
|
||||
Assert.assertFalse(full.getWeekTable().getDay(0).getLesson(1).isNewMovedInOrChanged());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(2).isNewMovedInOrChanged());
|
||||
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(3).isNewMovedInOrChanged());
|
||||
Assert.assertFalse(holidays.getWeekTable().getDay(3).getLesson(3).isNewMovedInOrChanged());
|
||||
}
|
||||
}
|
@ -4,47 +4,103 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BasicInformationTest extends UserTest {
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class BasicInformationTest extends StudentAndParentTestCase {
|
||||
|
||||
private BasicInformation basicInformation;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
basicInformation = new BasicInformation(snp);
|
||||
basicInformation = new BasicInformation(getSnp("UczenDanePodstawowe.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPersonalData() throws Exception {
|
||||
PersonalData data = basicInformation.getPersonalData();
|
||||
|
||||
Assert.assertEquals("Maria", data.getFirstName());
|
||||
Assert.assertEquals("Kamińska", data.getSurname());
|
||||
Assert.assertEquals("Maria Kamińska", data.getFirstAndLastName());
|
||||
Assert.assertEquals("Maria Aneta Kamińska", data.getName());
|
||||
Assert.assertEquals("01.01.1900, Warszawa", data.getDateAndBirthPlace());
|
||||
Assert.assertEquals("12345678900", data.getPesel());
|
||||
Assert.assertEquals("Kobieta", data.getGender());
|
||||
Assert.assertTrue(data.isPolishCitizenship());
|
||||
Assert.assertEquals("Nowak", data.getFamilyName());
|
||||
Assert.assertEquals("Gabriela, Kamil", data.getParentsNames());
|
||||
public void getPersonalFirstNameTest() throws Exception {
|
||||
Assert.assertEquals("Maria", basicInformation.getPersonalData().getFirstName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAddressData() throws Exception {
|
||||
AddressData data = basicInformation.getAddressData();
|
||||
|
||||
Assert.assertEquals("ul. Sportowa 16, 00-123 Warszawa", data.getAddress());
|
||||
Assert.assertEquals("ul. Sportowa 17, 00-123 Warszawa", data.getRegisteredAddress());
|
||||
Assert.assertEquals("ul. Sportowa 18, 00-123 Warszawa", data.getCorrespondenceAddress());
|
||||
public void getPersonalSurnameTest() throws Exception {
|
||||
Assert.assertEquals("Kamińska", basicInformation.getPersonalData().getSurname());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContactDetails() throws Exception {
|
||||
ContactDetails data = basicInformation.getContactDetails();
|
||||
public void getPersonalFirstAndLastNameTest() throws Exception {
|
||||
Assert.assertEquals("Maria Kamińska",
|
||||
basicInformation.getPersonalData().getFirstAndLastName());
|
||||
}
|
||||
|
||||
Assert.assertEquals("005554433", data.getPhoneNumber());
|
||||
Assert.assertEquals("555444333", data.getCellPhoneNumber());
|
||||
Assert.assertEquals("wulkanowy@example.null", data.getEmail());
|
||||
@Test
|
||||
public void getPersonalNameTest() throws Exception {
|
||||
Assert.assertEquals("Maria Aneta Kamińska", basicInformation.getPersonalData().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPersonalDateAndBirthPlaceTest() throws Exception {
|
||||
Assert.assertEquals("01.01.1900, Warszawa",
|
||||
basicInformation.getPersonalData().getDateAndBirthPlace());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPersonalPeselTest() throws Exception {
|
||||
Assert.assertEquals("12345678900", basicInformation.getPersonalData().getPesel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPersonalGenderTest() throws Exception {
|
||||
Assert.assertEquals("Kobieta", basicInformation.getPersonalData().getGender());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPersonalPolishCitizenshipTest() throws Exception {
|
||||
Assert.assertTrue(basicInformation.getPersonalData().isPolishCitizenship());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPersonalFamilyNameTest() throws Exception {
|
||||
Assert.assertEquals("Nowak", basicInformation.getPersonalData().getFamilyName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPersonalParentsNames() throws Exception {
|
||||
Assert.assertEquals("Gabriela, Kamil",
|
||||
basicInformation.getPersonalData().getParentsNames());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBasicAddressTest() throws Exception {
|
||||
Assert.assertEquals("ul. Sportowa 16, 00-123 Warszawa",
|
||||
basicInformation.getAddressData().getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBasicRegisteredAddressTest() throws Exception {
|
||||
Assert.assertEquals("ul. Sportowa 17, 00-123 Warszawa",
|
||||
basicInformation.getAddressData().getRegisteredAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBasicCorrespondenceAddressTest() throws Exception {
|
||||
Assert.assertEquals("ul. Sportowa 18, 00-123 Warszawa",
|
||||
basicInformation.getAddressData().getCorrespondenceAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContactPhoneNumberTest() throws Exception {
|
||||
Assert.assertEquals("005554433",
|
||||
basicInformation.getContactDetails().getPhoneNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContactCellPhoneNumberTest() throws Exception {
|
||||
Assert.assertEquals("555444333",
|
||||
basicInformation.getContactDetails().getCellPhoneNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContactEmailTest() throws Exception {
|
||||
Assert.assertEquals("wulkanowy@example.null",
|
||||
basicInformation.getContactDetails().getEmail());
|
||||
}
|
||||
}
|
||||
|
@ -6,34 +6,54 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FamilyInformationTest extends UserTest {
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
|
||||
public class FamilyInformationTest extends StudentAndParentTestCase {
|
||||
|
||||
private FamilyInformation familyInformation;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
familyInformation = new FamilyInformation(snp);
|
||||
familyInformation = new FamilyInformation(getSnp("UczenDanePodstawowe.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFamilyMembers() throws Exception {
|
||||
List<FamilyMember> familyMemberList = familyInformation.getFamilyMembers();
|
||||
Assert.assertEquals(2, familyInformation.getFamilyMembers().size());
|
||||
}
|
||||
|
||||
Assert.assertEquals(2, familyMemberList.size());
|
||||
@Test
|
||||
public void getNameTest() throws Exception {
|
||||
List<FamilyMember> list = familyInformation.getFamilyMembers();
|
||||
Assert.assertEquals("Marianna Pająk", list.get(0).getName());
|
||||
Assert.assertEquals("Dawid Świątek", list.get(1).getName());
|
||||
}
|
||||
|
||||
FamilyMember member0 = familyMemberList.get(0);
|
||||
Assert.assertEquals("Marianna Pająk", member0.getName());
|
||||
Assert.assertEquals("matka", member0.getKinship());
|
||||
Assert.assertEquals("ul. Sportowa 16, 00-123 Warszawa", member0.getAddress());
|
||||
Assert.assertEquals("555111222", member0.getTelephones());
|
||||
Assert.assertEquals("wulkanowy@example.null", member0.getEmail());
|
||||
@Test
|
||||
public void getKinshipTest() throws Exception {
|
||||
List<FamilyMember> list = familyInformation.getFamilyMembers();
|
||||
Assert.assertEquals("matka", list.get(0).getKinship());
|
||||
Assert.assertEquals("ojciec", list.get(1).getKinship());
|
||||
}
|
||||
|
||||
FamilyMember member1 = familyMemberList.get(1);
|
||||
Assert.assertEquals("Dawid Świątek", member1.getName());
|
||||
Assert.assertEquals("ojciec", member1.getKinship());
|
||||
Assert.assertEquals("ul. Sportowa 18, 00-123 Warszawa", member1.getAddress());
|
||||
Assert.assertEquals("555222111", member1.getTelephones());
|
||||
Assert.assertEquals("wulkanowy@example.null", member1.getEmail());
|
||||
@Test
|
||||
public void getAddressTest() throws Exception {
|
||||
List<FamilyMember> list = familyInformation.getFamilyMembers();
|
||||
Assert.assertEquals("ul. Sportowa 16, 00-123 Warszawa", list.get(0).getAddress());
|
||||
Assert.assertEquals("ul. Sportowa 18, 00-123 Warszawa", list.get(1).getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTelephonesTest() throws Exception {
|
||||
List<FamilyMember> list = familyInformation.getFamilyMembers();
|
||||
Assert.assertEquals("555111222", list.get(0).getTelephones());
|
||||
Assert.assertEquals("555222111", list.get(1).getTelephones());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEmailTest() throws Exception {
|
||||
List<FamilyMember> list = familyInformation.getFamilyMembers();
|
||||
Assert.assertEquals("wulkanowy@example.null", list.get(0).getEmail());
|
||||
Assert.assertEquals("wulkanowy@example.null", list.get(1).getEmail());
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.junit.Before;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class UserTest {
|
||||
|
||||
protected StudentAndParent snp;
|
||||
|
||||
private String fixtureFileName = "UczenDanePodstawowe.html";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document pageDocument = Jsoup.parse(input);
|
||||
|
||||
snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(pageDocument);
|
||||
Mockito.when(snp.getRowDataChildValue(Mockito.any(Element.class), Mockito.anyInt()))
|
||||
.thenCallRealMethod();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user