Search in sources :

Example 31 with CatalogItem

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));
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SelectionModelStateSerializer(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModelStateSerializer) Operation(org.eclipse.epp.mpc.ui.Operation) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 32 with CatalogItem

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);
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) Test(org.junit.Test)

Example 33 with CatalogItem

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);
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) HashSet(java.util.HashSet)

Aggregations

CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)30 ArrayList (java.util.ArrayList)10 MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)9 Operation (org.eclipse.epp.mpc.ui.Operation)9 HashSet (java.util.HashSet)7 INode (org.eclipse.epp.mpc.core.model.INode)7 CoreException (org.eclipse.core.runtime.CoreException)6 IStatus (org.eclipse.core.runtime.IStatus)6 HashMap (java.util.HashMap)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Status (org.eclipse.core.runtime.Status)4 FeatureEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry)4 URISyntaxException (java.net.URISyntaxException)3 Entry (java.util.Map.Entry)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 CatalogCategory (org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)3 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)3