### Question:
Filter { public Filter clone(boolean paginate) { Filter filter = new Filter(); filter.conditions = new ArrayList<>(conditions); filter.sortFields = new ArrayList<>(sortFields); if (paginate) { filter.page(pageNo, perPage); } return filter; } Filter(Class<?> clazz);  Filter(int perPage, int pageNo, Condition... conditions);  Filter();  Filter(Condition... conditions); Filter condition(String name, Object value); Filter condition(String name, Operator operator, Object value); Filter page(int pageNo, int perPage); Filter sortBy(String name, boolean asc); Filter sortBy(SortField sortField); Filter cacheable(boolean cacheable); Filter clone(boolean paginate); List<T> list(); long count(); void delete();  }### Answer:
@Test public void shouldCloneFilter() { Filter filter = new Filter(); Filter clonedFilter = filter.clone(false); assertTrue(clonedFilter.getConditions().isEmpty()); assertEquals(clonedFilter.getPageNo(), 1); assertEquals(clonedFilter.getPerPage(), Integer.MAX_VALUE); }
@Test public void shouldCloneFilterWithConditions() { Filter filter = new Filter(mock(Condition.class)); Filter clonedFilter = filter.clone(false); assertEquals(clonedFilter.getConditions().size(), 1); }
@Test public void shouldCloneFilterWithConditionsWithPaginate() { Filter filter = new Filter(2, 20, mock(Condition.class)); Filter clonedFilter = filter.clone(true); assertEquals(clonedFilter.getConditions().size(), 1); assertEquals(clonedFilter.getPageNo(), 20); assertEquals(clonedFilter.getPerPage(), 2); }
@Test public void shouldCloneFilterWithConditionsWithoutPaginate() { Filter filter = new Filter(2, 20, mock(Condition.class)); Filter clonedFilter = filter.clone(false); assertEquals(clonedFilter.getConditions().size(), 1); assertEquals(clonedFilter.getPageNo(), 1); assertEquals(clonedFilter.getPerPage(), Integer.MAX_VALUE); }