<commit_before>package guitests;

import org.junit.Test;
import seedu.malitio.testutil.TestFloatingTask;
import seedu.malitio.testutil.TestUtil;

import static org.junit.Assert.assertTrue;
import static seedu.malitio.logic.commands.DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS;

public class DeleteCommandTest extends MalitioGuiTest {
    
    /**
     * Uses boundary condition testing
     */
    @Test
    public void delete() {

        //delete the first in the list
        TestFloatingTask[] currentList = td.getTypicalFloatingTasks();
        int targetIndex = 1;
        assertDeleteSuccess(targetIndex, currentList);

        //delete the last in the list
        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);
        targetIndex = currentList.length;
        assertDeleteSuccess(targetIndex, currentList);

        //delete from the middle of the list
        currentList = TestUtil.removeTaskFromList(currentList, targetIndex);
        targetIndex = currentList.length/2;
        assertDeleteSuccess(targetIndex, currentList);

        //invalid index
        commandBox.runCommand("delete f" + currentList.length + 1);
        assertResultMessage("The task index provided is invalid");

    }

    /**
     * Runs the delete command to delete the task at specified index and confirms the result is correct.
     * @param targetIndexOneIndexed e.g. to delete the first task in the list, 1 should be given as the target index.
     * @param currentList A copy of the current list of tasks (before deletion).
     */
    private void assertDeleteSuccess(int targetIndexOneIndexed, final TestFloatingTask[] currentList) {
        TestFloatingTask taskToDelete = currentList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing
        TestFloatingTask[] expectedRemainder = TestUtil.removeTaskFromList(currentList, targetIndexOneIndexed);

        commandBox.runCommand("delete f" + targetIndexOneIndexed);

        //confirm the list now contains all previous tasks except the deleted task
        assertTrue(floatingTaskListPanel.isListMatching(expectedRemainder));

        //confirm the result message is correct
        assertResultMessage(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete));
    }

}<commit_msg>Update test for delete command<commit_after>package guitests;

import org.junit.Test;

import seedu.malitio.commons.exceptions.IllegalValueException;
import seedu.malitio.testutil.TestDeadline;
import seedu.malitio.testutil.TestEvent;
import seedu.malitio.testutil.TestFloatingTask;
import seedu.malitio.testutil.TestUtil;

import static org.junit.Assert.assertTrue;
import static seedu.malitio.logic.commands.DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS;

public class DeleteCommandTest extends MalitioGuiTest {
  
    private static final String FLOATING_TASK_KEYWORD = "f";
    private static final String DEADLINE_KEYWORD = "d";
    private static final String EVENT_KEYWORD = "e";
    
    @Test
    public void delete() {

        //Populate test tasks
        TestFloatingTask[] floatingTaskList = td.getTypicalFloatingTasks(); //5 floating tasks
        TestDeadline[] deadlineList = td.getTypicalDeadlines(); // 2 deadlines
        TestEvent[] eventList = td.getTypicalEvents(); // 4 events
        
  /*      //invalid index argument
        commandBox.runCommand("delete " + FLOATING_TASK_KEYWORD + floatingTaskList.length + 1); // boundary
        assertResultMessage("The task index provided is invalid");
        commandBox.runCommand("delete " + EVENT_KEYWORD + 0); // boundary
        assertResultMessage("The task index provided is invalid");
        commandBox.runCommand("delete " + "g1"); // invalid task type
        assertResultMessage("The task index provided is invalid");
  */      
        //delete first in floating task
        int targetIndex = 1;
        assertDeleteSuccess(targetIndex, floatingTaskList);

        //delete the last in deadline
        targetIndex = deadlineList.length;   
        assertDeleteSuccess(targetIndex, deadlineList);
  //      deadlineList = TestUtil.removeTaskFromList(deadlineList, targetIndex);

  /*      //delete from the middle of event list
        targetIndex = eventList.length/2;
        assertDeleteSuccess(targetIndex, eventList);
        eventList = TestUtil.removeTaskFromList(eventList, targetIndex);
*/

    }

    /**
     * Runs the delete command to delete the task at specified index and confirms the result is correct.
     * @param targetIndexOneIndexed e.g. to delete the first task in the list, 1 should be given as the target index.
     * @param floatingTaskList A copy of the current list of tasks (before deletion).
     */
    private void assertDeleteSuccess(int targetIndexOneIndexed, final TestFloatingTask[] floatingTaskList) {
        TestFloatingTask taskToDelete = floatingTaskList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing
        TestFloatingTask[] expectedRemainder = TestUtil.removeTaskFromList(floatingTaskList, targetIndexOneIndexed);

        commandBox.runCommand("delete " + FLOATING_TASK_KEYWORD + targetIndexOneIndexed);

        //confirm the list now contains all previous tasks except the deleted task
        assertTrue(floatingTaskListPanel.isListMatching(expectedRemainder));

        //confirm the result message is correct
        assertResultMessage(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete));
    }
    
    private void assertDeleteSuccess(int targetIndexOneIndexed, final TestDeadline[] deadlineList) {
        TestDeadline taskToDelete = deadlineList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing
        TestDeadline[] expectedRemainder = TestUtil.removeTaskFromList(deadlineList, targetIndexOneIndexed);

        commandBox.runCommand("delete " + DEADLINE_KEYWORD + targetIndexOneIndexed);

        //confirm the list now contains all previous tasks except the deleted task
        assertTrue(deadlineListPanel.isListMatching(expectedRemainder));

        //confirm the result message is correct
  //      assertResultMessage(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete));
    }
    
    private void assertDeleteSuccess(int targetIndexOneIndexed, final TestEvent[] eventList) {
        TestEvent taskToDelete = eventList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing
        TestEvent[] expectedRemainder = TestUtil.removeTaskFromList(eventList, targetIndexOneIndexed);

        commandBox.runCommand("delete " + EVENT_KEYWORD + targetIndexOneIndexed);

        //confirm the list now contains all previous tasks except the deleted task
        try {
            assertTrue(eventListPanel.isListMatching(expectedRemainder));
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalValueException e) {
            e.printStackTrace();
        }

        //confirm the result message is correct
        //assertResultMessage(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete));
    }

}
{'fraction_non_alphanumeric': 0.0761986301369863, 'fraction_numerical': 0.0029965753424657533, 'mean_word_length': 3.5453955901426717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7478308', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1811, 'n_words': 502}