title: Testing methods using JUnit
body: <p>I am new to JUnit and I have to test a method using JUnit api. One method internall calls another. My test case goes inside the method but while catchign the exception it fails. </p>
  
  <p>Method under test is</p>
  
  <pre><code>public void checkANDCondition( Map&lt;String, Message&gt; messagesMap ) throws EISClientException
  {
      List&lt;String&gt; codes = getMessageCodes();
      if(isAllReturnedMessagesContainCodes(codes, messagesMap))
      {
          StringBuffer buff = new StringBuffer("All of the specified message codes matched returned errors.");
          for(String code: codes )
          {
              Message message = messagesMap.get(code);
              buff.append(message.getMessageCode() + ": " + message.getMessageType() + ": " + message.getMessageText() + " ");
          }
          throw new EISClientException(buff.toString());
      }
  }
  
  public boolean isAllReturnedMessagesContainCodes(List&lt;String&gt; codes, Map&lt;String, Message&gt; messagesMap)
  {
      if(codes!=null)
      {
          for(String code: codes)
          {
              if(!messagesMap.containsKey(code))
              {
                  return false;
              }
          }
      }
      return true;
  }
  </code></pre>
  
  <p>What I have done so far is</p>
  
  <pre><code>@Test
  public void testPostProcess() throws Exception {
      clientResponse = mock(ClientResponse.class);
  
      MessageToExceptionPostProcessFilter postProcessFilter = new MessageToExceptionPostProcessFilter();
      RetrieveBillingServiceResponse serviceResponse = new RetrieveBillingServiceResponse();caughtException = false;
      try {
          postProcessFilter.setCondition(ConditionOperator.AND);
  
          List&lt;String&gt; messagesCodes = new ArrayList&lt;String&gt;();
          messagesCodes.add("200");
          messagesCodes.add("400");
  
          Message message = new Message();
          message.setMessageCode("200");
          message.setMessageType(MessageTypeEnum.MESSAGE_TYPE_INFO);
          message.setMessageText("Service completed successfully");
  
          serviceResponse.setMessages(Arrays.asList(message));
          postProcessFilter.setMessageCodes(messagesCodes);
  
          serviceResponse = postProcessFilter.postProcess(serviceResponse, clientResponse);
  
          assertNotNull(serviceResponse.getMessages());
  
      } catch (EISClientException ex) {
          caughtException = true;
          assertEquals("All of the specified message codes matched returned errors.", ex.getMessage());
      }
      assertTrue(caughtException);
  </code></pre>
  
  <p>}</p>
  
  <p>How can I make it pass?</p>
  
  <p>Thanks</p>