@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(); }
@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; } 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() + " ."); } String elapsedTime = formatElapasedTime(startTime, System.currentTimeMillis()); results.setElapsedTime(elapsedTime); return results; }
GetGallerySearchResultsExecution implements ExecutionStrategy<ServiceActionContext> { @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; } 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() + " ."); } String elapsedTime = formatElapasedTime(startTime, System.currentTimeMillis()); results.setElapsedTime(elapsedTime); return results; } }
GetGallerySearchResultsExecution implements ExecutionStrategy<ServiceActionContext> { @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; } 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() + " ."); } String elapsedTime = formatElapasedTime(startTime, System.currentTimeMillis()); results.setElapsedTime(elapsedTime); return results; } GetGallerySearchResultsExecution(final LuceneSearchMapper<GalleryItem> inSearchMapper); }
GetGallerySearchResultsExecution implements ExecutionStrategy<ServiceActionContext> { @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; } 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() + " ."); } String elapsedTime = formatElapasedTime(startTime, System.currentTimeMillis()); results.setElapsedTime(elapsedTime); return results; } GetGallerySearchResultsExecution(final LuceneSearchMapper<GalleryItem> inSearchMapper); @Override PagedSet<GalleryItem> execute(final ServiceActionContext inActionContext); }
GetGallerySearchResultsExecution implements ExecutionStrategy<ServiceActionContext> { @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; } 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() + " ."); } String elapsedTime = formatElapasedTime(startTime, System.currentTimeMillis()); results.setElapsedTime(elapsedTime); return results; } GetGallerySearchResultsExecution(final LuceneSearchMapper<GalleryItem> inSearchMapper); @Override PagedSet<GalleryItem> execute(final ServiceActionContext inActionContext);  }