mil.dod.th.ose.shell/test/mil/dod/th/ose/shell/TestRemoteEventAdminCommands.java
@Test
    public void testGetEventRegistrations()
    {
        //system id to use
        int sysId1 = 1;
        int sysId2 = 2;
        
        //dummy remote event messages
        EventRegistrationRequestData.Builder request1 = EventRegistrationRequestData.newBuilder().addTopic("TOPIC-A");
        // add required fields
        request1 = RemoteUtils.appendRequiredFields(request1, false);
        RemoteEventRegistration reg1 = new RemoteEventRegistration(sysId1, (ServiceRegistration<EventHandler>)null, 
                request1.build());

        EventRegistrationRequestData.Builder request2 = EventRegistrationRequestData.newBuilder().addTopic("TOPIC-B");
        // add required fields
        request2 = RemoteUtils.appendRequiredFields(request2, false);
        RemoteEventRegistration reg2 = new RemoteEventRegistration(sysId2, (ServiceRegistration<EventHandler>)null,
                request2.build());
       
        //map of registrations
        Map<Integer, RemoteEventRegistration> registrations = new HashMap<Integer, RemoteEventRegistration>();
        registrations.put(1, reg1);
        registrations.put(2, reg2);
        
        //behavior
        when(m_RemoteEventAdmin.getRemoteEventRegistrations()).thenReturn(registrations);
        when(m_RemoteEventAdmin.getRemoteEventExpirationHours(1)).thenReturn(167L);
        when(m_RemoteEventAdmin.getRemoteEventExpirationHours(2)).thenReturn(5L);
        
        CommandSession testSession = mock(CommandSession.class);
        PrintStream testStream = mock(PrintStream.class);
        when(testSession.getConsole()).thenReturn(testStream);
        
        m_SUT.eventRegs(testSession);
        
        verify(testStream).printf("Registration ID: %d (Expires in %d-%d hours)\n%s", 1,
                (long)RemoteConstants.REMOTE_EVENT_DEFAULT_REG_TIMEOUT_HOURS - 1,
                (long)RemoteConstants.REMOTE_EVENT_DEFAULT_REG_TIMEOUT_HOURS, reg1);
        verify(testStream).printf("Registration ID: %d (Expires in %d-%d hours)\n%s", 2, 5L, 6L, reg2);
    }
/**
     * Verify the ability to get the registrations known for a particular system Id.
     */
Verify the ability to get the registrations known for a particular system Id.
Verify the ability to get the registrations known for a particular system Id .
@Test
    public void testGetEventRegistrations()
    {
        int sysId1 = 1;
        int sysId2 = 2;
        EventRegistrationRequestData.Builder request1 = EventRegistrationRequestData.newBuilder().addTopic("TOPIC-A");
        request1 = RemoteUtils.appendRequiredFields(request1, false);
        RemoteEventRegistration reg1 = new RemoteEventRegistration(sysId1, (ServiceRegistration<EventHandler>)null, 
                request1.build());
        EventRegistrationRequestData.Builder request2 = EventRegistrationRequestData.newBuilder().addTopic("TOPIC-B");
        request2 = RemoteUtils.appendRequiredFields(request2, false);
        RemoteEventRegistration reg2 = new RemoteEventRegistration(sysId2, (ServiceRegistration<EventHandler>)null,
                request2.build());
        Map<Integer, RemoteEventRegistration> registrations = new HashMap<Integer, RemoteEventRegistration>();
        registrations.put(1, reg1);
        registrations.put(2, reg2);
        when(m_RemoteEventAdmin.getRemoteEventRegistrations()).thenReturn(registrations);
        when(m_RemoteEventAdmin.getRemoteEventExpirationHours(1)).thenReturn(167L);
        when(m_RemoteEventAdmin.getRemoteEventExpirationHours(2)).thenReturn(5L);
        CommandSession testSession = mock(CommandSession.class);
        PrintStream testStream = mock(PrintStream.class);
        when(testSession.getConsole()).thenReturn(testStream);
        m_SUT.eventRegs(testSession);
        verify(testStream).printf("Registration ID: %d (Expires in %d-%d hours)\n%s", 1,
                (long)RemoteConstants.REMOTE_EVENT_DEFAULT_REG_TIMEOUT_HOURS - 1,
                (long)RemoteConstants.REMOTE_EVENT_DEFAULT_REG_TIMEOUT_HOURS, reg1);
        verify(testStream).printf("Registration ID: %d (Expires in %d-%d hours)\n%s", 2, 5L, 6L, reg2);
    }
@ Test public void testGetEventRegistrations ( ) { int sysId1 = 1 ; int sysId2 = 2 ; EventRegistrationRequestData . Builder request1 = EventRegistrationRequestData . newBuilder ( ) . addTopic ( "TOPIC-A" ) ; request1 = RemoteUtils . appendRequiredFields ( request1 , false ) ; RemoteEventRegistration reg1 = new RemoteEventRegistration ( sysId1 , ( ServiceRegistration < EventHandler > ) null , request1 . build ( ) ) ; EventRegistrationRequestData . Builder request2 = EventRegistrationRequestData . newBuilder ( ) . addTopic ( "TOPIC-B" ) ; request2 = RemoteUtils . appendRequiredFields ( request2 , false ) ; RemoteEventRegistration reg2 = new RemoteEventRegistration ( sysId2 , ( ServiceRegistration < EventHandler > ) null , request2 . build ( ) ) ; Map < Integer , RemoteEventRegistration > registrations = new HashMap < Integer , RemoteEventRegistration > ( ) ; registrations . put ( 1 , reg1 ) ; registrations . put ( 2 , reg2 ) ; when ( m_RemoteEventAdmin . getRemoteEventRegistrations ( ) ) . thenReturn ( registrations ) ; when ( m_RemoteEventAdmin . getRemoteEventExpirationHours ( 1 ) ) . thenReturn ( 167L ) ; when ( m_RemoteEventAdmin . getRemoteEventExpirationHours ( 2 ) ) . thenReturn ( 5L ) ; CommandSession testSession = mock ( CommandSession . class ) ; PrintStream testStream = mock ( PrintStream . class ) ; when ( testSession . getConsole ( ) ) . thenReturn ( testStream ) ; m_SUT . eventRegs ( testSession ) ; verify ( testStream ) . printf ( "Registration ID: %d (Expires in %d-%d hours)\n%s" , 1 , ( long ) RemoteConstants . REMOTE_EVENT_DEFAULT_REG_TIMEOUT_HOURS - 1 , ( long ) RemoteConstants . REMOTE_EVENT_DEFAULT_REG_TIMEOUT_HOURS , reg1 ) ; verify ( testStream ) . printf ( "Registration ID: %d (Expires in %d-%d hours)\n%s" , 2 , 5L , 6L , reg2 ) ; }
Verify the ability to get the registrations known for a particular system Id.
Verify the ability to get the registrations known for a particular system Id .
//system id to use //dummy remote event messages // add required fields // add required fields //map of registrations //behavior