mil.dod.th.ose.test/src/mil/dod/th/ose/test/ComponentFactoryMocker.java
@SuppressWarnings("unchecked")
    public static <T> List<ComponentInfo<T>> mockComponents(Class<T> clazz, ComponentFactory factory, 
            final int instanceCount)
    {
        NewInstanceAnswer<T> mocker = new NewInstanceAnswer<T>(clazz, instanceCount);
        when(factory.newInstance(Mockito.any(Dictionary.class))).thenAnswer(mocker);
        
        List<ComponentInfo<T>> components = new ArrayList<>();
        
        for (int i=0; i < instanceCount; i++)
        {
            ComponentInfo<T> info = new ComponentInfo<T>(factory, mocker.getComponentInstances()[i], 
                    (T)mocker.getComponentInstances()[i].getInstance());
            components.add(info);
        }
        
        return components;
    }
/**
     * Mock component instances for a {@link ComponentFactory}.  Will mock the backing object as well as the 
     * {@link ComponentInstance}.  Factory will return each instance created when {@link 
     * ComponentFactory#newInstance(Dictionary)} is called up to the <code>instanceCount</code>.
     * 
     * @param <T>
     *      type that the factory creates
     * @param clazz
     *      type that the factory creates
     * @param factory
     *      factory to mock
     * @param instanceCount
     *      how many instances to mock, will throw {@link IndexOutOfBoundsException} if factory tries to create more
     */
Mock component instances for a  ComponentFactory.  Will mock the backing object as well as the
ComponentInstance.  Factory will return each instance created when {@link
ComponentFactory#newInstance(Dictionary)} is called up to the instanceCount.

@param 
type that the factory creates
@param clazz
type that the factory creates
@param factory
factory to mock
@param instanceCount
how many instances to mock, will throw  IndexOutOfBoundsException if factory tries to create more
Mock component instances for a ComponentFactory . Will mock the backing object as well as the ComponentInstance . Factory will return each instance created when { @link ComponentFactory#newInstance ( Dictionary ) } is called up to the instanceCount . @param type that the factory creates @param clazz type that the factory creates @param factory factory to mock @param instanceCount how many instances to mock will throw IndexOutOfBoundsException if factory tries to create more
@SuppressWarnings("unchecked")
    public static <T> List<ComponentInfo<T>> mockComponents(Class<T> clazz, ComponentFactory factory, 
            final int instanceCount)
    {
        NewInstanceAnswer<T> mocker = new NewInstanceAnswer<T>(clazz, instanceCount);
        when(factory.newInstance(Mockito.any(Dictionary.class))).thenAnswer(mocker);
        List<ComponentInfo<T>> components = new ArrayList<>();
        for (int i=0; i < instanceCount; i++)
        {
            ComponentInfo<T> info = new ComponentInfo<T>(factory, mocker.getComponentInstances()[i], 
                    (T)mocker.getComponentInstances()[i].getInstance());
            components.add(info);
        }
        return components;
    }
@ SuppressWarnings ( "unchecked" ) public static < T > List < ComponentInfo < T > > mockComponents ( Class < T > clazz , ComponentFactory factory , final int instanceCount ) { NewInstanceAnswer < T > mocker = new NewInstanceAnswer < T > ( clazz , instanceCount ) ; when ( factory . newInstance ( Mockito . any ( Dictionary . class ) ) ) . thenAnswer ( mocker ) ; List < ComponentInfo < T > > components = new ArrayList < > ( ) ; for ( int i = 0 ; i < instanceCount ; i ++ ) { ComponentInfo < T > info = new ComponentInfo < T > ( factory , mocker . getComponentInstances ( ) [ i ] , ( T ) mocker . getComponentInstances ( ) [ i ] . getInstance ( ) ) ; components . add ( info ) ; } return components ; }
Mock component instances for a {@link ComponentFactory}.
Mock component instances for a { @link ComponentFactory } .