From: Erik Brakkee Date: Mon, 8 Aug 2011 21:08:59 +0000 (+0200) Subject: simplifications. X-Git-Tag: PAX_EXAM_MOCKITO_ISSUE~12 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=ef3c789029b09fe8bc279a07a7b2208e286957f0;p=xmlrouter simplifications. --- diff --git a/config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java b/config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java index 60eaa61..9656441 100644 --- a/config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java +++ b/config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java @@ -25,9 +25,6 @@ import org.wamblee.xmlrouter.common.Id; */ public interface RouterConfigService { - // TODO must deal with conflicts with ids provided by applications and those - // used by the xmlrouter internally. - /** * @return New empty configuration. */ diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java index d837f17..c9e250e 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java @@ -37,23 +37,21 @@ import org.wamblee.xmlrouter.config.Identifiable; public class CompositeConfig> implements ExtendedConfig { + private static final Id ID = new Id("compositeconfig"); private static final String READ_ONLY_INSTANCE = "read only instance"; private Set> ids; - private Id id; private List> valueIds; private List values; - public CompositeConfig(Id aId) { - notNull("aId", aId); + public CompositeConfig() { ids = new HashSet>(); - id = aId; valueIds = new ArrayList>(); values = new ArrayList(); } @Override public Id getId() { - return id; + return ID; } public void addConfig(Config aConfig) { diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeRouterConfig.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeRouterConfig.java index 08a95de..eabbf3e 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeRouterConfig.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeRouterConfig.java @@ -24,22 +24,19 @@ import org.wamblee.xmlrouter.config.Filter; import org.wamblee.xmlrouter.config.RouterConfig; import org.wamblee.xmlrouter.config.Transformation; -// TODO test this class. public class CompositeRouterConfig implements ExtendedRouterConfig { - private Id id; + private static final Id ID = new Id( + "compositerouterconfig"); private CompositeConfig documentTypes; private CompositeConfig transformations; private CompositeConfig filters; public CompositeRouterConfig(Id aId, Collection aConfigs) { - id = aId; - documentTypes = new CompositeConfig(new Id( - "documentTypes")); - transformations = new CompositeConfig(new Id( - "transformations")); - filters = new CompositeConfig(new Id("filters")); + documentTypes = new CompositeConfig(); + transformations = new CompositeConfig(); + filters = new CompositeConfig(); for (RouterConfig config : aConfigs) { documentTypes.addConfig(config.documentTypeConfig()); transformations.addConfig(config.transformationConfig()); @@ -47,11 +44,9 @@ public class CompositeRouterConfig implements ExtendedRouterConfig { } } - // TODO test id. - @Override public Id getId() { - return id; + return ID; } @Override diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java index 75b8222..980bd07 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java @@ -33,8 +33,6 @@ import org.wamblee.xmlrouter.config.Identifiable; * * @param */ -// TODO make sure that each item inside this config is prefixed with the id of -// the config. public abstract class ConfigImpl> implements ExtendedConfig { diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java index f0bf090..40cbcc5 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java @@ -69,7 +69,6 @@ public class SingleRouterConfig implements ExtendedRouterConfig { }; } - // TODO test getId. @Override public Id getId() { return id; diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java index cd19972..ff8c6de 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java @@ -26,9 +26,6 @@ import org.wamblee.xmlrouter.config.RouterConfig; import org.wamblee.xmlrouter.config.RouterConfigService; import org.wamblee.xmlrouter.config.Transformation; -// TODO pass unique id of config service in the constructor to allow multiple instances with -// unique ids (ServiceFactory) - /** * Router configuration service providing an atomic configuration API for the * XML router. diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java index 1f17b68..9905046 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java @@ -60,24 +60,23 @@ public class CompositeConfigTest { @Test public void testEmptyConfig() { - Config composite = composite("c"); - assertEquals(id("c"), composite.getId()); + Config composite = composite(); assertTrue(composite.values().isEmpty()); } @Test(expected = RuntimeException.class) public void testAddNotAllowed() { - composite("c").add(new IntClass(10)); + composite().add(new IntClass(10)); } @Test(expected = RuntimeException.class) public void testRemoveNotAllowed() { - composite("c").remove(new Id("xxx")); + composite().remove(new Id("xxx")); } @Test public void testAddConfig() { - CompositeConfig composite = composite("c"); + CompositeConfig composite = composite(); Config c1 = new ConfigImpl(id("c1")) { @Override public Identifiable wrap(String aPrefix, Identifiable aT) { @@ -118,7 +117,7 @@ public class CompositeConfigTest { @Test(expected = ConfigException.class) public void testDuplicatesNotAllowed() { - CompositeConfig composite = composite("c"); + CompositeConfig composite = composite(); Config c1 = new ConfigImpl(id("c1")) { @Override public Identifiable wrap(String aPrefix, Identifiable aT) { @@ -137,7 +136,7 @@ public class CompositeConfigTest { @Test public void testDuplicateItem() { - CompositeConfig composite = composite("c"); + CompositeConfig composite = composite(); Config c1 = new ConfigImpl(id("c1")) { @Override public Identifiable wrap(String aPrefix, Identifiable aT) { @@ -166,8 +165,8 @@ public class CompositeConfigTest { assertTrue(composite.values().contains(i1)); } - private CompositeConfig composite(String aId) { - return new CompositeConfig(id(aId)); + private CompositeConfig composite() { + return new CompositeConfig(); } private Id id(String aId) { diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/SingleRouterConfigTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/SingleRouterConfigTest.java index a344f72..6ec16b1 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/SingleRouterConfigTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/SingleRouterConfigTest.java @@ -33,6 +33,7 @@ public class SingleRouterConfigTest { @Before public void setUp() { config = new SingleRouterConfig(new Id("routerconfig")); + assertEquals("routerconfig", config.getId().getId()); } @Test