removed the prefix argument from ConfigImpl.wrap().
authorErik Brakkee <erik@brakkee.org>
Tue, 9 Aug 2011 15:30:59 +0000 (17:30 +0200)
committerErik Brakkee <erik@brakkee.org>
Tue, 9 Aug 2011 15:30:59 +0000 (17:30 +0200)
12 files changed:
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java
impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustIdentifiableTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java

index 0e1da0be84853fb6b7690d5ddecfef1f1bd3c3ed..777ecd0ac2c45864328605eeff9955419197673a 100644 (file)
@@ -88,7 +88,7 @@ public abstract class ConfigImpl<T extends Identifiable<T>> implements
         if (registered.containsKey(aT.getId())) {
             throw new ConfigException("Duplicate id '" + aT.getId() + "'");
         }
-        registered.put(aT.getId(), wrap(id.getId() + ".", aT));
+        registered.put(aT.getId(), wrap(aT));
     }
 
     /**
@@ -98,7 +98,7 @@ public abstract class ConfigImpl<T extends Identifiable<T>> implements
      *            Object to wrap.
      * @return Wrapped object.
      */
-    public abstract T wrap(String aPrefix, T aT);
+    public abstract T wrap(T aT);
 
     /*
      * (non-Javadoc)
index 3f26f7b7c761fd57b2677ae9f5cd63f86d68286f..52244837dda20bcc70de5513c7c87be487a59857 100644 (file)
@@ -45,8 +45,8 @@ public class RobustDocumentType extends RobustIdentifiable<DocumentType>
      * @param aType
      *            Document type to wrap.
      */
-    public RobustDocumentType(String aPrefix, DocumentType aType) {
-        super(aPrefix, aType);
+    public RobustDocumentType(DocumentType aType) {
+        super(aType);
         type = aType;
     }
 
index 823c64d77276a2c0ff0abd9a70ad544b33c352be..625f8945ca5fb3063f79994acf26cca9ac340e33 100644 (file)
@@ -38,15 +38,13 @@ public class RobustFilter extends RobustIdentifiable<Filter> implements Filter {
     /**
      * Constructs the wrapper.
      * 
-     * @param aPrefix
-     *            prefix to use for ids.
      * @param aId
      *            Id.
      * @param aFilter
      *            Filter to wrap.
      */
     public RobustFilter(String aPrefix, Filter aFilter) {
-        super(aPrefix, aFilter);
+        super(aFilter);
         filter = aFilter;
     }
 
index 47b000055ea98025606c59d7a55d84daa8dcb1f4..2e63a9799901f2616e6fdc6fc1438c80adf570a1 100644 (file)
@@ -38,15 +38,13 @@ public class RobustIdentifiable<T> implements Identifiable<T> {
 
     private Id<T> id;
 
-    public RobustIdentifiable(String aPrefix, Identifiable<T> aIdentifiable) {
-        notNull("prefix", aPrefix);
+    public RobustIdentifiable(Identifiable<T> aIdentifiable) {
         notNull("identifiable", aIdentifiable);
         try {
             id = aIdentifiable.getId();
             if (id == null) {
                 throwConfigException("identifiable.getId() returned null", null);
             }
-            id = new Id<T>(aPrefix + id.getId());
         } catch (Exception e) {
             throwConfigException("identifiable.getId() threw exception", e);
         }
index cf0210d3094045b85e5a9c4d36b1b0ce4475bf52..2fa025e005a836410517332d8f7ff2b3053ffbf7 100644 (file)
@@ -45,8 +45,8 @@ public class RobustTransformation extends RobustIdentifiable<Transformation>
      * @param aTransformation
      *            Wrapped transformation.
      */
-    public RobustTransformation(String aPrefix, Transformation aTransformation) {
-        super(aPrefix, aTransformation);
+    public RobustTransformation(Transformation aTransformation) {
+        super(aTransformation);
         transformation = aTransformation;
     }
 
index 4ecaad4a35d633679620f791426242f868784b35..d7d8070ca00fff7d311288e1f14db4bd3b63d2cb 100644 (file)
@@ -42,8 +42,8 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
 
         @Override
-        public DocumentType wrap(String aPrefix, DocumentType aT) {
-            return new RobustDocumentType("", aT);
+        public DocumentType wrap(DocumentType aT) {
+            return new RobustDocumentType(aT);
         }
     }
 
@@ -58,9 +58,8 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
 
         @Override
-        public Transformation wrap(String aPrefix,
-            Transformation aTransformation) {
-            return new RobustTransformation("", aTransformation);
+        public Transformation wrap(Transformation aTransformation) {
+            return new RobustTransformation(aTransformation);
         }
     }
 
@@ -74,7 +73,7 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
 
         @Override
-        public Filter wrap(String aPrefix, Filter aFilter) {
+        public Filter wrap(Filter aFilter) {
             return new RobustFilter("", aFilter);
         }
     }
index da883d241155f18b9196c4a9c9e3c7919d9b1fde..198855ee2752c9f5e2f38cce6908bd898b29dedf 100644 (file)
@@ -46,11 +46,11 @@ public class XMLRouterConfigService implements RouterConfigService {
         config = aConfig;
         routerConfigs = new ConfigImpl<RouterConfig>(RouterConfig.class,
             new Id<Config>(aApplication)) {
-            public RouterConfig wrap(final String aPrefix, final RouterConfig aT) {
+            public RouterConfig wrap(final RouterConfig aT) {
                 return new RouterConfig() {
                     @Override
                     public Id<RouterConfig> getId() {
-                        return new Id<RouterConfig>(aT.getId().toString());
+                        return aT.getId();
                     }
 
                     @Override
index cd0879d59cbcc3b98cb737bbda2c53b1ab1d8fb8..efca7216cf4262de03de06fd04703e361125d8a9 100644 (file)
@@ -90,14 +90,14 @@ public class CompositeConfigTest {
         Config<StringClassInterface> c1 = new ConfigImpl(
             StringClassInterface.class, id("c1")) {
             @Override
-            public Identifiable wrap(String aPrefix, Identifiable aT) {
+            public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
         Config<StringClassInterface> c2 = new ConfigImpl(
             StringClassInterface.class, id("c2")) {
             @Override
-            public Identifiable wrap(String aPrefix, Identifiable aT) {
+            public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
@@ -141,14 +141,14 @@ public class CompositeConfigTest {
         Config<StringClassInterface> c1 = new ConfigImpl(
             StringClassInterface.class, id("c1")) {
             @Override
-            public Identifiable wrap(String aPrefix, Identifiable aT) {
+            public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
         Config<StringClassInterface> c2 = new ConfigImpl(
             StringClassInterface.class, id("c1")) {
             @Override
-            public Identifiable wrap(String aPrefix, Identifiable aT) {
+            public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
@@ -162,14 +162,14 @@ public class CompositeConfigTest {
         Config<StringClassInterface> c1 = new ConfigImpl(
             StringClassInterface.class, id("c.x")) {
             @Override
-            public Identifiable wrap(String aPrefix, Identifiable aT) {
+            public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
         Config<StringClassInterface> c2 = new ConfigImpl(
             StringClassInterface.class, id("c")) {
             @Override
-            public Identifiable wrap(String aPrefix, Identifiable aT) {
+            public Identifiable wrap(Identifiable aT) {
                 return aT;
             }
         };
index 85860122b71c75bcac18fb61a6b469e000ffb780..9925c0b74a7637aa6065cca0cd7a49a7f597474f 100644 (file)
@@ -35,11 +35,9 @@ public class ConfigImplTest {
     }
 
     private static class MyTypeWrapper implements MyType {
-        private String prefix;
         private MyType type;
 
-        public MyTypeWrapper(String aPrefix, MyType aType) {
-            prefix = aPrefix;
+        public MyTypeWrapper(MyType aType) {
             type = aType;
         }
 
@@ -49,7 +47,7 @@ public class ConfigImplTest {
 
         @Override
         public Id getId() {
-            return new Id(prefix + type.getId().getId());
+            return type.getId();
         }
     }
 
@@ -63,8 +61,8 @@ public class ConfigImplTest {
         }
 
         @Override
-        public MyType wrap(String aPrefix, MyType aT) {
-            return new MyTypeWrapper(aPrefix, aT);
+        public MyType wrap(MyType aT) {
+            return new MyTypeWrapper(aT);
         }
     }
 
@@ -89,8 +87,7 @@ public class ConfigImplTest {
 
         assertTrue(firstValue instanceof MyTypeWrapper);
         assertSame(type1, ((MyTypeWrapper) firstValue).getType());
-        assertEquals(CONFIG_TYPE + "." + type1.getId().getId(), firstValue
-            .getId().getId());
+        assertEquals(type1.getId().getId(), firstValue.getId().getId());
 
         // add another one.
         MyType type2 = mock(MyType.class);
index 2c295b59623fd071cb3fe0627eaa67a5af106d30..8db9ff25fe2d855381c4e9c258dd6ada67c728b9 100644 (file)
@@ -36,7 +36,7 @@ public class RobustDocumentTypeTest {
     public void setUp() {
         documentType = mock(DocumentType.class);
         when(documentType.getId()).thenReturn(new Id<DocumentType>("docid"));
-        robust = new RobustDocumentType("app1", documentType);
+        robust = new RobustDocumentType(documentType);
         source = mock(DOMSource.class);
     }
 
index 257ea93a171d93c99ded1fa7ff9e27e4e027ac18..86d55ab921c07230edb3cf4ac76592a7a1715d02 100644 (file)
@@ -37,26 +37,26 @@ public class RobustIdentifiableTest {
     public void testIdIsNull() {
         when(ident.getId()).thenReturn(null);
         RobustIdentifiable<Integer> robust = new RobustIdentifiable<Integer>(
-            "prefix", ident);
+            ident);
     }
 
     @Test(expected = ConfigException.class)
     public void testIdThrowsException() {
         doThrow(new RuntimeException("xxx")).when(ident).getId();
         RobustIdentifiable<Integer> robust = new RobustIdentifiable<Integer>(
-            "prefix", ident);
+            ident);
     }
 
     @Test
     public void testNormalCase() {
         when(ident.getId()).thenReturn(new Id<Integer>("myid"));
         RobustIdentifiable<Integer> robust = new RobustIdentifiable<Integer>(
-            "prefix.", ident);
-        assertEquals("prefix.myid", robust.getId().toString());
+            ident);
+        assertEquals("myid", robust.getId().toString());
 
         // changes later do not have any effect, the id should be immutable.
         when(ident.getId()).thenReturn(new Id<Integer>("myid2"));
-        assertEquals("prefix.myid", robust.getId().toString());
+        assertEquals("myid", robust.getId().toString());
     }
 
     @Test
@@ -70,11 +70,11 @@ public class RobustIdentifiableTest {
         when(ident3.getId()).thenReturn(new Id<Integer>("x"));
 
         RobustIdentifiable<Integer> robust1 = new RobustIdentifiable<Integer>(
-            "prefix.", ident1);
+            ident1);
         RobustIdentifiable<Integer> robust2 = new RobustIdentifiable<Integer>(
-            "prefix.", ident2);
+            ident2);
         RobustIdentifiable<Integer> robust3 = new RobustIdentifiable<Integer>(
-            "prefix.", ident3);
+            ident3);
 
         assertEquals(robust1, robust1);
         assertEquals(robust1, robust3);
index 5e73d6fe239ab0557f12c9d701a63e1ae958433d..f7b4ec6a88a4545a535ef995fc693747062d4492 100644 (file)
@@ -36,7 +36,7 @@ public class RobustTransformationTest {
     public void setUp() {
         transformation = mock(Transformation.class);
         when(transformation.getId()).thenReturn(new Id<Transformation>("t1"));
-        robust = new RobustTransformation("transformation", transformation);
+        robust = new RobustTransformation(transformation);
         source = mock(DOMSource.class);
         resSource = mock(DOMSource.class);
     }