RobustIdentifiable implemented and tested + test impacts.
[xmlrouter] / impl / src / test / java / org / wamblee / xmlrouter / impl / TransformationPathsTest.java
index a45853272272806d0441b8958c12796b1868919f..33e16bfcd792d7f7bdded62c4febf585cfd0ebd1 100644 (file)
@@ -17,13 +17,12 @@ package org.wamblee.xmlrouter.impl;
 
 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;
@@ -41,8 +40,8 @@ public class TransformationPathsTest {
         }
 
         @Override
-        public String getName() {
-            return "myname";
+        public Id<Transformation> getId() {
+            return new Id<Transformation>("myname");
         }
 
         @Override
@@ -68,25 +67,19 @@ public class TransformationPathsTest {
 
     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());
@@ -106,14 +99,14 @@ public class TransformationPathsTest {
 
     @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"));
@@ -121,13 +114,15 @@ public class TransformationPathsTest {
 
     @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());