Package org.eurekastreams.server.search.modelview

Examples of org.eurekastreams.server.search.modelview.PersonModelView


    public void setup()
    {
        results = new ArrayList<ModelView>();
        result1 = new DomainGroupModelView();
        result1.setSearchIndexExplanationString(result1Explanation);
        result2 = new PersonModelView();
        result2.setSearchIndexExplanationString(result2Explanation);
        results.add(result1);
        results.add(result2);
    }
View Full Code Here


     * Tests execute.
     */
    @Test
    public void testExecuteAsSystemAdmin()
    {
        final PersonModelView retPerson = new PersonModelView();
        retPerson.setEntityId(PERSON_ID);

        final Date personLastAcceptedTOSDate = new Date();
        retPerson.setLastAcceptedTermsOfService(personLastAcceptedTOSDate);

        context.checking(new Expectations()
        {
            {
                allowing(authentication).getPrincipal();
                will(returnValue(null));

                allowing(getPersonModelViewByAccountIdMapper).execute(ACCOUNT_ID);
                will(returnValue(retPerson));

                allowing(toSAcceptanceStrategy).isValidTermsOfServiceAcceptanceDate(with(personLastAcceptedTOSDate));
                will(returnValue(true));

                allowing(systemAdminIdsMapper).execute(null);
                will(returnValue(Collections.singletonList(PERSON_ID)));
            }
        });

        PrincipalActionContext actionContext = TestContextCreator.createPrincipalActionContext(null, ACCOUNT_ID, 0);

        PersonModelView result = (PersonModelView) sut.execute(actionContext);

        context.assertIsSatisfied();

        assertTrue(result.getRoles().contains(Role.SYSTEM_ADMIN));
        assertTrue(result.getTosAcceptance());
        assertEquals(AuthenticationType.NOTSET, result.getAuthenticationType());
    }
View Full Code Here

     * Tests execute.
     */
    @Test
    public void testExecuteNotSystemAdmin()
    {
        final PersonModelView retPerson = new PersonModelView();
        retPerson.setEntityId(PERSON_ID);

        final Date personLastAcceptedTOSDate = new Date();
        retPerson.setLastAcceptedTermsOfService(personLastAcceptedTOSDate);

        context.checking(new Expectations()
        {
            {
                allowing(authentication).getPrincipal();
                will(returnValue(null));

                allowing(getPersonModelViewByAccountIdMapper).execute(ACCOUNT_ID);
                will(returnValue(retPerson));

                allowing(toSAcceptanceStrategy).isValidTermsOfServiceAcceptanceDate(with(personLastAcceptedTOSDate));
                will(returnValue(true));

                allowing(systemAdminIdsMapper).execute(null);
                will(returnValue(Collections.singletonList(9L)));
            }
        });

        PrincipalActionContext actionContext = TestContextCreator.createPrincipalActionContext(null, ACCOUNT_ID, 0);

        PersonModelView result = (PersonModelView) sut.execute(actionContext);

        context.assertIsSatisfied();

        assertFalse(result.getRoles().contains(Role.SYSTEM_ADMIN));
        assertTrue(result.getTosAcceptance());
        assertEquals(AuthenticationType.NOTSET, result.getAuthenticationType());
    }
View Full Code Here

     * @param expectedAuthType
     *            Expected auth type.
     */
    private void coreAuthTest(final Object principal, final AuthenticationType expectedAuthType)
    {
        final PersonModelView retPerson = new PersonModelView();
        retPerson.setEntityId(PERSON_ID);

        final Date personLastAcceptedTOSDate = new Date();
        retPerson.setLastAcceptedTermsOfService(personLastAcceptedTOSDate);

        context.checking(new Expectations()
        {
            {
                allowing(authentication).getPrincipal();
                will(returnValue(principal));

                allowing(getPersonModelViewByAccountIdMapper).execute(ACCOUNT_ID);
                will(returnValue(retPerson));

                allowing(toSAcceptanceStrategy).isValidTermsOfServiceAcceptanceDate(with(personLastAcceptedTOSDate));
                will(returnValue(true));

                allowing(systemAdminIdsMapper).execute(null);
                will(returnValue(Collections.EMPTY_LIST));
            }
        });

        PrincipalActionContext actionContext = TestContextCreator.createPrincipalActionContext(null, ACCOUNT_ID, 0);

        PersonModelView result = (PersonModelView) sut.execute(actionContext);

        context.assertIsSatisfied();

        assertEquals(expectedAuthType, result.getAuthenticationType());
    }
View Full Code Here

        transDef.setName("TokenAddressMessageAuthenticator");
        transDef.setReadOnly(false);
        TransactionStatus transStatus = transactionMgr.getTransaction(transDef);
        byte[] key;
        Long personId;
        PersonModelView person;
        try
        {
            personId = personIdByEmailDao.execute(fromAddress);
            key = userKeyByIdDao.execute(personId);
            person = personDao.execute(personId);
View Full Code Here

        queueRequests.add(new UserActionRequest("postActivityAsyncAction", null, new PostActivityRequest(
                persistedActivityDTO)));

        inActionContext.getUserActionRequests().addAll(queueRequests);

        PersonModelView person = getPersonModelViewByAccountIdMapper.execute(actorAccountName);

        // execute filter strategies.
        for (ActivityFilter filter : filters)
        {
            filter.filter(Collections.singletonList(persistedActivityDTO), person);
View Full Code Here

            results.remove(currentMax);
        }

        final List<ActivityDTO> dtoResults = bulkActivitiesMapper.execute(results);

        PersonModelView person = getPersonModelViewByAccountIdMapper.execute(userAccountId);

        // execute filter strategies.
        for (ActivityFilter filter : filters)
        {
            filter.filter(dtoResults, person);
View Full Code Here

     *
     * @return Person.
     */
    private PersonModelView expectPersonStream()
    {
        final PersonModelView person = mockery.mock(PersonModelView.class);
        mockery.checking(new Expectations()
        {
            {
                allowing(stream).getType();
                will(returnValue(EntityType.PERSON));
View Full Code Here

     *            Use SUT's strict checking (must be true for ALL users).
     * @return Result of SUT.
     */
    private boolean corePersonStreamInGeneralPostTest(final boolean streamAllowsAction, final boolean strict)
    {
        final PersonModelView person = expectPersonStream();
        mockery.checking(new Expectations()
        {
            {
                allowing(person).isStreamPostable();
                will(returnValue(streamAllowsAction));
View Full Code Here

     *            If the stream should allow posting.
     * @return Result of SUT.
     */
    private boolean corePersonStreamPostTest(final long testUser, final boolean streamAllowsAction)
    {
        final PersonModelView person = expectPersonStream();
        mockery.checking(new Expectations()
        {
            {
                allowing(person).isStreamPostable();
                will(returnValue(streamAllowsAction));
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.search.modelview.PersonModelView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.