use of org.eclipse.epp.internal.mpc.core.model.Search in project epp.mpc by eclipse.
the class UnmarshallerTest method search.
@Test
public void search() throws IOException, UnmarshalException {
// from http://www.eclipseplugincentral.net/api/v2/search/apachesolr_search/test?filters=tid:16%20tid:31
Object model = processResource("resources/search.xml");
assertNotNull(model);
assertTrue(model instanceof Marketplace);
Marketplace marketplace = (Marketplace) model;
Search search = marketplace.getSearch();
assertNotNull(search);
assertEquals("test", search.getTerm());
assertEquals("http://www.eclipseplugincentral.net/search/apachesolr/test?filters=tid%3A16%20tid%3A31", search.getUrl());
assertEquals(Integer.valueOf(62), search.getCount());
assertEquals(7, search.getNode().size());
INode node = search.getNode().get(0);
assertEquals("983", node.getId());
assertEquals("Run All Tests", node.getName());
assertEquals("http://www.eclipseplugincentral.net/content/run-all-tests", node.getUrl());
assertEquals("resource", node.getType());
ICategories categories = node.getCategories();
assertNotNull(categories);
assertEquals(1, categories.getCategory().size());
ICategory category = categories.getCategory().get(0);
assertEquals("16", category.getId());
assertEquals("Testing", category.getName());
assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/16", category.getUrl());
assertEquals("ipreuss", node.getOwner());
assertNotNull(node.getBody());
assertEquals("Allows the execution of JUnit tests for several projects at once.", node.getBody());
assertTrue(!node.getFoundationmember());
assertEquals("https://sourceforge.net/projects/e-rat/", node.getHomepageurl());
assertNull(node.getImage());
assertEquals("1.0.1", node.getVersion());
assertEquals("Other", node.getLicense());
assertEquals("Ilja Preu\u00DF", node.getCompanyname());
assertEquals("Production/Stable", node.getStatus());
assertEquals("3.5", node.getEclipseversion());
assertEquals("https://sourceforge.net/projects/e-rat/support", node.getSupporturl());
assertEquals("http://e-rat.sf.net/updatesite", node.getUpdateurl());
assertEquals(Integer.valueOf(136), node.getFavorited());
assertEquals(Integer.valueOf(299995), node.getInstallsTotal());
assertEquals(Integer.valueOf(34540), node.getInstallsRecent());
INode lastNode = search.getNode().get(search.getNode().size() - 1);
assertEquals("1011", lastNode.getId());
assertEquals("JUnit Flux", lastNode.getName());
assertNull(lastNode.getFavorited());
assertNull(lastNode.getInstallsTotal());
assertNull(lastNode.getInstallsRecent());
}
use of org.eclipse.epp.internal.mpc.core.model.Search in project epp.mpc by eclipse.
the class DefaultMarketplaceService method processSearchRequest.
private SearchResult processSearchRequest(String relativeUrl, String queryText, IProgressMonitor monitor) throws CoreException {
SearchResult result = new SearchResult();
if (relativeUrl == null) {
// empty search
result.setMatchCount(0);
result.setNodes(new ArrayList<Node>());
} else {
Marketplace marketplace;
try {
marketplace = processRequest(relativeUrl, monitor);
} catch (CoreException ex) {
Throwable cause = ex.getCause();
if (cause instanceof FileNotFoundException) {
throw new CoreException(createErrorStatus(NLS.bind(Messages.DefaultMarketplaceService_UnsupportedSearchString, queryText), cause));
}
throw ex;
}
Search search = marketplace.getSearch();
if (search != null) {
result.setMatchCount(search.getCount());
result.setNodes(search.getNode());
} else if (marketplace.getCategory().size() == 1) {
Category category = marketplace.getCategory().get(0);
result.setMatchCount(category.getNode().size());
result.setNodes(category.getNode());
} else {
throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, relativeUrl));
}
}
return result;
}
Aggregations