Fakultas Ilmu Komputer UI

Commit 21bf7de2 authored by Al Taaj Kautsar Supangkat's avatar Al Taaj Kautsar Supangkat
Browse files

Completing the timetableListTest and assignmentListTest

parent d77ba3c9
Pipeline #81996 passed with stages
in 5 minutes and 19 seconds
st,t1,rpl st,t1,rpl
null,test,RPL
null,test,RPL,RPL
null,test,RPL,RPL,RPL
null,test,RPL,RPL,RPL,RPL
null,test,RPL,RPL,RPL,RPL,RPL
null,test,RPL
null,test,RPL,RPL
null,test,RPL,RPL,RPL
null,test,RPL,RPL,RPL,RPL
null,test,RPL,RPL,RPL,RPL,RPL
...@@ -31,12 +31,19 @@ public class AssignmentListTest { ...@@ -31,12 +31,19 @@ public class AssignmentListTest {
} }
@Test @Test
void getAssignmentList(){ void getAssignmentListTest(){
assignmentList.addAssignment("name", assignment); assignmentList.addAssignment("name", assignment);
List<Assignment> TestList = assignmentList.getAssignmentList(); List<Assignment> TestList = assignmentList.getAssignmentList();
assertNotEquals(null, TestList); assertNotEquals(null, TestList);
} }
@Test
void getAssignmentTest(){
assignmentList.addAssignment("name", assignment);
String name = assignmentList.getAssignment("name").getAssignmentName();
assertEquals("name", name);
}
@Test @Test
void addAssignmentTest(){ void addAssignmentTest(){
int before = assignmentList.getAssignmentList().size(); int before = assignmentList.getAssignmentList().size();
......
package repository; package repository;
import Softeng.Group3.SiJadwal.Main;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User; import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.model.Timetable; import Softeng.Group3.SiJadwal.model.Timetable;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.repository.TimetableList; import Softeng.Group3.SiJadwal.repository.TimetableList;
import Softeng.Group3.SiJadwal.repository.UserList;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TimetableListTest { class TimetableListTest {
private final PrintStream standardOut = System.out;
private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
private static final List<Course> courses = new ArrayList<>();
@Test @Test
void getAllTimetableList() { void getAllTimetableList() {
TimetableList timetableList = new TimetableList(); TimetableList timetableList = new TimetableList();
...@@ -21,23 +39,75 @@ class TimetableListTest { ...@@ -21,23 +39,75 @@ class TimetableListTest {
@Test @Test
void getTimetableList() { void getTimetableList() {
TimetableList timetableList = new TimetableList(); TimetableList timetableList = new TimetableList();
Timetable timetableA = new Timetable(); Course rpl = new Course("RPL", "Ade", new Time(500), new Time(1000));
courses.add(rpl);
User A = new User(); User A = new User();
Timetable timetableA = new Timetable("test", courses, A);
timetableList.addTimetable("test", timetableA);
assertNotEquals(null, timetableList.getTimetableList(A));
} }
@Test @Test
void getTimetable() { void getTimetable() {
TimetableList timetableList = new TimetableList();
Course rpl = new Course("RPL", "Ade", new Time(500), new Time(1000));
courses.add(rpl);
User A = new User();
Timetable timetableA = new Timetable("test", courses, A);
timetableList.addTimetable("test", timetableA);
assertEquals("test", timetableList.getTimetable("test", A).getTimetableName());
} }
@Test @Test
void addTimetable() { void addTimetable() {
TimetableList timetableList = new TimetableList();
Course rpl = new Course("RPL", "Ade", new Time(500), new Time(1000));
courses.add(rpl);
User A = new User();
Timetable timetableA = new Timetable("test", courses, A);
int before = timetableList.getTimetableList(A).size();
timetableList.addTimetable("test", timetableA);
int after = timetableList.getTimetableList(A).size();
assertEquals(before + 1, after);
} }
@Test @Test
void listToString() { void listToString() {
System.setOut(new PrintStream(outputStreamCaptor));
TimetableList timetableList = new TimetableList();
Course rpl = new Course("RPL", "Ade", new Time(500), new Time(1000));
courses.add(rpl);
User A = new User();
Timetable timetableA = new Timetable("test", courses, A);
timetableList.addTimetable("test", timetableA);
timetableList.listToString(timetableList.getTimetableList(A));
assertEquals("1. test", outputStreamCaptor.toString().trim());
System.setOut(standardOut);
} }
@Test @Test
void deleteTimetable() { void deleteTimetable() {
TimetableList timetableList = new TimetableList();
Course rpl = new Course("RPL", "Ade", new Time(500), new Time(1000));
courses.add(rpl);
User A = new User();
Timetable timetableA = new Timetable("test", courses, A);
timetableList.addTimetable("test", timetableA);
int before = timetableList.getTimetableList(A).size();
timetableList.deleteTimetable(timetableA);
int after = timetableList.getTimetableList(A).size();
assertEquals(before - 1, after);
} }
} }
\ 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