PentahoSubstringRoleVoter implements AccessDecisionVoter { public boolean supports( final ConfigAttribute attribute ) { if ( ( attribute.getAttribute() != null ) && attribute.getAttribute().startsWith( processConfigAttributePrefix ) ) { return true; } else { return false; } } PentahoSubstringRoleVoter( final String processConfigAttributePrefix ); boolean supports( final ConfigAttribute attribute ); boolean supports( final Class clazz ); int vote( final Authentication authentication, final Object object, final Collection configAttributes );  }
@Test public void supportsValidConfigAttributeTest() { ConfigAttribute validConfigAttribute = new SecurityConfig( PREFIX + TEST_VALUE ); assertTrue( "Valid prefix must be supported", pentahoSubstringRoleVoter.supports( validConfigAttribute ) ); }
@Test public void supportsInvalidConfigAttributeTest() { ConfigAttribute invalidConfigAttribute = new SecurityConfig( INVALID_PREFIX + TEST_VALUE ); assertFalse( "Invalid prefix must not be supported", pentahoSubstringRoleVoter.supports( invalidConfigAttribute ) ); }
@Test public void supportsNullConfigAttributeTest() { ConfigAttribute nullConfigAttribute = mock( ConfigAttribute.class ); when( nullConfigAttribute.getAttribute() ).thenReturn( null ); assertFalse( "Null argument must not be supported", pentahoSubstringRoleVoter.supports( nullConfigAttribute ) ); }
@Test public void supportsClassTest() { boolean isSupports = pentahoSubstringRoleVoter.supports( Class.class ); assertTrue( "this method must always return true", isSupports ); }