Source:
<code>public void testNotExistsNonInitialFragmentPartlyMerge() throws IOException { IExtension[] createExtensions = createExtensions( "org.eclipse.e4.ui.tests/data/ModelAssembler/fragment_notexists_partlyMerge.xml"); MTrimmedWindow mainTrimmedWindow = modelService.createModelElement(MTrimmedWindow.class); mainTrimmedWindow.setElementId("mainWindow"); MTrimBar trimBar = modelService.createModelElement(MTrimBar.class); trimBar.setElementId("TestApp.trimbar.top"); MToolBar toolBar = modelService.createModelElement(MToolBar.class); toolBar.setElementId("org.eclipse.ui.main.toolbar"); trimBar.getChildren().add(toolBar); mainTrimmedWindow.getTrimBars().add(trimBar); MCommand commandOpen = modelService.createModelElement(MCommand.class); <START> commandOpen.setElementId("command.open"); <END> MHandler handlerOpen = modelService.createModelElement(MHandler.class); handlerOpen.setCommand(commandOpen); handlerOpen.setElementId("handler.open"); application.getCommands().add(commandOpen); application.getHandlers().add(handlerOpen); application.getChildren().add(mainTrimmedWindow); assembler.processFragments(createExtensions, false); List<MHandledToolItem> foundElements = modelService.findElements(application, "handledtoolitem.open", MHandledToolItem.class); assertThat(foundElements, hasSize(1)); MHandledToolItem mToolItem = foundElements.get(0); assertThat(mToolItem.getCommand().getElementId(), equalTo(commandOpen.getElementId())); assertThat(mToolItem.getElementId(), equalTo("handledtoolitem.open")); }</code><technical_language>important is create elements XMI-ID elements in fragment. Elements compared XMI-ID, element ID</technical_language>

Target:
public void testNotExistsNonInitialFragmentPartlyMerge() throws IOException { IExtension[] createExtensions = createExtensions( "org.eclipse.e4.ui.tests/data/ModelAssembler/fragment_notexists_partlyMerge.xml"); MTrimmedWindow mainTrimmedWindow = modelService.createModelElement(MTrimmedWindow.class); mainTrimmedWindow.setElementId("mainWindow"); MTrimBar trimBar = modelService.createModelElement(MTrimBar.class); trimBar.setElementId("TestApp.trimbar.top"); MToolBar toolBar = modelService.createModelElement(MToolBar.class); toolBar.setElementId("org.eclipse.ui.main.toolbar"); trimBar.getChildren().add(toolBar); mainTrimmedWindow.getTrimBars().add(trimBar); MCommand commandOpen = modelService.createModelElement(MCommand.class); commandOpen.setElementId("command.open"); MHandler handlerOpen = modelService.createModelElement(MHandler.class); handlerOpen.setCommand(commandOpen); handlerOpen.setElementId("handler.open"); application.getCommands().add(commandOpen); application.getHandlers().add(handlerOpen); application.getChildren().add(mainTrimmedWindow); EObject eCommandOpen = (EObject) commandOpen; E4XMIResource rCommandOpen = (E4XMIResource) eCommandOpen.eResource(); rCommandOpen.setID(eCommandOpen, "_YlobgZQUEem9FqSgVrNMpA"); EObject eHandlerOpen = (EObject) handlerOpen; E4XMIResource rHandlerOpen = (E4XMIResource) eHandlerOpen.eResource(); rHandlerOpen.setID(eHandlerOpen, "_b7xQ4ZQUEem9FqSgVrNMpA"); assembler.processFragments(createExtensions, false); List<MHandledToolItem> foundElements = modelService.findElements(application, "handledtoolitem.open", MHandledToolItem.class); assertThat(foundElements, hasSize(1)); MHandledToolItem mToolItem = foundElements.get(0); assertThat(mToolItem.getCommand().getElementId(), equalTo(commandOpen.getElementId())); assertThat(mToolItem.getElementId(), equalTo("handledtoolitem.open")); }