ListCondition extends BasicCondition<T, ListCondition<T, E>> implements ListChecks<T, E, ListCondition<T, E>> { @Override public ListCondition<T, E> hasSizeLessThanOrEqual(int maxSize) { require(this.subject).isNotNull(); if (!(this.subject.size() <= maxSize)) { DbcAssertionError.throwNew(new IllegalStateException("Expected list size to be less than or equal <" + maxSize + "> but was <" + this.subject.size() + ">"), 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 hasSizeLessThanOrEqual() throws Exception { ListCondition<ArrayList<String>, String> condition = new ListCondition<>(this.input); condition.hasSizeLessThanOrEqual(3); Assertions.assertThatThrownBy(() -> condition.hasSizeLessThanOrEqual(2)) .isInstanceOf(DbcAssertionError.class) .hasCauseInstanceOf(IllegalStateException.class); }