[Bugfix] added missing cloning of StringSetTimedState in Resources

This commit is contained in:
Robert von Burg 2014-10-04 17:06:58 +02:00
parent d55371e9b7
commit c1cdfbb4ea
8 changed files with 56 additions and 8 deletions

View File

@ -172,6 +172,10 @@ public class Resource extends GroupedParameterizedElement implements StrolchRoot
super.fillClone(clone);
for (StrolchTimedState<IValue<?>> timedState : this.timedStateMap.values()) {
clone.addTimedState(timedState.getClone());
}
return clone;
}

View File

@ -17,7 +17,6 @@ package li.strolch.model.timedstate;
import java.util.SortedSet;
import li.strolch.model.StrolchElement;
import li.strolch.model.Tags;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.impl.BooleanValue;
@ -82,7 +81,7 @@ public class BooleanTimedState extends AbstractStrolchTimedState<BooleanValue> {
}
@Override
public StrolchElement getClone() {
public BooleanTimedState getClone() {
BooleanTimedState clone = new BooleanTimedState();
fillClone(clone);
return clone;

View File

@ -17,7 +17,6 @@ package li.strolch.model.timedstate;
import java.util.SortedSet;
import li.strolch.model.StrolchElement;
import li.strolch.model.Tags;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.impl.FloatValue;
@ -82,7 +81,7 @@ public class FloatTimedState extends AbstractStrolchTimedState<FloatValue> {
}
@Override
public StrolchElement getClone() {
public FloatTimedState getClone() {
FloatTimedState clone = new FloatTimedState();
fillClone(clone);
return clone;

View File

@ -17,7 +17,6 @@ package li.strolch.model.timedstate;
import java.util.SortedSet;
import li.strolch.model.StrolchElement;
import li.strolch.model.Tags;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.impl.IntegerValue;
@ -82,7 +81,7 @@ public class IntegerTimedState extends AbstractStrolchTimedState<IntegerValue> {
}
@Override
public StrolchElement getClone() {
public IntegerTimedState getClone() {
IntegerTimedState clone = new IntegerTimedState();
fillClone(clone);
return clone;

View File

@ -20,7 +20,6 @@ import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import li.strolch.model.StrolchElement;
import li.strolch.model.Tags;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.impl.AString;
@ -105,7 +104,7 @@ public class StringSetTimedState extends AbstractStrolchTimedState<StringSetValu
}
@Override
public StrolchElement getClone() {
public StringSetTimedState getClone() {
StringSetTimedState clone = new StringSetTimedState();
fillClone(clone);
return clone;

View File

@ -112,5 +112,8 @@ public interface StrolchTimedState<T extends IValue> extends StrolchElement {
public void setParent(Resource aThis);
@Override
public StrolchTimedState<T> getClone();
public <U> U accept(TimedStateVisitor visitor);
}

View File

@ -130,6 +130,25 @@ public class ModelTest {
assertTrue("Same Resource should be deep equal!", visitor.isEqual());
}
@Test
public void shouldPerformResourceClone() {
Resource srcRes = createResource("@res01", "Test resource", "MyType");
Resource dstRes = srcRes.getClone();
ResourceDeepEqualsVisitor visitor = new ResourceDeepEqualsVisitor(srcRes);
visitor.visit(dstRes);
assertTrue("Cloned Resource should be deep equal!", visitor.isEqual());
}
@Test
public void shouldPerformOrderClone() {
Date date = new Date();
Order srcOrder = createOrder("@ord01", "Test Order", "MyType", date, State.OPEN);
Order dstOrder = srcOrder.getClone();
OrderDeepEqualsVisitor visitor = new OrderDeepEqualsVisitor(srcOrder);
visitor.visit(dstOrder);
assertTrue("Cloned Order should be deep equal: " + visitor.getMismatchedLocators(), visitor.isEqual());
}
@Test
public void shouldFailDeepResourceEquals1() {
Resource srcRes = createResource("@res01", "Test resource", "MyType");

View File

@ -14,5 +14,31 @@
<Parameter Id="@param2" Name="Float Param" Type="Float" Value="44.3" />
<Parameter Id="@param1" Name="Boolean Param" Type="Boolean" Value="true" />
</ParameterBag>
<TimedState Id="@booleanState" Name="Boolean State" Type="BooleanState">
<Value Time="0" Value="false" />
<Value Time="1" Value="true" />
<Value Time="2" Value="false" />
</TimedState>
<TimedState Id="@integerState" Name="Integer State" Type="IntegerState">
<Value Time="0" Value="1" />
<Value Time="1" Value="2" />
<Value Time="2" Value="3" />
<Value Time="3" Value="2" />
<Value Time="4" Value="1" />
<Value Time="5" Value="0" />
</TimedState>
<TimedState Id="@floatState" Name="Float State" Type="FloatState">
<Value Time="0" Value="1.1" />
<Value Time="1" Value="2.2" />
<Value Time="2" Value="3.3" />
<Value Time="3" Value="2.2" />
<Value Time="4" Value="1.1" />
<Value Time="5" Value="0.0" />
</TimedState>
<TimedState Id="@stringSetState" Name="StringSet State" Type="StringSetState">
<Value Time="0" Value="foo" />
<Value Time="1" Value="foo, bar" />
<Value Time="2" Value="bar" />
</TimedState>
</Resource>
</StrolchModel>