package foodtruck.schedule;

import org.easymock.EasyMockSupport;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Before;
import org.junit.Test;

import foodtruck.model.TweetSummary;
import foodtruck.util.Clock;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;

/**
 * @author aviolette@gmail.com
 * @since 10/20/11
 */
public class TerminationDetectorTest extends EasyMockSupport {
  private DateTime now;
  private Clock clock;
  private TerminationDetector detector;
  private TweetSummary.Builder tweetBuilder;

  @Before
  public void before() {
    now = new DateTime(2011, 10, 10, 9, 8, 7, 0, DateTimeZone.UTC);
    clock = createMock(Clock.class);
    expect(clock.now()).andStubReturn(now);
    detector = new TerminationDetector(clock);
    tweetBuilder = new TweetSummary.Builder();
  }

  @Test
  public void test1() {
    replayAll();
    assertEquals(now, detector.detect(tweetBuilder.text("Thank you U of Chicago for braving the weather today and South Loop for closing out our day!  Enjoy the rest of your night!").build()));
    verifyAll();
  }

  @Test
  public void test2() {
    replayAll();
    assertEquals(now, detector.detect(tweetBuilder.text("Thanks so very much AON&Streeterville!!").build()));
    verifyAll();
  }
}

@@ -893,17 +893,24 @@
 oid test
-1
+ThankYou
 () %7B%0A   
@@ -975,24 +975,33 @@
 uilder.text(
+%0A        
 %22Thank you U
@@ -1114,16 +1114,262 @@
 night!%22)
+%0A        .build()));%0A    assertEquals(now, detector.detect(tweetBuilder.text(%0A        %22fidotogo: Thank you so much everyone in Andersonville! Goodnight Stockton, Prince, Toby, Shaggy, Anthony  and all the rest of our wonderful pups!...%22)%0A        
 .build()
@@ -1456,32 +1456,40 @@
 ssertEquals(now,
+%0A       
  detector.detect
@@ -1581,11 +1581,180 @@
 l();%0A  %7D
+%0A%0A  @Test%0A  public void testGoodNight() %7B%0A    replayAll();%0A    assertEquals(now, detector.detect(tweetBuilder.text(%22Good night Chicago!%22).build()));%0A    verifyAll();%0A  %7D
 %0A%7D%0A

Test Good Night termination keyword.