/*
 * Copyright (C) 2015 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.cloud.dataflow.sdk.transforms.windowing;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 * Tests for {@link Trigger}.
 */
@RunWith(JUnit4.class)
public class TriggerTest {

  @Test
  public void testTriggerToString() throws Exception {
    assertEquals("AfterWatermark.pastEndOfWindow()", AfterWatermark.pastEndOfWindow().toString());
    assertEquals("Repeatedly(AfterWatermark.pastEndOfWindow())",
        Repeatedly.forever(AfterWatermark.pastEndOfWindow()).toString());
  }
}

@@ -694,16 +694,133 @@
 Equals;%0A
+import static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport org.joda.time.Instant;
 %0Aimport 
@@ -902,16 +902,65 @@
 Unit4;%0A%0A
+import java.util.Arrays;%0Aimport java.util.List;%0A%0A
 /**%0A * T
@@ -1344,11 +1344,2245 @@
 ());%0A  %7D
+%0A%0A  @Test%0A  public void testIsCompatible() throws Exception %7B%0A    assertTrue(new Trigger1(null).isCompatible(new Trigger1(null)));%0A    assertTrue(new Trigger1(Arrays.%3CTrigger%3CIntervalWindow%3E%3EasList(new Trigger2(null)))%0A        .isCompatible(new Trigger1(Arrays.%3CTrigger%3CIntervalWindow%3E%3EasList(new Trigger2(null)))));%0A%0A    assertFalse(new Trigger1(null).isCompatible(new Trigger2(null)));%0A    assertFalse(new Trigger1(Arrays.%3CTrigger%3CIntervalWindow%3E%3EasList(new Trigger1(null)))%0A        .isCompatible(new Trigger1(Arrays.%3CTrigger%3CIntervalWindow%3E%3EasList(new Trigger2(null)))));%0A  %7D%0A%0A  private static class Trigger1 extends Trigger%3CIntervalWindow%3E %7B%0A%0A    private Trigger1(List%3CTrigger%3CIntervalWindow%3E%3E subTriggers) %7B%0A      super(subTriggers);%0A    %7D%0A%0A    @Override%0A    public Trigger.TriggerResult onElement(Trigger%3CIntervalWindow%3E.OnElementContext c) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    public Trigger.MergeResult onMerge(Trigger%3CIntervalWindow%3E.OnMergeContext c) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    public Trigger.TriggerResult onTimer(Trigger%3CIntervalWindow%3E.OnTimerContext c) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    protected Trigger%3CIntervalWindow%3E getContinuationTrigger(%0A        List%3CTrigger%3CIntervalWindow%3E%3E continuationTriggers) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    public Instant getWatermarkThatGuaranteesFiring(IntervalWindow window) %7B%0A      return null;%0A    %7D%0A  %7D%0A%0A  private static class Trigger2 extends Trigger%3CIntervalWindow%3E %7B%0A%0A    private Trigger2(List%3CTrigger%3CIntervalWindow%3E%3E subTriggers) %7B%0A      super(subTriggers);%0A    %7D%0A%0A    @Override%0A    public Trigger.TriggerResult onElement(Trigger%3CIntervalWindow%3E.OnElementContext c) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    public Trigger.MergeResult onMerge(Trigger%3CIntervalWindow%3E.OnMergeContext c) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    public Trigger.TriggerResult onTimer(Trigger%3CIntervalWindow%3E.OnTimerContext c) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    protected Trigger%3CIntervalWindow%3E getContinuationTrigger(%0A        List%3CTrigger%3CIntervalWindow%3E%3E continuationTriggers) %7B%0A      return null;%0A    %7D%0A%0A    @Override%0A    public Instant getWatermarkThatGuaranteesFiring(IntervalWindow window) %7B%0A      return null;%0A    %7D%0A  %7D
 %0A%7D%0A

Add tests for the default implementation of isCompatible