use of com.sun.identity.entitlement.URLResourceName in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method validResourcesPass.
@Test
public void validResourcesPass() {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addPattern("a://b:c/*").addPattern("d://*:*/*").build();
// When
Set<String> resources = CollectionUtils.asSet("a://b:c/def/hij", "d://fried:egg/test/home");
boolean successful = validator.verifyResources(resources).using(new URLResourceName()).against(resourceType).isSuccessful();
// Then
assertThat(successful).isTrue();
}
use of com.sun.identity.entitlement.URLResourceName in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method throwsExceptionWhenResourcesFail.
@Test(expectedExceptions = ConstraintFailureException.class, expectedExceptionsMessageRegExp = "Invalid value fail://uri:blah/goodbye for property resources")
public void throwsExceptionWhenResourcesFail() throws ConstraintFailureException {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addPattern("a://b:c/*").addPattern("d://*:*/*").build();
// When
Set<String> resources = CollectionUtils.asSet("a://b:c/def/hij", "fail://uri:blah/goodbye");
validator.verifyResources(resources).using(new URLResourceName()).against(resourceType).throwExceptionIfFailure();
}
use of com.sun.identity.entitlement.URLResourceName in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method invalidResourcesFail.
@Test
public void invalidResourcesFail() {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addPattern("a://b:c/*").addPattern("d://*:*/*").build();
// When
Set<String> resources = CollectionUtils.asSet("a://b:c/def/hij", "fail://uri:blah/goodbye");
boolean successful = validator.verifyResources(resources).using(new URLResourceName()).against(resourceType).isSuccessful();
// Then
assertThat(successful).isFalse();
}
Aggregations