CoreComponentRegistry mockRegistry = Mockito.mock(CoreComponentRegistry.class);
PolicyManager mockPolicyManager = Mockito.mock(PolicyManager.class);
Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockRegistry);
Mockito.when(mockRegistry.getViewInfos(Mockito.anyString(), Mockito.same(type))).thenReturn(viewInfos);
Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
Mockito.when(mockPolicyManager.execute(Mockito.matches(PolicyInfo.CategoryType.FILTER_VIEW_ROLE.getKey()), Mockito.any(PolicyContext.class))).thenAnswer(
new Answer() {
public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments();
PolicyContext pc = (PolicyContext) args[1];
ViewInfo vi = pc.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);