use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class SelectionModelStateSerializerTest method testSerialize.
// (expected=AssertionError.class)//FIXME bug 487157: disabled until entries declare Neon compatibility
@Test
@Category(RemoteTests.class)
public void testSerialize() {
catalog.performDiscovery(new NullProgressMonitor());
assertFalse(catalog.getItems().isEmpty());
assertTrue(catalog.getItems().size() > 4);
// first two are promoted downloads, which might not be installable in current target
CatalogItem firstItem = catalog.getItems().get(2);
CatalogItem secondItem = catalog.getItems().get(3);
assertThat(firstItem.getDescription(), not(startsWith(PROMOTED_MARKER)));
assertThat(secondItem.getDescription(), not(startsWith(PROMOTED_MARKER)));
assertThat(firstItem.getInstallableUnits(), not(empty()));
assertThat(secondItem.getInstallableUnits(), not(empty()));
selectionModel.select(firstItem, Operation.INSTALL);
selectionModel.select(secondItem, Operation.INSTALL);
SelectionModelStateSerializer serializer = new SelectionModelStateSerializer(catalog, selectionModel);
String state = serializer.serialize();
assertNotNull(state);
assertFalse(state.trim().length() == 0);
assertTrue(selectionModel.computeProvisioningOperationViable());
selectionModel.clear();
assertTrue(selectionModel.getItemToSelectedOperation().isEmpty());
assertFalse(selectionModel.computeProvisioningOperationViable());
serializer.deserialize(state, new NullProgressMonitor());
assertEquals(2, selectionModel.getItemToSelectedOperation().size());
assertTrue(selectionModel.computeProvisioningOperationViable());
Map<CatalogItem, Operation> itemToOperation = selectionModel.getItemToSelectedOperation();
assertEquals(Operation.INSTALL, itemToOperation.get(firstItem));
assertEquals(Operation.INSTALL, itemToOperation.get(secondItem));
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class MarketplaceCatalogTest method testCheckUpdateOnPerformDiscovery.
@Test
public void testCheckUpdateOnPerformDiscovery() {
assertTrue(checkedForUpdate.isEmpty());
catalog.performDiscovery(new NullProgressMonitor());
List<CatalogItem> items = catalog.getItems();
assertEquals(discoveryNodes.size(), items.size());
assertEquals(installedNodes.size(), checkedForUpdate.size());
int updateable = 0;
for (CatalogItem item : items) {
Boolean hasUpdate = ((MarketplaceNodeCatalogItem) item).getUpdateAvailable();
if (installedNodes.contains(item.getData())) {
assertNotNull(hasUpdate);
} else {
assertNull(hasUpdate);
}
assertEquals(updateAvailable.contains(item.getData()), Boolean.TRUE.equals(hasUpdate));
if (Boolean.TRUE.equals(hasUpdate)) {
updateable++;
}
}
assertEquals(updateAvailable.size(), updateable);
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class ResolveFeatureNamesOperation method run.
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.ResolveFeatureNamesOperation_resolvingFeatures, 100);
try {
List<IMetadataRepository> repositories = addRepositories(monitor.newChild(50));
List<IInstallableUnit> installableUnits = queryInstallableUnits(monitor.newChild(50), repositories);
Set<String> resolvedFeatureIds = new HashSet<String>();
for (IInstallableUnit iu : installableUnits) {
FeatureDescriptor descriptor = new FeatureDescriptor(iu);
resolvedFeatureIds.add(descriptor.getId());
resolvedFeatureIds.add(descriptor.getSimpleId());
featureDescriptors.add(descriptor);
}
for (CatalogItem catalogItem : items) {
for (String iu : catalogItem.getInstallableUnits()) {
if (!resolvedFeatureIds.contains(iu)) {
FeatureDescriptor descriptor = new FeatureDescriptor(iu);
unresolvedFeatureDescriptors.add(descriptor);
}
}
}
} finally {
// SECURITY: resolving feature names should never add repositories
removeAddedRepositoryLocations();
monitor.done();
}
} catch (OperationCanceledException e) {
throw new InterruptedException();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
Aggregations