mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/pm/TestPowerManagerImpl.java
@Test
    public void testDeleteWakeLockRemoveContext()
    {
        WakeLock lock1 = m_SUT.createWakeLock(TestContext1.class, "lock1");
        when(lock1.getId()).thenReturn("lock1");
        doReturn(TestContext1.class).when(lock1).getContext();

        WakeLock lock2 = m_SUT.createWakeLock(TestContext1.class, "lock2");
        when(lock2.getId()).thenReturn("lock2");
        doReturn(TestContext1.class).when(lock2).getContext();

        WakeLock lock3 = m_SUT.createWakeLock(TestContext2.class, "lock3");
        when(lock3.getId()).thenReturn("lock3");
        doReturn(TestContext2.class).when(lock3).getContext();

        FactoryObject sourceObject = mockFactoryObject();
        WakeLock lock4 = m_SUT.createWakeLock(FactoryObjectProxy.class, sourceObject, "lock4");
        when(lock4.getId()).thenReturn("lock4");
        when(lock4.getSourceObject()).thenReturn(sourceObject);
        doReturn(FactoryObjectProxy.class).when(lock4).getContext();

        assertThat(m_SUT.getWakeLockContexts(), hasSize(3));

        m_SUT.deleteWakeLock(lock1);

        assertThat(m_SUT.getWakeLockContexts(), hasSize(3));

        m_SUT.deleteWakeLock(lock2);

        assertThat(m_SUT.getWakeLockContexts(), hasSize(2));

        m_SUT.deleteWakeLock(lock4);

        assertThat(m_SUT.getWakeLockContexts(), hasSize(1));
    }
/**
     * Test method for {@link PowerManagerImpl#deleteWakeLock(mil.dod.th.core.pm.WakeLock)} when the last wake lock
     * has been removed for a context or source object.
     */
Test method for  PowerManagerImpl#deleteWakeLock(mil.dod.th.core.pm.WakeLock) when the last wake lock
has been removed for a context or source object.
Test method for PowerManagerImpl#deleteWakeLock ( mil . dod . th . core . pm . WakeLock ) when the last wake lock has been removed for a context or source object .
@Test
    public void testDeleteWakeLockRemoveContext()
    {
        WakeLock lock1 = m_SUT.createWakeLock(TestContext1.class, "lock1");
        when(lock1.getId()).thenReturn("lock1");
        doReturn(TestContext1.class).when(lock1).getContext();
        WakeLock lock2 = m_SUT.createWakeLock(TestContext1.class, "lock2");
        when(lock2.getId()).thenReturn("lock2");
        doReturn(TestContext1.class).when(lock2).getContext();
        WakeLock lock3 = m_SUT.createWakeLock(TestContext2.class, "lock3");
        when(lock3.getId()).thenReturn("lock3");
        doReturn(TestContext2.class).when(lock3).getContext();
        FactoryObject sourceObject = mockFactoryObject();
        WakeLock lock4 = m_SUT.createWakeLock(FactoryObjectProxy.class, sourceObject, "lock4");
        when(lock4.getId()).thenReturn("lock4");
        when(lock4.getSourceObject()).thenReturn(sourceObject);
        doReturn(FactoryObjectProxy.class).when(lock4).getContext();
        assertThat(m_SUT.getWakeLockContexts(), hasSize(3));
        m_SUT.deleteWakeLock(lock1);
        assertThat(m_SUT.getWakeLockContexts(), hasSize(3));
        m_SUT.deleteWakeLock(lock2);
        assertThat(m_SUT.getWakeLockContexts(), hasSize(2));
        m_SUT.deleteWakeLock(lock4);
        assertThat(m_SUT.getWakeLockContexts(), hasSize(1));
    }
@ Test public void testDeleteWakeLockRemoveContext ( ) { WakeLock lock1 = m_SUT . createWakeLock ( TestContext1 . class , "lock1" ) ; when ( lock1 . getId ( ) ) . thenReturn ( "lock1" ) ; doReturn ( TestContext1 . class ) . when ( lock1 ) . getContext ( ) ; WakeLock lock2 = m_SUT . createWakeLock ( TestContext1 . class , "lock2" ) ; when ( lock2 . getId ( ) ) . thenReturn ( "lock2" ) ; doReturn ( TestContext1 . class ) . when ( lock2 ) . getContext ( ) ; WakeLock lock3 = m_SUT . createWakeLock ( TestContext2 . class , "lock3" ) ; when ( lock3 . getId ( ) ) . thenReturn ( "lock3" ) ; doReturn ( TestContext2 . class ) . when ( lock3 ) . getContext ( ) ; FactoryObject sourceObject = mockFactoryObject ( ) ; WakeLock lock4 = m_SUT . createWakeLock ( FactoryObjectProxy . class , sourceObject , "lock4" ) ; when ( lock4 . getId ( ) ) . thenReturn ( "lock4" ) ; when ( lock4 . getSourceObject ( ) ) . thenReturn ( sourceObject ) ; doReturn ( FactoryObjectProxy . class ) . when ( lock4 ) . getContext ( ) ; assertThat ( m_SUT . getWakeLockContexts ( ) , hasSize ( 3 ) ) ; m_SUT . deleteWakeLock ( lock1 ) ; assertThat ( m_SUT . getWakeLockContexts ( ) , hasSize ( 3 ) ) ; m_SUT . deleteWakeLock ( lock2 ) ; assertThat ( m_SUT . getWakeLockContexts ( ) , hasSize ( 2 ) ) ; m_SUT . deleteWakeLock ( lock4 ) ; assertThat ( m_SUT . getWakeLockContexts ( ) , hasSize ( 1 ) ) ; }
Test method for {@link PowerManagerImpl#deleteWakeLock(mil.dod.th.core.pm.WakeLock)} when the last wake lock
 has been removed for a context or source object.
Test method for { @link PowerManagerImpl#deleteWakeLock ( mil . dod . th . core . pm . WakeLock ) } when the last wake lock has been removed for a context or source object .