UuidDomain extends AbstractStringDomain { public boolean contains( String value) { return super.contains( value) && isUuid( value); } UuidDomain(); boolean contains( String value);  }
@Test public void whenConstant() { String value = "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"; StringConstant domain = new UuidConstant( value); List<String> values = valuesOf( domain, 10); assertThat( "Constant values size", values.size(), is( 1)); assertThat( "Constant value", domain.select( getResolverContext()), matches( dataValueMatcher( value, Type.STRING, "uuid"))); assertThat( "Contains", domain.contains( value), is( true)); assertThat( "Contains", domain.contains( ""), is( false)); }
@Test public void whenEnum() { List<String> uuids = Arrays.asList( "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"); UuidEnum domain = new UuidEnum( uuids); List<String> values = valuesOf( domain, 1000); assertThat( "Enum values size", values.size(), is( 1000)); assertThat( "Enum values content", values.stream().collect( toSet()), containsMembers( Arrays.asList( "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"))); assertThat( "Contains", domain.contains( "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"), is( true)); assertThat( "Contains", domain.contains( "f81d4fae-7dec-11d0-a765-00a0c91e6bf7"), is( false)); }
@Test public void whenDefaultLength() { UuidDomain domain = new UuidDomain(); domain.setExcluded( Stream.of( "f81d4fae-7dec-11d0-a765-00a0c91e6bf6").collect( toSet())); verifyContainsValues( domain, 1000); assertThat( "Contains", domain.contains( "F81D4FAE-7DEC-11D0-A765-00A0C91E6BF6"), is( false)); assertThat( "Contains", domain.contains( ""), is( false)); DataValue<String> value = domain.select( getResolverContext()); assertThat( "Value", value, matches( dataValueMatcher( value.getValue(), Type.STRING, "uuid"))); }
@Test public void whenLengthValid() { UuidDomain domain = new UuidDomain(); domain.setLengthRange(36); domain.setMatching( "^a"); domain.setNotMatching( "f$"); verifyContainsValues( domain, 1000); assertThat( "Contains", domain.contains( "a81d4fae-7dec-11d0-a765-00a0c91e6bf6"), is( true)); assertThat( "Contains", domain.contains( "a81d4fae-7dec-11d0-a765-00a0c91e6bff"), is( false)); assertThat( "Contains", domain.contains( "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"), is( false)); }