ListCondition extends BasicCondition<T, ListCondition<T, E>> implements ListChecks<T, E, ListCondition<T, E>> { @Override public ListCondition<T, E> hasSizeBetween(int startInclusive, int endInclusive) { require(this.subject).isNotNull(); int listSize = this.subject.size(); if (!((listSize >= startInclusive && listSize <= endInclusive) || (listSize <= startInclusive && listSize >= endInclusive))) { DbcAssertionError.throwNew(new IllegalArgumentException("Expected list size to be between <" + startInclusive + "> and < " + endInclusive + "> but was <" + listSize + ">"), this.message); } return result(); } ListCondition(T subject); @Override ListCondition<T, E> isNotEmpty(); @Override ListCondition<T, E> hasSize(int size); @Override ListCondition<T, E> hasSizeBetween(int startInclusive, int endInclusive); @Override ListCondition<T, E> hasSizeGreaterThan(int minSizeExclusive); @Override ListCondition<T, E> hasSizeGreaterThanOrEqual(int minSize); @Override ListCondition<T, E> hasSizeLessThan(int maxSizeExclusive); @Override ListCondition<T, E> hasSizeLessThanOrEqual(int maxSize);  }
@Test public void hasSizeBetween() throws Exception { ListCondition<ArrayList<String>, String> condition = new ListCondition<>(this.input); condition.hasSizeBetween(2, 4); Assertions.assertThatThrownBy(() -> condition.hasSizeBetween(4, 7)) .isInstanceOf(DbcAssertionError.class) .hasCauseInstanceOf(IllegalArgumentException.class); }