Example usage for org.apache.hadoop.hdfs.server.namenode INode getUserName

List of usage examples for org.apache.hadoop.hdfs.server.namenode INode getUserName

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.namenode INode getUserName.

Prototype

@Override
public final String getUserName() 

Source Link

Document

The same as getUserName(Snapshot.CURRENT_STATE_ID).

Usage

From source file:org.apache.ranger.services.hdfs.RangerHdfsAuthorizerTest.java

License:Apache License

private static INode createNode(String[] pathSegments, int i, String owner, String group, boolean file) {
    String fullPath = StringUtils.join(pathSegments, '/', 0, i + 1);
    String name = pathSegments[i];
    INode mock = Mockito.mock(INode.class);
    try {/* w ww  . ja  v  a 2s  .  co  m*/
        when(mock.getLocalNameBytes()).thenReturn(name.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    when(mock.getUserName()).thenReturn(owner);
    when(mock.getGroupName()).thenReturn(group);
    when(mock.getFullPathName()).thenReturn(fullPath);
    when(mock.isFile()).thenReturn(file);
    when(mock.isDirectory()).thenReturn(!file);
    when(mock.toString()).thenReturn(name);
    return mock;
}