Update dependencies and improve build process (#15)

This commit is contained in:
Mikołaj Pich
2017-08-10 12:59:13 +02:00
committed by GitHub
parent 0ea13cdadd
commit 344ba537fd
8 changed files with 127 additions and 62 deletions

View File

@ -42,6 +42,5 @@ dependencies {
compile 'org.apache.commons:commons-collections4:4.1'
testCompile 'junit:junit:4.12'
testCompile 'org.powermock:powermock-api-mockito:1.6.1'
testCompile group: 'org.unitils', name: 'unitils-core', version: '3.3'
testCompile 'org.mockito:mockito-core:2.8.47'
}

View File

@ -47,6 +47,10 @@ public class StudentAndParent extends Vulcan {
.replace("{ID}", getID());
}
public String getGradesPageUrl() {
return gradesPageUrl;
}
public String getLocationID() {
return locationID;
}
@ -66,9 +70,7 @@ public class StudentAndParent extends Vulcan {
}
public String getRowDataChildValue(Element e, int index) {
Elements es = e.select(".daneWiersz .wartosc");
return es.get(index - 1).text();
return e.select(".daneWiersz .wartosc").get(index - 1).text();
}
public Document getSnPPageDocument(String url) throws IOException {
@ -76,7 +78,7 @@ public class StudentAndParent extends Vulcan {
}
public List<Semester> getSemesters() throws IOException {
return getSemesters(getSnPPageDocument(gradesPageUrl));
return getSemesters(getSnPPageDocument(getGradesPageUrl()));
}
public List<Semester> getSemesters(Document gradesPage) {

View File

@ -6,7 +6,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import java.util.ArrayList;
import java.util.List;
@ -25,17 +24,15 @@ public class StudentAndParentTest {
Document gradesPageDocument = Jsoup.parse(input);
snp = Mockito.mock(StudentAndParent.class);
PowerMockito.whenNew(StudentAndParent.class)
.withArguments(Mockito.any(Cookies.class), Mockito.anyString()).thenReturn(snp);
Mockito.when(snp.getSnPPageDocument(Mockito.anyString())).thenReturn(gradesPageDocument);
Mockito.when(snp.getCalculatedID(Mockito.anyString())).thenCallRealMethod();
Mockito.when(snp.getLocationID()).thenReturn("symbol");
Mockito.when(snp.getID()).thenReturn("123456");
Mockito.when(snp.getSemesters()).thenCallRealMethod();
Mockito.when(snp.getGradesPageUrl()).thenReturn("http://wulkanowy.null");
Mockito.when(snp.getSemesters(Mockito.any(Document.class))).thenCallRealMethod();
Mockito.when(snp.getCurrentSemester(Mockito.anyListOf(Semester.class)))
.thenCallRealMethod();
Mockito.when(snp.getCurrentSemester(Mockito.<Semester>anyList())).thenCallRealMethod();
}
@Test

View File

@ -20,7 +20,7 @@ public class GradesTest {
Mockito.when(snp.getSnPPageDocument(Mockito.anyString()))
.thenReturn(gradesPageDocument);
Mockito.when(snp.getSemesters(Mockito.any(Document.class))).thenCallRealMethod();
Mockito.when(snp.getCurrentSemester(Mockito.anyListOf(Semester.class)))
Mockito.when(snp.getCurrentSemester(Mockito.<Semester>anyList()))
.thenCallRealMethod();
}
}