Fakultas Ilmu Komputer UI

Commit 5c33791c authored by hazlazuardi's avatar hazlazuardi
Browse files

Add test for Timetable

parent e9f1c892
......@@ -24,5 +24,21 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
......@@ -21,6 +21,14 @@ public class User {
return role;
}
public User() {
}
public User(String username, Role role) {
this.username = username;
this.role = role;
}
public void setRole(RoleType roleType) {
switch (roleType){
case STUDENT:
......
......@@ -26,6 +26,11 @@ public class Timetable {
private User owner;
public Timetable(String timetableName, List<Course> courses, User owner) {
this.timetableName = timetableName;
this.courses = courses;
this.owner = owner;
}
public String getTimetableName() {
return timetableName;
......@@ -39,10 +44,6 @@ public class Timetable {
return courses;
}
public void setCourses(List<Course> courses) {
this.courses = courses;
}
public void addCourse(Course course) {
courses.add(course);
}
......
package Softeng.Group3.SiJadwal.test;
import static org.junit.jupiter.api.Assertions.*;
class TimetableTest {
}
\ No newline at end of file
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 TimetableTest {
private User owner;
private List<Course> courses;
private String timetableName;
private Timetable timetable;
@BeforeEach
void setup() {
owner = new User();
courses = new ArrayList<>();
timetableName = "Semester 5";
timetable = new Timetable(timetableName, courses, owner);
}
@Test
void getOwner() {
assertEquals(owner, timetable.getOwner());
}
@Test
void setOwner() {
User owner2 = new User();
timetable.setOwner(owner2);
assertEquals(owner2, timetable.getOwner());
}
@Test
void getTimetableName() {
assertEquals("Semester 5", timetable.getTimetableName());
}
@Test
void setTimetableName() {
String timetableName2 = "Semester 6";
timetable.setTimetableName(timetableName2);
assertEquals("Semester 6", timetable.getTimetableName());
}
@Test
void getCourses() {
assertEquals(courses, timetable.getCourses());
}
@Test
void addCourse() {
Course newCourse = new Course();
assertEquals(0, timetable.getCourses().size());
timetable.addCourse(newCourse);
assertEquals(1, timetable.getCourses().size());
}
}
\ No newline at end of file
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