mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/persistence/TestObservationQueryImpl.java
@Test
    public void testAssetUuidAlreadySet()
    {
        // mock
        UUID uuid1 = UUID.randomUUID();
        Asset asset1 = mock(Asset.class);
        when(asset1.getUuid()).thenReturn(uuid1);
        
        // replay
        m_SUT.withAssetUuid(uuid1);
        
        // replay with the same UUID, should pass
        m_SUT.withAssetUuid(uuid1);
        m_SUT.withAsset(asset1);
        
        // replay each asset method and verify it fails
        UUID uuid2 = UUID.randomUUID();
        try
        {
            m_SUT.withAssetUuid(uuid2);
            fail("Expecting exception since already restriced to a different asset");
        }
        catch (IllegalStateException e)
        {
        }
        
        try
        {
            Asset asset2 = mock(Asset.class);
            when(asset2.getUuid()).thenReturn(uuid2);
            m_SUT.withAsset(asset2);
            fail("Expecting exception since already restriced to a different asset");
        }
        catch (IllegalStateException e)
        {
        }
        
        try
        {
            m_SUT.withAssetType("anything");
            fail("Expecting exception since already restriced to a specific asset, no point in restricting to a type");
        }
        catch (IllegalStateException e)
        {
        }
    }
/**
     * Verify if the asset UUID is already set that subsequent calls to set the id or type will fail.
     */
Verify if the asset UUID is already set that subsequent calls to set the id or type will fail.
Verify if the asset UUID is already set that subsequent calls to set the id or type will fail .
@Test
    public void testAssetUuidAlreadySet()
    {
        UUID uuid1 = UUID.randomUUID();
        Asset asset1 = mock(Asset.class);
        when(asset1.getUuid()).thenReturn(uuid1);
        m_SUT.withAssetUuid(uuid1);
         with the same UUID, should pass
        m_SUT.withAssetUuid(uuid1);
        m_SUT.withAsset(asset1);
         each asset method and verify it fails
        UUID uuid2 = UUID.randomUUID();
        try
        {
            m_SUT.withAssetUuid(uuid2);
            fail("Expecting exception since already restriced to a different asset");
        }
        catch (IllegalStateException e)
        {
        }
        try
        {
            Asset asset2 = mock(Asset.class);
            when(asset2.getUuid()).thenReturn(uuid2);
            m_SUT.withAsset(asset2);
            fail("Expecting exception since already restriced to a different asset");
        }
        catch (IllegalStateException e)
        {
        }
        try
        {
            m_SUT.withAssetType("anything");
            fail("Expecting exception since already restriced to a specific asset, no point in restricting to a type");
        }
        catch (IllegalStateException e)
        {
        }
    }
@ Test public void testAssetUuidAlreadySet ( ) { UUID uuid1 = UUID . randomUUID ( ) ; Asset asset1 = mock ( Asset . class ) ; when ( asset1 . getUuid ( ) ) . thenReturn ( uuid1 ) ; m_SUT . withAssetUuid ( uuid1 ) ; m_SUT . withAssetUuid ( uuid1 ) ; m_SUT . withAsset ( asset1 ) ; UUID uuid2 = UUID . randomUUID ( ) ; try { m_SUT . withAssetUuid ( uuid2 ) ; fail ( "Expecting exception since already restriced to a different asset" ) ; } catch ( IllegalStateException e ) { } try { Asset asset2 = mock ( Asset . class ) ; when ( asset2 . getUuid ( ) ) . thenReturn ( uuid2 ) ; m_SUT . withAsset ( asset2 ) ; fail ( "Expecting exception since already restriced to a different asset" ) ; } catch ( IllegalStateException e ) { } try { m_SUT . withAssetType ( "anything" ) ; fail ( "Expecting exception since already restriced to a specific asset, no point in restricting to a type" ) ; } catch ( IllegalStateException e ) { } }
Verify if the asset UUID is already set that subsequent calls to set the id or type will fail.
Verify if the asset UUID is already set that subsequent calls to set the id or type will fail .
// mock // replay // replay with the same UUID, should pass // replay each asset method and verify it fails