diff --git a/app/build.gradle b/app/build.gradle index 277334181..bbd40a295 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,6 +55,8 @@ dependencies { debugCompile 'com.amitshekhar.android:debug-db:1.0.1' debugCompile 'net.zetetic:android-database-sqlcipher:3.5.7@aar' + + androidTestCompile 'org.mockito:mockito-android:2.10.0' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:2.10.0' diff --git a/app/src/androidTest/java/io/github/wulkanowy/services/VulcanSynchronizationTest.java b/app/src/androidTest/java/io/github/wulkanowy/services/VulcanSynchronizationTest.java new file mode 100644 index 000000000..69ecbd77f --- /dev/null +++ b/app/src/androidTest/java/io/github/wulkanowy/services/VulcanSynchronizationTest.java @@ -0,0 +1,23 @@ +package io.github.wulkanowy.services; + +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class VulcanSynchronizationTest { + + @Test + public void syncNoLoginSessionSubjectTest() { + VulcanSynchronization vulcanSynchronization = new VulcanSynchronization(new LoginSession()); + Assert.assertFalse(vulcanSynchronization.syncSubjectsAndGrades()); + } + + @Test + public void syncNoLoginSessionGradeTest() { + VulcanSynchronization vulcanSynchronization = new VulcanSynchronization(new LoginSession()); + Assert.assertFalse(vulcanSynchronization.syncGrades()); + } +} diff --git a/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/AccountSynchronizationTest.java b/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/AccountSynchronizationTest.java new file mode 100644 index 000000000..754da85b6 --- /dev/null +++ b/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/AccountSynchronizationTest.java @@ -0,0 +1,142 @@ +package io.github.wulkanowy.services.synchronization; + +import android.content.Context; +import android.content.SharedPreferences; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.greenrobot.greendao.database.Database; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; + +import java.io.IOException; + +import io.github.wulkanowy.api.Vulcan; +import io.github.wulkanowy.api.login.AccountPermissionException; +import io.github.wulkanowy.api.login.BadCredentialsException; +import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.user.BasicInformation; +import io.github.wulkanowy.api.user.PersonalData; +import io.github.wulkanowy.dao.entities.Account; +import io.github.wulkanowy.dao.entities.AccountDao; +import io.github.wulkanowy.dao.entities.DaoMaster; +import io.github.wulkanowy.dao.entities.DaoSession; +import io.github.wulkanowy.security.CryptoException; +import io.github.wulkanowy.security.Safety; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.synchronisation.AccountSynchronisation; + +@RunWith(AndroidJUnit4.class) +public class AccountSynchronizationTest { + + private static DaoSession daoSession; + + private Context context; + + private Context targetContext; + + @BeforeClass + public static void setUpClass() { + + DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(InstrumentationRegistry.getTargetContext(), "wulkanowyTest-database"); + Database database = devOpenHelper.getWritableDb(); + + daoSession = new DaoMaster(database).newSession(); + } + + @Before + public void setUp() { + context = InstrumentationRegistry.getContext(); + targetContext = InstrumentationRegistry.getTargetContext(); + + daoSession.getAccountDao().deleteAll(); + daoSession.clear(); + + setUserIdSharePreferences(0); + } + + @Test(expected = IOException.class) + public void emptyUserIdTest() throws CryptoException, BadCredentialsException, + AccountPermissionException, IOException, LoginErrorException { + + AccountSynchronisation accountSynchronisation = new AccountSynchronisation(); + accountSynchronisation.loginCurrentUser(context, daoSession, new Vulcan()); + } + + @Test + public void loginCurrentUserTest() throws Exception { + AccountDao accountDao = daoSession.getAccountDao(); + + Safety safety = new Safety(context); + + Long userId = accountDao.insert(new Account() + .setEmail("TEST@TEST") + .setPassword(safety.encrypt("TEST@TEST", "TEST")) + .setSymbol("")); + + setUserIdSharePreferences(userId); + + Vulcan vulcan = Mockito.mock(Vulcan.class); + Mockito.doNothing().when(vulcan).login("TEST@TEST", "TEST", ""); + + AccountSynchronisation accountSynchronisation = new AccountSynchronisation(); + LoginSession loginSession = accountSynchronisation.loginCurrentUser(targetContext, daoSession, vulcan); + + Assert.assertNotNull(loginSession); + Assert.assertEquals(loginSession.getUserId(), userId); + Assert.assertNotNull(loginSession.getDaoSession()); + Assert.assertEquals(loginSession.getVulcan(), vulcan); + } + + @Test + public void loginNewUserTest() throws Exception { + PersonalData personalData = Mockito.mock(PersonalData.class); + Mockito.doReturn("NAME-TEST").when(personalData).getFirstAndLastName(); + + BasicInformation basicInformation = Mockito.mock(BasicInformation.class); + Mockito.doReturn(personalData).when(basicInformation).getPersonalData(); + + Vulcan vulcan = Mockito.mock(Vulcan.class); + Mockito.doNothing().when(vulcan).login("TEST@TEST", "TEST", ""); + Mockito.doReturn(basicInformation).when(vulcan).getBasicInformation(); + + AccountSynchronisation accountSynchronisation = new AccountSynchronisation(); + LoginSession loginSession = accountSynchronisation + .loginNewUser("TEST@TEST", "TEST", "", targetContext, daoSession, vulcan); + + Long userId = targetContext.getSharedPreferences("LoginData", Context.MODE_PRIVATE).getLong("userId", 0); + + Assert.assertNotNull(loginSession); + Assert.assertNotEquals(0, userId.longValue()); + Assert.assertEquals(loginSession.getUserId(), userId); + Assert.assertNotNull(loginSession.getDaoSession()); + Assert.assertEquals(loginSession.getVulcan(), vulcan); + + Safety safety = new Safety(context); + Account account = daoSession.getAccountDao().load(userId); + + Assert.assertNotNull(account); + Assert.assertEquals("TEST@TEST", account.getEmail()); + Assert.assertEquals("NAME-TEST", account.getName()); + Assert.assertEquals("TEST", safety.decrypt("TEST@TEST", account.getPassword())); + + } + + @AfterClass + public static void cleanUp() { + daoSession.getAccountDao().deleteAll(); + daoSession.clear(); + } + + private void setUserIdSharePreferences(long id) { + SharedPreferences sharedPreferences = targetContext.getSharedPreferences("LoginData", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putLong("userId", id); + editor.apply(); + } +} diff --git a/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/GradeSynchronizationTest.java b/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/GradeSynchronizationTest.java new file mode 100644 index 000000000..8a7a0a49f --- /dev/null +++ b/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/GradeSynchronizationTest.java @@ -0,0 +1,88 @@ +package io.github.wulkanowy.services.synchronization; + +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.greenrobot.greendao.database.Database; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; + +import java.util.ArrayList; +import java.util.List; + +import io.github.wulkanowy.api.Vulcan; +import io.github.wulkanowy.api.grades.Grade; +import io.github.wulkanowy.api.grades.GradesList; +import io.github.wulkanowy.dao.entities.Account; +import io.github.wulkanowy.dao.entities.DaoMaster; +import io.github.wulkanowy.dao.entities.DaoSession; +import io.github.wulkanowy.dao.entities.Subject; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.synchronisation.GradesSynchronisation; + +@RunWith(AndroidJUnit4.class) +public class GradeSynchronizationTest { + + private static DaoSession daoSession; + + @BeforeClass + public static void setUpClass() { + DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(InstrumentationRegistry.getTargetContext(), "wulkanowyTest-database"); + Database database = devOpenHelper.getWritableDb(); + + daoSession = new DaoMaster(database).newSession(); + } + + @Before + public void setUp() { + daoSession.getAccountDao().deleteAll(); + daoSession.getGradeDao().deleteAll(); + daoSession.getSubjectDao().deleteAll(); + daoSession.clear(); + } + + @Test + public void syncGradesEmptyBaseTest() throws Exception { + Long userId = daoSession.getAccountDao().insert(new Account().setEmail("TEST@TEST")); + Long subjectId = daoSession.getSubjectDao().insert(new Subject().setName("Matematyka").setUserId(userId)); + + List gradeList = new ArrayList<>(); + gradeList.add(new Grade().setSubject("Matematyka").setValue("5")); + + GradesList gradesListApi = Mockito.mock(GradesList.class); + Mockito.doReturn(gradeList).when(gradesListApi).getAll(); + + Vulcan vulcan = Mockito.mock(Vulcan.class); + Mockito.doReturn(gradesListApi).when(vulcan).getGradesList(); + + LoginSession loginSession = Mockito.mock(LoginSession.class); + Mockito.doReturn(vulcan).when(loginSession).getVulcan(); + Mockito.doReturn(daoSession).when(loginSession).getDaoSession(); + Mockito.doReturn(userId).when(loginSession).getUserId(); + + GradesSynchronisation gradesSynchronisation = new GradesSynchronisation(); + gradesSynchronisation.sync(loginSession); + + io.github.wulkanowy.dao.entities.Grade grade = daoSession.getGradeDao().load(1L); + + Assert.assertNotNull(grade); + Assert.assertEquals(userId, grade.getUserId()); + Assert.assertEquals(subjectId, grade.getSubjectId()); + Assert.assertEquals("Matematyka", grade.getSubject()); + Assert.assertEquals("5", grade.getValue()); + Assert.assertTrue(grade.getIsNew()); + } + + @AfterClass + public static void cleanUp() { + daoSession.getAccountDao().deleteAll(); + daoSession.getGradeDao().deleteAll(); + daoSession.getSubjectDao().deleteAll(); + daoSession.clear(); + } +} diff --git a/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/SubjectSynchronizationTest.java b/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/SubjectSynchronizationTest.java new file mode 100644 index 000000000..317d8ecde --- /dev/null +++ b/app/src/androidTest/java/io/github/wulkanowy/services/synchronization/SubjectSynchronizationTest.java @@ -0,0 +1,82 @@ +package io.github.wulkanowy.services.synchronization; + +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.greenrobot.greendao.database.Database; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; + +import java.util.ArrayList; +import java.util.List; + +import io.github.wulkanowy.api.Vulcan; +import io.github.wulkanowy.api.grades.SubjectsList; +import io.github.wulkanowy.dao.entities.DaoMaster; +import io.github.wulkanowy.dao.entities.DaoSession; +import io.github.wulkanowy.dao.entities.Subject; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.synchronisation.SubjectsSynchronisation; + +@RunWith(AndroidJUnit4.class) +public class SubjectSynchronizationTest { + + private static DaoSession daoSession; + + @BeforeClass + public static void setUpClass() { + DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(InstrumentationRegistry.getTargetContext(), "wulkanowyTest-database"); + Database database = devOpenHelper.getWritableDb(); + + daoSession = new DaoMaster(database).newSession(); + } + + @Before + public void setUp() { + daoSession.getSubjectDao().deleteAll(); + daoSession.clear(); + } + + @Test + public void syncSubjectTest() throws Exception { + List subjectList = new ArrayList<>(); + subjectList.add(new io.github.wulkanowy.api.grades.Subject() + .setName("Matematyka") + .setFinalRating("5") + .setPredictedRating("4")); + + SubjectsList subjectsListApi = Mockito.mock(SubjectsList.class); + Mockito.doReturn(subjectList).when(subjectsListApi).getAll(); + + Vulcan vulcan = Mockito.mock(Vulcan.class); + Mockito.doReturn(subjectsListApi).when(vulcan).getSubjectsList(); + + LoginSession loginSession = Mockito.mock(LoginSession.class); + Mockito.doReturn(vulcan).when(loginSession).getVulcan(); + Mockito.doReturn(2L).when(loginSession).getUserId(); + Mockito.doReturn(daoSession).when(loginSession).getDaoSession(); + + SubjectsSynchronisation subjectsSynchronisation = new SubjectsSynchronisation(); + subjectsSynchronisation.sync(loginSession); + + Subject subject = daoSession.getSubjectDao().load(1L); + + Assert.assertNotNull(subject); + Assert.assertEquals(2, subject.getUserId().longValue()); + Assert.assertEquals("Matematyka", subject.getName()); + Assert.assertEquals("5", subject.getFinalRating()); + Assert.assertEquals("4", subject.getPredictedRating()); + + } + + @AfterClass + public static void cleanUp() { + daoSession.getSubjectDao().deleteAll(); + daoSession.clear(); + } +} diff --git a/app/src/main/java/io/github/wulkanowy/activity/main/LoginTask.java b/app/src/main/java/io/github/wulkanowy/activity/main/LoginTask.java index 558429e61..a5295daaa 100644 --- a/app/src/main/java/io/github/wulkanowy/activity/main/LoginTask.java +++ b/app/src/main/java/io/github/wulkanowy/activity/main/LoginTask.java @@ -9,14 +9,17 @@ import android.widget.Toast; import java.io.IOException; import io.github.wulkanowy.R; +import io.github.wulkanowy.activity.WulkanowyApp; import io.github.wulkanowy.activity.dashboard.DashboardActivity; +import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.AccountPermissionException; import io.github.wulkanowy.api.login.BadCredentialsException; -import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; +import io.github.wulkanowy.dao.entities.DaoSession; import io.github.wulkanowy.security.CryptoException; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.VulcanSynchronization; import io.github.wulkanowy.services.jobs.GradesSync; -import io.github.wulkanowy.services.synchronisation.DataSynchronisation; -import io.github.wulkanowy.services.synchronisation.VulcanSynchronisation; import io.github.wulkanowy.utilities.ConnectionUtilities; public class LoginTask extends AsyncTask { @@ -44,21 +47,22 @@ public class LoginTask extends AsyncTask { protected Integer doInBackground(String... credentials) { if (ConnectionUtilities.isOnline(activity)) { - VulcanSynchronisation vulcanSynchronisation = new VulcanSynchronisation(); + VulcanSynchronization vulcanSynchronization = new VulcanSynchronization(new LoginSession()); + DaoSession daoSession = ((WulkanowyApp) activity.getApplication()).getDaoSession(); try { - vulcanSynchronisation.loginNewUser(credentials[0], credentials[1], credentials[2], activity); + vulcanSynchronization + .loginNewUser(credentials[0], credentials[1], credentials[2], activity, daoSession, new Vulcan()); } catch (BadCredentialsException e) { return R.string.login_bad_credentials_text; } catch (AccountPermissionException e) { return R.string.login_bad_account_permission_text; } catch (CryptoException e) { return R.string.encrypt_failed_text; - } catch (LoginErrorException | IOException e) { + } catch (NotLoggedInErrorException | IOException e) { return R.string.login_denied_text; } - DataSynchronisation dataSynchronisation = new DataSynchronisation(activity); - dataSynchronisation.syncSubjectsAndGrades(vulcanSynchronisation); + vulcanSynchronization.syncSubjectsAndGrades(); return R.string.login_accepted_text; diff --git a/app/src/main/java/io/github/wulkanowy/api/Api.java b/app/src/main/java/io/github/wulkanowy/api/Api.java new file mode 100644 index 000000000..e62fbdefa --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/api/Api.java @@ -0,0 +1,37 @@ +package io.github.wulkanowy.api; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; + +import java.io.IOException; +import java.util.Map; + +public abstract class Api { + + protected Cookies cookies; + + public Cookies getCookiesObject() { + return cookies; + } + + public Map getCookies() { + return cookies.getItems(); + } + + public Cookies setCookies(Map cookies) { + this.cookies.setItems(cookies); + return this.cookies; + } + + public Cookies addCookies(Map cookies) { + this.cookies.addItems(cookies); + return this.cookies; + } + + public Document getPageByUrl(String url) throws IOException { + return Jsoup.connect(url) + .followRedirects(true) + .cookies(getCookies()) + .get(); + } +} diff --git a/app/src/main/java/io/github/wulkanowy/api/StudentAndParent.java b/app/src/main/java/io/github/wulkanowy/api/StudentAndParent.java index e2d8bcc7c..fb521df82 100644 --- a/app/src/main/java/io/github/wulkanowy/api/StudentAndParent.java +++ b/app/src/main/java/io/github/wulkanowy/api/StudentAndParent.java @@ -10,9 +10,9 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; -public class StudentAndParent extends Vulcan { +public class StudentAndParent extends Api { private String startPageUrl = "https://uonetplus.vulcan.net.pl/{symbol}/Start.mvc/Index"; @@ -20,37 +20,32 @@ public class StudentAndParent extends Vulcan { private String gradesPageUrl = baseUrl + "Oceny/Wszystkie"; - private String symbol = ""; + private String symbol; - private String id = ""; + private String id; - public StudentAndParent(Cookies cookies, String locID) throws IOException, LoginErrorException { + public StudentAndParent(Cookies cookies, String symbol) { this.cookies = cookies; - this.symbol = locID; + this.symbol = symbol; + } - // get link to uonetplus-opiekun.vulcan.net.pl module - Document startPage = getPageByUrl(startPageUrl.replace("{symbol}", symbol)); - Element studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a").first(); - String uonetPlusOpiekunUrl = studentTileLink.attr("href"); - - //get context module cookie - Connection.Response res = Jsoup.connect(uonetPlusOpiekunUrl) - .followRedirects(true) - .cookies(getCookies()) - .execute(); - - cookies.addItems(res.cookies()); - - this.id = getCalculatedID(uonetPlusOpiekunUrl); - this.baseUrl = baseUrl - .replace("{symbol}", getSymbol()) - .replace("{ID}", getId()); + public StudentAndParent(Cookies cookies, String symbol, String id) { + this(cookies, symbol); + this.id = id; } public String getGradesPageUrl() { return gradesPageUrl; } + public String getBaseUrl() { + return baseUrl; + } + + public String getStartPageUrl() { + return startPageUrl; + } + public String getSymbol() { return symbol; } @@ -59,11 +54,41 @@ public class StudentAndParent extends Vulcan { return id; } - public String getCalculatedID(String uonetPlusOpiekunUrl) throws LoginErrorException { - String[] path = uonetPlusOpiekunUrl.split("vulcan.net.pl/")[1].split("/"); + public void storeContextCookies() throws IOException, NotLoggedInErrorException { + //get context cookie + Connection.Response res = Jsoup.connect(getSnpPageUrl()) + .followRedirects(true) + .cookies(getCookies()) + .execute(); + + cookies.addItems(res.cookies()); + } + + public String getSnpPageUrl() throws IOException, NotLoggedInErrorException { + if (null != getId()) { + return getBaseUrl().replace("{symbol}", getSymbol()).replace("{ID}", getId()); + } + + // get url to uonetplus-opiekun.vulcan.net.pl + Document startPage = getPageByUrl(getStartPageUrl().replace("{symbol}", getSymbol())); + Element studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a").first(); + + if (null == studentTileLink) { + throw new NotLoggedInErrorException(); + } + + String snpPageUrl = studentTileLink.attr("href"); + + this.id = getExtractedIdFromUrl(snpPageUrl); + + return snpPageUrl; + } + + public String getExtractedIdFromUrl(String snpPageUrl) throws NotLoggedInErrorException { + String[] path = snpPageUrl.split("vulcan.net.pl/")[1].split("/"); if (4 != path.length) { - throw new LoginErrorException(); + throw new NotLoggedInErrorException(); } return path[1]; @@ -74,7 +99,9 @@ public class StudentAndParent extends Vulcan { } public Document getSnPPageDocument(String url) throws IOException { - return getPageByUrl(baseUrl + url); + return getPageByUrl(getBaseUrl() + .replace("{symbol}", getSymbol()) + .replace("{ID}", getId()) + url); } public List getSemesters() throws IOException { diff --git a/app/src/main/java/io/github/wulkanowy/api/Vulcan.java b/app/src/main/java/io/github/wulkanowy/api/Vulcan.java index ff5efac1b..2b6d366ac 100644 --- a/app/src/main/java/io/github/wulkanowy/api/Vulcan.java +++ b/app/src/main/java/io/github/wulkanowy/api/Vulcan.java @@ -1,37 +1,111 @@ package io.github.wulkanowy.api; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; - import java.io.IOException; -import java.util.Map; -public abstract class Vulcan { +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.AccountPermissionException; +import io.github.wulkanowy.api.login.BadCredentialsException; +import io.github.wulkanowy.api.login.Login; +import io.github.wulkanowy.api.login.LoginErrorException; +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; - protected Cookies cookies; +public class Vulcan extends Api { - public Cookies getCookiesObject() { - return cookies; + private String id; + + private String symbol; + + private StudentAndParent snp; + + public void login(String email, String password, String symbol) + throws BadCredentialsException, AccountPermissionException, LoginErrorException { + Login login = new Login(new Cookies()); + login.login(email, password, symbol); + + this.symbol = symbol; + this.cookies = login.getCookiesObject(); } - public Map getCookies() { - return cookies.getItems(); + public void login(String email, String password, String symbol, String id) + throws BadCredentialsException, AccountPermissionException, LoginErrorException { + login(email, password, symbol); + + this.id = id; } - public Cookies setCookies(Map cookies) { - this.cookies.setItems(cookies); - return this.cookies; + public StudentAndParent getStudentAndParent() throws IOException, NotLoggedInErrorException { + if (null == getCookiesObject()) { + throw new NotLoggedInErrorException(); + } + + if (null != snp) { + return snp; + } + + if (null == id) { + snp = new StudentAndParent(cookies, symbol); + } else { + snp = new StudentAndParent(cookies, symbol, id); + } + + snp.storeContextCookies(); + + this.cookies = snp.getCookiesObject(); + + return snp; } - public Cookies addCookies(Map cookies) { - this.cookies.addItems(cookies); - return this.cookies; + public AttendanceStatistics getAttendanceStatistics() throws IOException, NotLoggedInErrorException { + return new AttendanceStatistics(getStudentAndParent()); } - public Document getPageByUrl(String url) throws IOException { - return Jsoup.connect(url) - .followRedirects(true) - .cookies(getCookies()) - .get(); + public AttendanceTable getAttendanceTable() throws IOException, NotLoggedInErrorException { + return new AttendanceTable(getStudentAndParent()); + } + + public GradesList getGradesList() throws IOException, NotLoggedInErrorException { + return new GradesList(getStudentAndParent()); + } + + public SubjectsList getSubjectsList() throws IOException, NotLoggedInErrorException { + return new SubjectsList(getStudentAndParent()); + } + + public AchievementsList getAchievementsList() throws IOException, NotLoggedInErrorException { + return new AchievementsList(getStudentAndParent()); + } + + public NotesList getNotesList() throws IOException, NotLoggedInErrorException { + return new NotesList(getStudentAndParent()); + } + + public SchoolInfo getSchoolInfo() throws IOException, NotLoggedInErrorException { + return new SchoolInfo(getStudentAndParent()); + } + + public TeachersInfo getTeachersInfo() throws IOException, NotLoggedInErrorException { + return new TeachersInfo(getStudentAndParent()); + } + + public Timetable getTimetable() throws IOException, NotLoggedInErrorException { + return new Timetable(getStudentAndParent()); + } + + public BasicInformation getBasicInformation() throws IOException, NotLoggedInErrorException { + return new BasicInformation(getStudentAndParent()); + } + + public FamilyInformation getFamilyInformation() throws IOException, NotLoggedInErrorException { + return new FamilyInformation(getStudentAndParent()); } } diff --git a/app/src/main/java/io/github/wulkanowy/api/attendance/Statistics.java b/app/src/main/java/io/github/wulkanowy/api/attendance/AttendanceStatistics.java similarity index 96% rename from app/src/main/java/io/github/wulkanowy/api/attendance/Statistics.java rename to app/src/main/java/io/github/wulkanowy/api/attendance/AttendanceStatistics.java index 55eec175b..53d9bcfaf 100644 --- a/app/src/main/java/io/github/wulkanowy/api/attendance/Statistics.java +++ b/app/src/main/java/io/github/wulkanowy/api/attendance/AttendanceStatistics.java @@ -10,13 +10,13 @@ import java.util.List; import io.github.wulkanowy.api.StudentAndParent; -public class Statistics { +public class AttendanceStatistics { private StudentAndParent snp; private String attendancePageUrl = "Frekwencja.mvc"; - public Statistics(StudentAndParent snp) { + public AttendanceStatistics(StudentAndParent snp) { this.snp = snp; } diff --git a/app/src/main/java/io/github/wulkanowy/api/attendance/Table.java b/app/src/main/java/io/github/wulkanowy/api/attendance/AttendanceTable.java similarity index 97% rename from app/src/main/java/io/github/wulkanowy/api/attendance/Table.java rename to app/src/main/java/io/github/wulkanowy/api/attendance/AttendanceTable.java index 404f519a9..1452d9e14 100644 --- a/app/src/main/java/io/github/wulkanowy/api/attendance/Table.java +++ b/app/src/main/java/io/github/wulkanowy/api/attendance/AttendanceTable.java @@ -9,13 +9,13 @@ import java.util.List; import io.github.wulkanowy.api.StudentAndParent; -public class Table { +public class AttendanceTable { private StudentAndParent snp; private String attendancePageUrl = "Frekwencja.mvc?data="; - public Table(StudentAndParent snp) { + public AttendanceTable(StudentAndParent snp) { this.snp = snp; } diff --git a/app/src/main/java/io/github/wulkanowy/api/grades/Grade.java b/app/src/main/java/io/github/wulkanowy/api/grades/Grade.java index 0e0c85246..564b3e47c 100644 --- a/app/src/main/java/io/github/wulkanowy/api/grades/Grade.java +++ b/app/src/main/java/io/github/wulkanowy/api/grades/Grade.java @@ -2,10 +2,10 @@ package io.github.wulkanowy.api.grades; public class Grade { - private String subject = ""; - protected String value = ""; + private String subject = ""; + private String color = ""; private String symbol = ""; diff --git a/app/src/main/java/io/github/wulkanowy/api/grades/GradesList.java b/app/src/main/java/io/github/wulkanowy/api/grades/GradesList.java index d65be926d..1e665a27d 100644 --- a/app/src/main/java/io/github/wulkanowy/api/grades/GradesList.java +++ b/app/src/main/java/io/github/wulkanowy/api/grades/GradesList.java @@ -16,10 +16,9 @@ import java.util.regex.Pattern; import io.github.wulkanowy.api.Semester; import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.LoginErrorException; -public class GradesList extends Vulcan { +public class GradesList { private StudentAndParent snp = null; diff --git a/app/src/main/java/io/github/wulkanowy/api/grades/SubjectsList.java b/app/src/main/java/io/github/wulkanowy/api/grades/SubjectsList.java index 6a5f24ee6..24217242e 100644 --- a/app/src/main/java/io/github/wulkanowy/api/grades/SubjectsList.java +++ b/app/src/main/java/io/github/wulkanowy/api/grades/SubjectsList.java @@ -9,10 +9,9 @@ import java.util.ArrayList; import java.util.List; import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.LoginErrorException; -public class SubjectsList extends Vulcan { +public class SubjectsList { private StudentAndParent snp = null; diff --git a/app/src/main/java/io/github/wulkanowy/api/login/Login.java b/app/src/main/java/io/github/wulkanowy/api/login/Login.java index 83656d97e..23ce6e9cb 100644 --- a/app/src/main/java/io/github/wulkanowy/api/login/Login.java +++ b/app/src/main/java/io/github/wulkanowy/api/login/Login.java @@ -6,17 +6,17 @@ import org.jsoup.nodes.Document; import java.io.IOException; +import io.github.wulkanowy.api.Api; import io.github.wulkanowy.api.Cookies; -import io.github.wulkanowy.api.Vulcan; -public class Login extends Vulcan { +public class Login extends Api { private String loginPageUrl = "https://cufs.vulcan.net.pl/{symbol}/Account/LogOn"; private String certificatePageUrl = "https://cufs.vulcan.net.pl/{symbol}" - + "/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplus.vulcan.net.pl/{symbol}" - + "/LoginEndpoint.aspx&wctx=https://uonetplus.vulcan.net.pl/{symbol}" - + "/LoginEndpoint.aspx"; + + "/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplus.vulcan.net.pl/{symbol}" + + "/LoginEndpoint.aspx&wctx=https://uonetplus.vulcan.net.pl/{symbol}" + + "/LoginEndpoint.aspx"; private String loginEndpointPageUrl = "https://uonetplus.vulcan.net.pl/{symbol}/LoginEndpoint.aspx"; diff --git a/app/src/main/java/io/github/wulkanowy/api/login/LoginErrorException.java b/app/src/main/java/io/github/wulkanowy/api/login/LoginErrorException.java index 89596090c..eec2b4e41 100644 --- a/app/src/main/java/io/github/wulkanowy/api/login/LoginErrorException.java +++ b/app/src/main/java/io/github/wulkanowy/api/login/LoginErrorException.java @@ -1,4 +1,4 @@ package io.github.wulkanowy.api.login; -public class LoginErrorException extends Exception { +public class LoginErrorException extends NotLoggedInErrorException { } diff --git a/app/src/main/java/io/github/wulkanowy/api/login/NotLoggedInErrorException.java b/app/src/main/java/io/github/wulkanowy/api/login/NotLoggedInErrorException.java new file mode 100644 index 000000000..d1c6c1650 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/api/login/NotLoggedInErrorException.java @@ -0,0 +1,5 @@ +package io.github.wulkanowy.api.login; + + +public class NotLoggedInErrorException extends Exception { +} diff --git a/app/src/main/java/io/github/wulkanowy/api/school/SchoolInfo.java b/app/src/main/java/io/github/wulkanowy/api/school/SchoolInfo.java index 0b05b7a85..c479a7309 100644 --- a/app/src/main/java/io/github/wulkanowy/api/school/SchoolInfo.java +++ b/app/src/main/java/io/github/wulkanowy/api/school/SchoolInfo.java @@ -5,10 +5,9 @@ import org.jsoup.nodes.Element; import java.io.IOException; import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.LoginErrorException; -public class SchoolInfo extends Vulcan { +public class SchoolInfo { private StudentAndParent snp = null; diff --git a/app/src/main/java/io/github/wulkanowy/api/school/TeachersInfo.java b/app/src/main/java/io/github/wulkanowy/api/school/TeachersInfo.java index 915455486..236b6f832 100644 --- a/app/src/main/java/io/github/wulkanowy/api/school/TeachersInfo.java +++ b/app/src/main/java/io/github/wulkanowy/api/school/TeachersInfo.java @@ -9,10 +9,9 @@ import java.util.ArrayList; import java.util.List; import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.LoginErrorException; -public class TeachersInfo extends Vulcan { +public class TeachersInfo { private StudentAndParent snp = null; diff --git a/app/src/main/java/io/github/wulkanowy/api/timetable/Table.java b/app/src/main/java/io/github/wulkanowy/api/timetable/Timetable.java similarity index 92% rename from app/src/main/java/io/github/wulkanowy/api/timetable/Table.java rename to app/src/main/java/io/github/wulkanowy/api/timetable/Timetable.java index 503538855..21a312c76 100644 --- a/app/src/main/java/io/github/wulkanowy/api/timetable/Table.java +++ b/app/src/main/java/io/github/wulkanowy/api/timetable/Timetable.java @@ -9,16 +9,15 @@ import java.util.ArrayList; import java.util.List; import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.LoginErrorException; -public class Table extends Vulcan { +public class Timetable { private StudentAndParent snp; - private String timetablePageurl = "Lekcja.mvc/PlanLekcji?data="; + private String timetablePageUrl = "Lekcja.mvc/PlanLekcji?data="; - public Table(StudentAndParent snp) { + public Timetable(StudentAndParent snp) { this.snp = snp; } @@ -27,7 +26,7 @@ public class Table extends Vulcan { } public Week getWeekTable(String tick) throws IOException, LoginErrorException { - Element table = snp.getSnPPageDocument(timetablePageurl + tick) + Element table = snp.getSnPPageDocument(timetablePageUrl + tick) .select(".mainContainer .presentData").first(); Elements tableHeaderCells = table.select("thead th"); @@ -95,6 +94,12 @@ public class Table extends Vulcan { lesson.setTeacher(spans.get(1).text()); lesson.setRoom(spans.get(2).text()); + // okienko dla uczniów + if (5 == spans.size()) { + lesson.setTeacher(spans.get(2).text()); + lesson.setRoom(spans.get(3).text()); + } + lesson = getLessonGroupDivisionInfo(lesson, spans); lesson = getLessonTypeInfo(lesson, spans); lesson = getLessonDescriptionInfo(lesson, spans); diff --git a/app/src/main/java/io/github/wulkanowy/api/user/FamilyInformation.java b/app/src/main/java/io/github/wulkanowy/api/user/FamilyInformation.java index 997402907..66ecc59e1 100644 --- a/app/src/main/java/io/github/wulkanowy/api/user/FamilyInformation.java +++ b/app/src/main/java/io/github/wulkanowy/api/user/FamilyInformation.java @@ -8,10 +8,9 @@ import java.util.ArrayList; import java.util.List; import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.LoginErrorException; -public class FamilyInformation extends Vulcan { +public class FamilyInformation { private StudentAndParent snp; diff --git a/app/src/main/java/io/github/wulkanowy/dao/EntitiesCompare.java b/app/src/main/java/io/github/wulkanowy/dao/EntitiesCompare.java index 4ded7fd75..b368c6076 100644 --- a/app/src/main/java/io/github/wulkanowy/dao/EntitiesCompare.java +++ b/app/src/main/java/io/github/wulkanowy/dao/EntitiesCompare.java @@ -17,7 +17,7 @@ public class EntitiesCompare { .removeAll(newList, addedOrUpdatedGradeList)); for (Grade grade : addedOrUpdatedGradeList) { - grade.setNew(true); + grade.setIsNew(true); updatedList.add(grade); } diff --git a/app/src/main/java/io/github/wulkanowy/dao/entities/Grade.java b/app/src/main/java/io/github/wulkanowy/dao/entities/Grade.java index eaf934b6b..759c66003 100644 --- a/app/src/main/java/io/github/wulkanowy/dao/entities/Grade.java +++ b/app/src/main/java/io/github/wulkanowy/dao/entities/Grade.java @@ -280,15 +280,6 @@ public class Grade implements Parcelable { return this; } - public boolean isNew() { - return isNew; - } - - public Grade setNew(boolean aNew) { - isNew = aNew; - return this; - } - public boolean getIsNew() { return this.isNew; } diff --git a/app/src/main/java/io/github/wulkanowy/security/Scrambler.java b/app/src/main/java/io/github/wulkanowy/security/Scrambler.java index aa02bbf60..ae3cd7f5a 100644 --- a/app/src/main/java/io/github/wulkanowy/security/Scrambler.java +++ b/app/src/main/java/io/github/wulkanowy/security/Scrambler.java @@ -29,19 +29,19 @@ import javax.security.auth.x500.X500Principal; public class Scrambler { - private KeyStore keyStore; + public final static String DEBUG_TAG = "WulkanowySecurity"; private static final String ANDROID_KEYSTORE = "AndroidKeyStore"; - public final static String DEBUG_TAG = "WulkanowySecurity"; + protected Context context; - public Context context; + private KeyStore keyStore; - public Scrambler(Context context) { + protected Scrambler(Context context) { this.context = context; } - public void loadKeyStore() throws CryptoException { + protected void loadKeyStore() throws CryptoException { try { keyStore = KeyStore.getInstance(ANDROID_KEYSTORE); @@ -54,7 +54,7 @@ public class Scrambler { } @TargetApi(18) - public void generateNewKey(String alias) throws CryptoException { + protected void generateNewKey(String alias) throws CryptoException { Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); @@ -105,7 +105,7 @@ public class Scrambler { } - public String encryptString(String alias, String text) throws CryptoException { + protected String encryptString(String alias, String text) throws CryptoException { if (!alias.isEmpty() && !text.isEmpty()) { try { @@ -135,7 +135,7 @@ public class Scrambler { } } - public String decryptString(String alias, String text) throws CryptoException { + protected String decryptString(String alias, String text) throws CryptoException { if (!alias.isEmpty() && !text.isEmpty()) { try { diff --git a/app/src/main/java/io/github/wulkanowy/services/LoginSession.java b/app/src/main/java/io/github/wulkanowy/services/LoginSession.java new file mode 100644 index 000000000..57f69a3be --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/services/LoginSession.java @@ -0,0 +1,41 @@ +package io.github.wulkanowy.services; + + +import io.github.wulkanowy.api.Vulcan; +import io.github.wulkanowy.dao.entities.DaoSession; + +public class LoginSession { + + private Long userId; + + private Vulcan vulcan; + + private DaoSession daoSession; + + public Long getUserId() { + return userId; + } + + public LoginSession setUserId(Long userId) { + this.userId = userId; + return this; + } + + public Vulcan getVulcan() { + return vulcan; + } + + public LoginSession setVulcan(Vulcan vulcan) { + this.vulcan = vulcan; + return this; + } + + public DaoSession getDaoSession() { + return daoSession; + } + + public LoginSession setDaoSession(DaoSession daoSession) { + this.daoSession = daoSession; + return this; + } +} diff --git a/app/src/main/java/io/github/wulkanowy/services/VulcanSynchronization.java b/app/src/main/java/io/github/wulkanowy/services/VulcanSynchronization.java new file mode 100644 index 000000000..b058e57db --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/services/VulcanSynchronization.java @@ -0,0 +1,67 @@ +package io.github.wulkanowy.services; + +import android.content.Context; +import android.util.Log; + +import java.io.IOException; + +import io.github.wulkanowy.api.Vulcan; +import io.github.wulkanowy.api.login.AccountPermissionException; +import io.github.wulkanowy.api.login.BadCredentialsException; +import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; +import io.github.wulkanowy.dao.entities.DaoSession; +import io.github.wulkanowy.security.CryptoException; +import io.github.wulkanowy.services.jobs.VulcanSync; +import io.github.wulkanowy.services.synchronisation.AccountSynchronisation; +import io.github.wulkanowy.services.synchronisation.GradesSynchronisation; +import io.github.wulkanowy.services.synchronisation.SubjectsSynchronisation; + +public class VulcanSynchronization { + + private LoginSession loginSession; + + public VulcanSynchronization(LoginSession loginSession) { + this.loginSession = loginSession; + } + + public void loginCurrentUser(Context context, DaoSession daoSession, Vulcan vulcan) + throws CryptoException, BadCredentialsException, AccountPermissionException, IOException, LoginErrorException { + + AccountSynchronisation accountSynchronisation = new AccountSynchronisation(); + loginSession = accountSynchronisation.loginCurrentUser(context, daoSession, vulcan); + } + + public void loginNewUser(String email, String password, String symbol, + Context context, DaoSession daoSession, Vulcan vulcan) + throws BadCredentialsException, NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException { + + AccountSynchronisation accountSynchronisation = new AccountSynchronisation(); + loginSession = accountSynchronisation.loginNewUser(email, password, symbol, context, daoSession, vulcan); + } + + public boolean syncGrades() { + GradesSynchronisation gradesSynchronisation = new GradesSynchronisation(); + + try { + gradesSynchronisation.sync(loginSession); + return true; + } catch (Exception e) { + Log.e(VulcanSync.DEBUG_TAG, "Synchronisation of grades failed", e); + return false; + } + } + + public boolean syncSubjectsAndGrades() { + SubjectsSynchronisation subjectsSynchronisation = new SubjectsSynchronisation(); + + try { + subjectsSynchronisation.sync(loginSession); + syncGrades(); + return true; + } catch (Exception e) { + Log.e(VulcanSync.DEBUG_TAG, "Synchronisation of subjects failed", e); + return false; + } + } +} diff --git a/app/src/main/java/io/github/wulkanowy/services/jobs/GradesSync.java b/app/src/main/java/io/github/wulkanowy/services/jobs/GradesSync.java index e65ec165e..1410fbf3b 100644 --- a/app/src/main/java/io/github/wulkanowy/services/jobs/GradesSync.java +++ b/app/src/main/java/io/github/wulkanowy/services/jobs/GradesSync.java @@ -10,13 +10,14 @@ import com.firebase.jobdispatcher.Trigger; import java.io.IOException; import io.github.wulkanowy.activity.WulkanowyApp; +import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.AccountPermissionException; import io.github.wulkanowy.api.login.BadCredentialsException; -import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; import io.github.wulkanowy.dao.entities.DaoSession; import io.github.wulkanowy.security.CryptoException; -import io.github.wulkanowy.services.synchronisation.DataSynchronisation; -import io.github.wulkanowy.services.synchronisation.VulcanSynchronisation; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.VulcanSynchronization; public class GradesSync extends VulcanSync { @@ -44,14 +45,13 @@ public class GradesSync extends VulcanSync { @Override public void workToBePerformed() throws CryptoException, BadCredentialsException, - LoginErrorException, AccountPermissionException, IOException { + NotLoggedInErrorException, AccountPermissionException, IOException { DaoSession daoSession = ((WulkanowyApp) getApplication()).getDaoSession(); - VulcanSynchronisation vulcanSynchronisation = new VulcanSynchronisation(); - DataSynchronisation dataSynchronisation = new DataSynchronisation(daoSession); - vulcanSynchronisation.loginCurrentUser(getApplicationContext(), daoSession); - dataSynchronisation.syncGrades(vulcanSynchronisation); + VulcanSynchronization vulcanSynchronization = new VulcanSynchronization(new LoginSession()); + vulcanSynchronization.loginCurrentUser(getApplicationContext(), daoSession, new Vulcan()); + vulcanSynchronization.syncGrades(); } } } diff --git a/app/src/main/java/io/github/wulkanowy/services/jobs/SubjectsSync.java b/app/src/main/java/io/github/wulkanowy/services/jobs/SubjectsSync.java index 3360065b3..dc91e2459 100644 --- a/app/src/main/java/io/github/wulkanowy/services/jobs/SubjectsSync.java +++ b/app/src/main/java/io/github/wulkanowy/services/jobs/SubjectsSync.java @@ -10,13 +10,14 @@ import com.firebase.jobdispatcher.Trigger; import java.io.IOException; import io.github.wulkanowy.activity.WulkanowyApp; +import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.login.AccountPermissionException; import io.github.wulkanowy.api.login.BadCredentialsException; -import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; import io.github.wulkanowy.dao.entities.DaoSession; import io.github.wulkanowy.security.CryptoException; -import io.github.wulkanowy.services.synchronisation.DataSynchronisation; -import io.github.wulkanowy.services.synchronisation.VulcanSynchronisation; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.VulcanSynchronization; public class SubjectsSync extends VulcanSync { @@ -44,14 +45,13 @@ public class SubjectsSync extends VulcanSync { @Override public void workToBePerformed() throws CryptoException, BadCredentialsException, - LoginErrorException, AccountPermissionException, IOException { + NotLoggedInErrorException, AccountPermissionException, IOException { DaoSession daoSession = ((WulkanowyApp) getApplication()).getDaoSession(); - VulcanSynchronisation vulcanSynchronisation = new VulcanSynchronisation(); - DataSynchronisation dataSynchronisation = new DataSynchronisation(daoSession); - vulcanSynchronisation.loginCurrentUser(getApplicationContext(), daoSession); - dataSynchronisation.syncSubjectsAndGrades(vulcanSynchronisation); + VulcanSynchronization vulcanSynchronization = new VulcanSynchronization(new LoginSession()); + vulcanSynchronization.loginCurrentUser(getApplicationContext(), daoSession, new Vulcan()); + vulcanSynchronization.syncSubjectsAndGrades(); } } diff --git a/app/src/main/java/io/github/wulkanowy/services/jobs/VulcanJob.java b/app/src/main/java/io/github/wulkanowy/services/jobs/VulcanJob.java index eccb612fd..54da4214a 100644 --- a/app/src/main/java/io/github/wulkanowy/services/jobs/VulcanJob.java +++ b/app/src/main/java/io/github/wulkanowy/services/jobs/VulcanJob.java @@ -10,7 +10,7 @@ import java.io.IOException; import io.github.wulkanowy.api.login.AccountPermissionException; import io.github.wulkanowy.api.login.BadCredentialsException; -import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; import io.github.wulkanowy.security.CryptoException; public abstract class VulcanJob extends JobService { @@ -32,7 +32,7 @@ public abstract class VulcanJob extends JobService { } public abstract void workToBePerformed() throws CryptoException, BadCredentialsException, - LoginErrorException, AccountPermissionException, IOException; + NotLoggedInErrorException, AccountPermissionException, IOException; private class SyncTask extends AsyncTask { diff --git a/app/src/main/java/io/github/wulkanowy/services/synchronisation/AccountSynchronisation.java b/app/src/main/java/io/github/wulkanowy/services/synchronisation/AccountSynchronisation.java new file mode 100644 index 000000000..967c62d49 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/services/synchronisation/AccountSynchronisation.java @@ -0,0 +1,85 @@ +package io.github.wulkanowy.services.synchronisation; + +import android.content.Context; +import android.content.SharedPreferences; +import android.util.Log; + +import java.io.IOException; + +import io.github.wulkanowy.api.Vulcan; +import io.github.wulkanowy.api.login.AccountPermissionException; +import io.github.wulkanowy.api.login.BadCredentialsException; +import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; +import io.github.wulkanowy.api.user.PersonalData; +import io.github.wulkanowy.dao.entities.Account; +import io.github.wulkanowy.dao.entities.AccountDao; +import io.github.wulkanowy.dao.entities.DaoSession; +import io.github.wulkanowy.security.CryptoException; +import io.github.wulkanowy.security.Safety; +import io.github.wulkanowy.services.LoginSession; +import io.github.wulkanowy.services.jobs.VulcanSync; + +public class AccountSynchronisation { + + public LoginSession loginCurrentUser(Context context, DaoSession daoSession, Vulcan vulcan) throws CryptoException, + BadCredentialsException, AccountPermissionException, IOException, LoginErrorException { + + AccountDao accountDao = daoSession.getAccountDao(); + + long userId = context.getSharedPreferences("LoginData", Context.MODE_PRIVATE).getLong("userId", 0); + + if (userId != 0) { + + Log.d(VulcanSync.DEBUG_TAG, "Login current user id=" + String.valueOf(userId)); + + Safety safety = new Safety(context); + Account account = accountDao.load(userId); + vulcan.login( + account.getEmail(), + safety.decrypt(account.getEmail(), account.getPassword()), + account.getSymbol() + ); + + return new LoginSession() + .setDaoSession(daoSession) + .setUserId(userId) + .setVulcan(vulcan); + } else { + Log.wtf(VulcanSync.DEBUG_TAG, "loginCurrentUser - USERID IS EMPTY"); + throw new IOException("Can't find user with index 0"); + } + } + + public LoginSession loginNewUser(String email, String password, String symbol, Context context, DaoSession daoSession, Vulcan vulcan) + throws BadCredentialsException, NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException { + + long userId; + + vulcan.login(email, password, symbol); + + PersonalData personalData = vulcan.getBasicInformation().getPersonalData(); + AccountDao accountDao = daoSession.getAccountDao(); + Safety safety = new Safety(context); + + Account account = new Account() + .setName(personalData.getFirstAndLastName()) + .setEmail(email) + .setPassword(safety.encrypt(email, password)) + .setSymbol(symbol); + + userId = accountDao.insert(account); + + Log.d(VulcanSync.DEBUG_TAG, "Login and save new user id=" + String.valueOf(userId)); + + SharedPreferences sharedPreferences = context.getSharedPreferences("LoginData", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putLong("userId", userId); + editor.apply(); + + return new LoginSession() + .setVulcan(vulcan) + .setUserId(userId) + .setDaoSession(daoSession); + } +} diff --git a/app/src/main/java/io/github/wulkanowy/services/synchronisation/DataSynchronisation.java b/app/src/main/java/io/github/wulkanowy/services/synchronisation/DataSynchronisation.java deleted file mode 100644 index ff764beca..000000000 --- a/app/src/main/java/io/github/wulkanowy/services/synchronisation/DataSynchronisation.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.wulkanowy.services.synchronisation; - -import android.app.Activity; -import android.util.Log; - -import io.github.wulkanowy.activity.WulkanowyApp; -import io.github.wulkanowy.dao.entities.DaoSession; -import io.github.wulkanowy.services.jobs.VulcanSync; - -public class DataSynchronisation { - - private DaoSession daoSession; - - public DataSynchronisation(DaoSession daoSession) { - this.daoSession = daoSession; - } - - public DataSynchronisation(Activity activity) { - daoSession = ((WulkanowyApp) activity.getApplication()).getDaoSession(); - } - - public void syncGrades(VulcanSynchronisation vulcanSynchronisation) { - GradesSynchronisation gradesSynchronisation = new GradesSynchronisation(); - - try { - gradesSynchronisation.sync(vulcanSynchronisation, daoSession); - } catch (Exception e) { - Log.e(VulcanSync.DEBUG_TAG, "Synchronisation of grades failed", e); - } - } - - public void syncSubjectsAndGrades(VulcanSynchronisation vulcanSynchronisation) { - SubjectsSynchronisation subjectsSynchronisation = new SubjectsSynchronisation(); - - try { - subjectsSynchronisation.sync(vulcanSynchronisation, daoSession); - syncGrades(vulcanSynchronisation); - } catch (Exception e) { - Log.e(VulcanSync.DEBUG_TAG, "Synchronisation of subjects failed", e); - } - } -} diff --git a/app/src/main/java/io/github/wulkanowy/services/synchronisation/GradesSynchronisation.java b/app/src/main/java/io/github/wulkanowy/services/synchronisation/GradesSynchronisation.java index fccc4d56a..4f56cebeb 100644 --- a/app/src/main/java/io/github/wulkanowy/services/synchronisation/GradesSynchronisation.java +++ b/app/src/main/java/io/github/wulkanowy/services/synchronisation/GradesSynchronisation.java @@ -10,30 +10,30 @@ import java.util.ArrayList; import java.util.List; import io.github.wulkanowy.api.grades.GradesList; -import io.github.wulkanowy.api.login.LoginErrorException; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; import io.github.wulkanowy.dao.EntitiesCompare; import io.github.wulkanowy.dao.entities.Account; import io.github.wulkanowy.dao.entities.AccountDao; -import io.github.wulkanowy.dao.entities.DaoSession; import io.github.wulkanowy.dao.entities.Grade; import io.github.wulkanowy.dao.entities.GradeDao; import io.github.wulkanowy.dao.entities.Subject; import io.github.wulkanowy.dao.entities.SubjectDao; +import io.github.wulkanowy.services.LoginSession; import io.github.wulkanowy.services.jobs.VulcanSync; import io.github.wulkanowy.utilities.ConversionVulcanObject; public class GradesSynchronisation { - public void sync(VulcanSynchronisation vulcanSynchronisation, DaoSession daoSession) throws IOException, - ParseException, LoginErrorException { + public void sync(LoginSession loginSession) throws IOException, + ParseException, NotLoggedInErrorException { - GradesList gradesList = new GradesList(vulcanSynchronisation.getStudentAndParent()); + GradesList gradesList = loginSession.getVulcan().getGradesList(); - GradeDao gradeDao = daoSession.getGradeDao(); - AccountDao accountDao = daoSession.getAccountDao(); - SubjectDao subjectDao = daoSession.getSubjectDao(); + GradeDao gradeDao = loginSession.getDaoSession().getGradeDao(); + AccountDao accountDao = loginSession.getDaoSession().getAccountDao(); + SubjectDao subjectDao = loginSession.getDaoSession().getSubjectDao(); - Account account = accountDao.load(vulcanSynchronisation.getUserId()); + Account account = accountDao.load(loginSession.getUserId()); List gradesFromDb = account.getGradeList(); List gradeEntitiesList = ConversionVulcanObject.gradesToGradeEntities(gradesList.getAll()); @@ -49,7 +49,7 @@ public class GradesSynchronisation { .where(SubjectDao.Properties.Name.eq(grade.getSubject())) .build(); - grade.setUserId(vulcanSynchronisation.getUserId()); + grade.setUserId(loginSession.getUserId()); grade.setSubjectId((subjectQuery.uniqueOrThrow()).getId()); lastList.add(grade); diff --git a/app/src/main/java/io/github/wulkanowy/services/synchronisation/SubjectsSynchronisation.java b/app/src/main/java/io/github/wulkanowy/services/synchronisation/SubjectsSynchronisation.java index d894bc67f..7cb9b505e 100644 --- a/app/src/main/java/io/github/wulkanowy/services/synchronisation/SubjectsSynchronisation.java +++ b/app/src/main/java/io/github/wulkanowy/services/synchronisation/SubjectsSynchronisation.java @@ -8,26 +8,26 @@ import java.util.ArrayList; import java.util.List; import io.github.wulkanowy.api.grades.SubjectsList; -import io.github.wulkanowy.api.login.LoginErrorException; -import io.github.wulkanowy.dao.entities.DaoSession; +import io.github.wulkanowy.api.login.NotLoggedInErrorException; import io.github.wulkanowy.dao.entities.Subject; import io.github.wulkanowy.dao.entities.SubjectDao; +import io.github.wulkanowy.services.LoginSession; import io.github.wulkanowy.services.jobs.VulcanSync; import io.github.wulkanowy.utilities.ConversionVulcanObject; public class SubjectsSynchronisation { - public void sync(VulcanSynchronisation vulcanSynchronisation, DaoSession daoSession) throws IOException, - ParseException, LoginErrorException { + public void sync(LoginSession loginSession) throws IOException, + ParseException, NotLoggedInErrorException { - SubjectsList subjectsList = new SubjectsList(vulcanSynchronisation.getStudentAndParent()); - SubjectDao subjectDao = daoSession.getSubjectDao(); + SubjectsList subjectsList = loginSession.getVulcan().getSubjectsList(); + SubjectDao subjectDao = loginSession.getDaoSession().getSubjectDao(); List subjectEntitiesList = ConversionVulcanObject.subjectsToSubjectEntities(subjectsList.getAll()); List preparedList = new ArrayList<>(); for (Subject subject : subjectEntitiesList) { - subject.setUserId(vulcanSynchronisation.getUserId()); + subject.setUserId(loginSession.getUserId()); preparedList.add(subject); } diff --git a/app/src/main/java/io/github/wulkanowy/services/synchronisation/VulcanSynchronisation.java b/app/src/main/java/io/github/wulkanowy/services/synchronisation/VulcanSynchronisation.java deleted file mode 100644 index 28cd7adf2..000000000 --- a/app/src/main/java/io/github/wulkanowy/services/synchronisation/VulcanSynchronisation.java +++ /dev/null @@ -1,122 +0,0 @@ -package io.github.wulkanowy.services.synchronisation; - -import android.app.Activity; -import android.content.Context; -import android.content.SharedPreferences; -import android.util.Log; - -import java.io.IOException; -import java.util.Map; - -import io.github.wulkanowy.activity.WulkanowyApp; -import io.github.wulkanowy.api.Cookies; -import io.github.wulkanowy.api.StudentAndParent; -import io.github.wulkanowy.api.login.AccountPermissionException; -import io.github.wulkanowy.api.login.BadCredentialsException; -import io.github.wulkanowy.api.login.Login; -import io.github.wulkanowy.api.login.LoginErrorException; -import io.github.wulkanowy.api.user.BasicInformation; -import io.github.wulkanowy.api.user.PersonalData; -import io.github.wulkanowy.dao.entities.Account; -import io.github.wulkanowy.dao.entities.AccountDao; -import io.github.wulkanowy.dao.entities.DaoSession; -import io.github.wulkanowy.security.CryptoException; -import io.github.wulkanowy.security.Safety; -import io.github.wulkanowy.services.jobs.VulcanSync; - -public class VulcanSynchronisation { - - private StudentAndParent studentAndParent; - - private Long userId = 0L; - - public void loginCurrentUser(Context context, DaoSession daoSession) throws CryptoException, - BadCredentialsException, LoginErrorException, AccountPermissionException, IOException { - - AccountDao accountDao = daoSession.getAccountDao(); - - userId = context.getSharedPreferences("LoginData", Context.MODE_PRIVATE).getLong("userId", 0); - - if (userId != 0) { - - Log.d(VulcanSync.DEBUG_TAG, "Login current user id=" + String.valueOf(userId)); - - Safety safety = new Safety(context); - Account account = accountDao.load(userId); - Login login = loginUser( - account.getEmail(), - safety.decrypt(account.getEmail(), account.getPassword()), - account.getSymbol()); - - getAndSetStudentAndParentFromApi(account.getSymbol(), login.getCookies()); - } else { - Log.wtf(VulcanSync.DEBUG_TAG, "loginCurrentUser - USERID IS EMPTY"); - } - } - - public void loginNewUser(String email, String password, String symbol, Context context, DaoSession daoSession) - throws BadCredentialsException, LoginErrorException, AccountPermissionException, IOException, CryptoException { - - AccountDao accountDao = daoSession.getAccountDao(); - - Login login = loginUser(email, password, symbol); - - Safety safety = new Safety(context); - BasicInformation basicInformation = new BasicInformation(getAndSetStudentAndParentFromApi(symbol, login.getCookies())); - PersonalData personalData = basicInformation.getPersonalData(); - - Account account = new Account() - .setName(personalData.getFirstAndLastName()) - .setEmail(email) - .setPassword(safety.encrypt(email, password)) - .setSymbol(symbol); - - userId = accountDao.insert(account); - - Log.d(VulcanSync.DEBUG_TAG, "Login and save new user id=" + String.valueOf(userId)); - - SharedPreferences sharedPreferences = context.getSharedPreferences("LoginData", Context.MODE_PRIVATE); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putLong("userId", userId); - editor.apply(); - } - - public void loginNewUser(String email, String password, String symbol, Activity activity) - throws BadCredentialsException, LoginErrorException, AccountPermissionException, IOException, CryptoException { - loginNewUser(email, password, symbol, activity, ((WulkanowyApp) activity.getApplication()).getDaoSession()); - } - - private Login loginUser(String email, String password, String symbol) throws BadCredentialsException, - LoginErrorException, AccountPermissionException { - - Cookies cookies = new Cookies(); - Login login = new Login(cookies); - login.login(email, password, symbol); - return login; - - } - - public Long getUserId() { - return userId; - } - - public StudentAndParent getStudentAndParent() { - return studentAndParent; - } - - private StudentAndParent getAndSetStudentAndParentFromApi(String symbol, Map cookiesMap) - throws IOException, LoginErrorException { - - if (studentAndParent == null) { - Cookies cookies = new Cookies(); - cookies.setItems(cookiesMap); - - StudentAndParent snp = new StudentAndParent(cookies, symbol); - - studentAndParent = snp; - return snp; - } else { - return studentAndParent; - } - } -} diff --git a/app/src/test/java/io/github/wulkanowy/api/FixtureHelper.java b/app/src/test/java/io/github/wulkanowy/api/FixtureHelper.java index c487fb320..94dd47b87 100644 --- a/app/src/test/java/io/github/wulkanowy/api/FixtureHelper.java +++ b/app/src/test/java/io/github/wulkanowy/api/FixtureHelper.java @@ -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() : ""; } } diff --git a/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTest.java b/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTest.java index e2ecde39c..9b0609e32 100644 --- a/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTest.java @@ -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/")); } diff --git a/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTestCase.java b/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTestCase.java new file mode 100644 index 000000000..b18076cfa --- /dev/null +++ b/app/src/test/java/io/github/wulkanowy/api/StudentAndParentTestCase.java @@ -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.anyList())) + .thenCallRealMethod(); + Mockito.when(snp.getRowDataChildValue(Mockito.any(Element.class), + Mockito.anyInt())).thenCallRealMethod(); + + return snp; + } +} diff --git a/app/src/test/java/io/github/wulkanowy/api/VulcanTest.java b/app/src/test/java/io/github/wulkanowy/api/VulcanTest.java new file mode 100644 index 000000000..02b85ceac --- /dev/null +++ b/app/src/test/java/io/github/wulkanowy/api/VulcanTest.java @@ -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)); + } +} diff --git a/app/src/test/java/io/github/wulkanowy/api/attendance/StatisticsTest.java b/app/src/test/java/io/github/wulkanowy/api/attendance/AttendanceStatisticsTest.java similarity index 87% rename from app/src/test/java/io/github/wulkanowy/api/attendance/StatisticsTest.java rename to app/src/test/java/io/github/wulkanowy/api/attendance/AttendanceStatisticsTest.java index 442ff97ee..7b1e37631 100644 --- a/app/src/test/java/io/github/wulkanowy/api/attendance/StatisticsTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/attendance/AttendanceStatisticsTest.java @@ -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 diff --git a/app/src/test/java/io/github/wulkanowy/api/attendance/TableTest.java b/app/src/test/java/io/github/wulkanowy/api/attendance/AttendanceTableTest.java similarity index 90% rename from app/src/test/java/io/github/wulkanowy/api/attendance/TableTest.java rename to app/src/test/java/io/github/wulkanowy/api/attendance/AttendanceTableTest.java index 0282bae11..1420a4752 100644 --- a/app/src/test/java/io/github/wulkanowy/api/attendance/TableTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/attendance/AttendanceTableTest.java @@ -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 diff --git a/app/src/test/java/io/github/wulkanowy/api/grades/GradesListTest.java b/app/src/test/java/io/github/wulkanowy/api/grades/GradesListTest.java index 330809472..bee5b4fee 100644 --- a/app/src/test/java/io/github/wulkanowy/api/grades/GradesListTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/grades/GradesListTest.java @@ -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 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 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 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 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 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 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 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 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 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 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()); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/grades/GradesTest.java b/app/src/test/java/io/github/wulkanowy/api/grades/GradesTest.java deleted file mode 100644 index 9b3559184..000000000 --- a/app/src/test/java/io/github/wulkanowy/api/grades/GradesTest.java +++ /dev/null @@ -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.anyList())) - .thenCallRealMethod(); - } -} diff --git a/app/src/test/java/io/github/wulkanowy/api/grades/SubjectsListTest.java b/app/src/test/java/io/github/wulkanowy/api/grades/SubjectsListTest.java index fcae12624..d32283781 100644 --- a/app/src/test/java/io/github/wulkanowy/api/grades/SubjectsListTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/grades/SubjectsListTest.java @@ -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 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 list = getSetUpSubjectsList(fixtureAverageFileName).getAll(); + public void getNameTest() throws Exception { + List 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 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 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 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 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 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()); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/notes/AchievementsListTest.java b/app/src/test/java/io/github/wulkanowy/api/notes/AchievementsListTest.java index 2f0e340ff..0d7774bb4 100644 --- a/app/src/test/java/io/github/wulkanowy/api/notes/AchievementsListTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/notes/AchievementsListTest.java @@ -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 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 list = getSetUpAchievementsList(fixtureEmptyFileName).getAllAchievements(); + public void getAchievements() throws Exception { + List 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)); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/notes/NotesListTest.java b/app/src/test/java/io/github/wulkanowy/api/notes/NotesListTest.java index 14f1f69f2..d76c06486 100644 --- a/app/src/test/java/io/github/wulkanowy/api/notes/NotesListTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/notes/NotesListTest.java @@ -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 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 list = getSetUpNotesList(fixtureEmptyFileName).getAllNotes(); + public void getDateTest() throws Exception { + List 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 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 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 filledList = filled.getAllNotes(); + + Assert.assertEquals("Pomoc przy pikniku charytatywnym", filledList.get(0).getContent()); + Assert.assertEquals("Przeszkadzanie w prowadzeniu lekcji", filledList.get(2).getContent()); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/school/SchoolInfoTest.java b/app/src/test/java/io/github/wulkanowy/api/school/SchoolInfoTest.java index 850de52f8..947db9b8f 100644 --- a/app/src/test/java/io/github/wulkanowy/api/school/SchoolInfoTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/school/SchoolInfoTest.java @@ -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()); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/school/SchoolTest.java b/app/src/test/java/io/github/wulkanowy/api/school/SchoolTest.java deleted file mode 100644 index 81c3d28dd..000000000 --- a/app/src/test/java/io/github/wulkanowy/api/school/SchoolTest.java +++ /dev/null @@ -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(); - } -} diff --git a/app/src/test/java/io/github/wulkanowy/api/school/TeachersInfoTest.java b/app/src/test/java/io/github/wulkanowy/api/school/TeachersInfoTest.java index 3c7237c8c..b0da356b1 100644 --- a/app/src/test/java/io/github/wulkanowy/api/school/TeachersInfoTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/school/TeachersInfoTest.java @@ -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 subjects = teachersData.getSubjects(); + @Test + public void getTeachersDataSubjectsNameTest() throws Exception { + List 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 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]", diff --git a/app/src/test/java/io/github/wulkanowy/api/timetable/TableTest.java b/app/src/test/java/io/github/wulkanowy/api/timetable/TableTest.java deleted file mode 100644 index 230d68d48..000000000 --- a/app/src/test/java/io/github/wulkanowy/api/timetable/TableTest.java +++ /dev/null @@ -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()); - } -} diff --git a/app/src/test/java/io/github/wulkanowy/api/timetable/TimetableTest.java b/app/src/test/java/io/github/wulkanowy/api/timetable/TimetableTest.java new file mode 100644 index 000000000..5eb9487cb --- /dev/null +++ b/app/src/test/java/io/github/wulkanowy/api/timetable/TimetableTest.java @@ -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()); + } +} diff --git a/app/src/test/java/io/github/wulkanowy/api/user/BasicInformationTest.java b/app/src/test/java/io/github/wulkanowy/api/user/BasicInformationTest.java index e948235c8..6b729c95a 100644 --- a/app/src/test/java/io/github/wulkanowy/api/user/BasicInformationTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/user/BasicInformationTest.java @@ -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()); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/user/FamilyInformationTest.java b/app/src/test/java/io/github/wulkanowy/api/user/FamilyInformationTest.java index a523836f1..b4f858ece 100644 --- a/app/src/test/java/io/github/wulkanowy/api/user/FamilyInformationTest.java +++ b/app/src/test/java/io/github/wulkanowy/api/user/FamilyInformationTest.java @@ -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 familyMemberList = familyInformation.getFamilyMembers(); + Assert.assertEquals(2, familyInformation.getFamilyMembers().size()); + } - Assert.assertEquals(2, familyMemberList.size()); + @Test + public void getNameTest() throws Exception { + List 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 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 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 list = familyInformation.getFamilyMembers(); + Assert.assertEquals("555111222", list.get(0).getTelephones()); + Assert.assertEquals("555222111", list.get(1).getTelephones()); + } + + @Test + public void getEmailTest() throws Exception { + List list = familyInformation.getFamilyMembers(); + Assert.assertEquals("wulkanowy@example.null", list.get(0).getEmail()); + Assert.assertEquals("wulkanowy@example.null", list.get(1).getEmail()); } } diff --git a/app/src/test/java/io/github/wulkanowy/api/user/UserTest.java b/app/src/test/java/io/github/wulkanowy/api/user/UserTest.java deleted file mode 100644 index ab0ed9d49..000000000 --- a/app/src/test/java/io/github/wulkanowy/api/user/UserTest.java +++ /dev/null @@ -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(); - } -} diff --git a/app/src/test/resources/io/github/wulkanowy/api/Start.html b/app/src/test/resources/io/github/wulkanowy/api/Start.html new file mode 100644 index 000000000..40e691610 --- /dev/null +++ b/app/src/test/resources/io/github/wulkanowy/api/Start.html @@ -0,0 +1,24 @@ + + + + + Uonet+ + + +
+ +
+ + diff --git a/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-full.html b/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-full.html index fc717ae7e..24c889637 100644 --- a/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-full.html +++ b/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-full.html @@ -41,19 +41,19 @@ 08:00 08:45
- Język angielski [J1] - - Kobczyk Iwona - + Język angielski [J1] + + Kobczyk Iwona +
- Użytkowanie urządzeń peryferyjnych komputera [zaw2] - - Bączek Robert - + Użytkowanie urządzeń peryferyjnych komputera [zaw2] + + Bączek Robert +
@@ -64,9 +64,9 @@ 08:50 09:35
- Język polski - Bocian Natalia - + Język polski + Bocian Natalia +
@@ -84,24 +84,24 @@ (przeniesiona z lekcji 7, 20.06.2017)
- Język polski - Bocian Natalia - + Język polski + Bocian Natalia +
- Urządzenia techniki komputerowej [zaw2] - - Bocian Grzegorz - + Urządzenia techniki komputerowej [zaw2] + + Bocian Grzegorz +
- Matematyka - Baran Małgorzata - + Matematyka + Baran Małgorzata +
@@ -111,9 +111,9 @@ 09:40 10:25
- Język polski - Bocian Natalia - + Język polski + Bocian Natalia +
@@ -131,26 +131,26 @@ (przeniesiona z lekcji 4, 20.06.2017)
- Wychowanie fizyczne [wf2] - - Nowicka Irena - + Wychowanie fizyczne [wf2] + + Nowicka Irena +
- Metodologia programowania [zaw2] - - Baran Małgorzata - + Metodologia programowania [zaw2] + + Baran Małgorzata +
- Wychowanie fizyczne [wf2] - - Nowicka Irena - + Wychowanie fizyczne [wf2] + + Nowicka Irena +
@@ -160,10 +160,10 @@ 10:40 11:25
- Urządzenia techniki komputerowej [zaw2] - - Bocian Grzegorz - + Urządzenia techniki komputerowej [zaw2] + + Bocian Grzegorz +
@@ -177,17 +177,17 @@
- Matematyka - Baran Małgorzata - + Matematyka + Baran Małgorzata +
- Wychowanie fizyczne [wf2] - - Nowicka Irena - + Wychowanie fizyczne [wf2] + + Nowicka Irena +
@@ -197,10 +197,10 @@ 11:30 12:15
- Urządzenia techniki komputerowej [zaw2] - - Bocian Grzegorz - + Urządzenia techniki komputerowej [zaw2] + + Bocian Grzegorz +
@@ -213,17 +213,17 @@
- Religia - Cyranka Krystian - + Religia + Cyranka Krystian +
- Sieci komputerowe i administrowanie sieciami [zaw2] - - Rożeniec Piotr - + Sieci komputerowe i administrowanie sieciami [zaw2] + + Rożeniec Piotr +
@@ -233,9 +233,9 @@ 12:20 13:05
- Matematyka - Baran Małgorzata - + Matematyka + Baran Małgorzata +
@@ -248,17 +248,17 @@
- Język angielski [J1] - - Brodziec Sylwia - + Język angielski [J1] + + Brodziec Sylwia +
- Religia - Cyranka Krystian - + Religia + Cyranka Krystian +
@@ -284,17 +284,17 @@
- Multimedia i grafika komputerowa [zaw2] - - Bocian Konrad - + Multimedia i grafika komputerowa [zaw2] + + Bocian Konrad +
- Wiedza o kulturze - Bocian Natalia - + Wiedza o kulturze + Bocian Natalia +
@@ -304,9 +304,9 @@ 14:00 14:45
- Zajęcia z wychowawcą - Baran Małgorzata - + Zajęcia z wychowawcą + Baran Małgorzata +
diff --git a/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-std.html b/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-std.html index 345a1ff53..8bcc9794e 100644 --- a/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-std.html +++ b/app/src/test/resources/io/github/wulkanowy/api/timetable/PlanLekcji-std.html @@ -26,18 +26,18 @@ 08:00 08:45
- Edukacja dla bezpieczeństwa - Kobczyk Iwona - + Edukacja dla bezpieczeństwa + Kobczyk Iwona +
- Język niemiecki [JNPW] - - Dzwoniec Ewa - + Język niemiecki [JNPW] + + Dzwoniec Ewa +
@@ -49,10 +49,10 @@
- Język niemiecki [JNPW] - - Dzwoniec Ewa - + Język niemiecki [JNPW] + + Dzwoniec Ewa +
@@ -61,38 +61,38 @@ 08:50 09:35
- Historia - Bogatka Katarzyna - + Historia + Bogatka Katarzyna +
- Wychowanie fizyczne [CH] - - Brodziec Dominika - + Wychowanie fizyczne [CH] + + Brodziec Dominika +
- Fizyka - Bocian Łukasz - + Fizyka + Bocian Łukasz +
- Biologia - Kowalska Anna - + Biologia + Kowalska Anna +
- Religia - Kraska Maciej - + Religia + Kraska Maciej +
@@ -101,38 +101,38 @@ 09:40 10:25
- Wychowanie fizyczne [CH] - - Brodziec Dominika - + Wychowanie fizyczne [CH] + + Brodziec Dominika +
- Język polski - Rożeniec Paulina - + Język polski + Rożeniec Paulina +
- Matematyka - Bączek Dominika - + Matematyka + Bączek Dominika +
- Plastyka - Rożeniec Paulina - + Plastyka + Rożeniec Paulina +
- Zajęcia z wychowawcą - Kowalska Anna - + Zajęcia z wychowawcą + Kowalska Anna +
@@ -141,38 +141,38 @@ 10:30 11:15
- Geografia - Orłowski Konrad - + Geografia + Orłowski Konrad +
- Matematyka - Bączek Dominika - + Matematyka + Bączek Dominika +
- Język angielski [JAPN] - - Biegus Kazimiera - + Język angielski [JAPN] + + Biegus Kazimiera +
- Matematyka - Bączek Dominika - + Matematyka + Bączek Dominika +
- Historia - Bogatka Katarzyna - + Historia + Bogatka Katarzyna +
@@ -181,38 +181,38 @@ 11:30 12:15
- Matematyka - Bączek Dominika - + Matematyka + Bączek Dominika +
- Biologia - Kowalska Anna - + Biologia + Kowalska Anna +
- Zajęcia techniczne - Chlebowski Stanisław - + Zajęcia techniczne + Chlebowski Stanisław +
- Język angielski [JAPN] - - Biegus Kazimiera - + Język angielski [JAPN] + + Biegus Kazimiera +
- Język polski - Rożeniec Paulina - + Język polski + Rożeniec Paulina +
@@ -221,38 +221,38 @@ 12:30 13:15
- Matematyka - Bączek Dominika - + Matematyka + Bączek Dominika +
- Fizyka - Bocian Łukasz - + Fizyka + Bocian Łukasz +
- Język polski - Rożeniec Paulina - + Język polski + Rożeniec Paulina +
- Wychowanie fizyczne [CH] - - Brodziec Dominika - + Wychowanie fizyczne [CH] + + Brodziec Dominika +
- Język polski - Rożeniec Paulina - + Język polski + Rożeniec Paulina +
@@ -261,25 +261,25 @@ 13:20 14:05
- Język angielski [JAPN] - - Biegus Kazimiera - + Język angielski [JAPN] + + Biegus Kazimiera +
- Religia - Kraska Maciej - + Religia + Kraska Maciej +
- Wychowanie fizyczne [CH] - - Brodziec Dominika - + Wychowanie fizyczne [CH] + + Brodziec Dominika +