/*
 * Copyright 2014 LinkedIn Corp.
 *
 * 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 azkaban.execapp;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import azkaban.event.Event;
import azkaban.event.Event.Type;
import azkaban.event.EventListener;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class EventCollectorListener implements EventListener {

  public static final Object handleEvent = new Object();
  // CopyOnWriteArrayList allows concurrent iteration and modification
  private final List<Event> eventList = new CopyOnWriteArrayList<>();
  private final HashSet<Event.Type> filterOutTypes = new HashSet<>();

  public void setEventFilterOut(final Event.Type... types) {
    this.filterOutTypes.addAll(Arrays.asList(types));
  }
  
  @Override
  public void handleEvent(final Event event) {
    synchronized (handleEvent) {
      handleEvent.notifyAll();
    }
    if (!this.filterOutTypes.contains(event.getType())) {
      this.eventList.add(event);
    }
  }

  public List<Event> getEventList() {
    return this.eventList;
  }

  public boolean checkOrdering() {
    final long time = 0;
    for (final Event event : this.eventList) {
      if (time > event.getTime()) {
        return false;
      }
    }

    return true;
  }

  public void assertEvents(final Type... expected) {
    Object[] captured = this.eventList.stream()
        .filter(event -> event.getRunner() != null)
        .map(event -> event.getType())
        .toArray();
    assertThat(captured, is(expected));
  }
}

@@ -636,64 +636,48 @@
 org.
-hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert
+assertj.core.api.AssertionsForClassTypes
 .ass
@@ -1364,11 +1364,9 @@
   %7D%0A
-  
 %0A
+
   @O
@@ -1921,16 +1921,22 @@
 ) %7B%0A    
+final 
 Object%5B%5D
@@ -2109,12 +2109,19 @@
 ured
-, is
+).isEqualTo
 (exp
@@ -2126,17 +2126,16 @@
 xpected)
-)
 ;%0A  %7D%0A%7D%0A

Switch from hamcrest to assertj library for EventCollectorListener (#1184)