Search in sources :

Example 36 with INode

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

the class DefaultMarketplaceServiceTest method assertSearchResultSanity.

protected void assertSearchResultSanity(ISearchResult result) {
    assertNotNull(result);
    assertNotNull(result.getNodes());
    assertNotNull(result.getMatchCount());
    int promotedCount = 0;
    for (INode node : result.getNodes()) {
        if (node.getShortdescription() != null && node.getShortdescription().startsWith("**Promoted**")) {
            promotedCount++;
        }
    }
    assertTrue(result.getMatchCount() >= result.getNodes().size() - promotedCount);
    assertTrue(result.getNodes().size() > 0);
    Set<String> ids = new HashSet<String>();
    for (INode node : result.getNodes()) {
        assertNotNull(node.getId());
        assertTrue(ids.add(node.getId()));
        assertNotNull(node.getName());
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) HashSet(java.util.HashSet)

Example 37 with INode

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

the class SolutionCompatibilityFilterTest method format.

private static String format(String message, Object... details) {
    if (details == null || details.length == 0) {
        return message;
    }
    String contentPrefix = BASE_URL + "/content/";
    for (int i = 0; i < details.length; i++) {
        Object detail = details[i];
        if (detail instanceof INode) {
            INode node = (INode) detail;
            String url = node.getUrl();
            if (url != null) {
                if (url.startsWith(contentPrefix)) {
                    String shortName = url.substring(contentPrefix.length());
                    detail = shortName;
                } else {
                    detail = url;
                }
            } else {
                detail = node.getId();
            }
        } else if (detail instanceof Solution) {
            Solution solution = (Solution) detail;
            detail = solution.shortName();
        }
        details[i] = detail;
    }
    return MessageFormat.format(message, details);
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode)

Example 38 with INode

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

the class SolutionCompatibilityFilterTest method queryNode.

protected INode queryNode() throws CoreException {
    INode node = marketplaceService.getNode(QueryHelper.nodeByUrl(solution.url()), new NullProgressMonitor());
    assertNotNull("Node {0} not found", node);
    if (solution.id() != null) {
        assertEquals("Node {2} returned with wrong id {1}", solution.id(), node.getId(), solution);
    }
    if (solution.url() != null) {
        assertEquals("Node {2} returned with wrong url {1}", solution.url(), node.getUrl(), solution);
    }
    return node;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode)

Example 39 with INode

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

the class SolutionCompatibilityFilterTest method testCompatibleInstallableNode.

public void testCompatibleInstallableNode() throws CoreException {
    assumeTrue("Skipping test - this solution and Eclipse/OS are incompatible", compatible);
    assumeTrue("Skipping test - this solution is not installable", solution.installable());
    INode node = queryNode();
    String updateurl = node.getUpdateurl();
    assertThat("Node {1} has no update url", updateurl, not(isEmptyOrNullString()), node);
    IIus ius = node.getIus();
    assertNotNull("Node {1} is missing <ius> element", ius, node);
    List<IIu> iuElements = ius.getIuElements();
    assertNotNull(iuElements);
    assertThat("Node {1} has no IUs", iuElements, not(empty()), node);
    if (version != null) {
        assertEquals("Node {2} has wrong version", version, node.getVersion(), node);
    }
    if (site != null) {
        assertEquals("Node {2} has wrong update site", site, node.getUpdateurl(), node);
    }
    if (features != null) {
        Set<String> allIUs = new HashSet<String>();
        for (IIu iu : iuElements) {
            allIUs.add(iu.getId());
        }
        assertThat("Node {1} is missing some features", allIUs, hasItems(features), node);
        assertThat("Node {1} has some unexpected features", allIUs, hasSize(features.length), node);
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) IIu(org.eclipse.epp.mpc.core.model.IIu) IIus(org.eclipse.epp.mpc.core.model.IIus) HashSet(java.util.HashSet)

Example 40 with INode

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

the class SolutionCompatibilityFilterTest method testCompatibleSearchResult.

public void testCompatibleSearchResult() throws CoreException {
    assumeTrue("Skipping test - this solution and Eclipse/OS are incompatible", compatible);
    INode foundNode = searchForNode();
    assertNotNull("Compatible node {1} not found in search", foundNode, solution);
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode)

Aggregations

INode (org.eclipse.epp.mpc.core.model.INode)63 Node (org.eclipse.epp.internal.mpc.core.model.Node)13 ArrayList (java.util.ArrayList)12 CoreException (org.eclipse.core.runtime.CoreException)12 SubMonitor (org.eclipse.core.runtime.SubMonitor)12 Test (org.junit.Test)12 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)10 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 ICategory (org.eclipse.epp.mpc.core.model.ICategory)8 URISyntaxException (java.net.URISyntaxException)7 NotAuthorizedException (org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException)7 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)7 IOException (java.io.IOException)6 MalformedURLException (java.net.MalformedURLException)6 List (java.util.List)6 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)6 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)6