final String PAGE_NAME = "My New Page";
final String PAGE_LAYOUT_CODE = "layout1";
expect(pageService.addNewPage(PAGE_NAME, PAGE_LAYOUT_CODE)).andThrow(new IllegalArgumentException(PARAM_ERROR_MESSAGE));
replay(pageService);
RpcResult result = pageApi.addPage(PAGE_NAME, PAGE_LAYOUT_CODE);
verify(pageService);
assertThat(result, is(notNullValue()));
assertThat(result.getResult(), is(nullValue()));
assertThat(result.isError(), is(true));
assertThat(result.getErrorCode(), is(RpcResult.ErrorCode.INVALID_PARAMS));
assertThat(result.getErrorMessage(), is(equalTo(PARAM_ERROR_MESSAGE)));
}