Package net.shibboleth.idp.attribute.resolver.testing

# Class MockAttributeDefinition

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin<IdPAttribute>
net.shibboleth.idp.attribute.resolver.AbstractAttributeDefinition
net.shibboleth.idp.attribute.resolver.testing.MockAttributeDefinition

All Implemented Interfaces:
  `AttributeDefinition`, `ResolverPlugin<IdPAttribute>`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`, `UnmodifiableComponent`, `DisposableBean`

@ThreadSafe public class MockAttributeDefinition extends AbstractAttributeDefinition
An attribute definition that simply returns a static value.

## Field Summary

Fields
Modifier and Type
Field
Description
`private int`
`destroyCount`
Number of times `AbstractInitializableComponent.destroy()` was called.
`private int`
`initializeCount`
Number of times `AbstractInitializableComponent.initialize()` was called.
`private ResolutionException`
`resolutionException`
Exception thrown by resolution.
`private IdPAttribute`
`staticValue`
Static value returned by this definition.

## Constructor Summary

Constructors
Constructor
Description
`MockAttributeDefinition(String id, IdPAttribute value)`
Constructor.
`MockAttributeDefinition(String id, ResolutionException exception)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected IdPAttribute`
`doAttributeDefinitionResolve(AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext)`
Creates and populates the values for the resolved attribute.
`void`
`doDestroy()`
`void`
`doInitialize()`
`int`
`getDestroyCount()`
Gets the number of times `AbstractInitializableComponent.destroy()` was called.
`int`
`getInitializeCount()`
Gets the number of times `AbstractInitializableComponent.initialize()` was called.
`boolean`
`isInitialized()`

### Methods inherited from class net.shibboleth.idp.attribute.resolver.AbstractAttributeDefinition

`doResolve, getLogPrefix, isDependencyOnly, isPreRequested, setDependencyOnly, setPreRequested`

### Methods inherited from class net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin

`equals, getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, hashCode, isPropagateResolutionExceptions, resolve, setActivationCondition, setAttributeDependencies, setDataConnectorDependencies, setPropagateResolutionExceptions`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, initialize, isDestroyed`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.DestructableComponent

`destroy, isDestroyed`

### Methods inherited from interface org.springframework.beans.factory.DisposableBean

`destroy`

### Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent

`getId`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize`

### Methods inherited from interface net.shibboleth.idp.attribute.resolver.ResolverPlugin

`getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, isPropagateResolutionExceptions, resolve`

## Field Details

### destroyCount

private int destroyCount
Number of times `AbstractInitializableComponent.destroy()` was called.

### initializeCount

private int initializeCount
Number of times `AbstractInitializableComponent.initialize()` was called.

### staticValue

@Nullable private IdPAttribute staticValue
Static value returned by this definition.

### resolutionException

@Nullable private ResolutionException resolutionException
Exception thrown by resolution.

## Constructor Details

### MockAttributeDefinition

public MockAttributeDefinition(@Nonnull @NotEmpty String id, @Nullable IdPAttribute value) throws ComponentInitializationException
Constructor.

Parameters:
  `id` - unique ID of this attribute definition
  `value` - static value returned by this definition
Throws:
  `ComponentInitializationException` - ...

### MockAttributeDefinition

public MockAttributeDefinition(@Nonnull @NotEmpty String id, @Nullable ResolutionException exception)
Constructor.

Parameters:
  `id` - id of the data connector
  `exception` - exception thrown by resolution

## Method Details

### doAttributeDefinitionResolve

@Nullable protected IdPAttribute doAttributeDefinitionResolve(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext) throws ResolutionException
Creates and populates the values for the resolved attribute. Implementations should not set, or otherwise manage, the resolved attribute's display name, description or encoders. Nor should the resultant attribute be recorded in the given resolution context.

Specified by:
  `doAttributeDefinitionResolve` in class `AbstractAttributeDefinition`
Parameters:
  `resolutionContext` - current attribute resolution context
  `workContext` - current resolver work context
Returns:
  resolved attribute or null if nothing to resolve.
Throws:
  `ResolutionException` - thrown if there is a problem resolving and creating the attribute

### doDestroy

public void doDestroy()

Overrides:
  `doDestroy` in class `AbstractResolverPlugin<IdPAttribute>`

### isInitialized

public boolean isInitialized()

Specified by:
  `isInitialized` in interface `InitializableComponent`
Overrides:
  `isInitialized` in class `AbstractInitializableComponent`

### doInitialize

public void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractAttributeDefinition`
Throws:
  `ComponentInitializationException`

### getDestroyCount

public int getDestroyCount()
Gets the number of times `AbstractInitializableComponent.destroy()` was called.

Returns:
  number of times `AbstractInitializableComponent.destroy()` was called

### getInitializeCount

public int getInitializeCount()
Gets the number of times `AbstractInitializableComponent.initialize()` was called.

Returns:
  number of times `AbstractInitializableComponent.initialize()` was called