-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started course creation tests (cannot get presenter not controller to…
… work rip), still need to test for persistence as well as the enrolment tests too
- Loading branch information
Showing
9 changed files
with
248 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/test/java/test_course_features/CourseCreationControllerTest.java
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
src/test/java/test_course_features/CourseCreationInteractorTest.java
This file was deleted.
Oops, something went wrong.
79 changes: 17 additions & 62 deletions
79
src/test/java/test_course_features/CourseEnrolmentInteractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,19 @@ | ||
package test_course_features; | ||
|
||
//import entities.Course; | ||
//import entities.StudentUser; | ||
//import org.junit.jupiter.api.Assertions; | ||
//import org.junit.jupiter.api.Test; | ||
//import screens.course_features.InMemoryCourse; | ||
//import screens.login_registration.InMemoryUser; | ||
//import use_cases.course_features.course_creation_use_case.CourseCreationDsGateway; | ||
//import use_cases.login_registration.user_register_usecase.UserRegGateway; | ||
// | ||
//import use_cases.course_features.course_enrolment_use_case.*; | ||
// | ||
//import java.util.ArrayList; | ||
// | ||
//import static org.junit.Assert.*; | ||
// | ||
///** | ||
// * TODO: NEED TO ADD THE TASK PART | ||
// */ | ||
//class CourseEnrolmentInteractorTest { | ||
// | ||
// @Test | ||
// public void enrol() { | ||
// // well technically interactor not done so ...... | ||
// | ||
// CourseEnrolmentDsGateway courseGateway = new InMemoryCourse(); | ||
// CourseCreationDsGateway courseRepository = new InMemoryCourse(); | ||
// UserRegGateway userRepository = new InMemoryUser(); | ||
// | ||
// CourseEnrolmentOutputBoundary outputBoundary = new CourseEnrolmentOutputBoundary() { | ||
// @Override | ||
// public CourseEnrolmentResponseModel prepareSuccessView(CourseEnrolmentResponseModel newStudent) { | ||
// Assertions.assertEquals("course1inst1", newStudent.getCourseID()); | ||
// Assertions.assertEquals("user1", newStudent.getStudentID()); | ||
// Assertions.assertTrue(courseRepository.existsByCourseID("course1inst1")); | ||
// Assertions.assertTrue(userRepository.existsByName("user1")); | ||
// return null; | ||
// } | ||
// | ||
// @Override | ||
// public CourseEnrolmentResponseModel prepareFailView(String error) { | ||
// fail("Use case failure is unexpected."); | ||
// return null; | ||
// } | ||
// }; | ||
// | ||
// // make course | ||
// ArrayList<String> tasks = new ArrayList<>(); | ||
// tasks.add("task1"); | ||
// tasks.add("task2"); | ||
// Course course = new Course("course1", "inst1", tasks); | ||
// | ||
// // make student | ||
// StudentUser student = new StudentUser("user1", "pass1"); | ||
// | ||
// CourseEnrolmentInputBoundary interactor = new CourseEnrolmentInteractor(courseGateway, outputBoundary); | ||
// | ||
// CourseEnrolmentRequestModel inputData = new CourseEnrolmentRequestModel( | ||
// "course1", "inst1", "user1"); | ||
// | ||
// interactor.enrol(inputData); | ||
// } | ||
//} | ||
import entities.Course; | ||
import org.junit.jupiter.api.Test; | ||
import screens.course_features.InMemoryCourse; | ||
import use_cases.course_features.course_creation_use_case.*; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* testing the components of a course enrolment | ||
* which is basically every line of code in my interactor because clearly there are buuuuugs | ||
* acc maybe this is why i should be doing tests while i code oop | ||
*/ | ||
public class CourseEnrolmentInteractorTest { | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/test/java/test_course_features/course_creation/CourseCreationControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package test_course_features.course_creation; | ||
|
||
import entities.Course; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import screens.course_features.CourseCreationController; | ||
import screens.course_features.CourseCreationFailed; | ||
import screens.course_features.CourseCreationPresenter; | ||
import use_cases.course_features.course_creation_use_case.*; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class CourseCreationControllerTest { | ||
private CourseCreationController controller; | ||
|
||
@BeforeAll | ||
static void setUp() { | ||
CourseCreationDsGateway gateway = new CourseCreationDsGateway() { | ||
@Override | ||
public boolean existsByCourseID(String courseIdentifier) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void saveCourse(Course requestModel) throws IOException { | ||
|
||
} | ||
}; | ||
CourseCreationOutputBoundary presenter = new CourseCreationPresenter(); | ||
CourseCreationInputBoundary interactor = new CourseCreationInteractor(gateway, presenter); | ||
CourseCreationController controller = new CourseCreationController(interactor); | ||
} | ||
|
||
@Test | ||
void what() { | ||
Exception e; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/test_course_features/course_creation/CourseCreationInteractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package test_course_features.course_creation; | ||
|
||
import entities.Course; | ||
import org.junit.jupiter.api.Test; | ||
import screens.course_features.InMemoryCourse; | ||
import use_cases.course_features.course_creation_use_case.*; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
||
/** | ||
* testing the creation of a new course | ||
*/ | ||
class CourseCreationInteractorTest { | ||
@Test | ||
void createCourse() { | ||
InMemoryCourse courseGateway = new InMemoryCourse(); | ||
|
||
CourseCreationOutputBoundary outputBoundary = new CourseCreationOutputBoundary() { | ||
@Override | ||
public CourseCreationResponseModel prepareSuccessView(CourseCreationResponseModel newCourse) { | ||
ArrayList<String> tasks = new ArrayList<>(); | ||
tasks.add("task1"); | ||
tasks.add("task2"); | ||
tasks.add("task3"); | ||
Course course1 = new Course("course1", "inst1", tasks); | ||
|
||
assertEquals("course1inst1", course1.getCourseID()); | ||
assertEquals(course1.getTasks(), tasks); | ||
assertNotNull(course1.getTasks()); | ||
assertTrue(courseGateway.existsByCourseID(course1.getCourseID())); | ||
return null; | ||
} | ||
|
||
@Override | ||
public CourseCreationResponseModel prepareFailView(String error) { | ||
fail("Use case failure is unexpected."); | ||
return null; | ||
} | ||
}; | ||
ArrayList<String> requestTask = new ArrayList<>(); | ||
|
||
requestTask.add("task1,task2,task3"); | ||
CourseCreationRequestModel request = new CourseCreationRequestModel( | ||
"course1", "inst1", requestTask); | ||
CourseCreationInputBoundary interactor = new CourseCreationInteractor(courseGateway, outputBoundary); | ||
|
||
interactor.create(request); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/test/java/test_course_features/course_creation/CourseCreationPresenterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package test_course_features.course_creation; | ||
|
||
//import org.junit.jupiter.api.BeforeAll; | ||
//import org.junit.jupiter.api.BeforeEach; | ||
//import org.junit.jupiter.api.Test; | ||
//import screens.course_features.CourseCreationFailed; | ||
//import screens.course_features.CourseCreationPresenter; | ||
//import use_cases.course_features.course_creation_use_case.CourseCreationResponseModel; | ||
// | ||
//import java.util.ArrayList; | ||
// | ||
//import static org.junit.jupiter.api.Assertions.*; | ||
// | ||
///** | ||
// * testing presenter fail and success views | ||
// * currently failing oop | ||
// */ | ||
//class CourseCreationPresenterTest { | ||
// private CourseCreationPresenter presenter; | ||
// | ||
// @BeforeAll | ||
// static void setUp() { | ||
// CourseCreationPresenter presenter = new CourseCreationPresenter(); | ||
// | ||
// ArrayList<String> tasks = new ArrayList<>(); | ||
// tasks.add("1"); | ||
// tasks.add("2"); | ||
// tasks.add("3"); | ||
// presenter.prepareSuccessView(new CourseCreationResponseModel("id", tasks)); | ||
// } | ||
// | ||
// @Test | ||
// void prepareSuccessView() { | ||
// ArrayList<String> tasks = new ArrayList<>(); | ||
// tasks.add("1"); | ||
// tasks.add("2"); | ||
// tasks.add("3"); | ||
// CourseCreationResponseModel response = new CourseCreationResponseModel("id", tasks); | ||
// assertEquals(response, presenter.prepareSuccessView(response)); | ||
// } | ||
// | ||
// @Test | ||
// void prepareFailView() { | ||
// String error = "hm what should i put here"; | ||
// Exception e = assertThrows(CourseCreationFailed.class, () -> presenter.prepareFailView(error)); | ||
// assertEquals(error, e.getMessage()); | ||
// } | ||
//} |
48 changes: 48 additions & 0 deletions
48
src/test/java/test_course_features/course_creation/CourseCreationRequestModelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package test_course_features.course_creation; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import use_cases.course_features.course_creation_use_case.CourseCreationRequestModel; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* testing the methods of the request model | ||
*/ | ||
class CourseCreationRequestModelTest { | ||
static CourseCreationRequestModel courseCreationRequestModel; | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
ArrayList<String> badTasks = new ArrayList<>(); | ||
badTasks.add("task1,task2,task3"); | ||
courseCreationRequestModel = new CourseCreationRequestModel( | ||
"course1", "inst1", badTasks); | ||
} | ||
|
||
@Test | ||
void getCourseName() { | ||
assertEquals("course1", courseCreationRequestModel.getCourseName()); | ||
} | ||
|
||
@Test | ||
void getInstructorName() { | ||
assertEquals("inst1", courseCreationRequestModel.getCourseInstructor()); | ||
} | ||
|
||
@Test | ||
void getCourseID() { | ||
assertEquals("course1inst1", courseCreationRequestModel.getCourseID()); | ||
} | ||
|
||
@Test | ||
void getTasks() { | ||
ArrayList<String> goodTasks = new ArrayList<>(); | ||
goodTasks.add("task1"); | ||
goodTasks.add("task2"); | ||
goodTasks.add("task3"); | ||
assertEquals(courseCreationRequestModel.getTasks(), goodTasks); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/test/java/test_course_features/course_creation/CourseCreationResponseModelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package test_course_features.course_creation; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import use_cases.course_features.course_creation_use_case.CourseCreationResponseModel; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* testing methods of the response model | ||
*/ | ||
public class CourseCreationResponseModelTest { | ||
static CourseCreationResponseModel response; | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
ArrayList<String> tasks = new ArrayList<>(); | ||
tasks.add("task1"); | ||
tasks.add("task2"); | ||
tasks.add("task3"); | ||
response = new CourseCreationResponseModel("id", tasks); | ||
} | ||
|
||
@Test | ||
void getCourseID() { | ||
assertEquals("id", response.getCourseID()); | ||
} | ||
|
||
@Test | ||
void getTasks() { | ||
ArrayList<String> taskTesting = new ArrayList<>(); | ||
taskTesting.add("task1"); | ||
taskTesting.add("task2"); | ||
taskTesting.add("task3"); | ||
assertEquals(response.getTasks(), taskTesting); | ||
} | ||
} |