[MGNLUI-1418] JcrPropertyAdapter does not support changing both value and type Created: 21/May/13 Updated: 03/Apr/18 Resolved: 03/Apr/18 |
|
| Status: | Closed |
| Project: | Magnolia UI |
| Component/s: | framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Tobias Mattsson | Assignee: | Unassigned |
| Resolution: | Obsolete | Votes: | 0 |
| Labels: | adapters | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
The following test case fails: A property of type Integer with value 123 is to be changed to a String with value 'newValue'
@Test
public void testUpdatePropertyValueAndType() throws Exception {
// GIVEN
Node node = session.getRootNode();
node.setProperty(propertyName, 123);
JcrPropertyAdapter adapter = new JcrPropertyAdapter(node.getProperty(propertyName));
// WHEN
adapter.getItemProperty(JcrPropertyAdapter.TYPE_PROPERTY).setValue("String");
adapter.getItemProperty(JcrPropertyAdapter.VALUE_PROPERTY).setValue("newValue");
adapter.applyChanges();
// THEN
assertTrue(node.hasProperty(propertyName));
assertEquals(PropertyType.STRING, node.getProperty(propertyName).getType());
assertEquals("newValue", node.getProperty(propertyName).getString());
}
The failure is a ClassCastException in DefaultProperty that was added in com.vaadin.data.util.converter.Converter$ConversionException: Cannot convert class java.lang.String to class java.lang.Long at info.magnolia.ui.vaadin.integration.jcr.DefaultProperty.setValue(DefaultProperty.java:69) at info.magnolia.ui.vaadin.integration.jcr.JcrPropertyAdapterTest.testUpdatePropertyValueAndType(JcrPropertyAdapterTest.java:360) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) There's also an ignored testcase that seems to be related info.magnolia.ui.vaadin.integration.jcr.JcrPropertyAdapterTest#testUpdatePropertyValueKeepsPropertyType |
| Comments |
| Comment by Tobias Mattsson [ 22/May/13 ] |
|
It seems tis not enough to remove the conversion check in DefaultProperty, in JcrPropertyAdapter we change the property in steps, one for name, one for value, one for type. |
| Comment by Mikaël Geljić [ 03/Apr/18 ] |
|
Given test passes nowadays too |