Search in sources :

Example 1 with SelectionModelStateSerializer

use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModelStateSerializer 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)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SelectionModelStateSerializer (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModelStateSerializer)1 Operation (org.eclipse.epp.mpc.ui.Operation)1 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1