mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/TestCustomCommsServiceImpl_Physical.java
@Test
    public void testCreatePhysicalLinkKnown() throws CCommException, IOException, 
        InterruptedException, FactoryException, FactoryObjectInformationException, IllegalArgumentException, 
        ClassNotFoundException
    {
        //minor setup
        String name = "Some_Name";
        when(m_PhysRegistry.getObjectByName(name)).thenReturn(m_PhysInternal);
        
        // Verify physical link can be created 
        PhysicalLink physicalLink = m_SUT.createPhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, name);

        //reg mocking
        when(m_PhysRegistry.isObjectCreated(name)).thenReturn(true);
        
        Map<String, Object> props = new HashMap<>();
        props.put("String", "Value");
        //replay that if tryCreate is called that the UUID of the previously created link is returned, with props set
        UUID physicalLinkUuid = 
                m_SUT.tryCreatePhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, name, props);
        
        //verify same UUID
        assertThat(physicalLink.getUuid(), is(physicalLinkUuid));
        assertThat(physicalLinkUuid, is(m_PhysUuidUno));
        
        //verify create ONLY called once since reg is mocked to return the same link
        verify(m_PhysRegistry, times(1)).createNewObject(m_PhysFactory, name, new Hashtable<String, Object>());
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
        
        //verify set props called
        verify(m_PhysInternal, times(1)).setProperties(props);
    }
/**
     * Verify that if a physical link with the specified name already exists that the UUID for that link is returned.
     */
Verify that if a physical link with the specified name already exists that the UUID for that link is returned.
Verify that if a physical link with the specified name already exists that the UUID for that link is returned .
@Test
    public void testCreatePhysicalLinkKnown() throws CCommException, IOException, 
        InterruptedException, FactoryException, FactoryObjectInformationException, IllegalArgumentException, 
        ClassNotFoundException
    {
        String name = "Some_Name";
        when(m_PhysRegistry.getObjectByName(name)).thenReturn(m_PhysInternal);
        PhysicalLink physicalLink = m_SUT.createPhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, name);
        when(m_PhysRegistry.isObjectCreated(name)).thenReturn(true);
        Map<String, Object> props = new HashMap<>();
        props.put("String", "Value");
        UUID physicalLinkUuid = 
                m_SUT.tryCreatePhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, name, props);
        assertThat(physicalLink.getUuid(), is(physicalLinkUuid));
        assertThat(physicalLinkUuid, is(m_PhysUuidUno));
        verify(m_PhysRegistry, times(1)).createNewObject(m_PhysFactory, name, new Hashtable<String, Object>());
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
        verify(m_PhysInternal, times(1)).setProperties(props);
    }
@ Test public void testCreatePhysicalLinkKnown ( ) throws CCommException , IOException , InterruptedException , FactoryException , FactoryObjectInformationException , IllegalArgumentException , ClassNotFoundException { String name = "Some_Name" ; when ( m_PhysRegistry . getObjectByName ( name ) ) . thenReturn ( m_PhysInternal ) ; PhysicalLink physicalLink = m_SUT . createPhysicalLink ( PhysicalLinkTypeEnum . SERIAL_PORT , name ) ; when ( m_PhysRegistry . isObjectCreated ( name ) ) . thenReturn ( true ) ; Map < String , Object > props = new HashMap < > ( ) ; props . put ( "String" , "Value" ) ; UUID physicalLinkUuid = m_SUT . tryCreatePhysicalLink ( PhysicalLinkTypeEnum . SERIAL_PORT , name , props ) ; assertThat ( physicalLink . getUuid ( ) , is ( physicalLinkUuid ) ) ; assertThat ( physicalLinkUuid , is ( m_PhysUuidUno ) ) ; verify ( m_PhysRegistry , times ( 1 ) ) . createNewObject ( m_PhysFactory , name , new Hashtable < String , Object > ( ) ) ; verify ( m_WakeLock ) . activate ( ) ; verify ( m_WakeLock ) . cancel ( ) ; verify ( m_PhysInternal , times ( 1 ) ) . setProperties ( props ) ; }
Verify that if a physical link with the specified name already exists that the UUID for that link is returned.
Verify that if a physical link with the specified name already exists that the UUID for that link is returned .
//minor setup // Verify physical link can be created  //reg mocking //replay that if tryCreate is called that the UUID of the previously created link is returned, with props set //verify same UUID //verify create ONLY called once since reg is mocked to return the same link //verify set props called