private void testMethod_bodyParseException(ServiceTestInvocation testMethod) throws Exception {
    addExpectForInitialRequest(testMethod);

    Capture<Result> resultCapture = EasyMock.newCapture();
    BodyParseException e = new BodyParseException("TEST MSG");
    expect(bodyParser.parse(testMethod.getBody())).andThrow(e);
    expect(serializer.serialize(capture(resultCapture))).andReturn(serializedResult);

    replayMocks();

    Response r = testMethod.invoke();

    assertEquals(serializedResult, r.getEntity());
    assertEquals(400, r.getStatus());
    //todo: assert resource state
    verifyAndResetMocks();
  }
Base class for service unit tests.
ambari-server/src/test/java/org/apache/ambari/server/api/services/BaseServiceTest.java