import static junit.framework.Assert.*;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.List;
import javax.xml.transform.dom.DOMSource;
-import org.junit.Before;
import org.junit.Test;
import org.wamblee.xmlrouter.common.Id;
import org.wamblee.xmlrouter.config.Transformation;
}
@Override
- public String getName() {
- return "myname";
+ public Id<Transformation> getId() {
+ return new Id<Transformation>("myname");
}
@Override
private TransformationPaths transformations;
- @Before
- public void setUp() {
- transformations = new TransformationPaths();
- }
-
- private Map<Id<Transformation>, Transformation> createTransformations(
- long aStartId, Transformation... aTransformations) {
- Map<Id<Transformation>, Transformation> res = new LinkedHashMap<Id<Transformation>, Transformation>();
+ private List<Transformation> createTransformations(long aStartId,
+ Transformation... aTransformations) {
+ List<Transformation> res = new ArrayList<Transformation>();
- long id = aStartId;
for (Transformation t : aTransformations) {
- res.put(new Id<Transformation>(id++), t);
+ res.add(t);
}
return res;
}
@Test
public void testOneTransformation() {
- transformations.replaceTransformations(createTransformations(10L,
+ transformations = new TransformationPaths(createTransformations(10L,
new MyTransformation("A", "B")));
System.out.println(transformations.toString());
@Test
public void testMultipleTransformations() {
- transformations.replaceTransformations(createTransformations(10L,
+ transformations = new TransformationPaths(createTransformations(10L,
new MyTransformation("A", "B"), new MyTransformation("B", "C"),
new MyTransformation("C", "A")));
System.out.println(transformations);
assertEquals(2, transformations.getPath("C", "B").size());
- transformations.replaceTransformations(createTransformations(10L,
+ transformations = new TransformationPaths(createTransformations(10L,
new MyTransformation("B", "C"), new MyTransformation("C", "A")));
assertNull(transformations.getPath("C", "B"));
@Test
public void testUnknownDestination() {
- transformations.replaceTransformations(createTransformations(10L,
+ transformations = new TransformationPaths(createTransformations(10L,
new MyTransformation("A", "B")));
assertNull(transformations.getPath("A", "D"));
}
@Test
public void testWithoutTransformations() {
+ transformations = new TransformationPaths(
+ new ArrayList<Transformation>());
Collection<String> res = transformations.getPossibleTargetTypes("a");
assertEquals(1, res.size());