@Test
public void testUpdateUserNamespaceAuthorization()
{

    // Create a user namespace authorization key
    UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
    UserNamespaceAuthorization userNamespaceAuthorization =
        new UserNamespaceAuthorization(ID, key, Arrays.asList(NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT));
    UserNamespaceAuthorizationUpdateRequest request =
        new UserNamespaceAuthorizationUpdateRequest(Arrays.asList(NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT));
    // Mock calls to external method.
    when(userNamespaceAuthorizationService.updateUserNamespaceAuthorization(key, request)).thenReturn(userNamespaceAuthorization);
    // Update a user namespace authorization.
    UserNamespaceAuthorization resultUserNamespaceAuthorization =
        userNamespaceAuthorizationRestController.updateUserNamespaceAuthorization(key.getUserId(), key.getNamespace(), request);
    // Verify the external calls.
    verify(userNamespaceAuthorizationService).updateUserNamespaceAuthorization(key, request);
    verifyNoMoreInteractions(userNamespaceAuthorizationService);
    // Validate the returned object.
    assertEquals(userNamespaceAuthorization, resultUserNamespaceAuthorization);
}