forked from github/wulkanowy-mirror
API improvements (#13)
This commit is contained in:
@ -11,6 +11,8 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.login.LoginErrorException;
|
||||
|
||||
public class StudentAndParentTest {
|
||||
|
||||
private String fixtureFileName = "OcenyWszystkie-semester.html";
|
||||
@ -26,8 +28,8 @@ public class StudentAndParentTest {
|
||||
PowerMockito.whenNew(StudentAndParent.class)
|
||||
.withArguments(Mockito.any(Cookies.class), Mockito.anyString()).thenReturn(snp);
|
||||
|
||||
Mockito.when(snp.getPageByUrl(Mockito.anyString())).thenReturn(gradesPageDocument);
|
||||
Mockito.when(snp.getGradesPageUrl()).thenReturn("http://example.null");
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(gradesPageDocument);
|
||||
Mockito.when(snp.getCalculatedID(Mockito.anyString())).thenCallRealMethod();
|
||||
Mockito.when(snp.getLocationID()).thenReturn("symbol");
|
||||
Mockito.when(snp.getID()).thenReturn("123456");
|
||||
Mockito.when(snp.getSemesters()).thenCallRealMethod();
|
||||
@ -36,6 +38,24 @@ public class StudentAndParentTest {
|
||||
.thenCallRealMethod();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCalculatedIDStandardTest() throws Exception {
|
||||
Assert.assertEquals("123456", snp.getCalculatedID("https://uonetplus-opiekun"
|
||||
+ ".vulcan.net.pl/powiat/123456/Start/Index/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCalculatedIDDemoTest() throws Exception {
|
||||
Assert.assertEquals("demo12345", snp.getCalculatedID("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"
|
||||
+ ".vulcan.net.pl/powiat/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSemestersTest() throws Exception {
|
||||
List<Semester> semesters = snp.getSemesters();
|
||||
@ -61,4 +81,11 @@ public class StudentAndParentTest {
|
||||
Assert.assertEquals("2", snp.getCurrentSemester(semesters).getId());
|
||||
Assert.assertEquals("1500100901", snp.getCurrentSemester(semesters).getNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentSemesterFromEmptyTest() throws Exception {
|
||||
List<Semester> semesters = new ArrayList<>();
|
||||
|
||||
Assert.assertNull(snp.getCurrentSemester(semesters));
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,12 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
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 org.powermock.api.mockito.PowerMockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.Semester;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class GradesListTest {
|
||||
public class GradesListTest extends GradesTest {
|
||||
|
||||
private String fixtureFileName = "OcenyWszystkie-filled.html";
|
||||
|
||||
@ -22,25 +14,9 @@ public class GradesListTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
Document gradesPageDocument = Jsoup.parse(input);
|
||||
super.setUp(fixtureFileName);
|
||||
|
||||
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
|
||||
PowerMockito.whenNew(StudentAndParent.class).withAnyArguments().thenReturn(snp);
|
||||
Mockito.when(snp.getLocationID()).thenReturn("symbol");
|
||||
Mockito.when(snp.getID()).thenReturn("123456");
|
||||
Mockito.when(snp.getGradesPageUrl()).thenReturn("http://example.null");
|
||||
Mockito.when(snp.getSemesters()).thenCallRealMethod();
|
||||
Mockito.when(snp.getSemesters(Mockito.any(Document.class))).thenCallRealMethod();
|
||||
Mockito.when(snp.getCurrentSemester(Mockito.anyListOf(Semester.class)))
|
||||
.thenCallRealMethod();
|
||||
|
||||
Grades grades = Mockito.mock(Grades.class);
|
||||
PowerMockito.whenNew(Grades.class).withAnyArguments().thenReturn(grades);
|
||||
Mockito.when(grades.getGradesPageDocument(Mockito.anyString()))
|
||||
.thenReturn(gradesPageDocument);
|
||||
|
||||
gradesList = new GradesList(grades, snp);
|
||||
gradesList = new GradesList(snp);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -0,0 +1,26 @@
|
||||
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.anyListOf(Semester.class)))
|
||||
.thenCallRealMethod();
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubjectsListTest extends GradesTest {
|
||||
|
||||
private String fixtureStdFileName = "OcenyWszystkie-subjects.html";
|
||||
|
||||
private String fixtureAverageFileName = "OcenyWszystkie-subjects-average.html";
|
||||
|
||||
public SubjectsList getSetUpSubjectsList(String fixtureFileName) throws Exception {
|
||||
super.setUp(fixtureFileName);
|
||||
|
||||
return new SubjectsList(snp);
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllAverageTest() throws Exception {
|
||||
List<Subject> list = getSetUpSubjectsList(fixtureAverageFileName).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("Język polski", subject1.getName());
|
||||
Assert.assertEquals("-", subject1.getPredictedRating());
|
||||
Assert.assertEquals("dobry", subject1.getFinalRating());
|
||||
|
||||
Subject subject2 = list.get(2);
|
||||
Assert.assertEquals("Wychowanie fizyczne", subject2.getName());
|
||||
Assert.assertEquals("bardzo dobry", subject2.getPredictedRating());
|
||||
Assert.assertEquals("celujący", subject2.getFinalRating());
|
||||
|
||||
Subject subject3 = list.get(3);
|
||||
Assert.assertEquals("Język angielski", subject3.getName());
|
||||
Assert.assertEquals("4/5", subject3.getPredictedRating());
|
||||
Assert.assertEquals("bardzo dobry", subject3.getFinalRating());
|
||||
|
||||
Subject subject4 = list.get(4);
|
||||
Assert.assertEquals("Wiedza o społeczeństwie", subject4.getName());
|
||||
Assert.assertEquals("-", subject4.getPredictedRating());
|
||||
Assert.assertEquals("-", subject4.getFinalRating());
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package io.github.wulkanowy.api.login;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LoginTest {
|
||||
|
||||
|
@ -5,12 +5,11 @@ import org.jsoup.nodes.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.unitils.reflectionassert.ReflectionAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class AchievementsListTest {
|
||||
|
||||
@ -23,33 +22,25 @@ public class AchievementsListTest {
|
||||
|
||||
Document notesPageDocument = Jsoup.parse(input);
|
||||
|
||||
Notes notes = Mockito.mock(Notes.class);
|
||||
Mockito.when(notes.getNotesPageDocument()).thenReturn(notesPageDocument);
|
||||
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(notesPageDocument);
|
||||
|
||||
return new AchievementsList(notes);
|
||||
return new AchievementsList(snp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllAchievementsFilledTest() throws Exception {
|
||||
List<String> expectedList = new ArrayList<>();
|
||||
expectedList.add("I miejsce w ogólnopolskim konkursie ortograficznym");
|
||||
expectedList.add("III miejsce w ogólnopolskim konkursie plastycznym");
|
||||
List<String> list = getSetUpAchievementsList(fixtureFilledFileName).getAllAchievements();
|
||||
|
||||
List<String> actualList = getSetUpAchievementsList(
|
||||
fixtureFilledFileName).getAllAchievements();
|
||||
|
||||
Assert.assertEquals(2, actualList.size());
|
||||
ReflectionAssert.assertReflectionEquals(expectedList, actualList);
|
||||
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));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllAchievementsEmptyTest() throws Exception {
|
||||
List<String> expectedList = new ArrayList<>();
|
||||
List<String> list = getSetUpAchievementsList(fixtureEmptyFileName).getAllAchievements();
|
||||
|
||||
List<String> actualList = getSetUpAchievementsList(
|
||||
fixtureEmptyFileName).getAllAchievements();
|
||||
|
||||
Assert.assertEquals(0, actualList.size());
|
||||
ReflectionAssert.assertReflectionEquals(expectedList, actualList);
|
||||
Assert.assertEquals(0, list.size());
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,7 @@ import org.jsoup.nodes.Element;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.unitils.reflectionassert.ReflectionAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.FixtureHelper;
|
||||
@ -25,50 +23,35 @@ public class NotesListTest {
|
||||
|
||||
Document notesPageDocument = Jsoup.parse(input);
|
||||
|
||||
Notes notes = Mockito.mock(Notes.class);
|
||||
Mockito.when(notes.getNotesPageDocument()).thenReturn(notesPageDocument);
|
||||
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(notes, snp);
|
||||
return new NotesList(snp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllNotesFilledTest() throws Exception {
|
||||
List<Note> expectedList = new ArrayList<>();
|
||||
expectedList.add(new Note()
|
||||
.setDate("06.06.2017")
|
||||
.setTeacher("Jan Kowalski [JK]")
|
||||
.setCategory("Zaangażowanie społeczne")
|
||||
.setContent("Pomoc przy pikniku charytatywnym")
|
||||
);
|
||||
expectedList.add(new Note()
|
||||
.setDate("01.12.2016")
|
||||
.setTeacher("Ochocka Zofia [PZ]")
|
||||
.setCategory("Reprezentowanie szkoły")
|
||||
.setContent("Udział w przygotowaniu spektaklu")
|
||||
);
|
||||
expectedList.add(new Note()
|
||||
.setDate("01.10.2016")
|
||||
.setTeacher("Kochański Leszek [KL]")
|
||||
.setCategory("Zachowanie na lekcji")
|
||||
.setContent("Przeszkadzanie w prowadzeniu lekcji")
|
||||
);
|
||||
List<Note> list = getSetUpNotesList(fixtureFilledFileName).getAllNotes();
|
||||
|
||||
List<Note> actualList = getSetUpNotesList(fixtureFilledFileName).getAllNotes();
|
||||
Assert.assertEquals(3, list.size());
|
||||
|
||||
Assert.assertEquals(3, actualList.size());
|
||||
ReflectionAssert.assertReflectionEquals(expectedList, actualList);
|
||||
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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllNotesWhenEmpty() throws Exception {
|
||||
List<Note> actualList = getSetUpNotesList(fixtureEmptyFileName).getAllNotes();
|
||||
List<Note> list = getSetUpNotesList(fixtureEmptyFileName).getAllNotes();
|
||||
|
||||
List<Note> expectedList = new ArrayList<>();
|
||||
|
||||
Assert.assertEquals(0, actualList.size());
|
||||
ReflectionAssert.assertReflectionEquals(expectedList, actualList);
|
||||
Assert.assertEquals(0, list.size());
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class SchoolInfoTest extends SchoolTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
schoolInfo = new SchoolInfo(school, snp);
|
||||
schoolInfo = new SchoolInfo(snp);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -11,7 +11,6 @@ import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class SchoolTest {
|
||||
|
||||
protected School school;
|
||||
protected StudentAndParent snp;
|
||||
private String fixtureFileName = "Szkola.html";
|
||||
|
||||
@ -21,9 +20,8 @@ public class SchoolTest {
|
||||
|
||||
Document schoolPageDocument = Jsoup.parse(input);
|
||||
|
||||
school = Mockito.mock(School.class);
|
||||
Mockito.when(school.getSchoolPageDocument()).thenReturn(schoolPageDocument);
|
||||
snp = Mockito.mock(StudentAndParent.class);
|
||||
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(schoolPageDocument);
|
||||
Mockito.when(snp.getRowDataChildValue(Mockito.any(Element.class),
|
||||
Mockito.anyInt())).thenCallRealMethod();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class TeachersInfoTest extends SchoolTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
teachersInfo = new TeachersInfo(school);
|
||||
teachersInfo = new TeachersInfo(snp);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -7,27 +7,31 @@ 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 tick, String fixtureFileName) throws Exception {
|
||||
private Table getSetUpTable(String fixtureFileName) throws Exception {
|
||||
String input = FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
|
||||
|
||||
Document tablePageDocument = Jsoup.parse(input);
|
||||
|
||||
Timetable timetable = Mockito.mock(Timetable.class);
|
||||
Mockito.when(timetable.getTablePageDocument(tick)).thenReturn(tablePageDocument);
|
||||
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);
|
||||
Table table = getSetUpTable(fixtureStdFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertEquals(5, week.getDays().size());
|
||||
@ -41,7 +45,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableStandardLessonStartEndEndTest() throws Exception {
|
||||
Table tableStd = getSetUpTable("", fixtureStdFileName);
|
||||
Table tableStd = getSetUpTable(fixtureStdFileName);
|
||||
Week stdWeek = tableStd.getWeekTable();
|
||||
|
||||
Assert.assertEquals("08:00", stdWeek.getDay(0).getLesson(0).getStartTime());
|
||||
@ -49,7 +53,7 @@ public class TableTest {
|
||||
Assert.assertEquals("12:15", stdWeek.getDay(2).getLesson(4).getEndTime());
|
||||
Assert.assertEquals("14:10", stdWeek.getDay(3).getLesson(7).getStartTime());
|
||||
|
||||
Table tableFull = getSetUpTable("", fixtureFullFileName);
|
||||
Table tableFull = getSetUpTable(fixtureFullFileName);
|
||||
Week fullWeek = tableFull.getWeekTable();
|
||||
|
||||
Assert.assertEquals("07:10", fullWeek.getDay(0).getLesson(0).getStartTime());
|
||||
@ -61,7 +65,7 @@ public class TableTest {
|
||||
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void getWeekTableStandardOutOfBoundsIndex() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureStdFileName);
|
||||
Table table = getSetUpTable(fixtureStdFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
week.getDay(5);
|
||||
@ -69,7 +73,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableHolidaysTest() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureHolidaysFileName);
|
||||
Table table = getSetUpTable(fixtureHolidaysFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertTrue(week.getDay(1).isFreeDay());
|
||||
@ -84,7 +88,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableHolidaysWithEmptyLessonsTest() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureHolidaysFileName);
|
||||
Table table = getSetUpTable(fixtureHolidaysFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertEquals(5, week.getDays().size());
|
||||
@ -97,7 +101,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullTest() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureFullFileName);
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
Assert.assertFalse(week.getDay(1).getLesson(2).isEmpty());
|
||||
@ -105,7 +109,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullLessonsGroupsDivisionTest() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureFullFileName);
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
// class="", span*4
|
||||
@ -136,7 +140,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullLessonsTypesTest() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureFullFileName);
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
// class="", span*4
|
||||
@ -177,7 +181,7 @@ public class TableTest {
|
||||
|
||||
@Test
|
||||
public void getWeekTableFullLessonsBasicInfoTest() throws Exception {
|
||||
Table table = getSetUpTable("", fixtureFullFileName);
|
||||
Table table = getSetUpTable(fixtureFullFileName);
|
||||
Week week = table.getWeekTable();
|
||||
|
||||
// class="", span*4
|
||||
|
@ -0,0 +1,50 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BasicInformationTest extends UserTest {
|
||||
|
||||
private BasicInformation basicInformation;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
basicInformation = new BasicInformation(snp);
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContactDetails() throws Exception {
|
||||
ContactDetails data = basicInformation.getContactDetails();
|
||||
|
||||
Assert.assertEquals("005554433", data.getPhoneNumber());
|
||||
Assert.assertEquals("555444333", data.getCellPhoneNumber());
|
||||
Assert.assertEquals("wulkanowy@example.null", data.getEmail());
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FamilyInformationTest extends UserTest {
|
||||
|
||||
private FamilyInformation familyInformation;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
familyInformation = new FamilyInformation(snp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFamilyMembers() throws Exception {
|
||||
List<FamilyMember> familyMemberList = familyInformation.getFamilyMembers();
|
||||
|
||||
Assert.assertEquals(2, familyMemberList.size());
|
||||
|
||||
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());
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
29
app/src/test/java/io/github/wulkanowy/api/user/UserTest.java
Normal file
29
app/src/test/java/io/github/wulkanowy/api/user/UserTest.java
Normal file
@ -0,0 +1,29 @@
|
||||
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