content: package io.activej.cube.aggregation;
  
  import io.activej.datastream.consumer.StreamConsumer;
  import io.activej.datastream.supplier.StreamSupplier;
  
  import java.util.List;
  
  import static org.junit.Assert.assertTrue;
  
  public class StreamUtils {
  	public static void assertEndOfStream(StreamSupplier<?> streamSupplier) {
  		assertTrue(streamSupplier.isResult());
  	}
  
  	public static void assertEndOfStream(StreamConsumer<?> streamConsumer) {
  		assertTrue(streamConsumer.isResult());
  	}
  
  	public static void assertClosedWithError(StreamSupplier<?> streamSupplier) {
  		assertTrue(streamSupplier.isException());
  	}
  
  	public static void assertClosedWithError(StreamConsumer<?> streamConsumer) {
  		assertTrue(streamConsumer.isException());
  	}
  
  	public static void assertSuppliersEndOfStream(List<? extends StreamSupplier<?>> streamSuppliers) {
  		assertTrue(streamSuppliers.stream().allMatch(StreamSupplier::isResult));
  	}
  
  	public static void assertConsumersEndOfStream(List<? extends StreamConsumer<?>> streamConsumers) {
  		assertTrue(streamConsumers.stream().allMatch(StreamConsumer::isResult));
  	}
  
  	public static void assertSuppliersClosedWithError(List<? extends StreamSupplier<?>> streamSuppliers) {
  		assertTrue(streamSuppliers.stream().allMatch(StreamSupplier::isException));
  	}
  
  	public static void assertConsumersClosedWithError(List<? extends StreamConsumer<?>> streamConsumers) {
  		assertTrue(streamConsumers.stream().allMatch(StreamConsumer::isException));
  	}
  
  }
  