Skip to content

Commit

Permalink
Add testcase for UnarchiveCommandTest
Browse files Browse the repository at this point in the history
  • Loading branch information
xGladiate committed Oct 31, 2024
1 parent 94521c0 commit cc007ec
Showing 1 changed file with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_LIST;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_LIST;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalIndexes.*;
import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_LIST;
import static seedu.address.testutil.TypicalPersons.CARL;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import java.util.ArrayList;
Expand All @@ -13,9 +15,14 @@
import org.junit.jupiter.api.Test;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.Messages;
import seedu.address.logic.parser.AddressBookParser;
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.person.Person;
import seedu.address.testutil.PersonBuilder;


/**
Expand All @@ -26,6 +33,29 @@ public class UnarchiveCommandTest {

private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());

@Test
public void execute_validSingleIndexUnfilteredPersonList_success() {
Index lastIndex = Index.fromZeroBased(model.getFilteredPersonList().size());
List<Index> lastIndexList = new ArrayList<>();
lastIndexList.add(lastIndex);

Person archivedPerson = new PersonBuilder().withArchive("true").build();

Person unarchivedPerson = new PersonBuilder().build();

UnarchiveCommand unarchiveCommand = new UnarchiveCommand(lastIndexList);

String expectedMessage = String.format(UnarchiveCommand.MESSAGE_UNARCHIVED_PERSON_SUCCESS,
"\n" + Messages.format(archivedPerson));

Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs());
expectedModel.addPerson(unarchivedPerson);

AddressBookParser.setInspect(false);
model.addPerson(archivedPerson);
assertCommandSuccess(unarchiveCommand, model, expectedMessage, expectedModel);
}

@Test
public void equals() {
UnarchiveCommand unarchiveFirstCommand = new UnarchiveCommand(INDEX_FIRST_LIST);
Expand Down

0 comments on commit cc007ec

Please sign in to comment.