@Test
public void testCreateUserNamespaceAuthorization()
{

    // Create a user namespace authorization key.
    UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
    UserNamespaceAuthorizationCreateRequest request = new UserNamespaceAuthorizationCreateRequest(key,
        Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.WRITE, NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT));
    UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization(ID, key, SUPPORTED_NAMESPACE_PERMISSIONS);
    // Mock calls to external method.
    when(userNamespaceAuthorizationService.createUserNamespaceAuthorization(request)).thenReturn(userNamespaceAuthorization);
    UserNamespaceAuthorization response = userNamespaceAuthorizationRestController.createUserNamespaceAuthorization(request);
    // Verify the external calls.
    verify(userNamespaceAuthorizationService).createUserNamespaceAuthorization(request);
    verifyNoMoreInteractions(userNamespaceAuthorizationService);
    // Validate the returned object.
    assertEquals(userNamespaceAuthorization, response);
}