Search in sources :

Example 1 with NamespaceRole

use of org.eclipse.vorto.repository.domain.NamespaceRole 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)

Example 2 with NamespaceRole

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

the class RoleProvider method modelReviewer.

public static NamespaceRole modelReviewer() {
    NamespaceRole model_reviewer = new NamespaceRole();
    model_reviewer.setName("model_reviewer");
    model_reviewer.setPrivileges(3);
    model_reviewer.setRole(8);
    return model_reviewer;
}
Also used : NamespaceRole(org.eclipse.vorto.repository.domain.NamespaceRole)

Example 3 with NamespaceRole

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

the class RoleProvider method modelPublisher.

public static NamespaceRole modelPublisher() {
    NamespaceRole model_publisher = new NamespaceRole();
    model_publisher.setName("model_publisher");
    model_publisher.setPrivileges(3);
    model_publisher.setRole(4);
    return model_publisher;
}
Also used : NamespaceRole(org.eclipse.vorto.repository.domain.NamespaceRole)

Example 4 with NamespaceRole

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

the class RoleProvider method namespaceAdmin.

public static NamespaceRole namespaceAdmin() {
    NamespaceRole namespace_admin = new NamespaceRole();
    namespace_admin.setName("namespace_admin");
    namespace_admin.setPrivileges(7);
    namespace_admin.setRole(32);
    return namespace_admin;
}
Also used : NamespaceRole(org.eclipse.vorto.repository.domain.NamespaceRole)

Example 5 with NamespaceRole

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

the class RoleProvider method modelViewer.

public static NamespaceRole modelViewer() {
    NamespaceRole model_viewer = new NamespaceRole();
    model_viewer.setName("model_viewer");
    model_viewer.setPrivileges(1);
    model_viewer.setRole(1);
    return model_viewer;
}
Also used : NamespaceRole(org.eclipse.vorto.repository.domain.NamespaceRole)

Aggregations

NamespaceRole (org.eclipse.vorto.repository.domain.NamespaceRole)13 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 Privilege (org.eclipse.vorto.repository.domain.Privilege)1 User (org.eclipse.vorto.repository.domain.User)1 Matchers.anyString (org.mockito.Matchers.anyString)1