mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/asset/TestAssetServiceProxy.java
private void stubDeactivationAsset(final AssetInternal asset, AssetActiveStatus activated, final long waitSecs)
    {
        when(asset.getActiveStatus()).thenReturn(activated);
        
        when(asset.internalDeactivate(Mockito.any(AssetActivationListener[].class)))
            .thenAnswer(new Answer<Thread>()
            {
                @Override
                public Thread answer(final InvocationOnMock invocation) throws Throwable
                {
                    Thread thread = new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            AssetActivationListener[] listeners = 
                                    (AssetActivationListener[])invocation.getArguments()[1];
                            OnAssetDeactivateListener listener = (OnAssetDeactivateListener)listeners[1];
                            
                            try
                            {
                                Thread.sleep(waitSecs * 1000);
                            }
                            catch (InterruptedException e)
                            {
                                e.printStackTrace();
                            }

                            listener.assetDeactivationComplete(asset);
                        }
                    });
                    
                    return thread;
                }
            });
    }
/**
     * Stub out each asset that can be deactivated.
     * 
     * @param waitSecs
     *      how long to wait in seconds until deactivation is completed
     */
Stub out each asset that can be deactivated.

@param waitSecs
how long to wait in seconds until deactivation is completed
Stub out each asset that can be deactivated . @param waitSecs how long to wait in seconds until deactivation is completed
private void stubDeactivationAsset(final AssetInternal asset, AssetActiveStatus activated, final long waitSecs)
    {
        when(asset.getActiveStatus()).thenReturn(activated);
        when(asset.internalDeactivate(Mockito.any(AssetActivationListener[].class)))
            .thenAnswer(new Answer<Thread>()
            {
                @Override
                public Thread answer(final InvocationOnMock invocation) throws Throwable
                {
                    Thread thread = new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            AssetActivationListener[] listeners = 
                                    (AssetActivationListener[])invocation.getArguments()[1];
                            OnAssetDeactivateListener listener = (OnAssetDeactivateListener)listeners[1];
                            try
                            {
                                Thread.sleep(waitSecs * 1000);
                            }
                            catch (InterruptedException e)
                            {
                                e.printStackTrace();
                            }
                            listener.assetDeactivationComplete(asset);
                        }
                    });
                    return thread;
                }
            });
    }
private void stubDeactivationAsset ( final AssetInternal asset , AssetActiveStatus activated , final long waitSecs ) { when ( asset . getActiveStatus ( ) ) . thenReturn ( activated ) ; when ( asset . internalDeactivate ( Mockito . any ( AssetActivationListener [ ] . class ) ) ) . thenAnswer ( new Answer < Thread > ( ) { @ Override public Thread answer ( final InvocationOnMock invocation ) throws Throwable { Thread thread = new Thread ( new Runnable ( ) { @ Override public void run ( ) { AssetActivationListener [ ] listeners = ( AssetActivationListener [ ] ) invocation . getArguments ( ) [ 1 ] ; OnAssetDeactivateListener listener = ( OnAssetDeactivateListener ) listeners [ 1 ] ; try { Thread . sleep ( waitSecs * 1000 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } listener . assetDeactivationComplete ( asset ) ; } } ) ; return thread ; } } ) ; }
Stub out each asset that can be deactivated.
Stub out each asset that can be deactivated .