@Test
public void testPut() throws InterruptedException {

	// Without comparator
	CoalescedPipe<String> coalescedPipe = new CoalescedPipe<>();
	// Null
	try {
		coalescedPipe.put(null);
		Assert.fail();
	}
	catch (NullPointerException nullPointerException) {
	}
	// Normal
	coalescedPipe.put("test1");
	Assert.assertEquals(1, coalescedPipe.pendingCount());
	Assert.assertEquals(0, coalescedPipe.coalescedCount());
	coalescedPipe.put("test2");
	Assert.assertEquals(2, coalescedPipe.pendingCount());
	Assert.assertEquals(0, coalescedPipe.coalescedCount());
	// Coalesce
	coalescedPipe.put("test1");
	Assert.assertEquals(2, coalescedPipe.pendingCount());
	Assert.assertEquals(1, coalescedPipe.coalescedCount());
	coalescedPipe.put("test2");
	Assert.assertEquals(2, coalescedPipe.pendingCount());
	Assert.assertEquals(2, coalescedPipe.coalescedCount());
	// With comparator
	coalescedPipe = new CoalescedPipe<String>(
		new Comparator<String>() {
			@Override
			public int compare(String o1, String o2) {
				return o1.length() - o2.length();
			}
		});
	// Null
	try {
		coalescedPipe.put(null);
		Assert.fail();
	}
	catch (NullPointerException nullPointerException) {
	}
	// Normal
	coalescedPipe.put("a");
	Assert.assertEquals(1, coalescedPipe.pendingCount());
	Assert.assertEquals(0, coalescedPipe.coalescedCount());
	coalescedPipe.put("ab");
	Assert.assertEquals(2, coalescedPipe.pendingCount());
	Assert.assertEquals(0, coalescedPipe.coalescedCount());
	// Coalesce
	coalescedPipe.put("c");
	Assert.assertEquals(2, coalescedPipe.pendingCount());
	Assert.assertEquals(1, coalescedPipe.coalescedCount());
	coalescedPipe.put("cd");
	Assert.assertEquals(2, coalescedPipe.pendingCount());
	Assert.assertEquals(2, coalescedPipe.coalescedCount());
}