vitruv-tools / Vitruv

View-based Development and Model Consistency Framework
http://vitruv.tools
Eclipse Public License 1.0
14 stars 19 forks source link

Support Resource URI Changes #365

Closed jGleitz closed 3 years ago

jGleitz commented 3 years ago

:warning: depends on #361 :warning:

Unfortunately, this does not work with change propagation. It breaks because the remove root change’s EChange is set to null during change propagation, which later yield an IllegalArgumentException. After hours of debugging, I still don’t understand what is going on.

@HeikoKlare, can you help?

HeikoKlare commented 3 years ago

I will have a look at it as soon as possible.

jGleitz commented 3 years ago

Thank you!

jGleitz commented 3 years ago

@HeikoKlare If you find the time to reproduce this, you can check out the branch execution-testing in my CBS fork.

If you execute tools.vitruv.applications.cbs.equivalencetests, you’ll see exceptions like the one below in the ‘renaming’ tests:

java.lang.IllegalArgumentException: Unhandled parameter types: [null] ``` at tools.vitruv.framework.change.description.impl.AbstractConcreteChange.getAffectedEObjects(AbstractConcreteChange.java:342) at tools.vitruv.framework.change.description.impl.AbstractConcreteChange.getAffectedNotReferencedEObjects(AbstractConcreteChange.java:121) at tools.vitruv.framework.change.description.impl.ConcreteApplicableChangeImpl.tryToSetUri(ConcreteApplicableChangeImpl.java:63) at tools.vitruv.framework.change.description.impl.ConcreteApplicableChangeImpl.resolveBeforeAndApplyForward(ConcreteApplicableChangeImpl.java:41) at tools.vitruv.framework.change.description.impl.CompositeTransactionalChangeImpl.resolveBeforeAndApplyForward(CompositeTransactionalChangeImpl.java:38) at tools.vitruv.framework.vsum.modelsynchronization.ChangePropagatorImpl.lambda$3(ChangePropagatorImpl.java:177) at tools.vitruv.framework.vsum.modelsynchronization.ChangePropagatorImpl$$Lambda$1041/000000000000000000.apply(Unknown Source) at tools.vitruv.framework.vsum.modelsynchronization.ChangePropagatorImpl$1.accept(ChangePropagatorImpl.java:192) at tools.vitruv.framework.vsum.modelsynchronization.ChangePropagatorImpl$1.accept(ChangePropagatorImpl.java:1) at tools.vitruv.framework.vsum.repositories.ResourceRepositoryImpl.lambda$16(ResourceRepositoryImpl.java:491) at tools.vitruv.framework.vsum.repositories.ResourceRepositoryImpl$$Lambda$980/000000000000000000.run(Unknown Source) at tools.vitruv.framework.util.command.EMFCommandBridge.lambda$1(EMFCommandBridge.java:46) at tools.vitruv.framework.util.command.EMFCommandBridge$$Lambda$947/000000000000000000.call(Unknown Source) at tools.vitruv.framework.util.command.EMFCommandBridge$1.doExecute(EMFCommandBridge.java:20) at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135) at org.eclipse.emf.common.command.BasicCommandStack.execute(BasicCommandStack.java:78) at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.basicExecute(AbstractTransactionalCommandStack.java:241) at org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl.doExecute(TransactionalCommandStackImpl.java:63) at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165) at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219) at tools.vitruv.framework.util.command.VitruviusRecordingCommand.executeAndRethrowException(VitruviusRecordingCommand.java:73) at tools.vitruv.framework.util.command.EMFCommandBridge.lambda$2(EMFCommandBridge.java:51) at tools.vitruv.framework.util.command.EMFCommandBridge$$Lambda$950/000000000000000000.apply(Unknown Source) at org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow(ObjectExtensions.java:140) at tools.vitruv.framework.util.command.EMFCommandBridge.executeVitruviusRecordingCommand(EMFCommandBridge.java:53) at tools.vitruv.framework.vsum.repositories.ResourceRepositoryImpl.executeAsCommand(ResourceRepositoryImpl.java:485) at tools.vitruv.framework.vsum.repositories.ResourceRepositoryImpl.executeOnUuidResolver(ResourceRepositoryImpl.java:493) at tools.vitruv.framework.vsum.modelsynchronization.ChangePropagatorImpl.applyAndPropagateSingleChange(ChangePropagatorImpl.java:190) at tools.vitruv.framework.vsum.modelsynchronization.ChangePropagatorImpl.propagateChange(ChangePropagatorImpl.java:130) at tools.vitruv.framework.vsum.VirtualModelImpl.propagateChange(VirtualModelImpl.java:154) at tools.vitruv.testutils.ChangePublishingTestView.lambda$0(ChangePublishingTestView.java:82) at tools.vitruv.testutils.ChangePublishingTestView$$Lambda$987/000000000000000000.apply(Unknown Source) at tools.vitruv.testutils.ChangePublishingTestView.lambda$1(ChangePublishingTestView.java:125) at tools.vitruv.testutils.ChangePublishingTestView$$Lambda$1043/000000000000000000.apply(Unknown Source) at org.eclipse.xtext.xbase.lib.internal.FunctionDelegate.apply(FunctionDelegate.java:43) at com.google.common.collect.Iterators$6.transform(Iterators.java:783) at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47) at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47) at com.google.common.collect.Iterators$ConcatenatedIterator.hasNext(Iterators.java:1330) at com.google.common.collect.Iterators.addAll(Iterators.java:355) at com.google.common.collect.Lists.newArrayList(Lists.java:143) at com.google.common.collect.Lists.newArrayList(Lists.java:130) at org.eclipse.xtext.xbase.lib.IterableExtensions.toList(IterableExtensions.java:621) at tools.vitruv.testutils.ChangePublishingTestView.propagate(ChangePublishingTestView.java:127) at tools.vitruv.testutils.ChangePublishingTestView.propagate(ChangePublishingTestView.java:113) at tools.vitruv.applications.cbs.testutils.equivalencetest.EquivalenceTestExecutable$DirectoryTestView.propagate(EquivalenceTestExecutable.java:122) at tools.vitruv.applications.cbs.equivalencetesttemplates.RepositoryEquivalenceTemplate.lambda$23(RepositoryEquivalenceTemplate.java:144) at tools.vitruv.applications.cbs.equivalencetesttemplates.RepositoryEquivalenceTemplate$$Lambda$1286/000000000000000000.accept(Unknown Source) at tools.vitruv.applications.cbs.testutils.equivalencetest.MainStep.executeIn(MainStep.java:27) at tools.vitruv.applications.cbs.testutils.equivalencetest.EquivalenceTestExecutable._execute_with_safe_resources(EquivalenceTestExecutable.java:453) at tools.vitruv.applications.cbs.testutils.equivalencetest.EquivalenceTestExecutable.execute(EquivalenceTestExecutable.java:245) at tools.vitruv.applications.cbs.testutils.equivalencetest.EquivalenceTestExecutable.execute(EquivalenceTestExecutable.java:240) at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.lambda$execute$0(DynamicTestTestDescriptor.java:52) at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor$$Lambda$995/000000000000000000.proceed(Unknown Source) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.api.extension.InvocationInterceptor.interceptDynamicTest(InvocationInterceptor.java:161) at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.lambda$execute$1(DynamicTestTestDescriptor.java:58) at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor$$Lambda$996/000000000000000000.apply(Unknown Source) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptorCall.lambda$ofVoid$0(InvocationInterceptorChain.java:78) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptorCall$$Lambda$997/000000000000000000.apply(Unknown Source) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:57) at org.junit.jupiter.engine.descriptor.DynamicTestTestDescriptor.execute(DynamicTestTestDescriptor.java:31) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$841/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$840/000000000000000000.invoke(Unknown Source) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$839/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:212) at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:192) at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor$$Lambda$989/000000000000000000.accept(Unknown Source) at java.base/java.util.Optional.ifPresent(Optional.java:183) at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:106) at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor$$Lambda$971/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:93) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$841/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$840/000000000000000000.invoke(Unknown Source) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$839/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$845/000000000000000000.accept(Unknown Source) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$841/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$840/000000000000000000.invoke(Unknown Source) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$839/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$845/000000000000000000.accept(Unknown Source) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$841/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$840/000000000000000000.invoke(Unknown Source) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$839/000000000000000000.execute(Unknown Source) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator$$Lambda$822/000000000000000000.accept(Unknown Source) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84) at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464) at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:117) at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:45) at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$$Lambda$640/000000000000000000.run(Unknown Source) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:5023) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4529) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1157) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644) at org.eclipse.ui.internal.Workbench$$Lambda$126/000000000000000000.run(Unknown Source) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:53) at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:47) at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:48) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590) at org.eclipse.equinox.launcher.Main.run(Main.java:1461) at org.eclipse.equinox.launcher.Main.main(Main.java:1434) Suppressed: java.lang.IllegalStateException at tools.vitruv.framework.change.recording.AtomicEmfChangeRecorder.stopRecording(AtomicEmfChangeRecorder.java:112) at tools.vitruv.testutils.ChangePublishingTestView.close(ChangePublishingTestView.java:91) at tools.vitruv.applications.cbs.testutils.equivalencetest.EquivalenceTestExecutable$DirectoryTestView.close(EquivalenceTestExecutable.java:90) at tools.vitruv.applications.cbs.testutils.equivalencetest.EquivalenceTestExecutable.execute(EquivalenceTestExecutable.java:246) ... 125 more ```
jGleitz commented 3 years ago

@HeikoKlare you’ll need to do this against my continue branch, otherwise, the CBS branch won’t compile. The continue branch also contains the changes of this branch.

jGleitz commented 3 years ago

Since I got all my changes in, you should be able to reproduce the problem directly from this branch, no need for the continue branch anymore.

HeikoKlare commented 3 years ago

I have now taken a look into this. The problem seems to be that when changing the URI of a resource, both the remove and insert root changes reference the new resource and contain the new URI. Unresolving the change removes the resource and only the URI remains. This URI is, however, invalid for the old state, which is why the change cannot be resolved in the VirtualModel. It then fails when resolving the change in this line.

HeikoKlare commented 3 years ago

Oh, well, and if you then replace in the PackageCreated reaction of Java2PcmClassifier.reactions the trigger inserted as root with created and inserted as root, you will also avoid to retrigger the reaction after moving a package and avoid the faulty user interaction coming up.

HeikoKlare commented 3 years ago

I've pushed changes that should resolve the URI problem and produce properly resolvable changes. @jGleitz Can you tell me whether the changes are fine for you now?

Please note that despite the improved recording, the way how the Reactions consider root element changes is often rather strange in the current implementations. For example, the Java2PCM transformation does not properly handle root element renamings, because the Reactions for their creation apply to these changes as well (as they do not check for creations). This is because the changes generated by the Java code monitor do not produce create changes right now. This is, of course, an inappropriateness in the Java code monitor. However, Reactions should usually not be run after creating an element anyway, but after setting all relevant properties that are necessary to propagate it (which is, in most cases, at least the element name). Thus, for example, the transformation of a package should not depend on its creation but on the initial setting of its name.

jGleitz commented 3 years ago

It seems that your changes did the trick :+1:

Let’s merge!