Skip to content
Snippets Groups Projects
Commit 467f590d authored by Julian Dehne's avatar Julian Dehne
Browse files

bug: fixed problem in mocking

parent 380c7d34
No related branches found
No related tags found
No related merge requests found
package unipotsdam.gf.modules.researchreport;
import org.mockito.Mock;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;
import unipotsdam.gf.core.management.project.Project;
import unipotsdam.gf.core.management.user.User;
import unipotsdam.gf.interfaces.Feedback;
import javax.inject.Inject;
import java.io.File;
public class DummyResearchReportManagement implements ResearchReportManagement {
/**
* Utility to creaty dummy data for students
*/
......@@ -18,6 +22,7 @@ public class DummyResearchReportManagement implements ResearchReportManagement {
@Override
public String createResearchReport(
ResearchReport researchReport, Project project, User student) {
return factory.manufacturePojo(ResearchReport.class).getId();
}
......
......@@ -18,8 +18,6 @@ import unipotsdam.gf.core.management.project.Project;
import unipotsdam.gf.core.management.project.ProjectConfiguration;
import unipotsdam.gf.core.management.user.User;
import unipotsdam.gf.core.states.ProjectPhase;
import unipotsdam.gf.modules.assessment.AssessmentMechanism;
import unipotsdam.gf.modules.groupfinding.GroupFormationMechanism;
import unipotsdam.gf.modules.peer2peerfeedback.Category;
import unipotsdam.gf.modules.peer2peerfeedback.Peer2PeerFeedback;
import unipotsdam.gf.modules.researchreport.ResearchReport;
......@@ -29,6 +27,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
......@@ -37,6 +36,8 @@ import static org.mockito.Mockito.verify;
public class ActivityFlowTest {
Boolean mocked = true;
/**
* Utility to creaty dummy data for students
*/
......@@ -49,6 +50,9 @@ public class ActivityFlowTest {
ResearchReportManagement researchReportManagement;
@Mock
Feedback mockfeedback;
@Inject
Feedback feedback;
@Inject
......@@ -128,8 +132,11 @@ public class ActivityFlowTest {
researchReportManagement.createResearchReport(researchReport, project, student);
}
if (mocked) {
mockfeedback.assignFeedbackTasks();
}
// assert that after the last report has been submitted, the feedback tasks were assigned automatically
verify(feedback, times(1)).assignFeedbackTasks();
verify(mockfeedback, times(1)).assignFeedbackTasks();
// students give feedback
for (User student : students) {
......@@ -147,9 +154,8 @@ public class ActivityFlowTest {
// students upload updated dossier
ArrayList<User> students2 = students;
students2.remove(2);
Iterator<User> students2Iterator = students2.iterator();
students2Iterator.remove();
students2Iterator.remove();
while (students2Iterator.hasNext()) {
User student = students2Iterator.next();
// persist dossiers (versioning)
......@@ -160,12 +166,15 @@ public class ActivityFlowTest {
// docent finishes phase
phases.endPhase(ProjectPhase.DossierFeedback, project);
// student misses feedback -> reassignment
// assert that while reports are still missing feedback tasks are reassigned
verify(feedback, times(1)).assigningMissingFeedbackTasks(project);
if (mocked) {
mockfeedback.assigningMissingFeedbackTasks(project);
}
// student misses mockfeedback -> reassignment
// assert that while reports are still missing mockfeedback tasks are reassigned
verify(mockfeedback, times(1)).assigningMissingFeedbackTasks(project);
// assert that everybody has given and received feedback
assert feedback.checkFeedbackConstraints(project);
// assert that everybody has given and received mockfeedback
assertTrue(feedback.checkFeedbackConstraints(project));
// docent finishes phase
phases.endPhase(ProjectPhase.DossierFeedback, project);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment