mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestEventAdminMessageService.java
@Test
    public void testAddEventRegRemoteEventAdmin()
    {
        ServiceRegistration<EventHandler> handler1 = mock(ServiceRegistration.class);
        
        //service registration mocks
        when(m_Context.registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                Mockito.any(Dictionary.class))).thenReturn(handler1);
        
        EventRegistrationRequestData request = EventRegistrationRequestData.newBuilder()
                .setCanQueueEvent(true)
                .setExpirationTimeHours(1)
                .setFilter("(something.id=bob)")
                .addTopic("BURGERS")
                .build();
        
        m_SUT.addRemoteEventRegistration(1, request);
        
        verify(m_DataStore, never()).persist(Mockito.any(Class.class), Mockito.any(UUID.class), anyString(), anyByte());

        ArgumentCaptor<Dictionary> dictionaryCap = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_Context, times(1)).registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                dictionaryCap.capture());
        
        //verify dictionary catpured
        Dictionary<String, Object> dicOfProps = dictionaryCap.getValue();
        assertThat((String[])dicOfProps.get(EventConstants.EVENT_TOPIC), is(new String[]{"BURGERS"}));
        assertThat((String)dicOfProps.get(EventConstants.EVENT_FILTER), is("(&(!(remote=*))(something.id=bob))"));
        
        m_SUT.deactivate();
        
        verify(handler1).unregister();
    }
/**
     * Verify adding remote event not using the message service directly.
     * Verify they are not persisted.
     */
Verify adding remote event not using the message service directly.
Verify they are not persisted.
Verify adding remote event not using the message service directly . Verify they are not persisted .
@Test
    public void testAddEventRegRemoteEventAdmin()
    {
        ServiceRegistration<EventHandler> handler1 = mock(ServiceRegistration.class);
        when(m_Context.registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                Mockito.any(Dictionary.class))).thenReturn(handler1);
        EventRegistrationRequestData request = EventRegistrationRequestData.newBuilder()
                .setCanQueueEvent(true)
                .setExpirationTimeHours(1)
                .setFilter("(something.id=bob)")
                .addTopic("BURGERS")
                .build();
        m_SUT.addRemoteEventRegistration(1, request);
        verify(m_DataStore, never()).persist(Mockito.any(Class.class), Mockito.any(UUID.class), anyString(), anyByte());
        ArgumentCaptor<Dictionary> dictionaryCap = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_Context, times(1)).registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                dictionaryCap.capture());
        Dictionary<String, Object> dicOfProps = dictionaryCap.getValue();
        assertThat((String[])dicOfProps.get(EventConstants.EVENT_TOPIC), is(new String[]{"BURGERS"}));
        assertThat((String)dicOfProps.get(EventConstants.EVENT_FILTER), is("(&(!(remote=*))(something.id=bob))"));
        m_SUT.deactivate();
        verify(handler1).unregister();
    }
@ Test public void testAddEventRegRemoteEventAdmin ( ) { ServiceRegistration < EventHandler > handler1 = mock ( ServiceRegistration . class ) ; when ( m_Context . registerService ( eq ( EventHandler . class ) , Mockito . any ( EventHandler . class ) , Mockito . any ( Dictionary . class ) ) ) . thenReturn ( handler1 ) ; EventRegistrationRequestData request = EventRegistrationRequestData . newBuilder ( ) . setCanQueueEvent ( true ) . setExpirationTimeHours ( 1 ) . setFilter ( "(something.id=bob)" ) . addTopic ( "BURGERS" ) . build ( ) ; m_SUT . addRemoteEventRegistration ( 1 , request ) ; verify ( m_DataStore , never ( ) ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , anyString ( ) , anyByte ( ) ) ; ArgumentCaptor < Dictionary > dictionaryCap = ArgumentCaptor . forClass ( Dictionary . class ) ; verify ( m_Context , times ( 1 ) ) . registerService ( eq ( EventHandler . class ) , Mockito . any ( EventHandler . class ) , dictionaryCap . capture ( ) ) ; Dictionary < String , Object > dicOfProps = dictionaryCap . getValue ( ) ; assertThat ( ( String [ ] ) dicOfProps . get ( EventConstants . EVENT_TOPIC ) , is ( new String [ ] { "BURGERS" } ) ) ; assertThat ( ( String ) dicOfProps . get ( EventConstants . EVENT_FILTER ) , is ( "(&(!(remote=*))(something.id=bob))" ) ) ; m_SUT . deactivate ( ) ; verify ( handler1 ) . unregister ( ) ; }
Verify adding remote event not using the message service directly.
Verify adding remote event not using the message service directly .
//service registration mocks //verify dictionary catpured