package edu.pdx.cs410J.grader.poa;

import com.google.common.eventbus.EventBus;
import org.junit.Before;
import org.junit.Test;

import java.time.LocalDateTime;
import java.util.Collections;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class POASubmissionsPresentTest {

  private EventBus bus;
  private POASubmissionsPresenter presenter;
  private POASubmissionsView view;

  @Before
  public void setUp() {
    bus = new EventBus();
    view = mock(POASubmissionsView.class);
    presenter = new POASubmissionsPresenter(bus, view);
  }

  @Test
  public void poaSubmissionDownloadedEventPopulatesPOASubmissionView() {
    String subject = "POA for Project 1";
    String submitter = "Test Student";
    LocalDateTime submitTime = LocalDateTime.now();

    POASubmission submission = createPOASubmission(subject, submitter, submitTime);
    bus.post(submission);

    verify(view).setPOASubmissionsDescriptions(Collections.singletonList(subject));
  }

  private POASubmission createPOASubmission(String subject, String submitter, LocalDateTime submitTime) {
    POASubmission.Builder builder = POASubmission.builder();
    builder.setSubject(subject);
    builder.setSubmitter(submitter);
    builder.setSubmitTime(submitTime);
    return builder.create();
  }
}

@@ -171,26 +171,21 @@
 va.util.
-Collection
+Array
 s;%0A%0Aimpo
@@ -333,53 +333,8 @@
 us;%0A
-  private POASubmissionsPresenter presenter;%0A
   pr
@@ -475,20 +475,8 @@
 %0A   
- presenter =
  new
@@ -894,29 +894,569 @@
 ons(
-Collections.singleton
+Arrays.asList(subject));%0A  %7D%0A%0A  @Test%0A  public void submissionsDescriptionsAreDisplayedInOrderThatEventsWereSent() %7B%0A    String subject1 = %22POA for Project 1%22;%0A    String subject2 = %22POA for Project 2%22;%0A    String submitter = %22Test Student%22;%0A    LocalDateTime submitTime = LocalDateTime.now();%0A%0A    bus.post(createPOASubmission(subject1, submitter, submitTime));%0A    bus.post(createPOASubmission(subject2, submitter, submitTime));%0A%0A    verify(view).setPOASubmissionsDescriptions(Arrays.asList(subject1));%0A    verify(view).setPOASubmissionsDescriptions(Arrays.as
 List
@@ -1459,28 +1459,40 @@
 List(subject
+1, subject2
 ));%0A
+%0A
   %7D%0A%0A  priva

Test that multiple POASubmission events are displayed in the order in which they are sent.