@Override public void migrateBefore(Model model, Metamodel metamodel) throws MigrationException { for (Instance group : model.getAllInstances("process.Group")) { addReportChange( (String) group.get("name"), Messages.actorSelector, group.getContainer().getUuid(), Messages.removeGroupMigrationDescription, Messages.actorProperty, IStatus.ERROR); model.delete(group); } for (Instance assignable : model.getAllInstances("process.Assignable")) { final List<Instance> filters = assignable.get("filters"); for (Instance filter : filters) { addReportChange( (String) filter.get("name"), Messages.actorSelector, filter.getContainer().getUuid(), Messages.removeFilterMigrationDescription, Messages.actorProperty, IStatus.ERROR); model.delete(filter); } } }
@Test public void should_migrateAfter_update_version_in_connector_configuration() throws Exception { // Given doCallRealMethod().when(updateConnectorVersionMigration).migrateAfter(model, metamodel); final EList<Instance> connectorConfigInstanceList = connectorConfiguratiobInstanceList("id1", "id2"); final Instance oldConnectorConfInstance = aConnectorConfigurationInstance("id1", "0.9"); connectorConfigInstanceList.add(oldConnectorConfInstance); when(model.getAllInstances("connectorconfiguration.ConnectorConfiguration")) .thenReturn(connectorConfigInstanceList); when(model.getAllInstances("process.Connector")).thenReturn(new BasicEList<Instance>()); when(updateConnectorVersionMigration.shouldUpdateVersion("id1")).thenReturn(true); when(updateConnectorVersionMigration.getOldDefinitionVersion()).thenReturn("1.0"); when(updateConnectorVersionMigration.getNewDefinitionVersion()).thenReturn("2.0"); // When updateConnectorVersionMigration.migrateAfter(model, metamodel); // Then final Instance id1ConnectorConf = connectorConfigInstanceList.get(0); final Instance id2ConnectorConf = connectorConfigInstanceList.get(1); verify(id1ConnectorConf).set(UpdateConnectorVersionMigration.VERSION_FEATURE_NAME, "2.0"); verify(id2ConnectorConf, never()) .set(UpdateConnectorVersionMigration.VERSION_FEATURE_NAME, "2.0"); verify(oldConnectorConfInstance, never()) .set(UpdateConnectorVersionMigration.VERSION_FEATURE_NAME, "2.0"); }
/* (non-Javadoc) * @see org.eclipse.emf.edapt.migration.CustomMigration#migrateAfter(org.eclipse.emf.edapt.spi.migration.Model, org.eclipse.emf.edapt.migration.Metamodel) */ @Override public void migrateAfter(final Model model, final Metamodel metamodel) throws MigrationException { for (final Instance diagramInstance : model.getAllInstances("process.MainProcess")) { final List<Instance> datatypes = diagramInstance.get("datatypes"); if (!containsBusinessObjectType(datatypes)) { final Instance datatypeInstance = model.newInstance("process.BusinessObjectType"); datatypeInstance.set("name", NamingUtils.convertToId(DataTypeLabels.businessObjectType)); diagramInstance.add("datatypes", datatypeInstance); } } }