Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.DomainGroup


        final List<Long> admins = new ArrayList<Long>();
        admins.add(coord1id);
        admins.add(coord2id);

        final DomainGroup group = new DomainGroup();
        group.setName(groupName);

        final DomainMapper<Serializable, List<Long>> systemAdminIdsMapper = context.mock(DomainMapper.class,
                "SystemAdminIdsMapper");

        // expectations
View Full Code Here


    {
        final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
        final long id = 1L;
        final Person testPerson = new Person();
        formData.put(DomainGroupModelView.ID_KEY, Long.toString(id));
        final DomainGroup expectedGroup = new DomainGroup("newOrg", "newOrg", testPerson);

        final String accessingUser = "jschmoe";
        expectedGroup.addCoordinator(new Person(accessingUser, "b", "c", "d", "e"));

        context.checking(new Expectations()
        {
            {
                oneOf(groupMapperMock).findById(with(any(Long.class)));
                will(returnValue(expectedGroup));

                oneOf(activityStreamSearchClearer).execute(with(any(Long.class)));
            }
        });

        DomainGroup returnedGroup = sut.get(taskHandlerActionContext, formData);
        context.assertIsSatisfied();
        assertEquals(expectedGroup, returnedGroup);
    }
View Full Code Here

     *             not expected
     */
    @Test
    public void persistSuccessWithNoGroupNameUpdate() throws Exception
    {
        final DomainGroup group = new DomainGroup("Group Name", "shortName", new Person("id", "Homer", "Jay",
                "Simpson", "Homey"));

        final List<Person> attribMembers = new ArrayList<Person>();
        attribMembers.add(new Person("id", "Homer", "Jay", "Simpson", "Homey"));
        attribMembers.add(new Person("id", "Max", "X", "Power", "Homer"));

        group.setCoordinators(new HashSet(attribMembers));

        final long id = 1L;
        String newName = "NEW group name here";

        final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
        formData.put(DomainGroupModelView.ID_KEY, Long.toString(id));
        formData.put(DomainGroupModelView.NAME_KEY, newName);
        formData.put(DomainGroupModelView.KEYWORDS_KEY, "good,idea");
        formData.put("__KEY_ORIGINAL_GROUP_NAME_KEY", "Group Name");
        formData.put("__KEY_ORIGINAL_GROUP_COORDINATORS_KEY", (Serializable) group.getCoordinators());

        context.checking(new Expectations()
        {
            {
                oneOf(groupMapperMock).flush();

                // TODO: consider making a fake so we can make sure the right
                // action was called
                // oneOf(taskHandler).handleTask(with(any(UserActionRequest.class)));
            }
        });

        sut.persist(taskHandlerActionContext, formData, group);
        context.assertIsSatisfied();
        assertEquals("Group Name", group.getName());

        // TODO Could be more thorough - a list compare utility would help
        assertEquals(2, group.getCapabilities().size());

        // make sure the only queued task is the domain group cache update
        assertEquals(1, taskHandlerActionContext.getUserActionRequests().size());
        assertEquals("domainGroupCacheUpdaterAsyncAction", taskHandlerActionContext.getUserActionRequests().get(0)
                .getActionKey());
View Full Code Here

     */
    @SuppressWarnings("deprecation")
    @Test
    public void persistSuccessWithOrgUpdate() throws Exception
    {
        final DomainGroup group = new DomainGroup("Group Name", "shortName", new Person("id", "Homer", "Jay",
                "Simpson", "Homey"));

        final List<Person> attribMembers = new ArrayList<Person>();
        attribMembers.add(new Person("id", "Homer", "Jay", "Simpson", "Homey"));
        attribMembers.add(new Person("id", "Max", "X", "Power", "Homer"));

        group.setCoordinators(new HashSet(attribMembers));

        final long id = 1L;
        String newName = "NEW name here";

        final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
        formData.put(DomainGroupModelView.ID_KEY, Long.toString(id));
        formData.put(DomainGroupModelView.NAME_KEY, newName);
        formData.put(DomainGroupModelView.KEYWORDS_KEY, "good,idea");
        formData.put("__KEY_ORIGINAL_GROUP_NAME_KEY", "Group Name");
        formData.put("__KEY_ORIGINAL_GROUP_COORDINATORS_KEY", (Serializable) group.getCoordinators());

        context.checking(new Expectations()
        {
            {
                oneOf(groupMapperMock).flush();
            }
        });

        sut.persist(taskHandlerActionContext, formData, group);
        context.assertIsSatisfied();
        assertEquals("Group Name", group.getName());

        // TODO Could be more thorough - a list compare utility would help
        assertEquals(2, group.getCapabilities().size());

        // make sure the only queued task is the domain group cache update
        assertEquals(1, taskHandlerActionContext.getUserActionRequests().size());
    }
View Full Code Here

     *             not expected
     */
    @Test
    public void persistSuccessWithUpdatedGroupName() throws Exception
    {
        final DomainGroup newGroup = new DomainGroup("Group Name", "shortName", new Person("id", "Homer", "Jay",
                "Simpson", "Homey"));

        final List<Person> attribMembers = new ArrayList<Person>();
        attribMembers.add(new Person("id", "Homer", "Jay", "Simpson", "Homey"));
        attribMembers.add(new Person("id", "Max", "X", "Power", "Homer"));

        newGroup.setCoordinators(new HashSet(attribMembers));

        final long id = 1L;
        String newName = "NEW group name here";

        final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
        formData.put(DomainGroupModelView.ID_KEY, Long.toString(id));
        formData.put(DomainGroupModelView.NAME_KEY, newName);
        formData.put(DomainGroupModelView.KEYWORDS_KEY, "good,idea");
        formData.put("__KEY_ORIGINAL_GROUP_NAME_KEY", "Group Name Musta Changed");
        formData.put("__KEY_ORIGINAL_GROUP_COORDINATORS_KEY", (Serializable) newGroup.getCoordinators());

        context.checking(new Expectations()
        {
            {

                oneOf(groupMapperMock).flush();

                // TODO: consider making a fake so we can make sure the right
                // action was called
                // oneOf(taskHandler).handleTask(with(any(UserActionRequest.class)));
            }
        });

        sut.persist(taskHandlerActionContext, formData, newGroup);
        context.assertIsSatisfied();
        assertEquals("Group Name", newGroup.getName());

        // TODO Could be more thorough - a list compare utility would help
        assertEquals(2, newGroup.getCapabilities().size());

        // make sure two queued tasks are queued - the domain group cache update task, and the activity update for all
        // activities posted to this group
        assertEquals(2, taskHandlerActionContext.getUserActionRequests().size());
        assertEquals("domainGroupCacheUpdaterAsyncAction", taskHandlerActionContext.getUserActionRequests().get(0)
View Full Code Here

     *             not expected
     */
    @Test
    public void persistSuccessWithNewCoordinators() throws Exception
    {
        final DomainGroup group = new DomainGroup("Group Name", "shortName", new Person("id1", "Homer", "Jay",
                "Simpson", "Homey"));

        final Set<Person> attribMembers = new HashSet<Person>();
        attribMembers.add(new Person("id1", "Homer", "Jay", "Simpson", "Homey"));
        attribMembers.add(new Person("id2", "Max", "X", "Power", "Homer"));

        group.setCoordinators(new HashSet(attribMembers));

        group.getCoordinators().add(new Person("id3", "A", "New", "Member", "Guy"));

        final long id = 1L;
        String newName = "NEW group name here";

        final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
        formData.put(DomainGroupModelView.ID_KEY, Long.toString(id));
        formData.put(DomainGroupModelView.NAME_KEY, newName);
        formData.put(DomainGroupModelView.KEYWORDS_KEY, "good,idea");
        formData.put(DomainGroupModelView.COORDINATORS_KEY, (Serializable) group.getCoordinators());
        formData.put("__KEY_ORIGINAL_GROUP_NAME_KEY", "Group Name");
        formData.put("__KEY_ORIGINAL_GROUP_COORDINATORS_KEY", (Serializable) attribMembers);

        context.checking(new Expectations()
        {
            {
                ignoring(taskHandlerActionContext);
                allowing(taskHandlerActionContext).getActionContext();
                will(returnValue(actionContext));

                ignoring(actionContext);
                allowing(actionContext).getPrincipal();
                will(returnValue(userPrincipal));

                ignoring(userPrincipal);

                oneOf(groupMapperMock).flush();

                oneOf(followStrategyMock).execute(with(any(TaskHandlerActionContext.class)));

                // TODO: consider making a fake so we can make sure the right
                // action was called
                // oneOf(taskHandler).handleTask(with(any(UserActionRequest.class)));
            }
        });

        sut.persist(taskHandlerActionContext, formData, group);
        context.assertIsSatisfied();
        assertEquals("Group Name", group.getName());

        // TODO Could be more thorough - a list compare utility would help
        assertEquals(2, group.getCapabilities().size());

        // make sure the only queued task is the domain group cache update
        assertEquals(1, taskHandlerActionContext.getUserActionRequests().size());
        assertEquals("domainGroupCacheUpdaterAsyncAction", taskHandlerActionContext.getUserActionRequests().get(0)
                .getActionKey());
View Full Code Here

    public final void testUpdateSet() throws Exception
    {

        String message = "sets should be set appropriately";

        final DomainGroup group = new DomainGroup();
        final Person person = new Person("jschmoe", "Joe", "X", "Schmoe", "Joey");
        person.setEmail("joe@schmoe.com");
        person.setWorkPhone("1234567890");
        person.setTitle("Better than you!");
        person.setJobDescription("ahhh, snuts!");

        HashSet<Person> coords = new HashSet<Person>();
        coords.add(person);

        HashMap<String, Serializable> map = new HashMap<String, Serializable>();
        map.put("coordinators", coords);

        ReflectiveUpdater reflector = new ReflectiveUpdater();
        reflector.setProperties(group, map);

        assertEquals(message, coords, group.getCoordinators());

    }
View Full Code Here

     */
    @Test(expected = IllegalStateException.class)
    public void testObjectToStringOnNullMapper()
    {
        DomainGroupPeopleIdClassBridge.setDomainGroupMapper(null);
        sut.objectToString(new DomainGroup());
    }
View Full Code Here

     * Test add follower.
     */
    @Test
    public void testAddFollower()
    {
        DomainGroup group = jpaGroupMapper.findByShortName("group1");

        Person fordp2 = jpaPersonMapper.findByAccountId("fordp2");
        Person csagan = jpaPersonMapper.findByAccountId("csagan");

        // Verify initial state
        assertFalse(jpaGroupMapper.isFollowing("fordp2", "group1"));
        assertFalse(jpaGroupMapper.isFollowing("csagan", "group1"));
        assertEquals(0, fordp2.getFollowingCount());
        assertEquals(0, fordp2.getGroupCount());
        assertEquals(0, csagan.getFollowingCount());
        assertEquals(1, csagan.getGroupCount());

        // ford wants to follow the group
        jpaGroupMapper.addFollower(fordp2.getId(), group.getId());

        getEntityManager().clear();

        fordp2 = jpaPersonMapper.findByAccountId("fordp2");
        csagan = jpaPersonMapper.findByAccountId("csagan");

        // verify new state
        assertTrue(jpaGroupMapper.isFollowing("fordp2", "group1"));
        // Test case insensitivity (everything should be lower cased by the mapper).
        assertTrue(jpaGroupMapper.isFollowing("fordp2", "Group1"));
        assertFalse(jpaGroupMapper.isFollowing("csagan", "group1"));
        assertEquals(0, fordp2.getFollowingCount());
        assertEquals(1, fordp2.getGroupCount());
        assertEquals(0, csagan.getFollowingCount());
        assertEquals(1, csagan.getGroupCount());

        // csagan wants to follow the group
        jpaGroupMapper.addFollower(csagan.getId(), group.getId());

        getEntityManager().clear();

        fordp2 = jpaPersonMapper.findByAccountId("fordp2");
        csagan = jpaPersonMapper.findByAccountId("csagan");
View Full Code Here

     * Test objectToString with null mapper.
     */
    @Test
    public void testObjectToStringOnSuccess()
    {
        final DomainGroup group = context.mock(DomainGroup.class);
        final DomainGroupMapper groupMapper = context.mock(DomainGroupMapper.class);
        final Long[] personIds = { 1L, 2L, 5L, 8L, 10L, 382L };

        context.checking(new Expectations()
        {
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.DomainGroup

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.