Search in sources :

Example 11 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class UnmarshallerTest method news.

@Test
public void news() throws IOException, UnmarshalException {
    Object model = processResource("resources/news.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    News news = marketplace.getNews();
    assertNotNull(news);
    assertEquals("http://marketplace.eclipse.org/news", news.getUrl());
    assertEquals("News", news.getShortTitle());
    assertEquals(Long.valueOf(1363181064000l), news.getTimestamp());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) News(org.eclipse.epp.internal.mpc.core.model.News) INews(org.eclipse.epp.mpc.core.model.INews) Test(org.junit.Test)

Example 12 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class UnmarshallerTest method related.

public void related() throws Exception {
    Object model = processResource("resources/related.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Related related = marketplace.getRelated();
    assertNotNull(related);
    assertEquals(Integer.valueOf(6), related.getCount());
    assertEquals(6, related.getNode().size());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) Related(org.eclipse.epp.internal.mpc.core.model.Related)

Example 13 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class UnmarshallerTest method node.

@Test
public void node() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/content/mylyn-wikitext-lightweight-markup-editing-tools-and-framework/xml
    Object model = processResource("resources/node.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    assertEquals(1, marketplace.getNode().size());
    INode node = marketplace.getNode().get(0);
    assertEquals("1065", node.getId());
    assertEquals("Mylyn WikiText - Lightweight Markup Editing, Tools and Framework", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/mylyn-wikitext-lightweight-markup-editing-tools-and-framework", node.getUrl());
    assertNotNull(node.getBody());
    assertTrue(node.getBody().startsWith("Mylyn WikiText is a"));
    assertTrue(node.getBody().endsWith("FAQ</a>."));
    assertNotNull(node.getCategories());
    assertEquals(5, node.getCategories().getCategory().size());
    ICategory category = node.getCategories().getCategory().get(1);
    // <category name='Tools'>/taxonomy/term/17</category>
    assertEquals("Tools", category.getName());
    // FIXME category id.
    assertNotNull(node.getCreated());
    assertEquals(1259955243L, node.getCreated().getTime() / 1000);
    assertEquals(new Integer(3), node.getFavorited());
    assertEquals(Boolean.TRUE, node.getFoundationmember());
    assertNotNull(node.getChanged());
    assertEquals(1259964722L, node.getChanged().getTime() / 1000);
    assertEquals("David Green", node.getOwner());
    assertEquals("resource", node.getType());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Test(org.junit.Test)

Example 14 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class UnmarshallerTest method marketplaceRoot.

@Test
public void marketplaceRoot() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/xml
    Object model = processResource("resources/marketplace-root.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    assertEquals(4, marketplace.getMarket().size());
    IMarket market = marketplace.getMarket().get(0);
    assertEquals("31", market.getId());
    assertEquals("Tools", market.getName());
    assertEquals("http://www.eclipseplugincentral.net/category/markets/tools", market.getUrl());
    assertEquals(36, market.getCategory().size());
    ICategory category = market.getCategory().get(10);
    assertEquals("24", category.getId());
    assertEquals("IDE", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/24%2C31", category.getUrl());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarket(org.eclipse.epp.mpc.core.model.IMarket) Test(org.junit.Test)

Example 15 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class DefaultMarketplaceService method getNodesById.

private void getNodesById(Collection<? extends INode> nodes, Map<INode, INode> resolvedNodeMapping, IProgressMonitor monitor) throws CoreException {
    StringBuilder nodeIdQuery = new StringBuilder();
    Map<String, INode> nodeIds = new HashMap<String, INode>(nodes.size());
    for (INode node : nodes) {
        if (node.getId() == null) {
            continue;
        }
        nodeIds.put(node.getId(), node);
        String encodedId = urlEncode(node.getId());
        if (nodeIdQuery.length() > 0) {
            // $NON-NLS-1$
            nodeIdQuery.append(",");
        }
        nodeIdQuery.append(encodedId);
    }
    Marketplace marketplace = processRequest(API_NODE_URI + '/' + nodeIdQuery + '/' + API_URI_SUFFIX, monitor);
    List<Node> resolvedNodes = marketplace.getNode();
    for (Node node : resolvedNodes) {
        INode inputNode = nodeIds.get(node.getId());
        if (inputNode != null) {
            resolvedNodeMapping.put(inputNode, node);
        } else {
            throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, nodeIdQuery));
        }
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) CoreException(org.eclipse.core.runtime.CoreException) HashMap(java.util.HashMap) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode)

Aggregations

Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)18 INode (org.eclipse.epp.mpc.core.model.INode)11 ICategory (org.eclipse.epp.mpc.core.model.ICategory)9 Test (org.junit.Test)9 CoreException (org.eclipse.core.runtime.CoreException)4 ICategories (org.eclipse.epp.mpc.core.model.ICategories)4 Node (org.eclipse.epp.internal.mpc.core.model.Node)3 Category (org.eclipse.epp.internal.mpc.core.model.Category)2 Search (org.eclipse.epp.internal.mpc.core.model.Search)2 IMarket (org.eclipse.epp.mpc.core.model.IMarket)2 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Favorites (org.eclipse.epp.internal.mpc.core.model.Favorites)1 Featured (org.eclipse.epp.internal.mpc.core.model.Featured)1 Market (org.eclipse.epp.internal.mpc.core.model.Market)1 News (org.eclipse.epp.internal.mpc.core.model.News)1