//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws javax.servlet.ServletException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void setup() { currentEngine = getProcessEngine(engineName); authorizationServiceMock = mock(typeof(AuthorizationServiceImpl)); identityServiceMock = mock(typeof(IdentityServiceImpl)); repositoryServiceMock = mock(typeof(RepositoryService)); when(currentEngine.AuthorizationService).thenReturn(authorizationServiceMock); when(currentEngine.IdentityService).thenReturn(identityServiceMock); // for authentication userMock = MockProvider.createMockUser(); IList <Group> groupMocks = MockProvider.createMockGroups(); groupIds = setupGroupQueryMock(groupMocks); IList <Tenant> tenantMocks = Collections.singletonList(MockProvider.createMockTenant()); tenantIds = setupTenantQueryMock(tenantMocks); GroupQuery mockGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(mockGroupQuery); when(mockGroupQuery.groupMember(anyString())).thenReturn(mockGroupQuery); when(mockGroupQuery.list()).thenReturn(groupMocks); setupFilter(); }
private void createMockIdentityQueries() { UserQuery sampleUserQuery = mock(typeof(UserQuery)); IList <User> mockUsers = new List <User>(); mockUser = MockProvider.createMockUser(); mockUsers.Add(mockUser); when(sampleUserQuery.list()).thenReturn(mockUsers); when(sampleUserQuery.memberOfGroup(anyString())).thenReturn(sampleUserQuery); when(sampleUserQuery.count()).thenReturn((long)mockUsers.Count); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); IList <Group> mockGroups = MockProvider.createMockGroups(); when(sampleGroupQuery.list()).thenReturn(mockGroups); when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery); when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.orderByGroupId()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.orderByGroupType()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.desc()).thenReturn(sampleGroupQuery); when(processEngine.IdentityService.createGroupQuery()).thenReturn(sampleGroupQuery); when(processEngine.IdentityService.createUserQuery()).thenReturn(sampleUserQuery); }
private void createIdentityMocks() { // identity UserQuery sampleUserQuery = mock(typeof(UserQuery)); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); IList <User> mockUsers = new List <User>(); User mockUser = MockProvider.createMockUser(); mockUsers.Add(mockUser); // user query when(sampleUserQuery.memberOfGroup(anyString())).thenReturn(sampleUserQuery); when(sampleUserQuery.list()).thenReturn(mockUsers); // group query IList <Group> mockGroups = MockProvider.createMockGroups(); when(sampleGroupQuery.groupMember(anyString())).thenReturn(sampleGroupQuery); when(sampleGroupQuery.orderByGroupName()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.asc()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.list()).thenReturn(mockGroups); when(mockIdentityService.createGroupQuery()).thenReturn(sampleGroupQuery); when(mockIdentityService.createUserQuery()).thenReturn(sampleUserQuery); }
public virtual GroupInfoDto getGroupInfo(string userId) { if (string.ReferenceEquals(userId, null)) { throw new InvalidRequestException(Response.Status.BAD_REQUEST, "No user id was supplied"); } IdentityService identityService = ProcessEngine.IdentityService; GroupQuery query = identityService.createGroupQuery(); IList <Group> userGroups = query.groupMember(userId).orderByGroupName().asc().list(); ISet <UserDto> allGroupUsers = new HashSet <UserDto>(); IList <GroupDto> allGroups = new List <GroupDto>(); foreach (Group group in userGroups) { IList <User> groupUsers = identityService.createUserQuery().memberOfGroup(group.Id).list(); foreach (User user in groupUsers) { if (!user.Id.Equals(userId)) { allGroupUsers.Add(new UserDto(user.Id, user.FirstName, user.LastName)); } } allGroups.Add(new GroupDto(group.Id, group.Name)); } return(new GroupInfoDto(allGroups, allGroupUsers)); }
protected internal virtual IList <string> setupGroupQueryMock(IList <Group> groups) { GroupQuery mockGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(mockGroupQuery); when(mockGroupQuery.groupMember(anyString())).thenReturn(mockGroupQuery); when(mockGroupQuery.list()).thenReturn(groups); IList <string> groupIds = new List <string>(); foreach (Group groupMock in groups) { groupIds.Add(groupMock.Id); } return(groupIds); }