Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.Gadget


     *             should not be thrown
     */
    @Test
    public void performActionWithGoodParams() throws Exception
    {
        final Gadget expected = context.mock(Gadget.class);

        context.checking(new Expectations()
        {
            {
                allowing(principalMock).getId();
                will(returnValue(1L));

                allowing(deleteCacheKeysMapper).execute(with(any(Set.class)));

                oneOf(gadgetMapper).findById(GADGET_ID1);
                will(returnValue(expected));

                oneOf(expected).setMinimized(true);
                oneOf(expected).setMaximized(false);

                oneOf(gadgetMapper).flush();
            }
        });

        SetGadgetStateRequest currentRequest = new SetGadgetStateRequest(GADGET_ID1, State.MINIMIZED);
        ServiceActionContext currentContext = new ServiceActionContext(currentRequest, principalMock);
        Gadget actual = sut.execute(currentContext);

        assertEquals("Did not return the right Tab", actual, expected);
    }
View Full Code Here


            }

            private Gadget setupGadget(final long gadgetId, final long targetGadgetId, final int zoneNumber,
                    final int zoneIndex)
            {
                Gadget gadget = context.mock(Gadget.class, "gadget" + Long.toString(gadgetId));
                allowing(gadget).getId();
                will(returnValue(gadgetId));

                allowing(gadget).getZoneNumber();
                will(returnValue(zoneNumber));
View Full Code Here

                // setup the list of mocked gadgets

                // ----------------
                // -- Gadget #0 - zone 0, index 0
                Gadget gadget0 = context.mock(Gadget.class, "gadget0");

                exactly(1).of(gadget0).getZoneNumber();
                will(returnValue(0));

                // should never have to ask this gadget for its zone index
                never(gadget0).getZoneIndex();
                // ----------------

                // ----------------
                // -- Gadget #1 - <LAST ZONE>, index 0
                Gadget gadget1 = context.mock(Gadget.class, "gadget1");
                exactly(1).of(gadget1).getZoneNumber();
                will(returnValue(tabLayout.getNumberOfZones() - 1));

                // ----------------
                // -- Gadget #2 - <LAST ZONE>, index 1
                Gadget gadget2 = context.mock(Gadget.class, "gadget2");

                // set the zone number - it MUST be requested once
                exactly(1).of(gadget2).getZoneNumber();
                will(returnValue(tabLayout.getNumberOfZones() - 1));

                // add the gadgets to the collection
                gadgets.add(gadget0);
                gadgets.add(gadget1);
                gadgets.add(gadget2);

                oneOf(gadget0).getZoneIndex();
                will(returnValue(0));

                oneOf(gadget0).setZoneIndex(1);

                oneOf(person).getId();
                will(returnValue(0L));

                // when asked for the gadgets, return the mocked list
                atLeast(1).of(tab).getGadgets();
                will(returnValue(gadgets));

                allowing(actionContext).getPrincipal();
                will(returnValue(principal));

                allowing(principal).getAccountId();
                will(returnValue("username"));

                // action has to load the tab by ID
                allowing(personMapper).findByAccountId("username");
                will(returnValue(person));

                oneOf(person).getTabs(TabGroupType.START);
                will(returnValue(tabList));

                // will need a flush() when all done
                exactly(1).of(tabMapper).flush();

                allowing(deleteCacheKeysMapper).execute(with(any(Set.class)));
            }

        });

        Gadget actual = (Gadget) sut.execute(actionContext);

        // make sure the new gadget is of the type passed in
        assertEquals(gadgetDefinitionId, (Long) actual.getGadgetDefinition().getId());

        // make sure the gadget is in the right zone and index
        assertEquals(0, actual.getZoneIndex());
        assertEquals(0, actual.getZoneNumber());

        context.assertIsSatisfied();
    }
View Full Code Here

     *             should not be thrown
     */
    @Test
    public void performAction() throws Exception
    {
        final Gadget undeletedGadget = context.mock(Gadget.class);

        context.checking(new Expectations()
        {
            {
                allowing(principalMock).getId();
View Full Code Here

     *
     * @return the mocked Gadget.
     */
    private Gadget getGadget(final long id, final int zoneNumber, final int zoneIndex)
    {
        final Gadget g = context.mock(Gadget.class, "gadget#" + id);
        context.checking(new Expectations()
        {
            {
                States znState = context.states(id + ".zoneNumber").startsAs("initial");
                gadgetStates.put(id + ".zoneNumber", znState);
View Full Code Here

     * Unit Test Test: Test that states work like I think.
     */
    @Test
    public void testAssertStates()
    {
        final Gadget g = context.mock(Gadget.class, "foo");

        final States znState = context.states("500.zoneNumber").startsAs("initial");

        context.checking(new Expectations()
        {
            {
                allowing(g).getZoneIndex();
                will(returnValue(1));
                when(znState.isNot("changed"));

                one(g).setZoneIndex(2);
                then(znState.is("changed"));

                allowing(g).getZoneIndex();
                will(returnValue(2));
                when(znState.is("changed"));
            }
        });

        assertEquals(1, g.getZoneIndex());
        assertEquals(1, g.getZoneIndex());
        g.setZoneIndex(2);
        assertEquals(2, g.getZoneIndex());
        assertEquals(2, g.getZoneIndex());

        context.assertIsSatisfied();
    }
View Full Code Here

        final int gadgetZone = 123;
        final int gadgetIndex = 321;

        final int newGadgetIndex = 555;

        final Gadget g = getGadget(gadgetId, gadgetZone, gadgetIndex);
        context.checking(new Expectations()
        {
            {
                one(g).setZoneIndex(newGadgetIndex);
                then(gadgetStates.get(gadgetId + ".zoneIndex").is("changed"));

                allowing(g).getZoneIndex();
                will(returnValue(newGadgetIndex));
                when(gadgetStates.get(gadgetId + ".zoneIndex").is("changed"));
            }
        });

        assertEquals(gadgetId, g.getId());
        assertEquals(gadgetIndex, g.getZoneIndex());

        g.setZoneIndex(newGadgetIndex);

        assertEquals(newGadgetIndex, g.getZoneIndex());

        context.assertIsSatisfied();
    }
View Full Code Here

            for (GadgetDTO gadgetDTO : tabDTO.getGadgets())
            {
                GadgetDefinition gadgetDef = new GadgetDefinition(gadgetDTO.getGadgetDefinition().getUrl(), gadgetDTO
                        .getGadgetDefinition().getUuid());
                gadgetDef.setId(gadgetDTO.getGadgetDefinition().getId());
                Gadget gadget = new Gadget(gadgetDef, gadgetDTO.getZoneNumber(), gadgetDTO.getZoneIndex(), null,
                        gadgetDTO.getGadgetUserPref());
                gadget.setId(gadgetDTO.getId());
                gadget.setMaximized(gadgetDTO.isMaximized());
                gadget.setMinimized(gadgetDTO.isMinimized());
                gadgets.add(gadget);
            }

            tab.setGadgets(gadgets);
            startTabGroup.addTab(tab);
View Full Code Here

     */
    private List<Gadget> makeGadgets()
    {
        List<Gadget> gadgetList = new ArrayList<Gadget>();
        String url = "http://www.example.com/gadgets";
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 0, 0, new Person(), ""));
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 0, 1, new Person(), ""));
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 1, 0, new Person(), ""));
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 1, 1, new Person(), ""));
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 1, 2, new Person(), ""));
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 2, 0, new Person(), ""));
        gadgetList.add(new Gadget(new GadgetDefinition(url, UUID.randomUUID().toString(),
                 new GalleryItemCategory("somecategory")), 2, 1, new Person(), ""));

        return gadgetList;
    }
View Full Code Here

     */
    @Test
    public void testGadgetDefinition()
    {
        Tab fordTab1 = jpaTabMapper.findById(fordsFirstTabId);
        final Gadget g = fordTab1.getGadgets().get(0);
        afterTransactionAction = new PostTransactionAction()
        {
            @Override
            public void execute()
            {
                assertNotNull(g);
                junit.framework.Assert.assertEquals("http://www.example.com/gadget1.xml", g.getGadgetDefinition()
                        .getUrl());

            }
        };
    }
View Full Code Here

TOP

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

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.