mil.dod.th.ose.controller/test/mil/dod/th/ose/controller/impl/TestTerraHarvestControllerImpl.java
@Test
    public void testIdProxy() throws FileNotFoundException
    {
        TerraHarvestControllerProxy proxy = mock(TerraHarvestControllerProxy.class);
        // bind proxy, then unbind
        m_SUT.setProxy(proxy);
        m_SUT.setProxy(null);
        
        m_SUT.setId(5);
        m_SUT.getId();
        
        // verify that proxy is never called on since it has been unbound
        verify(proxy, never()).setId(anyInt());
        verify(proxy, never()).getId();
        
        m_SUT.setProxy(proxy);
        
        m_SUT.setId(8);
        m_SUT.getId();
        
        // verify that proxy is never called on since capabilities say not to
        verify(proxy, never()).setId(anyInt());
        verify(proxy, never()).getId();
        
        // make sure if no element if provided (null value), treated as false
        when(m_MockCaps.isIdOverridden()).thenReturn(null);
        
        m_SUT.setId(8);
        m_SUT.getId();
        
        // verify that proxy is never called on since capabilities are at defaults
        verify(proxy, never()).setId(anyInt());
        verify(proxy, never()).getId();
        
        // mock capabilities
        when(m_MockCaps.isIdOverridden()).thenReturn(true);
        
        // just make sure we have a baseline (3 times, set id 3 times here and 3 times during activation)
        verify(m_FileService, times(6)).createFileOutputStream(Mockito.any(File.class));
        
        // mock proxy
        when(proxy.getId()).thenReturn(27);
        
        m_SUT.setId(10);
        
        verify(proxy).setId(10);
        assertThat(m_SUT.getId(), is(27));

        // should still be 6 as the proxy should have been called the last go round
        verify(m_FileService, times(6)).createFileOutputStream(Mockito.any(File.class));
    }
/**
     * Verify the proxy method is called for ID field if capability is set and proxy is available
     */
Verify the proxy method is called for ID field if capability is set and proxy is available
Verify the proxy method is called for ID field if capability is set and proxy is available
@Test
    public void testIdProxy() throws FileNotFoundException
    {
        TerraHarvestControllerProxy proxy = mock(TerraHarvestControllerProxy.class);
        m_SUT.setProxy(proxy);
        m_SUT.setProxy(null);
        m_SUT.setId(5);
        m_SUT.getId();
        verify(proxy, never()).setId(anyInt());
        verify(proxy, never()).getId();
        m_SUT.setProxy(proxy);
        m_SUT.setId(8);
        m_SUT.getId();
        verify(proxy, never()).setId(anyInt());
        verify(proxy, never()).getId();
        when(m_MockCaps.isIdOverridden()).thenReturn(null);
        m_SUT.setId(8);
        m_SUT.getId();
        verify(proxy, never()).setId(anyInt());
        verify(proxy, never()).getId();
        when(m_MockCaps.isIdOverridden()).thenReturn(true);
        verify(m_FileService, times(6)).createFileOutputStream(Mockito.any(File.class));
        when(proxy.getId()).thenReturn(27);
        m_SUT.setId(10);
        verify(proxy).setId(10);
        assertThat(m_SUT.getId(), is(27));
        verify(m_FileService, times(6)).createFileOutputStream(Mockito.any(File.class));
    }
@ Test public void testIdProxy ( ) throws FileNotFoundException { TerraHarvestControllerProxy proxy = mock ( TerraHarvestControllerProxy . class ) ; m_SUT . setProxy ( proxy ) ; m_SUT . setProxy ( null ) ; m_SUT . setId ( 5 ) ; m_SUT . getId ( ) ; verify ( proxy , never ( ) ) . setId ( anyInt ( ) ) ; verify ( proxy , never ( ) ) . getId ( ) ; m_SUT . setProxy ( proxy ) ; m_SUT . setId ( 8 ) ; m_SUT . getId ( ) ; verify ( proxy , never ( ) ) . setId ( anyInt ( ) ) ; verify ( proxy , never ( ) ) . getId ( ) ; when ( m_MockCaps . isIdOverridden ( ) ) . thenReturn ( null ) ; m_SUT . setId ( 8 ) ; m_SUT . getId ( ) ; verify ( proxy , never ( ) ) . setId ( anyInt ( ) ) ; verify ( proxy , never ( ) ) . getId ( ) ; when ( m_MockCaps . isIdOverridden ( ) ) . thenReturn ( true ) ; verify ( m_FileService , times ( 6 ) ) . createFileOutputStream ( Mockito . any ( File . class ) ) ; when ( proxy . getId ( ) ) . thenReturn ( 27 ) ; m_SUT . setId ( 10 ) ; verify ( proxy ) . setId ( 10 ) ; assertThat ( m_SUT . getId ( ) , is ( 27 ) ) ; verify ( m_FileService , times ( 6 ) ) . createFileOutputStream ( Mockito . any ( File . class ) ) ; }
Verify the proxy method is called for ID field if capability is set and proxy is available
Verify the proxy method is called for ID field if capability is set and proxy is available
// bind proxy, then unbind // verify that proxy is never called on since it has been unbound // verify that proxy is never called on since capabilities say not to // make sure if no element if provided (null value), treated as false // verify that proxy is never called on since capabilities are at defaults // mock capabilities // just make sure we have a baseline (3 times, set id 3 times here and 3 times during activation) // mock proxy // should still be 6 as the proxy should have been called the last go round