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