mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/data/TestBaseFactoryObjectDataManager.java
@Test
    public void testPersistNewObjectPersistenceException() throws FactoryObjectInformationException, 
        IllegalArgumentException, PersistenceFailedException, InvalidProtocolBufferException
    {
        //the name to use
        String name = "name";
        //the uuid
        UUID uuid = UUID.randomUUID();

        FactoryDescriptor factory = FactoryMocker.mockFactoryDescriptor(PRODUCT_TYPE);

        //exception
        doThrow(new PersistenceFailedException("FAILURE!!")).when(m_PersistentDataStore).
                persist(eq(LinkLayer.class), eq(uuid), eq(PRODUCT_TYPE), (Serializable)any());

        //call to persist new data
        try
        {
            m_SUT.persistNewObjectData(uuid, factory, name);
            fail("Expected factory object information exception - persistence failed.");
        }
        catch (FactoryObjectInformationException e)
        {
            //expected exception
            assertThat(e.getCause().getClass().getName(), is(PersistenceFailedException.class.getName()));
        }
    }
/**
     * Verify that exceptions are handled as expected if there is a failure to persist new data
     * - error should be wrapped in a FactoryObjectInformationException and thrown
     */
Verify that exceptions are handled as expected if there is a failure to persist new data
- error should be wrapped in a FactoryObjectInformationException and thrown
Verify that exceptions are handled as expected if there is a failure to persist new data - error should be wrapped in a FactoryObjectInformationException and thrown
@Test
    public void testPersistNewObjectPersistenceException() throws FactoryObjectInformationException, 
        IllegalArgumentException, PersistenceFailedException, InvalidProtocolBufferException
    {
        String name = "name";
        UUID uuid = UUID.randomUUID();
        FactoryDescriptor factory = FactoryMocker.mockFactoryDescriptor(PRODUCT_TYPE);
        doThrow(new PersistenceFailedException("FAILURE!!")).when(m_PersistentDataStore).
                persist(eq(LinkLayer.class), eq(uuid), eq(PRODUCT_TYPE), (Serializable)any());
        try
        {
            m_SUT.persistNewObjectData(uuid, factory, name);
            fail("Expected factory object information exception - persistence failed.");
        }
        catch (FactoryObjectInformationException e)
        {
            assertThat(e.getCause().getClass().getName(), is(PersistenceFailedException.class.getName()));
        }
    }
@ Test public void testPersistNewObjectPersistenceException ( ) throws FactoryObjectInformationException , IllegalArgumentException , PersistenceFailedException , InvalidProtocolBufferException { String name = "name" ; UUID uuid = UUID . randomUUID ( ) ; FactoryDescriptor factory = FactoryMocker . mockFactoryDescriptor ( PRODUCT_TYPE ) ; doThrow ( new PersistenceFailedException ( "FAILURE!!" ) ) . when ( m_PersistentDataStore ) . persist ( eq ( LinkLayer . class ) , eq ( uuid ) , eq ( PRODUCT_TYPE ) , ( Serializable ) any ( ) ) ; try { m_SUT . persistNewObjectData ( uuid , factory , name ) ; fail ( "Expected factory object information exception - persistence failed." ) ; } catch ( FactoryObjectInformationException e ) { assertThat ( e . getCause ( ) . getClass ( ) . getName ( ) , is ( PersistenceFailedException . class . getName ( ) ) ) ; } }
Verify that exceptions are handled as expected if there is a failure to persist new data
 - error should be wrapped in a FactoryObjectInformationException and thrown
Verify that exceptions are handled as expected if there is a failure to persist new data - error should be wrapped in a FactoryObjectInformationException and thrown
//the name to use //the uuid //exception //call to persist new data //expected exception