use of org.apache.kylin.metadata.project.ProjectManager in project ranger by apache.
the class RangerKylinAuthorizerTest method mockKylinProjects.
/**
* Help function: mock kylin projects, to match projectUuid and projectName
*/
private static void mockKylinProjects() {
KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
ProjectManager projectManager = mock(ProjectManager.class);
@SuppressWarnings({ "rawtypes", "unchecked" }) Map<Class, Object> managersCache = (Map<Class, Object>) ReflectionTestUtils.getField(kylinConfig, "managersCache");
managersCache.put(ProjectManager.class, projectManager);
Answer<ProjectInstance> answer = new Answer<ProjectInstance>() {
@Override
public ProjectInstance answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
if (args == null || args.length == 0) {
return null;
}
String uuid = (String) args[0];
return uuid2Projects.get(uuid);
}
};
when(projectManager.getPrjByUuid(anyString())).thenAnswer(answer);
}
Aggregations