Package org.eurekastreams.server.action.request.gallery

Examples of org.eurekastreams.server.action.request.gallery.GetGallerySearchResultsRequest


     *             happens due to limitation in AnonymousClassInterceptor. Can't intercept and return a value.
     */
    @Test(expected = NullPointerException.class)
    public final void performActionTheme() throws Exception
    {
        final GetGallerySearchResultsRequest request = new GetGallerySearchResultsRequest();

        final ServiceActionContext currentContext = new ServiceActionContext(request, principalMock);

        request.setMaxResultsPerPage(1);
        request.setSearchText("search test");
        request.setSort("created");
        request.setStartingIndex(0);
        request.setType(GalleryItemType.THEME);

        final AnonymousClassInterceptor<LuceneSearchRequest> requestInt =
            new AnonymousClassInterceptor<LuceneSearchRequest>();

        context.checking(new Expectations()
        {
            {
                oneOf(mapper).execute(with(any(LuceneSearchRequest.class)));
                will(requestInt);
            }
        });

        sut.execute(currentContext);

        Assert.assertEquals(request.getStartingIndex(), requestInt.getObject().getFirstResult());
        Assert.assertEquals(request.getMaxResultsPerPage(), requestInt.getObject().getMaxResults());
        Assert.assertEquals(request.getSearchText(), requestInt.getObject().getSearchString());
        Assert.assertEquals(Theme.class, requestInt.getObject().getObjectType());
        Assert.assertNotNull(requestInt.getObject().getSortFields());
        Assert.assertNotNull(requestInt.getObject().getFields());

        context.assertIsSatisfied();
View Full Code Here


     *             happens due to limitation in AnonymousClassInterceptor. Can't intercept and return a value.
     */
    @Test(expected = NullPointerException.class)
    public final void performActionGadget() throws Exception
    {
        final GetGallerySearchResultsRequest request = new GetGallerySearchResultsRequest();

        final ServiceActionContext currentContext = new ServiceActionContext(request, principalMock);

        request.setMaxResultsPerPage(1);
        request.setSearchText("search test");
        request.setSort("created");
        request.setStartingIndex(0);
        request.setType(GalleryItemType.GADGET);

        final AnonymousClassInterceptor<LuceneSearchRequest> requestInt =
            new AnonymousClassInterceptor<LuceneSearchRequest>();

        context.checking(new Expectations()
        {
            {
                oneOf(mapper).execute(with(any(LuceneSearchRequest.class)));
                will(requestInt);
            }
        });

        sut.execute(currentContext);

        Assert.assertEquals(request.getStartingIndex(), requestInt.getObject().getFirstResult());
        Assert.assertEquals(request.getMaxResultsPerPage(), requestInt.getObject().getMaxResults());
        Assert.assertEquals(request.getSearchText(), requestInt.getObject().getSearchString());
        Assert.assertEquals(GadgetDefinition.class, requestInt.getObject().getObjectType());
        Assert.assertNotNull(requestInt.getObject().getSortFields());
        Assert.assertNotNull(requestInt.getObject().getFields());

        context.assertIsSatisfied();
View Full Code Here

    @Override
    public PagedSet<GalleryItem> execute(final ServiceActionContext inActionContext) throws ExecutionException
    {
        long startTime = System.currentTimeMillis();

        GetGallerySearchResultsRequest actionRequest = (GetGallerySearchResultsRequest) inActionContext.getParams();

        LuceneSearchRequest request = new LuceneSearchRequest();

        request.setMaxResults(actionRequest.getMaxResultsPerPage());
        request.setFirstResult(actionRequest.getStartingIndex());

        Class< ? > objectType;

        if (actionRequest.getType() == GalleryItemType.THEME)
        {
            objectType = Theme.class;
        }
        else
        {
            objectType = GadgetDefinition.class;
        }

        // TODO pull into Spring.
        Map<String, Float> fields = new HashMap<String, Float>();
        fields.put("name", 2.0F);
        fields.put("title", 2.0F);
        fields.put("description", 1.0F);
        fields.put("author", 1.0F);
        request.setFields(fields);

        List<String> sortFields = new ArrayList<String>();
        sortFields.add(actionRequest.getSort());
        request.setSortFields(sortFields);
        request.setObjectType(objectType);
        request.setSearchString(actionRequest.getSearchText());

        PagedSet<GalleryItem> results = searchMapper.execute(request);

        if (logger.isDebugEnabled())
        {
            logger.debug("Retrieved " + results.getTotal() + " from the search, returning "
                    + results.getPagedSet().size() + " items from the searchText: " + actionRequest.getSearchText()
                    + " .");
        }

        // set the elapsed time
        String elapsedTime = formatElapasedTime(startTime, System.currentTimeMillis());
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.action.request.gallery.GetGallerySearchResultsRequest

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.