@Test public void testProcessMessage_withNazgul() { NazgulMessageProcessor nazgul = Mockito.mock( NazgulMessageProcessor.class ); SauronAgent sauron = new SauronAgent(); Message msg = new MsgEcho( "ko" ); SauronMessageProcessor.THE_SINGLE_MQ.put( msg, nazgul ); SauronMessageProcessor processor = new SauronMessageProcessor( sauron ); processor.processMessage( msg ); Mockito.verify( nazgul, Mockito.times( 1 )).processMessageForReal( msg ); Mockito.verify( nazgul, Mockito.times( 1 )).getAgentId(); Mockito.verifyNoMoreInteractions( nazgul ); }
@Override protected void processMessage( Message message ) { NazgulMessageProcessor nazgul = THE_SINGLE_MQ.get( message ); if( nazgul == null ) { this.logger.warning( "No Nazgul was found for message " + message.getClass().getSimpleName() + ". Message is dropped." ); } else { this.logger.finer( "Delegating message " + message.getClass().getSimpleName() + " to Nazgul " + nazgul.getAgentId()); nazgul.processMessageForReal( message ); } }
SauronMessageProcessor extends AgentMessageProcessor { @Override protected void processMessage( Message message ) { NazgulMessageProcessor nazgul = THE_SINGLE_MQ.get( message ); if( nazgul == null ) { this.logger.warning( "No Nazgul was found for message " + message.getClass().getSimpleName() + ". Message is dropped." ); } else { this.logger.finer( "Delegating message " + message.getClass().getSimpleName() + " to Nazgul " + nazgul.getAgentId()); nazgul.processMessageForReal( message ); } } }
SauronMessageProcessor extends AgentMessageProcessor { @Override protected void processMessage( Message message ) { NazgulMessageProcessor nazgul = THE_SINGLE_MQ.get( message ); if( nazgul == null ) { this.logger.warning( "No Nazgul was found for message " + message.getClass().getSimpleName() + ". Message is dropped." ); } else { this.logger.finer( "Delegating message " + message.getClass().getSimpleName() + " to Nazgul " + nazgul.getAgentId()); nazgul.processMessageForReal( message ); } } SauronMessageProcessor( SauronAgent sauronAgent ); }
SauronMessageProcessor extends AgentMessageProcessor { @Override protected void processMessage( Message message ) { NazgulMessageProcessor nazgul = THE_SINGLE_MQ.get( message ); if( nazgul == null ) { this.logger.warning( "No Nazgul was found for message " + message.getClass().getSimpleName() + ". Message is dropped." ); } else { this.logger.finer( "Delegating message " + message.getClass().getSimpleName() + " to Nazgul " + nazgul.getAgentId()); nazgul.processMessageForReal( message ); } } SauronMessageProcessor( SauronAgent sauronAgent );  }
SauronMessageProcessor extends AgentMessageProcessor { @Override protected void processMessage( Message message ) { NazgulMessageProcessor nazgul = THE_SINGLE_MQ.get( message ); if( nazgul == null ) { this.logger.warning( "No Nazgul was found for message " + message.getClass().getSimpleName() + ". Message is dropped." ); } else { this.logger.finer( "Delegating message " + message.getClass().getSimpleName() + " to Nazgul " + nazgul.getAgentId()); nazgul.processMessageForReal( message ); } } SauronMessageProcessor( SauronAgent sauronAgent );   }