DiffListenerAdapter implements DiffListener { @Override @SuppressWarnings("unchecked") public void onEvent(final MatchResult res) { Class type = res.getType(); if (type.equals(DataCell.class)) { delegate.endCell((MatchResult<DataCell, DataCell>) res); } else if (type.equals(DataRow.class)) { delegate.endRow((MatchResult<DataRow, DataRow>) res); } else if (type.equals(DataTable.class)) { delegate.endTable((MatchResult<DataTable, DataTable>) res); } else { throw new IllegalArgumentException("Unknown type: " + res.getType()); } } protected  DiffListenerAdapter();  DiffListenerAdapter(final DiffHandler delegate); static DiffListenerAdapter from(final DiffHandler handler); @Override @SuppressWarnings("unchecked") void onEvent(final MatchResult res);  }
@Test @SuppressWarnings("unchecked") public void shouldDelegateToEndCell() { MatchResult res = createResult(DataCell.class); adapter.onEvent(res); verify(handler).endCell(res); verify(handler, never()).endRow(any(MatchResult.class)); verify(handler, never()).endTable(any(MatchResult.class)); }
@Test @SuppressWarnings("unchecked") public void shouldDelegatetoEndRow() { MatchResult res = createResult(DataRow.class); adapter.onEvent(res); verify(handler).endRow(res); verify(handler, never()).endCell(any(MatchResult.class)); verify(handler, never()).endTable(any(MatchResult.class)); }
@Test @SuppressWarnings("unchecked") public void shouldDelegateToEndTable() { MatchResult res = createResult(DataTable.class); adapter.onEvent(res); verify(handler).endTable(res); verify(handler, never()).endCell(any(MatchResult.class)); verify(handler, never()).endRow(any(MatchResult.class)); }