Fakultas Ilmu Komputer UI

Commit 0d10d3fe authored by Al Taaj Kautsar Supangkat's avatar Al Taaj Kautsar Supangkat
Browse files

add test for Course

parent 5c33791c
......@@ -40,5 +40,21 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="JUnit5.4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.4.2/junit-jupiter-5.4.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.4.2/junit-jupiter-api-5.4.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.4.2/junit-platform-commons-1.4.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.4.2/junit-jupiter-params-5.4.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.4.2/junit-jupiter-engine-5.4.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.4.2/junit-platform-engine-1.4.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
......@@ -8,6 +8,15 @@ public class Course {
private Time startTime;
private Time endTime;
public Course(){};
public Course(String courseName, String lecturer, Time startTime, Time endTime) {
this.courseName = courseName;
this.lecturer = lecturer;
this.startTime = startTime;
this.endTime = endTime;
}
public String getCourseName() {
return courseName;
}
......
package test;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.model.Timetable;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class CourseTest {
private String courseName;
private String lecturer;
private Time startTime;
private Time endTime;
private Course testCourse;
@BeforeEach
void setup() {
courseName = "RPL";
lecturer = "Ade";
startTime = Time.valueOf("08:00:00");
endTime = Time.valueOf("09:40:00");
testCourse = new Course(courseName, lecturer, startTime, endTime);
}
@Test
void getCourseName() {
assertEquals(courseName, testCourse.getCourseName());
}
@Test
void setCourseName() {
testCourse.setCourseName("DAA");
assertEquals("DAA", testCourse.getCourseName());
}
@Test
void getLecturer() {
assertEquals("Ade", testCourse.getLecturer());
}
@Test
void setLecturer() {
testCourse.setLecturer("Yugo");
assertEquals("Yugo", testCourse.getLecturer());
}
@Test
void getStartTime() {
assertEquals(Time.valueOf("08:00:00"), testCourse.getStartTime());
}
@Test
void setStartTime() {
Time startTime2 = Time.valueOf("13:00:00");
testCourse.setStartTime(startTime2);
assertEquals(startTime2, testCourse.getStartTime());
}
@Test
void getEndTime() {
assertEquals(Time.valueOf("09:40:00"), testCourse.getEndTime());
}
@Test
void setEndTime() {
Time endTime2 = Time.valueOf("14:40:00");
testCourse.setEndTime(endTime2);
assertEquals(endTime2, testCourse.getEndTime());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment