mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/asset/TestAssetImpl.java
@Test
    public void testActivateAsset() throws Exception
    {
        assertThat(m_SUT.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));

        EventAdminSyncer syncer = new EventAdminSyncer(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE);

        m_SUT.activateAsync();

        // wait for activation
        syncer.waitFor(5, TimeUnit.SECONDS);

        assertThat(m_SUT.getActiveStatus(), is(AssetActiveStatus.ACTIVATED));

        // make sure events fired with correct properties set
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_WILL_BE_ACTIVATED, m_SUT);
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE, m_SUT);

        verify(m_Proxy).onActivate();

        try
        {
            m_SUT.activateAsync();
            fail("Expecting exception");
        }
        catch (IllegalStateException e)
        {

        }

        // wait to see if activation start and success are called again
        Thread.sleep(1000);

        // verify nothing happened, still same amount of events
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_WILL_BE_ACTIVATED, 1);
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE, 1);
    }
/**
     * Verify activation will update status and invoke proxy.
     */
Verify activation will update status and invoke proxy.
Verify activation will update status and invoke proxy .
@Test
    public void testActivateAsset() throws Exception
    {
        assertThat(m_SUT.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));
        EventAdminSyncer syncer = new EventAdminSyncer(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE);
        m_SUT.activateAsync();
        syncer.waitFor(5, TimeUnit.SECONDS);
        assertThat(m_SUT.getActiveStatus(), is(AssetActiveStatus.ACTIVATED));
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_WILL_BE_ACTIVATED, m_SUT);
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE, m_SUT);
        verify(m_Proxy).onActivate();
        try
        {
            m_SUT.activateAsync();
            fail("Expecting exception");
        }
        catch (IllegalStateException e)
        {
        }
        Thread.sleep(1000);
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_WILL_BE_ACTIVATED, 1);
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE, 1);
    }
@ Test public void testActivateAsset ( ) throws Exception { assertThat ( m_SUT . getActiveStatus ( ) , is ( AssetActiveStatus . DEACTIVATED ) ) ; EventAdminSyncer syncer = new EventAdminSyncer ( m_EventAdmin , Asset . TOPIC_ACTIVATION_COMPLETE ) ; m_SUT . activateAsync ( ) ; syncer . waitFor ( 5 , TimeUnit . SECONDS ) ; assertThat ( m_SUT . getActiveStatus ( ) , is ( AssetActiveStatus . ACTIVATED ) ) ; EventAdminVerifier . assertEventByTopicAsset ( m_EventAdmin , Asset . TOPIC_WILL_BE_ACTIVATED , m_SUT ) ; EventAdminVerifier . assertEventByTopicAsset ( m_EventAdmin , Asset . TOPIC_ACTIVATION_COMPLETE , m_SUT ) ; verify ( m_Proxy ) . onActivate ( ) ; try { m_SUT . activateAsync ( ) ; fail ( "Expecting exception" ) ; } catch ( IllegalStateException e ) { } Thread . sleep ( 1000 ) ; EventAdminVerifier . assertEventByTopicOnly ( m_EventAdmin , Asset . TOPIC_WILL_BE_ACTIVATED , 1 ) ; EventAdminVerifier . assertEventByTopicOnly ( m_EventAdmin , Asset . TOPIC_ACTIVATION_COMPLETE , 1 ) ; }
Verify activation will update status and invoke proxy.
Verify activation will update status and invoke proxy .
// wait for activation // make sure events fired with correct properties set // wait to see if activation start and success are called again // verify nothing happened, still same amount of events