Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cucumber features for Student viewpoint #55

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting changes only in the first 3 files

import ca.mcgill.cooperator.model.Course;
import ca.mcgill.cooperator.model.CourseOffering;

import java.util.List;

import org.springframework.data.repository.CrudRepository;

public interface CourseOfferingRepository extends CrudRepository<CourseOffering, Integer> {

List<CourseOffering> findByCourse(Course c);


List<CourseOffering> findByCourse(Course c);
}
11 changes: 5 additions & 6 deletions Backend/src/main/java/ca/mcgill/cooperator/model/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ public List<CourseOffering> getCourseOfferings() {
}

public void setCourseOfferings(List<CourseOffering> courseOfferings) {
if(this.courseOfferings == null)
this.courseOfferings = courseOfferings;
else {
this.courseOfferings.clear();
this.courseOfferings.addAll(courseOfferings);
}
if (this.courseOfferings == null) this.courseOfferings = courseOfferings;
else {
this.courseOfferings.clear();
this.courseOfferings.addAll(courseOfferings);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public CourseOffering createCourseOffering(int year, Season season, Course c) {

return courseOfferingRepository.save(co);
}

@Transactional
public CourseOffering updateCourseOffering(CourseOffering co, int year, Season season, Course c) {
public CourseOffering updateCourseOffering(
CourseOffering co, int year, Season season, Course c) {
StringBuilder error = new StringBuilder();
if (year <= 0) {
error.append("Year is invalid! ");
Expand All @@ -70,13 +71,13 @@ public CourseOffering updateCourseOffering(CourseOffering co, int year, Season s
if (c == null) {
error.append("Course cannot be null! ");
}
if (co == null){
error.append("Course Offering cannot be null!");
if (co == null) {
error.append("Course Offering cannot be null!");
}
if (error.length() > 0) {
throw new IllegalArgumentException(error.toString().trim());
}

co.setYear(year);
co.setSeason(season);
co.setCourse(c);
Expand All @@ -92,42 +93,44 @@ public CourseOffering updateCourseOffering(CourseOffering co, int year, Season s

return courseOfferingRepository.save(co);
}

@Transactional
public CourseOffering getCourseOfferingById(int id) {
CourseOffering c = courseOfferingRepository.findById(id).orElse(null);
if (c == null) {
throw new IllegalArgumentException("Course Offering with ID " + id + " does not exist!");
CourseOffering c = courseOfferingRepository.findById(id).orElse(null);
if (c == null) {
throw new IllegalArgumentException(
"Course Offering with ID " + id + " does not exist!");
}
return c;
return c;
}

@Transactional
public List<CourseOffering> getCourseOfferingsByCourse(Course c) {
List<CourseOffering> co = courseOfferingRepository.findByCourse(c);
if (co == null) {
throw new IllegalArgumentException("There are no course offerings for the course " + c.getName() + "!");
List<CourseOffering> co = courseOfferingRepository.findByCourse(c);
if (co == null) {
throw new IllegalArgumentException(
"There are no course offerings for the course " + c.getName() + "!");
}
return co;
return co;
}

@Transactional
public List<CourseOffering> getAllCourseOfferings(){
List<CourseOffering> co = ServiceUtils.toList(courseOfferingRepository.findAll());
if (co == null) {
public List<CourseOffering> getAllCourseOfferings() {
List<CourseOffering> co = ServiceUtils.toList(courseOfferingRepository.findAll());
if (co == null) {
throw new IllegalArgumentException("There are no course offerings!");
}
return co;
return co;
}

@Transactional
public CourseOffering deleteCourseOffering(CourseOffering co) {
courseOfferingRepository.delete(co);
Course c = co.getCourse();
List<CourseOffering> cos = c.getCourseOfferings();
cos.remove(co);
c.setCourseOfferings(cos);
courseRepository.save(c);
return co;
courseOfferingRepository.delete(co);
Course c = co.getCourse();
List<CourseOffering> cos = c.getCourseOfferings();
cos.remove(co);
c.setCourseOfferings(cos);
courseRepository.save(c);
return co;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

import static org.junit.Assert.assertTrue;

import org.springframework.test.context.ActiveProfiles;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
public class AdminApproveCoopIT {

@When("the Student submits their offer letter")
public void studentSubmitsOfferLetter() {
assertTrue(true);
}

@Then("the Admin approves the Coop term")
public void adminApprovesCoopTerm() {
assertTrue(true);
}


@When("the Student submits their offer letter")
public void studentSubmitsOfferLetter() {
assertTrue(true);
}

@Then("the Admin approves the Coop term")
public void adminApprovesCoopTerm() {
assertTrue(true);
}

@Then("the Admin rejects the Coop term")
public void adminRejectsCoopTerm() {
assertTrue(true);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package ca.mcgill.cooperator.cucumber;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

/**
* Configuration for Cucumber tests
*/
/** Configuration for Cucumber tests */
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features", plugin = {"pretty", "json:target/cucumber-report.json"})
public class CucumberIT {

}
@CucumberOptions(
features = "classpath:features",
plugin = {"pretty", "json:target/cucumber-report.json"})
public class CucumberIT {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ca.mcgill.cooperator.cucumber;

import static org.junit.Assert.assertTrue;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
public class StudentGetCoopInfoIT {

@Given("the Student has at least one current or previous Coop term")
public void studentHasAtLeastOneCoopTerm() {
assertTrue(true);
}

@When("the Student requests to get their Coop term information")
public void studentRequestsCoopInformation() {
assertTrue(true);
}

@Then("the system returns the information for all of their Coop terms")
public void getCoopInformationForStudent() {
assertTrue(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ca.mcgill.cooperator.cucumber;

import static org.junit.Assert.assertTrue;

import io.cucumber.java.en.And;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
public class StudentSubmitOfferLetterIT {

@When("the Student uploads a copy of their offer letter")
public void studentSubmitsOfferLetter() {
assertTrue(true);
}

@And("submits the details of their Coop term")
public void studentSubmitsCoopDetails() {
assertTrue(true);
}

@Then("the offer letter is put up for review by an Admin")
public void offerLetterIsPutUpForReview() {
assertTrue(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ca.mcgill.cooperator.cucumber;

import static org.junit.Assert.assertTrue;

import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
public class StudentUploadReportIT {

@Given("the Student is currently doing a Coop term")
public void studentHasCurrentCoopTerm() {
assertTrue(true);
}

@And("the Student has a Report due")
public void studentHasReportDue() {
assertTrue(true);
}

@When("the Student uploads the proper Report")
public void studentUploadsReport() {
assertTrue(true);
}

@Then("the Report is saved in the system")
public void saveReport() {
assertTrue(true);
}

@And("the Student has uploaded a Report type previously")
public void studentHasUploadedReportPreviously() {
assertTrue(true);
}

@When("the Student uploads the same type of Report again")
public void studentUploadsReportAgain() {
assertTrue(true);
}

@Then("the new Report overwrites the old one in the system")
public void overwriteReport() {
assertTrue(true);
}
}
Loading