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

# Class MockDataConnector

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin<Map<String,IdPAttribute>>
net.shibboleth.idp.attribute.resolver.AbstractDataConnector
net.shibboleth.idp.attribute.resolver.testing.MockDataConnector

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

@ThreadSafe public class MockDataConnector extends AbstractDataConnector
A data connector that just returns a static collection of attributes.

## 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 final Map<String,IdPAttribute>`
`values`
Static collection of values returned by this connector.

## Constructor Summary

Constructors
Constructor
Description
`MockDataConnector(String id, Map<String,IdPAttribute> connectorValues)`
Constructor.
`MockDataConnector(String id, Map<String,IdPAttribute> connectorValues, Set<ResolverAttributeDefinitionDependency> attrDepends, Set<ResolverDataConnectorDependency> dcDepends)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected Map<String,IdPAttribute>`
`doDataConnectorResolve(AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext)`
Retrieves a collection of attributes from some data source.
`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()`
`void`
`setFailure(boolean fail)`
Fail resolutions

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

`doResolve, getExportAttributes, getFailoverDataConnectorId, getLastFail, getLastSuccess, getLogPrefix, getNoRetryDelay, setExportAttributes, setFailoverDataConnectorId, setLastFail, setLastSuccess, setNoRetryDelay`

### 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.

### values

@Nullable private final Map<String,IdPAttribute> values
Static collection of values returned by this connector.

### resolutionException

@Nullable private ResolutionException resolutionException
Exception thrown by resolution.

## Constructor Details

### MockDataConnector

public MockDataConnector(@Nonnull @NotEmpty String id, @Nullable Map<String,IdPAttribute> connectorValues) throws ComponentInitializationException
Constructor.

Parameters:
  `id` - unique ID for this data connector
  `connectorValues` - static collection of values returned by this connector
Throws:
  `ComponentInitializationException` - ...

### MockDataConnector

public MockDataConnector(@Nonnull @NotEmpty String id, @Nullable Map<String,IdPAttribute> connectorValues, @Nullable Set<ResolverAttributeDefinitionDependency> attrDepends, @Nullable Set<ResolverDataConnectorDependency> dcDepends) throws ComponentInitializationException
Constructor.

Parameters:
  `id` - unique ID for this data connector
  `connectorValues` - static collection of values returned by this connector
  `attrDepends` - The AD dependencies
  `dcDepends` - The DC dependencies
Throws:
  `ComponentInitializationException` - if initialization failed

## Method Details

### setFailure

public void setFailure(boolean fail)
Fail resolutions

Parameters:
  `fail` - `true` to return a `ResolutionException`, otherwise `null`

### doDataConnectorResolve

@Nullable protected Map<String,IdPAttribute> doDataConnectorResolve(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext) throws ResolutionException
Retrieves a collection of attributes from some data source.

Specified by:
  `doDataConnectorResolve` in class `AbstractDataConnector`
Parameters:
  `resolutionContext` - current resolution context
  `workContext` - current resolver work context
Returns:
  collected attributes indexed by attribute ID
Throws:
  `ResolutionException` - thrown if there is a problem resolving the attributes

### doDestroy

public void doDestroy()

Overrides:
  `doDestroy` in class `AbstractResolverPlugin<Map<String,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 `AbstractDataConnector`
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