Skip to content

Commit e465fed

Browse files
Merge pull request #237 from agnesnatasya/test-addition
Test addition
2 parents 7de17e5 + db3fb5d commit e465fed

File tree

5 files changed

+175
-0
lines changed

5 files changed

+175
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package hirelah.logic.commands;
2+
3+
import static hirelah.logic.commands.CloseReportCommand.MESSAGE_SUCCESS;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import hirelah.commons.exceptions.IllegalValueException;
10+
import hirelah.logic.commands.exceptions.CommandException;
11+
import hirelah.model.Model;
12+
import hirelah.model.ModelManager;
13+
import hirelah.model.hirelah.Interviewee;
14+
15+
class CloseReportCommandTest {
16+
17+
private CloseReportCommand command = new CloseReportCommand();
18+
19+
@Test
20+
void execute_validCloseReport_success() throws CommandException, IllegalValueException {
21+
StorageStub storage = new StorageStub();
22+
Model actualModel = new ModelManager();
23+
actualModel.setCurrentInterviewee(new Interviewee("Jane Doe", 1));
24+
CommandResult expectedCommandResult = new ToggleCommandResult(String.format(MESSAGE_SUCCESS, "Jane Doe"),
25+
ToggleView.CLOSE_TRANSCRIPT);
26+
CommandResult actualCommandResult = command.execute(actualModel, storage);
27+
assertEquals(actualCommandResult, expectedCommandResult);
28+
}
29+
30+
@Test
31+
void execute_invalidClose_failure() {
32+
StorageStub storage = new StorageStub();
33+
Model actualModel = new ModelManager();
34+
assertThrows(CommandException.class, () -> command.execute(actualModel, storage));
35+
}
36+
37+
@Test
38+
void test_equals_success() {
39+
assertEquals(new CloseReportCommand(), command);
40+
}
41+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package hirelah.logic.commands;
2+
3+
import static hirelah.logic.commands.CommandTestUtil.assertCommandSuccess;
4+
import static hirelah.logic.commands.DeleteQuestionCommand.MESSAGE_DELETE_QUESTION_SUCCESS;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import hirelah.commons.exceptions.IllegalValueException;
10+
import hirelah.model.Model;
11+
import hirelah.model.ModelManager;
12+
import hirelah.model.hirelah.QuestionList;
13+
14+
class DeleteQuestionCommandTest {
15+
16+
@Test
17+
void execute_deleteQuestion_success() throws IllegalValueException {
18+
StorageStub storage = new StorageStub();
19+
Model actual = new ModelManager();
20+
QuestionList actualQuestionList = new QuestionList();
21+
actualQuestionList.add("What is this");
22+
actual.setQuestionList(actualQuestionList);
23+
24+
QuestionList expectedQuestionList = new QuestionList();
25+
26+
Model expected = new ModelManager();
27+
expected.setQuestionList(expectedQuestionList);
28+
DeleteQuestionCommand command = new DeleteQuestionCommand(1);
29+
CommandResult expectedCommandResult =
30+
new ToggleCommandResult(String.format(MESSAGE_DELETE_QUESTION_SUCCESS,
31+
"What is this"),
32+
ToggleView.QUESTION);
33+
34+
assertCommandSuccess(command, actual, expectedCommandResult, expected, storage);
35+
}
36+
37+
@Test
38+
void test_equals_success() {
39+
DeleteQuestionCommand command = new DeleteQuestionCommand(1);
40+
assertEquals(new DeleteQuestionCommand(1), command);
41+
}
42+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package hirelah.logic.commands;
2+
3+
import static hirelah.logic.commands.ExitCommand.MESSAGE_EXIT_ACKNOWLEDGEMENT;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
import hirelah.commons.exceptions.IllegalValueException;
9+
import hirelah.logic.commands.exceptions.CommandException;
10+
import hirelah.model.Model;
11+
import hirelah.model.ModelManager;
12+
13+
14+
class ExitCommandTest {
15+
16+
private ExitCommand command = new ExitCommand();
17+
18+
@Test
19+
void execute_validExit_success() throws CommandException, IllegalValueException {
20+
StorageStub storage = new StorageStub();
21+
Model actualModel = new ModelManager();
22+
CommandResult expectedCommandResult = new ExitCommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT);
23+
CommandResult actualCommandResult = command.execute(actualModel, storage);
24+
assertEquals(expectedCommandResult, actualCommandResult);
25+
}
26+
27+
@Test
28+
void test_equals_success() {
29+
assertEquals(new ExitCommand(), command);
30+
}
31+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package hirelah.logic.commands;
2+
3+
import static hirelah.logic.commands.CommandTestUtil.assertCommandSuccess;
4+
import static hirelah.logic.commands.FinaliseCommand.MESSAGE_SUCCESS;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import hirelah.commons.exceptions.IllegalValueException;
10+
import hirelah.model.Model;
11+
import hirelah.model.ModelManager;
12+
13+
class FinaliseCommandTest {
14+
15+
private FinaliseCommand command = new FinaliseCommand();
16+
17+
@Test
18+
void execute_validFinalise_success() throws IllegalValueException {
19+
StorageStub storage = new StorageStub();
20+
Model actual = new ModelManager();
21+
22+
Model expected = new ModelManager();
23+
expected.finaliseInterviewProperties();
24+
CommandResult expectedCommandResult =
25+
new ToggleCommandResult(MESSAGE_SUCCESS, ToggleView.INTERVIEWEE);
26+
27+
assertCommandSuccess(command, actual, expectedCommandResult, expected, storage,
28+
expected::isFinalisedInterviewProperties);
29+
}
30+
31+
@Test
32+
void test_equals_success() {
33+
assertEquals(new FinaliseCommand(), command);
34+
}
35+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package hirelah.logic.commands;
2+
3+
import static hirelah.logic.commands.HelpCommand.SHOWING_HELP_MESSAGE;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
import hirelah.commons.exceptions.IllegalValueException;
9+
import hirelah.model.Model;
10+
import hirelah.model.ModelManager;
11+
import hirelah.model.hirelah.Interviewee;
12+
13+
class HelpCommandTest {
14+
15+
private HelpCommand command = new HelpCommand();
16+
17+
@Test
18+
void execute_validHelp_success() throws IllegalValueException {
19+
StorageStub storage = new StorageStub();
20+
Model actualModel = new ModelManager();
21+
actualModel.setCurrentInterviewee(new Interviewee("Jane Doe", 1));
22+
CommandResult actualCommandResult = command.execute(actualModel, storage);
23+
CommandResult expectedCommandResult = new HelpCommandResult(SHOWING_HELP_MESSAGE);
24+
assertEquals(expectedCommandResult, actualCommandResult);
25+
}
26+
}

0 commit comments

Comments
 (0)