Fakultas Ilmu Komputer UI

Commit eb3d0081 authored by Bagus Prabowo's avatar Bagus Prabowo
Browse files

Merge branch 'bagus2' into 'master'

Bagus2

See merge request !4
parents 5fb63536 7140cd27
......@@ -8,5 +8,53 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="opencsv" level="project" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.7.0">
<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>
<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>
<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
admin,Admin
st,Student
ta,Teaching Assistant
a,Student
b,Teaching Assistant
ta,Teaching Assistant
\ 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:
......@@ -39,12 +47,12 @@ public class User {
}
}
public void listToString(List<Timetable> timetableList){
int i = 1;
for (Timetable timetable: timetableList) {
System.out.println(i + ". " + timetable.getTimetableName());
i++;
}
}
// public void listToString(List<Timetable> timetableList){
// int i = 1;
// for (Timetable timetable: timetableList) {
// System.out.println(i + ". " + timetable.getTimetableName());
// i++;
// }
// }
}
......@@ -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;
}
......
......@@ -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 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());
}
}
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.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TimetableTest {
private User owner;
private List<Course> courses;
private Timetable timetable;
@BeforeEach
void setup() {
owner = new User();
courses = new ArrayList<>();
String 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
package test;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.repository.UserList;
import Softeng.Group3.SiJadwal.actor.User;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
import java.lang.System;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class UserListTest {
private static final UserList userList = new UserList();
private final PrintStream standardOut = System.out;
private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
@Test
void getUserList(){
userList.addUser("Test", RoleType.STUDENT);
List<User> TestList = userList.getUserList();
assertNotEquals(null, TestList);
}
@Test
void getUsernameTest(){
userList.addUser("Test", RoleType.STUDENT);
User TestGetUser = userList.getUser("Test");
assertEquals("Test", TestGetUser.getUsername());
}
@Test
void addUserTest(){
int initial = userList.getUserList().size();
userList.addUser("Test", RoleType.STUDENT);
int after = userList.getUserList().size();
assertEquals(initial + 1, after);
}
@Test
void updateRoleTest(){
userList.addUser("Test", RoleType.STUDENT);
userList.updateRole("Test", RoleType.TEACHING_ASSISTANT);
User TestRole = userList.getUser("Test");
System.out.println(TestRole.getRole());
assertEquals(RoleType.TEACHING_ASSISTANT, TestRole.getRole().getRoleName());
}
@Test
void ListToStringTest(){
System.setOut(new PrintStream(outputStreamCaptor));
userList.addUser("Test", RoleType.STUDENT);
userList.listToString(userList.getUserList());
assertEquals("1. Test", outputStreamCaptor.toString().trim());
System.setOut(standardOut);
}
}
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