Skip to content
Snippets Groups Projects
Commit 65b1cca3 authored by Martin Schmollinger's avatar Martin Schmollinger
Browse files

Extension of test class for lecture

parent 19bb33ef
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,12 @@ public class Faculty {
}
public void addProfessor(Professor professor) {
if (!profs.contains(professor))
if (!profs.contains(professor)) {
profs.add(professor);
}
else {
throw new RuntimeException();
}
}
public void addAssistent(Assistent assistent) {
......
package io.fp.campus;
import java.util.ArrayList;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class FacultyTest {
......@@ -13,21 +14,16 @@ public class FacultyTest {
@BeforeEach
void setUp() {
hogwarts = new Faculty("Hogwarts");
Professor dumbledore = new Professor("Dumbledore", 77, "BPM", hogwarts);
dumbledore.setTalking(false);
Professor dumbledore = new Professor("Dumbledore", 77, "Dragons", hogwarts);
Assistent hagrid = new Assistent("Hagrid", 26, hogwarts);
hagrid.setBoss(dumbledore);
Assistent dobby = new Assistent("Dobby", 130, hogwarts);
dobby.setBoss(dumbledore);
Assistent pince = new Assistent("Madam Pince", 40, hogwarts);
hogwarts.addProfessor(dumbledore);
hogwarts.addAssistent(hagrid);
hogwarts.addAssistent(dobby);
hogwarts.addAssistent(pince);
}
@Test
void testGetProfsWithAssis() {
......@@ -35,4 +31,13 @@ public class FacultyTest {
ArrayList<Professor> profsWithAssis = hogwarts.getProfsWithAssis();
assertEquals(profs, profsWithAssis);
}
@Test
void testAddProfessor() {
ArrayList<Professor> profs = hogwarts.getProfs();
Professor prof1 = profs.get(0);
assertThrows(RuntimeException.class,
()->{hogwarts.addProfessor(prof1);}
);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment