@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 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 whitespacesAreToTrimOnRequiredNotNull() throws Exception { sut.assumeWhitspacesEqualsAnEmptyString().setNullIsAValue(false).required(false); { // valid List<Representant<String>> all = sut.getValidRepresentations(); assertEquals(4, all.size()); assertThat(all, not(hasItem(valid((String) null)))); assertThat(all, hasItem(valid(""))); assertThat(all, hasItem(valid(" "))); assertThat(all, hasItem(valid("\t"))); assertThat(all, hasItem(valid(StringGenerator.gen(fill, 8077)))); } { // invalid List<Representant<String>> all = sut.getInValidRepresentations(); assertEquals(0, all.size()); } }
@Test public void whitespacesAreNotToTrim() throws Exception { sut.assumeWhitspacesEqualsAnEmptyString(); { // valid List<Representant<String>> all = sut.getValidRepresentations(); assertEquals(5, all.size()); assertThat(all, hasItem(valid((String) null))); assertThat(all, hasItem(valid(""))); assertThat(all, hasItem(valid(" "))); assertThat(all, hasItem(valid("\t"))); assertThat(all, hasItem(valid(StringGenerator.gen(fill, 8077)))); } { // invalid List<Representant<String>> all = sut.getInValidRepresentations(); assertEquals(0, all.size()); } }
@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()); } }