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());
}
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());
}
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());
}
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());
}
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));
}
}
}
Aggregations