@Test public void withOwnEmptySpecInValidNotNull() throws Exception { sut.setNullIsAValue(false); sut.setWhitspaceStrings("rw"); List<Representant<String>> all = sut.getInValidRepresentations(); assertEquals(0, all.size()); }
@Test public void withOwnEmptySpecInValidAndRequiredWithoutEmptyString() throws Exception { sut.setWhitspaceStrings("rw"); sut.noEmptyStringCheck(); sut.required(true); List<Representant<String>> all = sut.getInValidRepresentations(); assertEquals(2, all.size()); assertThat(all, hasItem(invalid((String) null))); assertThat(all, hasItem(invalid("rw"))); }
@Test public void withOwnEmptySpecValid() throws Exception { sut.setWhitspaceStrings("rw"); List<Representant<String>> all = sut.getValidRepresentations(); assertEquals(4, all.size()); assertThat(all, hasItem(valid((String) null))); assertThat(all, hasItem(valid(""))); assertThat(all, hasItem(valid("rw"))); assertThat(all, hasItem(valid(StringGenerator.gen(fill, 8077)))); }
@Test public void withOwnEmptySpecInValidAndRequiredNotNull() throws Exception { sut.setNullIsAValue(false); sut.setWhitspaceStrings("rw"); sut.required(true); List<Representant<String>> all = sut.getInValidRepresentations(); assertEquals(2, all.size()); assertThat(all, not(hasItem(invalid((String) null)))); assertThat(all, hasItem(invalid(""))); assertThat(all, hasItem(invalid("rw"))); }
@Test public void withOwnEmptyStringValidNotNull() throws Exception { sut.setNullIsAValue(false); sut.setWhitspaceStrings("rw"); sut.setEmptyString("-"); List<Representant<String>> all = sut.getValidRepresentations(); assertEquals(3, all.size()); assertThat(all, not(hasItem(valid((String) null)))); assertThat(all, hasItem(valid("-"))); assertThat(all, hasItem(valid("rw"))); assertThat(all, hasItem(valid(StringGenerator.gen(fill, 8077)))); }
@Test public void trimAndFilltoMaxLength() throws Exception { sut.trim(true); sut.maxLength(97); sut.noEmptyStringCheck(); sut.setWhitspaceStrings(""); sut.setNullIsAValue(false); { // valid List<Representant<String>> all = sut.getValidRepresentations(); assertEquals(2, all.size()); assertThat(all, hasItem(valid(""))); for (Representant<String> representant : all) { assertThat(representant.getValue(), equalTo(representant.getValue().trim())); } } { List<Representant<String>> all = sut.getInValidRepresentations(); assertEquals(1, all.size()); } }