Buggy code:
public class DefaultPermissionFactoryTestCase { private static final ManagementResourceRegistration ROOT_RR = Factory . create ( new SimpleResourceDefinition ( null , new NonResolvingResourceDescriptionResolver ( ) ) { @ Override public List < AccessConstraintDefinition > getAccessConstraints ( ) { } } ) ; private Caller caller ; private Environment environment ; @ Before public void setUp ( ) { } @ Test public void testSingleRoleRejectingCombinationPolicy ( ) { } @ Test public void testSingleRolePermissiveCombinationPolicy ( ) { } @ Test public void testSingleUserRoleMoreAllowedRoles ( ) { } @ Test public void testMoreUserRolesSingleAllowedRole ( ) { } @ Test public void testMoreUserRolesMoreAllowedRoles ( ) { } private void testResourceSingleRole ( CombinationPolicy combinationPolicy , StandardRole userRole , StandardRole allowedRole , boolean accessExpectation ) { } private void testAttributeSingleRole ( CombinationPolicy combinationPolicy , StandardRole userRole , StandardRole allowedRole , boolean accessExpectation ) { } private void testResource ( CombinationPolicy combinationPolicy , StandardRole [ ] userRoles , StandardRole [ ] allowedRoles , boolean accessExpectation ) { } private void testAttribute ( CombinationPolicy combinationPolicy , StandardRole [ ] userRoles , StandardRole [ ] allowedRoles , boolean accessExpectation ) { ConstraintFactory constraintFactory = new DefaultPermissionFactoryTestCase . TestConstraintFactory ( allowedRoles ) ; DefaultPermissionFactoryTestCase . TestRoleMapper roleMapper = new DefaultPermissionFactoryTestCase . TestRoleMapper ( userRoles ) ; DefaultPermissionFactory permissionFactory = new DefaultPermissionFactory ( combinationPolicy , roleMapper , Collections . singleton ( constraintFactory ) , null ) ; Action action = new Action ( null , null , EnumSet . of ( ADDRESS ) ) ; TargetResource targetResource = TargetResource . forStandalone ( EMPTY_ADDRESS , DefaultPermissionFactoryTestCase . ROOT_RR , null ) ; <START_BUG> TargetAttribute targetAttribute = new TargetAttribute ( null , new ModelNode ( ) , targetResource ) ; <END_BUG> PermissionCollection userPermissions = permissionFactory . getUserPermissions ( caller , environment , action , targetAttribute ) ; PermissionCollection requiredPermissions = permissionFactory . getRequiredPermissions ( action , targetAttribute ) ; for ( Permission requiredPermission : DefaultPermissionFactoryTestCase . toSet ( requiredPermissions ) ) { assertEquals ( accessExpectation , userPermissions . implies ( requiredPermission ) ) ; } } @ Test public void testRoleCombinationRejecting ( ) { } private static Set < Permission > toSet ( PermissionCollection permissionCollection ) { } private static final class TestRoleMapper implements RoleMapper { private final Set < String > roles ; private TestRoleMapper ( StandardRole ... roles ) { } @ Override public Set < String > mapRoles ( Caller caller , Environment callEnvironment , Action action , TargetAttribute attribute ) { } @ Override public Set < String > mapRoles ( Caller caller , Environment callEnvironment , Action action , TargetResource resource ) { } @ Override public Set < String > mapRoles ( Caller caller , Environment callEnvironment , Set < String > operationHeaderRoles ) { } @ Override public boolean canRunAs ( Set < String > mappedRoles , String runAsRole ) { } } private static final class TestConstraintFactory implements ConstraintFactory { private final Set < StandardRole > allowedRoles ; private TestConstraintFactory ( StandardRole ... allowedRoles ) { } @ Override public Constraint getStandardUserConstraint ( StandardRole role , Action . ActionEffect actionEffect ) { } @ Override public Constraint getRequiredConstraint ( Action . ActionEffect actionEffect , Action action , TargetAttribute target ) { } @ Override public Constraint getRequiredConstraint ( Action . ActionEffect actionEffect , Action action , TargetResource target ) { } @ Override public boolean equals ( Object obj ) { } @ Override public int hashCode ( ) { } @ Override public int compareTo ( ConstraintFactory o ) { } } private static final class TestConstraint implements Constraint { private final boolean allowed ; private TestConstraint ( boolean allowed ) { } @ Override public boolean violates ( Constraint other , Action . ActionEffect actionEffect ) { } @ Override public boolean replaces ( Constraint other ) { } } }

Fix:
TargetAttribute targetAttribute = new TargetAttribute ( "test" , null , new ModelNode ( ) , targetResource ) ;