package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static seedu.address.commons.time.TypicalLocalDateTimes.UNIX_EPOCH;
import static seedu.address.testutil.TestUtil.assertThrows;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Optional;

import org.junit.Before;
import org.junit.Test;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.EditDeadlineCommand;

public class EditDeadlineParserTest {

    private EditDeadlineParser parser;

    @Before
    public void setupParser() {
        parser = new EditDeadlineParser(UNIX_EPOCH);
    }

    @Test
    public void parse() throws ParseException {
        // No modifications
        assertParse("d1", 1, null, null);

        // Date
        assertParse("d2 dd-4/5/2016", 2, LocalDate.of(2016, 5, 4), null);

        // Time
        assertParse("d3 dt-5:32am", 3, null, LocalTime.of(5, 32));

        // Date and Time
        assertParse("d4 dd-7/8 dt-4:00pm", 4, LocalDate.of(1970, 8, 7), LocalTime.of(16, 0));

        // Index cannot be negative
        assertIncorrect("d-1");

        // Invalid flags
        assertIncorrect("d8 invalid-flag");
    }

    private void assertParse(String args, int targetIndex, LocalDate newDate, LocalTime newTime)
                throws ParseException {
        final Command command = parser.parse(args);
        assertTrue(command instanceof EditDeadlineCommand);
        final EditDeadlineCommand editCommand = (EditDeadlineCommand) command;
        assertEquals(targetIndex, editCommand.getTargetIndex());
        assertEquals(Optional.ofNullable(newDate), editCommand.getNewDate());
        assertEquals(Optional.ofNullable(newTime), editCommand.getNewTime());

    }

    private void assertIncorrect(String args) {
        assertThrows(ParseException.class, () -> parser.parse(args));
    }

}

@@ -310,16 +310,71 @@
 alTime;%0A
+import java.util.Arrays;%0Aimport java.util.Collections;%0A
 import j
@@ -548,182 +548,468 @@
 nd;%0A
-%0Apublic class EditDeadlineParserTest %7B%0A%0A    private EditDeadlineParser parser;%0A%0A    @Before%0A    public void setupParser() %7B%0A        parser = new EditDeadlineParser(UNIX_EPOCH
+import seedu.address.model.ModelManager;%0Aimport seedu.address.model.task.TypicalDeadlineTasks;%0A%0Apublic class EditDeadlineParserTest %7B%0A%0A    private final TypicalDeadlineTasks tdt = new TypicalDeadlineTasks();%0A%0A    private final ModelManager model = new ModelManager();%0A%0A    private EditDeadlineParser parser = new EditDeadlineParser(UNIX_EPOCH);%0A%0A    @Before%0A    public void setupParser() %7B%0A        assertEquals(1, model.addDeadlineTask(tdt.assembleTheMissiles)
 );%0A 
@@ -2265,10 +2265,1324 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void autocompleteName_returnsDeadlineTaskName() %7B%0A        assertEquals(Arrays.asList(%22Assemble The Missiles%22), parser.autocomplete(model, %22d1 n- %22, 5));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %22d2 n- %22, 5));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %22d1 n-a%22, 5));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %221 n-%22, 4));%0A    %7D%0A%0A    @Test%0A    public void autocompleteDueDate_returnsDeadlineDueDate() %7B%0A        assertEquals(Arrays.asList(%221/1/1970%22), parser.autocomplete(model, %22d1 dd- %22, 6));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %22d2 dd- %22, 6));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %22d1 dd-4/5%22, 6));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %221 dd-%22, 5));%0A    %7D%0A%0A    @Test%0A    public void autocompleteDueTime_returnsDeadlineDueTime() %7B%0A        assertEquals(Arrays.asList(%222am%22), parser.autocomplete(model, %22d1 dt- %22, 6));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %22d2 dt- %22, 6));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %22d1 dt-6am%22, 6));%0A        assertEquals(Collections.emptyList(), parser.autocomplete(model, %221 dt-%22, 5));%0A    %7D%0A%0A
 %7D%0A

improve test coverage