title: how to test anonymous class object inside method
body: <p>I'm writing unit cases using testNg and Mockito.The problem, I'm facing is with the method given below:</p>
  
  <pre><code>public void publishRequest(final NotificationRequest request){
  
      MessageCreator messageCreator = new MessageCreator() {
  
          @Override
          public Message createMessage(Session session) throws JMSException {
              if (logger.isDebugEnabled()) {
                  logger.debug("Start of MessagePublisher publishRequest");
              }
              ObjectMessage msg = session.createObjectMessage();
  
              msg.setStringProperty(
                      "SELECTOR",
                      request.getAvailaibilityTier() + "-"
                              + request.getEsbReference());
  
              if (logger.isDebugEnabled()) {
              logger.debug("Message Selector=&gt;"+msg.getStringProperty("SELECTOR"));
              }
  
              msg.setStringProperty(NotificationConstants.CACHE_KEY.name(),
                      request.getId());
  
              msg.setObject(request.getData());
              if (logger.isDebugEnabled()) {
                  logger.debug("Publishing request --&gt;" + request);
              }
  
              if (logger.isDebugEnabled()) {
                  logger.debug("End of MessagePublisher publishRequest");
              }
              return msg;
          }
      };
      producerTemplate.send(messageCreator);
  }
  </code></pre>
  
  <p>While writing the unit case createMessage() method is not being called even if my test case creates the MessageCreater object. I want to include that also in my unit case to get the better coverage. Any Idea how to test inner class method?</p>