Skip to content
Snippets Groups Projects
Commit 6bff6ff0 authored by René Schöne's avatar René Schöne
Browse files

Remove more unnecessary errors in tests.

parent 16eb24d8
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,8 @@ import de.tudresden.inf.st.eraser.jastadd.model.*;
import org.junit.Assert;
import org.junit.Test;
import java.util.function.Consumer;
/**
* Testing the simple rule engine.
*
......@@ -61,21 +63,17 @@ public class ControllingItemTest {
Group g = TestUtils.getDefaultGroup(model);
StringItem stringItem = new StringItem();
stringItem.setState("0");
initAndAddItem(g, stringItem);
StringItem stringItem = initAndAddItem(g, new StringItem(),
item -> item.setState("0"));
SwitchItem booleanItem = new SwitchItem();
booleanItem.setState(false);
initAndAddItem(g, booleanItem);
SwitchItem booleanItem = initAndAddItem(g, new SwitchItem(),
item -> item.setState(false));
ColorItem colorItem = new ColorItem();
colorItem.setState(TupleHSB.of(0, 0, 0));
initAndAddItem(g, colorItem);
ColorItem colorItem = initAndAddItem(g, new ColorItem(),
item -> item.setState(TupleHSB.of(0, 0, 0)));
ColorItem target = new ColorItem();
target.setState(TupleHSB.of(0, 0, 0));
initAndAddItem(g, target);
ColorItem target = initAndAddItem(g, new ColorItem(),
item -> item.setState(TupleHSB.of(0, 0, 0)));
target.addControlledBy(numberItem);
target.addControlledBy(stringItem);
......@@ -119,9 +117,11 @@ public class ControllingItemTest {
Assert.assertEquals("Item was not controlled correctly", TupleHSB.of(33, 33, 44), target.getState());
}
private void initAndAddItem(Group group, Item item) {
item.enableSendState();
private <T extends Item> T initAndAddItem(Group group, T item, Consumer<T> setState) {
item.setID("item" + group.getNumItem());
group.addItem(item);
setState.accept(item);
item.enableSendState();
return item;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment