コード例 #1
0
  /** Test the failure path for authorization. */
  @Test(expected = AuthorizationException.class)
  public void testAuthorizeFailBadStreamView() {
    context.checking(
        new Expectations() {
          {
            oneOf(principalMock).getId();
            will(returnValue(1L));

            oneOf(findUserStreamViewByIdMock)
                .execute(with(any(FindUserStreamFilterByIdRequest.class)));
            will(throwException(new NoResultException()));
          }
        });

    ServiceActionContext currentContext = new ServiceActionContext(fields, principalMock);
    sut.authorize(currentContext);

    context.assertIsSatisfied();
  }
コード例 #2
0
  /** Test the successful path for authorization. */
  @Test
  public void testAuthorize() {
    context.checking(
        new Expectations() {
          {
            oneOf(principalMock).getId();
            will(returnValue(1L));

            oneOf(findUserStreamViewByIdMock)
                .execute(with(any(FindUserStreamFilterByIdRequest.class)));
            will(returnValue(streamViewMock));

            oneOf(streamViewMock).getType();
            will(returnValue(null));
          }
        });

    ServiceActionContext currentContext = new ServiceActionContext(fields, principalMock);
    sut.authorize(currentContext);

    context.assertIsSatisfied();
  }