Skip to content

Commit

Permalink
More debugging stuff, need Jsoup lib
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-inge committed Feb 23, 2018
1 parent 05b3f6d commit 6918d52
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,18 @@ private String findEnrollCode(String html){
@param lect Lecture to set with the parsed elements
*/
private UCSBLecture parseEnd(String html, UCSBLecture lect){
System.out.println(html);
UCSBLecture temp = lect;
UCSBLecture temp = lect;

html = removeLastElement(html);
String enrollment_html = getEndElement(html);

System.out.println(html.toString());

int enrollment = Integer.parseInt(enrollment_html.substring(0, enrollment_html.indexOf("/")).trim());
int capacity = Integer.parseInt(enrollment_html.substring(enrollment_html.indexOf("/") + 1).trim());

//int enrollment = 23;
//int capacity = 36;

// Take out the enrollment/capacity because it has been parsed
html = removeLastElement(html);
Expand Down Expand Up @@ -516,7 +520,7 @@ public UCSBLecture parseLectureHtml(String html){

// String description = findDescription(html); // @TODO: This is unused as of now. Not in ticket but written by accident.
String status = findStatus(html);
String enrollcode = findEnrollCode(html);
String enrollcode = findEnrollCode(html);

lect.setCourseTitle(courseTitle);
lect.setPrimaryCourseAbbr(primaryCourseAbbr);
Expand All @@ -528,7 +532,7 @@ public UCSBLecture parseLectureHtml(String html){

lect = parseEnd(html, lect);

return lect;
return lect;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,63 @@
import org.junit.Test;
import static org.junit.Assert.assertEquals;

/** Test class for UCSBCurriculumSearch
/**
* Test class for UCSBCurriculumSearch
*
* @author Phill Conrad
* @author Daniel Vicory
* @version cs56.projects.W11, Issue 50
* @see UCSBCurriculumSearch
*/
*/

public class UCSBCurriculumSearchTest {



@Test
public void test_loadCourses() {
@Test
public void test_loadCourses() {
try {
System.setProperty("javax.net.ssl.trustStore", "jssecacerts");

UCSBCurriculumSearch uccs = new UCSBCurriculumSearch();
final String dept = "CMPSC"; // the department
final String qtr = "20112"; // 2012 = S11 [yyyyQ, where Q is 1,2,3,4 (1=W, 2=S, 3=M, 4=F)]
final String level = "Undergraduate"; // other options: "Graduate", "All".

//String page = uccs.getPage(dept,qtr,level);

final String qtr = "20112"; // 2012 = S11 [yyyyQ, where Q is 1,2,3,4
// (1=W, 2=S, 3=M, 4=F)]
final String level = "Undergraduate"; // other options: "Graduate",
// "All".

String page = uccs.getPage(dept,qtr,level);

int num_courses = uccs.loadCourses(dept, qtr, level);

// Should have found 23 lectures
assertEquals(23, num_courses);

} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}
}

@Test
public void test_loadCourses2() {
try{
try {
System.setProperty("javax.net.ssl.trustStore", "jssecacerts");

UCSBCurriculumSearch uccs2 = new UCSBCurriculumSearch();
final String dept = "JAPAN"; //the department
final String qtr = "20112"; //2016 Winter quarter
final String dept = "JAPAN"; // the department
final String qtr = "20161"; // 2016 Winter quarter
final String level = "Undergraduate";
//String page = uccs2.getPage(dept,qtr,level);

String page = uccs2.getPage(dept,qtr,level);

int num_courses = uccs2.loadCourses(dept, qtr, level);

assertEquals(21, num_courses);
}catch (Exception e) {

} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}

}

}

0 comments on commit 6918d52

Please sign in to comment.