// for Expect and Return expect scenario
 public String getFileName(String name, String type) throws RuntimeException {
   if (name == null || name.equalsIgnoreCase(""))
     throw new RuntimeException("null or empty name");
   if (type.equalsIgnoreCase(XML_TYPE)) return xmlNameGenerator.generateFileName(name);
   if (type.equalsIgnoreCase(HTML_TYPE)) return htmlNameGenerator.generateFileName(name);
   return name + ".txt";
 }
  // Expect and Answer
  @Test
  public void testPerformAndTrackDiagnostic() {
    // xml
    IAnswer xmlPerformAndTrackDiagnostic =
        new IAnswer() {
          public Integer answer() throws Throwable {
            numberOfXmlDiagnosticPerformed++;
            return numberOfXmlDiagnosticPerformed;
          }
        };
    EasyMock.expect(xmlNameGeneratorMock.performAndTrackDiagnostic())
        .andAnswer(xmlPerformAndTrackDiagnostic);

    // html
    IAnswer htmlPerformAndTrackDiagnostic =
        new IAnswer() {
          public Integer answer() throws Throwable {
            numberOfHtmlDiagnosticPerformed++;
            return numberOfHtmlDiagnosticPerformed;
          }
        };
    EasyMock.expect(htmlNameGeneratorMock.performAndTrackDiagnostic())
        .andAnswer(htmlPerformAndTrackDiagnostic);

    // into replay mode
    EasyMock.replay(this.xmlNameGeneratorMock);
    EasyMock.replay(this.htmlNameGeneratorMock);

    // run the method
    int expectedXmlPerformAndTrackDiagnostic = 1;
    int actualXmlPerformAndTrackDiagnostic = this.nameGenerator.xmlPerformAndTrackDiagnostic();
    Assert.assertEquals(expectedXmlPerformAndTrackDiagnostic, actualXmlPerformAndTrackDiagnostic);

    int expectedHtmlPerformAndTrackDiagnostic = 1;
    int actualHtmlPerformAndTrackDiagnostic = this.nameGenerator.htmlPerformAndTrackDiagnostic();
    Assert.assertEquals(expectedHtmlPerformAndTrackDiagnostic, actualHtmlPerformAndTrackDiagnostic);

    // Verify behavior.
    EasyMock.verify(this.xmlNameGeneratorMock);
    EasyMock.verify(this.htmlNameGeneratorMock);
  }
 public int xmlPerformAndTrackDiagnostic() {
   return xmlNameGenerator.performAndTrackDiagnostic();
 }
 // for Expect and Nothing expect scenario
 public void checkStatus() {
   xmlNameGenerator.performDiagnostic();
   htmlNameGenerator.performDiagnostic();
 }