Search in sources :

Example 11 with ICategory

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

the class MarketplaceDiscoveryStrategyTest method testSearchByNodeUrl.

@Test
public void testSearchByNodeUrl() throws Exception {
    final INode[] testNode = new INode[1];
    final IMarketplaceService marketplaceService = new DefaultMarketplaceService(catalogUrl) {

        @Override
        public Node getNode(INode node, IProgressMonitor monitor) throws CoreException {
            testNode[0] = node;
            return (Node) node;
        }

        @Override
        public SearchResult search(IMarket market, ICategory category, String queryText, IProgressMonitor monitor) throws CoreException {
            Assert.fail("Unexpected invocation");
            // dead code
            return null;
        }
    };
    setupCatalog(marketplaceService);
    testNode[0] = null;
    catalog.performQuery(null, null, new URL(catalogUrl, "content/test").toExternalForm(), new NullProgressMonitor());
    assertNotNull(testNode[0]);
    assertNotNull(testNode[0].getUrl());
    testNode[0] = null;
    catalog.performQuery(null, null, new URL(catalogUrl, "node/12345").toExternalForm(), new NullProgressMonitor());
    assertNotNull(testNode[0]);
    assertNotNull(testNode[0].getId());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DefaultMarketplaceService(org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) IMarket(org.eclipse.epp.mpc.core.model.IMarket) URL(java.net.URL) Test(org.junit.Test)

Example 12 with ICategory

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

the class DefaultMarketplaceServiceTest method findCategory.

private ICategory findCategory(IMarket toolsMarket, String categoryName) {
    ICategory namedCategory = null;
    for (ICategory category : toolsMarket.getCategory()) {
        if (categoryName.equals(category.getName())) {
            namedCategory = category;
            break;
        }
    }
    assertNotNull(namedCategory);
    return namedCategory;
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory)

Example 13 with ICategory

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

the class DefaultMarketplaceServiceTest method getCategory.

@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void getCategory() throws CoreException {
    List<? extends IMarket> markets = marketplaceService.listMarkets(new NullProgressMonitor());
    assertNotNull(markets);
    assertFalse(markets.isEmpty());
    final String marketName = "Tools";
    IMarket market = null;
    for (IMarket m : markets) {
        if (marketName.equals(m.getName())) {
            market = m;
            break;
        }
    }
    assertNotNull("Expected market " + marketName, market);
    assertFalse(market.getCategory().isEmpty());
    final String categoryName = "Mylyn Connectors";
    ICategory category = null;
    for (ICategory c : market.getCategory()) {
        if (categoryName.equals(c.getName())) {
            category = c;
            break;
        }
    }
    assertNotNull("Expected category " + categoryName, category);
    ICategory result = marketplaceService.getCategory(category, new NullProgressMonitor());
    assertNotNull(result);
// FIXME: pending bug 302671
// assertEquals(category.getId(),result.getId());
// FIXME: pending bug 497242
// assertEquals(category.getName(), result.getName());
// assertEquals(category.getUrl(), result.getUrl());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarket(org.eclipse.epp.mpc.core.model.IMarket) Test(org.junit.Test)

Example 14 with ICategory

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

the class UnmarshallerTest method featured.

@Test
public void featured() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/api/v2/featured
    Object model = processResource("resources/featured.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Featured featured = marketplace.getFeatured();
    assertNotNull(featured);
    assertEquals(Integer.valueOf(6), featured.getCount());
    assertEquals(6, featured.getNode().size());
    INode node = featured.getNode().get(0);
    assertEquals("248", node.getId());
    assertEquals("eUML2 free edition", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/euml2-free-edition", node.getUrl());
    assertEquals("resource", node.getType());
    ICategories categories = node.getCategories();
    assertNotNull(categories);
    assertEquals(1, categories.getCategory().size());
    ICategory category = categories.getCategory().get(0);
    assertEquals("19", category.getId());
    assertEquals("UML", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/19", category.getUrl());
    assertEquals("Yves YANG", node.getOwner());
    assertEquals(Integer.valueOf(0), node.getFavorited());
    assertNotNull(node.getBody());
    // bug 303149		assertTrue(node.getBody().startsWith("<P><STRONG>eUML2 for Java<"));
    // bug 303149		assertTrue(node.getBody().endsWith("</LI></UL>"));
    assertTrue(node.getFoundationmember());
    assertEquals("http://www.soyatec.com/", node.getHomepageurl());
    assertEquals("http://www.soyatec.com/euml2/images/product_euml2_110x80.png", node.getImage());
    assertEquals("3.4", node.getVersion());
    assertEquals("Free for non-commercial use", node.getLicense());
    assertEquals("Soyatec", node.getCompanyname());
    assertEquals("Mature", node.getStatus());
    assertEquals("3.4.x/3.5.x", node.getEclipseversion());
    assertEquals("http://www.soyatec.com/forum", node.getSupporturl());
    assertEquals("http://www.soyatec.com/update", node.getUpdateurl());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategories(org.eclipse.epp.mpc.core.model.ICategories) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Featured(org.eclipse.epp.internal.mpc.core.model.Featured) Test(org.junit.Test)

Example 15 with ICategory

use of org.eclipse.epp.mpc.core.model.ICategory 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)

Aggregations

ICategory (org.eclipse.epp.mpc.core.model.ICategory)22 IMarket (org.eclipse.epp.mpc.core.model.IMarket)11 Test (org.junit.Test)10 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)8 INode (org.eclipse.epp.mpc.core.model.INode)8 ICategories (org.eclipse.epp.mpc.core.model.ICategories)5 ArrayList (java.util.ArrayList)3 NoSuchElementException (java.util.NoSuchElementException)3 CoreException (org.eclipse.core.runtime.CoreException)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 SubMonitor (org.eclipse.core.runtime.SubMonitor)3 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)2 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)2 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1