Search in sources :

Example 1 with Privilege

use of org.eclipse.vorto.repository.domain.Privilege in project vorto by eclipse.

the class SearchTestInfrastructure method setupNamespaceMocking.

private void setupNamespaceMocking() throws OperationForbiddenException, DoesNotExistException {
    when(namespaceService.resolveWorkspaceIdForNamespace(anyString())).thenReturn(Optional.of("playground"));
    when(namespaceService.findNamespaceByWorkspaceId(anyString())).thenReturn(mockNamespace());
    when(namespaceRepository.findAll()).thenReturn(Arrays.asList(mockNamespace()));
    when(userNamespaceRoleService.hasRole(anyString(), any(), any())).thenReturn(true);
    when(userNamespaceRoleService.getNamespaces(anyString(), anyString())).thenReturn(Arrays.asList(mockNamespace()));
    List<String> workspaceIds = new ArrayList<>();
    workspaceIds.add("playground");
    when(namespaceService.findAllWorkspaceIds()).thenReturn(workspaceIds);
    NamespaceRole role = new NamespaceRole();
    role.setName("namespace_admin");
    role.setPrivileges(7);
    role.setRole(32);
    Set<IRole> roles = new HashSet<>();
    roles.add(role);
    when(userNamespaceRoleService.getRoles(anyString(), anyString())).thenReturn(roles);
    when(userNamespaceRoleService.getRoles(any(User.class), any(Namespace.class))).thenReturn(roles);
    Set<Privilege> privileges = new HashSet<>(Arrays.asList(Privilege.DEFAULT_PRIVILEGES));
    when(privilegeService.getPrivileges(anyLong())).thenReturn(privileges);
}
Also used : User(org.eclipse.vorto.repository.domain.User) IRole(org.eclipse.vorto.repository.domain.IRole) ArrayList(java.util.ArrayList) NamespaceRole(org.eclipse.vorto.repository.domain.NamespaceRole) Matchers.anyString(org.mockito.Matchers.anyString) Privilege(org.eclipse.vorto.repository.domain.Privilege) Namespace(org.eclipse.vorto.repository.domain.Namespace) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IRole (org.eclipse.vorto.repository.domain.IRole)1 Namespace (org.eclipse.vorto.repository.domain.Namespace)1 NamespaceRole (org.eclipse.vorto.repository.domain.NamespaceRole)1 Privilege (org.eclipse.vorto.repository.domain.Privilege)1 User (org.eclipse.vorto.repository.domain.User)1 Matchers.anyString (org.mockito.Matchers.anyString)1