API as java module (#34)

This commit is contained in:
Mikołaj Pich
2017-11-18 22:17:18 +01:00
committed by Rafał Borcz
parent 428b372827
commit 29d12b79ca
90 changed files with 352 additions and 34 deletions

View File

@ -1,12 +0,0 @@
package io.github.wulkanowy.api;
import java.io.InputStream;
import java.util.Scanner;
public class FixtureHelper {
public static String getAsString(InputStream inputStream) {
Scanner s = new Scanner(inputStream).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
}

View File

@ -1,131 +0,0 @@
package io.github.wulkanowy.api;
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.ArrayList;
import java.util.List;
import io.github.wulkanowy.api.login.NotLoggedInErrorException;
public class StudentAndParentTest {
private StudentAndParent snp;
@Before
public void setUp() throws Exception {
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.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();
Mockito.when(snp.getGradesPageUrl()).thenReturn("http://wulkanowy.null");
Mockito.when(snp.getSemesters(Mockito.any(Document.class))).thenCallRealMethod();
Mockito.when(snp.getCurrentSemester(Mockito.<Semester>anyList())).thenCallRealMethod();
}
@Test
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 getExtractedIDDemoTest() throws Exception {
Assert.assertEquals("demo12345", snp.getExtractedIdFromUrl("https://uonetplus-opiekundemo"
+ ".vulcan.net.pl/demoupowiat/demo12345/Start/Index/"));
}
@Test(expected = NotLoggedInErrorException.class)
public void getExtractedIDNotLoggedTest() throws Exception {
Assert.assertEquals("123", snp.getExtractedIdFromUrl("https://uonetplus"
+ ".vulcan.net.pl/powiat/"));
}
@Test
public void getSemestersTest() throws Exception {
List<Semester> semesters = snp.getSemesters();
Assert.assertEquals(2, semesters.size());
Assert.assertEquals("1", semesters.get(0).getId());
Assert.assertEquals("1234", semesters.get(0).getNumber());
Assert.assertFalse(semesters.get(0).isCurrent());
Assert.assertEquals("2", semesters.get(1).getId());
Assert.assertEquals("1235", semesters.get(1).getNumber());
Assert.assertTrue(semesters.get(1).isCurrent());
}
@Test
public void getCurrentSemesterTest() throws Exception {
List<Semester> semesters = new ArrayList<>();
semesters.add(new Semester().setNumber("1500100900").setId("1").setCurrent(false));
semesters.add(new Semester().setNumber("1500100901").setId("2").setCurrent(true));
Assert.assertTrue(snp.getCurrentSemester(semesters).isCurrent());
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));
}
}

View File

@ -1,26 +0,0 @@
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;
}
}

View File

@ -1,158 +0,0 @@
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
public void getStudentAndParentTest() throws Exception {
Cookies cookies = new Cookies();
Vulcan vulcan = Mockito.mock(Vulcan.class);
Mockito.when(vulcan.getCookiesObject()).thenReturn(cookies);
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
Mockito.doNothing().when(snp).storeContextCookies();
Mockito.when(snp.getCookiesObject()).thenReturn(cookies);
Mockito.when(vulcan.createSnp( // nullable because method uses class vars, refactor?
Mockito.nullable(Cookies.class), Mockito.nullable(String.class), Mockito.nullable(String.class)
)).thenReturn(snp);
Mockito.when(vulcan.getStudentAndParent()).thenCallRealMethod();
StudentAndParent vulcanSnP = vulcan.getStudentAndParent();
Assert.assertEquals(snp, vulcanSnP);
Assert.assertEquals(vulcanSnP, vulcan.getStudentAndParent());
}
@Test(expected = NotLoggedInErrorException.class)
public void getStudentAndParentNotLoggedInTest() throws Exception {
Mockito.when(vulcan.getStudentAndParent()).thenCallRealMethod();
vulcan.getStudentAndParent();
}
@Test
public void createSnPTest() throws Exception {
Vulcan vulcan = new Vulcan();
vulcan.login(new Cookies(), "testSymbol");
Assert.assertThat(vulcan.createSnp(new Cookies(), "testSymbol", null),
CoreMatchers.instanceOf(StudentAndParent.class));
Assert.assertThat(vulcan.createSnp(new Cookies(), "testSymbol", "testId"),
CoreMatchers.instanceOf(StudentAndParent.class));
}
@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));
}
}

View File

@ -1,143 +0,0 @@
package io.github.wulkanowy.api.attendance;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class AttendanceStatisticsTest extends StudentAndParentTestCase {
private AttendanceStatistics excellent;
private AttendanceStatistics full;
@Before
public void setUp() throws Exception {
this.excellent = new AttendanceStatistics(getSnp("Frekwencja-excellent.html"));
this.full = new AttendanceStatistics(getSnp("Frekwencja-full.html"));
}
@Test
public void getSubjectList() throws Exception {
Assert.assertEquals(26, excellent.getSubjectList().size());
Assert.assertEquals(23, full.getSubjectList().size());
}
@Test
public void getSubjectListId() throws Exception {
Assert.assertEquals(-1, excellent.getSubjectList().get(0).getId());
Assert.assertEquals(63, excellent.getSubjectList().get(10).getId());
Assert.assertEquals(0, excellent.getSubjectList().get(25).getId());
Assert.assertEquals(-1, full.getSubjectList().get(0).getId());
Assert.assertEquals(108, full.getSubjectList().get(14).getId());
Assert.assertEquals(492, full.getSubjectList().get(21).getId());
}
@Test
public void getSubjectListName() throws Exception {
Assert.assertEquals("Wszystkie", excellent.getSubjectList().get(0).getName());
Assert.assertEquals("Fizyka", excellent.getSubjectList().get(8).getName());
Assert.assertEquals("Sieci komputerowe i administrowanie sieciami",
excellent.getSubjectList().get(21).getName());
Assert.assertEquals("Praktyka zawodowa", full.getSubjectList().get(11).getName());
Assert.assertEquals("Użytkowanie urządzeń peryferyjnych komputera",
full.getSubjectList().get(16).getName());
Assert.assertEquals("Brak opisu lekcji", full.getSubjectList().get(22).getName());
}
@Test
public void getTypesTotal() throws Exception {
Assert.assertEquals(100.0, excellent.getTypesTable().getTotal(), 0);
Assert.assertEquals(80.94, full.getTypesTable().getTotal(), 0);
}
@Test
public void getTypeName() throws Exception {
List<Type> typeList1 = excellent.getTypesTable().getTypeList();
Assert.assertEquals("Obecność", typeList1.get(0).getName());
Assert.assertEquals("Nieobecność nieusprawiedliwiona", typeList1.get(1).getName());
Assert.assertEquals("Nieobecność usprawiedliwiona", typeList1.get(2).getName());
Assert.assertEquals("Nieobecność z przyczyn szkolnych", typeList1.get(3).getName());
List<Type> typeList2 = full.getTypesTable().getTypeList();
Assert.assertEquals("Spóźnienie nieusprawiedliwione", typeList2.get(4).getName());
Assert.assertEquals("Spóźnienie usprawiedliwione", typeList2.get(5).getName());
Assert.assertEquals("Zwolnienie", typeList2.get(6).getName());
}
@Test
public void getTypeTotal() throws Exception {
List<Type> typeList1 = excellent.getTypesTable().getTypeList();
Assert.assertEquals(1211, typeList1.get(0).getTotal());
Assert.assertEquals(0, typeList1.get(1).getTotal());
Assert.assertEquals(0, typeList1.get(2).getTotal());
Assert.assertEquals(0, typeList1.get(3).getTotal());
Assert.assertEquals(0, typeList1.get(4).getTotal());
Assert.assertEquals(0, typeList1.get(5).getTotal());
Assert.assertEquals(0, typeList1.get(6).getTotal());
List<Type> typeList2 = full.getTypesTable().getTypeList();
Assert.assertEquals(822, typeList2.get(0).getTotal());
Assert.assertEquals(6, typeList2.get(1).getTotal());
Assert.assertEquals(192, typeList2.get(2).getTotal());
Assert.assertEquals(7, typeList2.get(3).getTotal());
Assert.assertEquals(12, typeList2.get(4).getTotal());
Assert.assertEquals(1, typeList2.get(5).getTotal());
Assert.assertEquals(2, typeList2.get(6).getTotal());
}
@Test
public void getTypeList() throws Exception {
List<Type> typesList1 = excellent.getTypesTable().getTypeList();
Assert.assertEquals(12, typesList1.get(0).getMonthList().size());
Assert.assertEquals(12, typesList1.get(5).getMonthList().size());
List<Type> typesList2 = full.getTypesTable().getTypeList();
Assert.assertEquals(12, typesList2.get(0).getMonthList().size());
Assert.assertEquals(12, typesList2.get(5).getMonthList().size());
}
@Test
public void getMonthList() throws Exception {
List<Type> typeList1 = excellent.getTypesTable().getTypeList();
Assert.assertEquals(12, typeList1.get(0).getMonthList().size());
List<Type> typeList2 = full.getTypesTable().getTypeList();
Assert.assertEquals(12, typeList2.get(0).getMonthList().size());
}
@Test
public void getMonthName() throws Exception {
List<Month> monthsList1 = excellent.getTypesTable().getTypeList().get(0).getMonthList();
Assert.assertEquals("IX", monthsList1.get(0).getName());
Assert.assertEquals("III", monthsList1.get(6).getName());
Assert.assertEquals("VIII", monthsList1.get(11).getName());
List<Month> monthsList2 = full.getTypesTable().getTypeList().get(0).getMonthList();
Assert.assertEquals("XI", monthsList2.get(2).getName());
Assert.assertEquals("II", monthsList2.get(5).getName());
Assert.assertEquals("VI", monthsList2.get(9).getName());
}
@Test
public void getMonthValue() throws Exception {
List<Month> monthsList1 = excellent.getTypesTable().getTypeList().get(0).getMonthList();
Assert.assertEquals(142, monthsList1.get(0).getValue());
Assert.assertEquals(131, monthsList1.get(4).getValue());
Assert.assertEquals(139, monthsList1.get(7).getValue());
Assert.assertEquals(114, monthsList1.get(9).getValue());
Assert.assertEquals(0, monthsList1.get(11).getValue());
List<Type> typeList1 = full.getTypesTable().getTypeList();
Assert.assertEquals(135, typeList1.get(0).getMonthList().get(0).getValue());
Assert.assertEquals(7, typeList1.get(3).getMonthList().get(5).getValue());
Assert.assertEquals(1, typeList1.get(5).getMonthList().get(0).getValue());
Assert.assertEquals(27, typeList1.get(2).getMonthList().get(9).getValue());
Assert.assertEquals(0, typeList1.get(0).getMonthList().get(11).getValue());
}
}

View File

@ -1,165 +0,0 @@
package io.github.wulkanowy.api.attendance;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class AttendanceTableTest extends StudentAndParentTestCase {
private AttendanceTable excellent;
private AttendanceTable full;
@Before
public void setUp() throws Exception {
excellent = new AttendanceTable(getSnp("Frekwencja-excellent.html"));
full = new AttendanceTable(getSnp("Frekwencja-full.html"));
}
@Test
public void getWeekStartByDate() throws Exception {
Assert.assertEquals("31.08.2015", excellent.getWeekTable().getStartDayDate());
Assert.assertEquals("05.09.2016", full.getWeekTable().getStartDayDate());
}
@Test
public void getWeekDaysNumber() throws Exception {
Assert.assertEquals(5, excellent.getWeekTable().getDays().size());
Assert.assertEquals(5, full.getWeekTable().getDays().size());
}
@Test
public void getDayLessonsNumber() throws Exception {
Assert.assertEquals(14, excellent.getWeekTable().getDay(0).getLessons().size());
Assert.assertEquals(14, full.getWeekTable().getDay(0).getLessons().size());
}
@Test
public void getDayDate() throws Exception {
Assert.assertEquals("31.08.2015", excellent.getWeekTable().getDay(0).getDate());
Assert.assertEquals("02.09.2015", excellent.getWeekTable().getDay(2).getDate());
Assert.assertEquals("04.09.2015", excellent.getWeekTable().getDay(4).getDate());
Assert.assertEquals("05.09.2016", full.getWeekTable().getDay(0).getDate());
Assert.assertEquals("07.09.2016", full.getWeekTable().getDay(2).getDate());
Assert.assertEquals("09.09.2016", full.getWeekTable().getDay(4).getDate());
}
@Test
public void getLessonSubject() throws Exception {
Assert.assertEquals("",
excellent.getWeekTable().getDay(0).getLesson(7).getSubject());
Assert.assertEquals("Uroczyste rozpoczęcie roku szkolnego 2015/2016",
excellent.getWeekTable().getDay(1).getLesson(1).getSubject());
Assert.assertEquals("Geografia",
excellent.getWeekTable().getDay(3).getLesson(4).getSubject());
Assert.assertEquals("Naprawa komputera",
full.getWeekTable().getDay(1).getLesson(8).getSubject());
Assert.assertEquals("Religia",
full.getWeekTable().getDay(3).getLesson(1).getSubject());
Assert.assertEquals("Metodologia programowania",
full.getWeekTable().getDay(4).getLesson(5).getSubject());
}
@Test
public void getLessonIsNotExist() throws Exception {
Assert.assertTrue(excellent.getWeekTable().getDay(0).getLesson(5).isNotExist());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(1).isNotExist());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(12).isNotExist());
Assert.assertFalse(full.getWeekTable().getDay(1).getLesson(12).isAbsenceUnexcused());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isAbsenceUnexcused());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(5).isAbsenceUnexcused());
}
@Test
public void getLessonIsEmpty() throws Exception {
Assert.assertTrue(excellent.getWeekTable().getDay(0).getLesson(0).isEmpty());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(6).isEmpty());
Assert.assertTrue(excellent.getWeekTable().getDay(4).getLesson(12).isEmpty());
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(9).isEmpty());
Assert.assertFalse(full.getWeekTable().getDay(2).getLesson(5).isEmpty());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(2).isEmpty());
}
@Test
public void getLessonIsPresence() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(7).isPresence());
Assert.assertTrue(excellent.getWeekTable().getDay(1).getLesson(1).isPresence());
Assert.assertTrue(excellent.getWeekTable().getDay(3).getLesson(7).isPresence());
Assert.assertTrue(full.getWeekTable().getDay(0).getLesson(1).isPresence());
Assert.assertTrue(full.getWeekTable().getDay(2).getLesson(6).isPresence());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(7).isPresence());
}
@Test
public void getLessonIsAbsenceUnexcused() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(7).isAbsenceUnexcused());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(0).isAbsenceUnexcused());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(4).isAbsenceUnexcused());
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(8).isAbsenceUnexcused());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isAbsenceUnexcused());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(8).isAbsenceUnexcused());
}
@Test
public void getLessonIsAbsenceExcused() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(7).isAbsenceExcused());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(0).isAbsenceExcused());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(4).isAbsenceExcused());
Assert.assertFalse(full.getWeekTable().getDay(2).getLesson(5).isAbsenceExcused());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isAbsenceExcused());
Assert.assertTrue(full.getWeekTable().getDay(4).getLesson(3).isAbsenceExcused());
}
@Test
public void getLessonIsAbsenceForSchoolReasons() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(4).isAbsenceForSchoolReasons());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(8).isAbsenceForSchoolReasons());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(12).isAbsenceForSchoolReasons());
Assert.assertTrue(full.getWeekTable().getDay(2).getLesson(5).isAbsenceForSchoolReasons());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isAbsenceForSchoolReasons());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(8).isAbsenceForSchoolReasons());
}
@Test
public void getLessonIsUnexcusedLateness() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(4).isUnexcusedLateness());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(8).isUnexcusedLateness());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(12).isUnexcusedLateness());
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(6).isUnexcusedLateness());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isUnexcusedLateness());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(8).isUnexcusedLateness());
}
@Test
public void getLessonIsExcusedLateness() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(4).isExcusedLateness());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(8).isExcusedLateness());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(12).isExcusedLateness());
Assert.assertTrue(full.getWeekTable().getDay(1).getLesson(7).isExcusedLateness());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isExcusedLateness());
Assert.assertFalse(full.getWeekTable().getDay(4).getLesson(8).isExcusedLateness());
}
@Test
public void getLessonIsExemption() throws Exception {
Assert.assertFalse(excellent.getWeekTable().getDay(0).getLesson(4).isExemption());
Assert.assertFalse(excellent.getWeekTable().getDay(2).getLesson(8).isExemption());
Assert.assertFalse(excellent.getWeekTable().getDay(4).getLesson(12).isExemption());
Assert.assertFalse(full.getWeekTable().getDay(2).getLesson(5).isExemption());
Assert.assertFalse(full.getWeekTable().getDay(3).getLesson(1).isExemption());
Assert.assertTrue(full.getWeekTable().getDay(4).getLesson(8).isExemption());
}
}

View File

@ -1,97 +0,0 @@
package io.github.wulkanowy.api.exams;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class ExamsWeekTest extends StudentAndParentTestCase {
private ExamsWeek onePerDay;
@Before
public void getCurrent() throws Exception {
onePerDay = new ExamsWeek(getSnp("Sprawdziany-one-per-day.html"));
}
@Test
public void getWeekTest() throws Exception {
Assert.assertEquals("23.10.2017", onePerDay.getCurrent().getStartDate());
}
@Test
public void getDaysListTest() throws Exception {
Assert.assertEquals(3, onePerDay.getCurrent().getDayList().size());
Assert.assertEquals(7, onePerDay.getWeek("", false).getDayList().size());
}
@Test
public void getExamsListTest() throws Exception {
List<Day> notEmpty = onePerDay.getCurrent().getDayList();
Assert.assertEquals(1, notEmpty.get(0).getExamList().size());
Assert.assertEquals(1, notEmpty.get(1).getExamList().size());
Assert.assertEquals(1, notEmpty.get(2).getExamList().size());
List<Day> emptyToo = onePerDay.getWeek("", false).getDayList();
Assert.assertEquals(1, emptyToo.get(0).getExamList().size());
Assert.assertEquals(1, emptyToo.get(1).getExamList().size());
Assert.assertEquals(1, emptyToo.get(4).getExamList().size());
}
@Test
public void getDayDateTest() throws Exception {
List<Day> dayList = onePerDay.getCurrent().getDayList();
Assert.assertEquals("23.10.2017", dayList.get(0).getDate());
Assert.assertEquals("24.10.2017", dayList.get(1).getDate());
Assert.assertEquals("27.10.2017", dayList.get(2).getDate());
}
@Test
public void getExamSubjectAndGroupTest() throws Exception {
List<Day> dayList = onePerDay.getCurrent().getDayList();
Assert.assertEquals("Sieci komputerowe 3Ti|zaw2", dayList.get(0).getExamList().get(0).getSubjectAndGroup());
Assert.assertEquals("Język angielski 3Ti|J1", dayList.get(1).getExamList().get(0).getSubjectAndGroup());
Assert.assertEquals("Metodologia programowania 3Ti|zaw2", dayList.get(2).getExamList().get(0).getSubjectAndGroup());
}
@Test
public void getExamTypeTest() throws Exception {
List<Day> dayList = onePerDay.getCurrent().getDayList();
Assert.assertEquals("Sprawdzian", dayList.get(0).getExamList().get(0).getType());
Assert.assertEquals("Sprawdzian", dayList.get(1).getExamList().get(0).getType());
Assert.assertEquals("Sprawdzian", dayList.get(2).getExamList().get(0).getType());
}
@Test
public void getExamDescriptionTest() throws Exception {
List<Day> dayList = onePerDay.getCurrent().getDayList();
Assert.assertEquals("Łącza danych", dayList.get(0).getExamList().get(0).getDescription());
Assert.assertEquals("Czasy teraźniejsze", dayList.get(1).getExamList().get(0).getDescription());
Assert.assertEquals("", dayList.get(2).getExamList().get(0).getDescription());
}
@Test
public void getExamTeacherTest() throws Exception {
List<Day> dayList = onePerDay.getCurrent().getDayList();
Assert.assertEquals("Adam Wiśniewski [AW]", dayList.get(0).getExamList().get(0).getTeacher());
Assert.assertEquals("Natalia Nowak [NN]", dayList.get(1).getExamList().get(0).getTeacher());
Assert.assertEquals("Małgorzata Nowacka [MN]", dayList.get(2).getExamList().get(0).getTeacher());
}
@Test
public void getExamEntryDateTest() throws Exception {
List<Day> dayList = onePerDay.getCurrent().getDayList();
Assert.assertEquals("16.10.2017", dayList.get(0).getExamList().get(0).getEntryDate());
Assert.assertEquals("17.10.2017", dayList.get(1).getExamList().get(0).getEntryDate());
Assert.assertEquals("16.10.2017", dayList.get(2).getExamList().get(0).getEntryDate());
}
}

View File

@ -1,114 +0,0 @@
package io.github.wulkanowy.api.grades;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class GradesListTest extends StudentAndParentTestCase {
private GradesList filled;
@Before
public void setUp() throws Exception {
filled = new GradesList(getSnp("OcenyWszystkie-filled.html"));
}
@Test
public void getAllTest() throws Exception {
Assert.assertEquals(6, filled.getAll().size()); // 2 items are skipped
}
@Test
public void getSubjectTest() throws Exception {
List<Grade> list = filled.getAll();
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());
}
@Test
public void getValueTest() throws Exception {
List<Grade> list = filled.getAll();
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());
}
}

View File

@ -1,82 +0,0 @@
package io.github.wulkanowy.api.grades;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class SubjectsListTest extends StudentAndParentTestCase {
private SubjectsList std;
private SubjectsList average;
@Before
public void setUp() throws Exception {
std = new SubjectsList(getSnp("OcenyWszystkie-subjects.html"));
average = new SubjectsList(getSnp("OcenyWszystkie-subjects-average.html"));
}
@Test
public void getAllTest() throws Exception {
Assert.assertEquals(5, std.getAll().size());
Assert.assertEquals(5, average.getAll().size());
}
@Test
public void getNameTest() throws Exception {
List<Subject> stdList = std.getAll();
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());
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());
}
@Test
public void getPredictedRatingTest() throws Exception {
List<Subject> stdList = std.getAll();
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());
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());
}
@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());
}
}

View File

@ -1,126 +0,0 @@
package io.github.wulkanowy.api.login;
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.Cookies;
import io.github.wulkanowy.api.FixtureHelper;
public class LoginTest {
public String getFixtureAsString(String fixtureFileName) {
return FixtureHelper.getAsString(getClass().getResourceAsStream(fixtureFileName));
}
public Login getSetUpLogin(String fixtureFileName) throws Exception {
Document tablePageDocument = Jsoup.parse(getFixtureAsString(fixtureFileName));
Login login = Mockito.mock(Login.class);
Mockito.when(login.postPageByUrl(Mockito.anyString(), Mockito.any(String[][].class))
).thenReturn(tablePageDocument);
Mockito.when(login.getLoginPageUrl()).thenReturn("");
Mockito.when(login.getLoginEndpointPageUrl()).thenReturn("asdf");
return login;
}
@Test
public void loginTest() throws Exception {
Login login = getSetUpLogin("Logowanie-success.html");
Mockito.when(login.login(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
.thenCallRealMethod();
Mockito.when(login.sendCredentials(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
.thenReturn("<xml>");
Mockito.when(login.sendCertificate(Mockito.anyString(), Mockito.anyString())).thenReturn("d123");
Assert.assertEquals("d123", login.login("a@a", "pswd", "d123"));
}
@Test
public void loginDefaultTest() throws Exception {
Login login = getSetUpLogin("Logowanie-success.html");
Mockito.when(login.getLoginEndpointPageUrl()).thenReturn("asdf");
Mockito.when(login.login(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
.thenCallRealMethod();
Mockito.when(login.sendCredentials(Mockito.anyString(), Mockito.anyString(), Mockito.eq("Default")))
.thenReturn(getFixtureAsString("cert.xml"));
Mockito.when(login.findSymbol(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.sendCertificate(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.findSymbolInCertificate(Mockito.anyString())).thenCallRealMethod();
Assert.assertEquals("demo12345", login.login("a@a", "pswd", "Default"));
}
@Test(expected = BadCredentialsException.class)
public void sendWrongCredentialsTest() throws Exception {
Login login = getSetUpLogin("Logowanie-error.html");
Mockito.when(login.sendCredentials(
Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
login.sendCredentials("a@a", "pswd", "d123");
}
@Test
public void sendCredentialsCertificateTest() throws Exception {
Login login = getSetUpLogin("Logowanie-certyfikat.html");
Mockito.when(login.sendCredentials(
Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.getLoginPageUrl()).thenReturn("http://a.a");
Assert.assertEquals(
getFixtureAsString("cert.xml").replaceAll("\\s+",""),
login.sendCredentials("a@a", "passwd", "d123").replaceAll("\\s+","")
);
}
@Test
public void sendCertificateNotDefaultSymbolSuccessTest() throws Exception {
Login login = getSetUpLogin("Logowanie-success.html");
Mockito.when(login.findSymbol(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.sendCertificate(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Assert.assertEquals("wulkanowyschool321", login.sendCertificate("", "wulkanowyschool321"));
}
@Test
public void sendCertificateDefaultSymbolSuccessTest() throws Exception {
Login login = getSetUpLogin("Logowanie-success.html");
Mockito.when(login.findSymbol(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.findSymbolInCertificate(Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.sendCertificate(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Assert.assertEquals("demo12345",
login.sendCertificate(getFixtureAsString("cert.xml"), "Default"));
}
@Test(expected = AccountPermissionException.class)
public void sendCertificateAccountPermissionTest() throws Exception {
Login login = getSetUpLogin("Logowanie-brak-dostepu.html");
Mockito.when(login.findSymbol(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.sendCertificate(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
login.sendCertificate(getFixtureAsString("cert.xml"), "demo123");
}
@Test(expected = LoginErrorException.class)
public void sendCertificateLoginErrorTest() throws Exception {
Login login = getSetUpLogin("Logowanie-certyfikat.html"); // change to other document
Mockito.when(login.findSymbol(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
Mockito.when(login.sendCertificate(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
login.sendCertificate(getFixtureAsString("cert.xml"), "demo123");
}
@Test
public void findSymbolInCertificateTest() throws Exception {
Login login = new Login(new Cookies());
String certificate = getFixtureAsString("cert.xml");
Assert.assertEquals("demo12345", login.findSymbolInCertificate(certificate));
}
@Test
public void findSymbolInInvalidCertificateTest() throws Exception {
Login login = new Login(new Cookies());
Assert.assertEquals("", login.findSymbolInCertificate("<xml></xml>")); // change to real cert with empty symbols
}
}

View File

@ -1,36 +0,0 @@
package io.github.wulkanowy.api.notes;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class AchievementsListTest extends StudentAndParentTestCase {
private AchievementsList filledAchievementsList;
private AchievementsList emptyAchievementsList;
@Before
public void setUp() throws Exception {
filledAchievementsList = new AchievementsList(getSnp("UwagiOsiagniecia-filled.html"));
emptyAchievementsList = new AchievementsList(getSnp("UwagiOsiagniecia-empty.html"));
}
@Test
public void getAllAchievementsTest() throws Exception {
Assert.assertEquals(2, filledAchievementsList.getAllAchievements().size());
Assert.assertEquals(0, emptyAchievementsList.getAllAchievements().size());
}
@Test
public void getAchievements() throws Exception {
List<String> filledList = filledAchievementsList.getAllAchievements();
Assert.assertEquals("I miejsce w ogólnopolskim konkursie ortograficznym", filledList.get(0));
Assert.assertEquals("III miejsce w ogólnopolskim konkursie plastycznym", filledList.get(1));
}
}

View File

@ -1,60 +0,0 @@
package io.github.wulkanowy.api.notes;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class NotesListTest extends StudentAndParentTestCase {
private NotesList filled;
private NotesList empty;
@Before
public void setUp() throws Exception {
filled = new NotesList(getSnp("UwagiOsiagniecia-filled.html"));
empty = new NotesList(getSnp("UwagiOsiagniecia-empty.html"));
}
@Test
public void getAllNotesTest() throws Exception {
Assert.assertEquals(3, filled.getAllNotes().size());
Assert.assertEquals(0, empty.getAllNotes().size());
}
@Test
public void getDateTest() throws Exception {
List<Note> filledList = filled.getAllNotes();
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());
}
}

View File

@ -1,48 +0,0 @@
package io.github.wulkanowy.api.school;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class SchoolInfoTest extends StudentAndParentTestCase {
private SchoolInfo schoolInfo;
@Before
public void setUp() throws Exception {
schoolInfo = new SchoolInfo(getSnp("Szkola.html"));
}
@Test
public void getNameTest() throws Exception {
Assert.assertEquals("Zespół Szkół nr 64", schoolInfo.getSchoolData().getName());
}
@Test
public void getAddressTest() throws Exception {
Assert.assertEquals("ul. Wiśniowa 128, 01-234 Rogalowo, Nibylandia",
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]"
}, schoolInfo.getSchoolData().getPedagogues());
}
}

View File

@ -1,56 +0,0 @@
package io.github.wulkanowy.api.school;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class TeachersInfoTest extends StudentAndParentTestCase {
private TeachersInfo teachersInfo;
@Before
public void setUp() throws Exception {
teachersInfo = new TeachersInfo(getSnp("Szkola.html"));
}
@Test
public void getClassNameTest() throws Exception {
Assert.assertEquals("1a", teachersInfo.getTeachersData().getClassName());
}
@Test
public void getClassTeacherTest() throws Exception {
Assert.assertArrayEquals(new String[]{
"Karolina Kowalska [AN]",
"Antoni Sobczyk [AS]"
}, teachersInfo.getTeachersData().getClassTeacher());
}
@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.assertArrayEquals(new String[]{
"Karolina Kowalska [AN]",
"Mateusz Kowal [MK]",
"Amelia Mazur [AM]"
}, subjects.get(6).getTeachers());
}
}

View File

@ -1,195 +0,0 @@
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());
}
}

View File

@ -1,106 +0,0 @@
package io.github.wulkanowy.api.user;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class BasicInformationTest extends StudentAndParentTestCase {
private BasicInformation basicInformation;
@Before
public void setUp() throws Exception {
basicInformation = new BasicInformation(getSnp("UczenDanePodstawowe.html"));
}
@Test
public void getPersonalFirstNameTest() throws Exception {
Assert.assertEquals("Maria", basicInformation.getPersonalData().getFirstName());
}
@Test
public void getPersonalSurnameTest() throws Exception {
Assert.assertEquals("Kamińska", basicInformation.getPersonalData().getSurname());
}
@Test
public void getPersonalFirstAndLastNameTest() throws Exception {
Assert.assertEquals("Maria Kamińska",
basicInformation.getPersonalData().getFirstAndLastName());
}
@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());
}
}

View File

@ -1,59 +0,0 @@
package io.github.wulkanowy.api.user;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase;
public class FamilyInformationTest extends StudentAndParentTestCase {
private FamilyInformation familyInformation;
@Before
public void setUp() throws Exception {
familyInformation = new FamilyInformation(getSnp("UczenDanePodstawowe.html"));
}
@Test
public void getFamilyMembers() throws Exception {
Assert.assertEquals(2, familyInformation.getFamilyMembers().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());
}
@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());
}
@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());
}
}