Fakultas Ilmu Komputer UI

Commit 6f17a345 authored by hazlazuardi's avatar hazlazuardi
Browse files

Increase test coverage and adding test for User

parent 83ab1f04
Pipeline #81947 passed with stages
in 4 minutes
...@@ -48,7 +48,7 @@ jacocoTestReport { ...@@ -48,7 +48,7 @@ jacocoTestReport {
afterEvaluate { afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect { classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude:['**/Main*', "**/CSV*", "**/Student*", "**/Admin*", fileTree(dir: it, exclude:['**/Main*', "**/CSV*", "**/Student*", "**/Admin*",
"**/TeachingAssistant*"] "**/TeachingAssistant*", "**/Role*", "**/utility/*", ]
) )
})) }))
} }
......
...@@ -15,6 +15,10 @@ public class Admin extends Role { ...@@ -15,6 +15,10 @@ public class Admin extends Role {
private Time startTime; private Time startTime;
private Time endTime; private Time endTime;
public Admin() {
this.setRoleName(RoleType.ADMIN);
}
@Override @Override
public void setRole(RoleType role) { public void setRole(RoleType role) {
System.out.println("Admin setting Role"); System.out.println("Admin setting Role");
......
...@@ -23,6 +23,11 @@ public class Student extends Role { ...@@ -23,6 +23,11 @@ public class Student extends Role {
private String assignmentName; private String assignmentName;
private Course assignmentCourse; private Course assignmentCourse;
private LocalDate dueDate; private LocalDate dueDate;
public Student() {
this.setRoleName(RoleType.STUDENT);
}
private Boolean validated; private Boolean validated;
private Set<User> validatedBy = new HashSet<>(); private Set<User> validatedBy = new HashSet<>();
private User createdBy; private User createdBy;
......
...@@ -29,6 +29,11 @@ public class TeachingAssistant extends Role { ...@@ -29,6 +29,11 @@ public class TeachingAssistant extends Role {
private String assignmentName; private String assignmentName;
private Course assignmentCourse; private Course assignmentCourse;
public TeachingAssistant() {
this.setRoleName(RoleType.TEACHING_ASSISTANT);
}
private LocalDate dueDate; private LocalDate dueDate;
private Boolean validated; private Boolean validated;
private Set<User> validatedBy = new HashSet<>(); private Set<User> validatedBy = new HashSet<>();
......
package actor;
import Softeng.Group3.SiJadwal.actor.*;
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 static org.junit.jupiter.api.Assertions.*;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class UserTest {
private User newUser;
@BeforeEach
void setup() {
newUser = new User();
}
@Test
void getUsername() {
assertNull(newUser.getUsername());
}
@Test
void setUsername() {
newUser.setUsername("Haz");
assertEquals("Haz", newUser.getUsername());
}
@Test
void getRole() {
assertNull(newUser.getRole());
}
@Test
void setRoleStudent() {
Role newRole = new Student();
newUser.setRole(newRole.getRoleName());
assertEquals(newRole.getRoleName(), newUser.getRole().getRoleName());
}
@Test
void setRoleAdmin() {
Role newRole = new Admin();
newUser.setRole(newRole.getRoleName());
assertEquals(newRole.getRoleName(), newUser.getRole().getRoleName());
}
@Test
void setRoleTeachingAssistant() {
Role newRole = new TeachingAssistant();
newUser.setRole(newRole.getRoleName());
assertEquals(newRole.getRoleName(), newUser.getRole().getRoleName());
}
@Test
void testToString() {
newUser.setUsername("Haz");
assertEquals("Haz", newUser.toString());
}
}
\ 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