Exemple #1
0
        public virtual void testQuerySorting()
        {
            // asc
            assertEquals(4, identityService.createGroupQuery().orderByGroupId().asc().count());
            assertEquals(4, identityService.createGroupQuery().orderByGroupName().asc().count());
            assertEquals(4, identityService.createGroupQuery().orderByGroupType().asc().count());

            // desc
            assertEquals(4, identityService.createGroupQuery().orderByGroupId().desc().count());
            assertEquals(4, identityService.createGroupQuery().orderByGroupName().desc().count());
            assertEquals(4, identityService.createGroupQuery().orderByGroupType().desc().count());

            // Multiple sortings
            GroupQuery    query  = identityService.createGroupQuery().orderByGroupType().asc().orderByGroupName().desc();
            IList <Group> groups = query.list();

            assertEquals(4, query.count());

            assertEquals("security", groups[0].Type);
            assertEquals("user", groups[1].Type);
            assertEquals("user", groups[2].Type);
            assertEquals("user", groups[3].Type);

            assertEquals("admin", groups[0].Id);
            assertEquals("muppets", groups[1].Id);
            assertEquals("mammals", groups[2].Id);
            assertEquals("frogs", groups[3].Id);
        }
Exemple #2
0
//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();
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        private GroupQuery setUpMockGroupQuery(IList <Group> list)
        {
            GroupQuery sampleGroupQuery = mock(typeof(GroupQuery));

            when(sampleGroupQuery.list()).thenReturn(list);
            when(sampleGroupQuery.count()).thenReturn((long)list.Count);

            when(processEngine.IdentityService.createGroupQuery()).thenReturn(sampleGroupQuery);

            return(sampleGroupQuery);
        }
Exemple #6
0
        public virtual void testQueryByMember()
        {
            GroupQuery query = identityService.createGroupQuery().groupMember("fozzie");

            verifyQueryResults(query, 2);

            query = identityService.createGroupQuery().groupMember("kermit");
            verifyQueryResults(query, 3);

            query = query.orderByGroupId().asc();
            IList <Group> groups = query.list();

            assertEquals(3, groups.Count);
            assertEquals("admin", groups[0].Id);
            assertEquals("frogs", groups[1].Id);
            assertEquals("muppets", groups[2].Id);

            query  = query.groupType("user");
            groups = query.list();
            assertEquals(2, groups.Count);
            assertEquals("frogs", groups[0].Id);
            assertEquals("muppets", groups[1].Id);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        public virtual IList <GroupDto> queryGroups(GroupQueryDto queryDto, int?firstResult, int?maxResults)
        {
            queryDto.ObjectMapper = ObjectMapper;
            GroupQuery query = queryDto.toQuery(ProcessEngine);

            IList <Group> resultList;

            if (firstResult != null || maxResults != null)
            {
                resultList = executePaginatedQuery(query, firstResult, maxResults);
            }
            else
            {
                resultList = query.list();
            }

            return(GroupDto.fromGroupList(resultList));
        }
Exemple #9
0
        private void verifyQueryResults(GroupQuery query, int countExpected)
        {
            assertEquals(countExpected, query.list().size());
            assertEquals(countExpected, query.count());

            if (countExpected == 1)
            {
                assertNotNull(query.singleResult());
            }
            else if (countExpected > 1)
            {
                verifySingleResultFails(query);
            }
            else if (countExpected == 0)
            {
                assertNull(query.singleResult());
            }
        }