{
? "Expected [" + targetName + "] to be damaged after colliding with [" + otherName + "] but it was not!"
: "Expected [" + targetName + "] not to be damaged after colliding with [" + otherName + "] but it was!";
- assertEquals(errorMessage, expectedDamage, target.isDamaged());
+ assertEquals(expectedDamage, target.isDamaged(), errorMessage);
}
}
diff --git a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/FlamingAsteroidTest.java b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/FlamingAsteroidTest.java
index 120c9a883..7c5edb5c9 100644
--- a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/FlamingAsteroidTest.java
+++ b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/FlamingAsteroidTest.java
@@ -22,11 +22,11 @@
*/
package com.iluwatar.doubledispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/10/15 - 11:31 PM
diff --git a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/MeteoroidTest.java b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/MeteoroidTest.java
index 8eed497c0..40ba0f60d 100644
--- a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/MeteoroidTest.java
+++ b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/MeteoroidTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.doubledispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Date: 12/10/15 - 11:31 PM
diff --git a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/RectangleTest.java b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/RectangleTest.java
index 1f4e476de..8f547c11f 100644
--- a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/RectangleTest.java
+++ b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/RectangleTest.java
@@ -22,11 +22,11 @@
*/
package com.iluwatar.doubledispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for Rectangle
diff --git a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationIssTest.java b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationIssTest.java
index 8cde65d11..f99f6bdf5 100644
--- a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationIssTest.java
+++ b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationIssTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.doubledispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Date: 12/10/15 - 11:31 PM
diff --git a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationMirTest.java b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationMirTest.java
index 3dbab58ba..f0cbd3668 100644
--- a/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationMirTest.java
+++ b/double-dispatch/src/test/java/com/iluwatar/doubledispatch/SpaceStationMirTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.doubledispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Date: 12/10/15 - 11:31 PM
diff --git a/eip-aggregator/README.md b/eip-aggregator/README.md
new file mode 100644
index 000000000..a1dc18ea8
--- /dev/null
+++ b/eip-aggregator/README.md
@@ -0,0 +1,33 @@
+---
+layout: pattern
+title: EIP Aggregator
+folder: eip-aggregator
+permalink: /patterns/eip-aggregator/
+categories: Integration
+tags:
+ - Java
+ - Difficulty-Intermittent
+ - EIP
+---
+
+## Intent
+Sometimes in enterprise systems there is a need to group incoming data in order to process it as a whole. For example
+you may need to gather offers and after defined number of offers has been received you would like to choose the one with
+the best parameters.
+
+Aggregator allows you to merge messages based on defined criteria and parameters. It gathers original messages,
+applies aggregation strategy and upon fulfilling given criteria, releasing merged messages.
+
+
+
+## Applicability
+Use the Aggregator pattern when
+
+* You need to combine multiple incoming messages
+* You want to process grouped data
+
+## Credits
+
+* [Gregor Hohpe, Bobby Woolf - Enterprise Integration Patterns](http://www.enterpriseintegrationpatterns.com/patterns/messaging/Aggregator.html)
+* [Apache Camel - Documentation](http://camel.apache.org/aggregator2.html)
+
diff --git a/eip-aggregator/etc/aggregator.gif b/eip-aggregator/etc/aggregator.gif
new file mode 100644
index 000000000..b06cdfb0c
Binary files /dev/null and b/eip-aggregator/etc/aggregator.gif differ
diff --git a/eip-aggregator/pom.xml b/eip-aggregator/pom.xml
new file mode 100644
index 000000000..8a51b8218
--- /dev/null
+++ b/eip-aggregator/pom.xml
@@ -0,0 +1,78 @@
+
+
+
+ 4.0.0
+ eip-aggregator
+
+ com.iluwatar
+ java-design-patterns
+ 1.19.0-SNAPSHOT
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.apache.camel
+ camel-core
+ ${camel.version}
+
+
+
+ org.apache.camel
+ camel-spring-boot
+ ${camel.version}
+
+
+
+
+ com.github.sbrannen
+ spring-test-junit5
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+
+ org.apache.camel
+ camel-test-spring
+ ${camel.version}
+
+
+
+
\ No newline at end of file
diff --git a/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/App.java b/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/App.java
new file mode 100644
index 000000000..d55f24e3d
--- /dev/null
+++ b/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/App.java
@@ -0,0 +1,73 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.aggregator;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ * Sometimes in enterprise systems there is a need to group incoming data in order to process it as a whole. For example
+ * you may need to gather offers and after defined number of offers has been received you would like to choose the one
+ * with the best parameters.
+ *
+ *
+ * Aggregator allows you to merge messages based on defined criteria and parameters. It gathers original messages,
+ * applies aggregation strategy and upon fulfilling given criteria, releasing merged messages.
+ *
+ *
+ */
+@SpringBootApplication
+public class App {
+
+ /**
+ * Program entry point. It starts Spring Boot application and using Apache Camel it auto-configures routes.
+ *
+ * @param args command line args
+ */
+ public static void main(String[] args) throws Exception {
+ // Run Spring Boot application and obtain ApplicationContext
+ ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
+
+ // Get CamelContext from ApplicationContext
+ CamelContext camelContext = (CamelContext) context.getBean("camelContext");
+
+ // Add a new routes that will handle endpoints form SplitterRoute class.
+ camelContext.addRoutes(new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ from("{{endpoint}}").log("ENDPOINT: ${body}");
+ }
+
+ });
+
+ // Add producer that will send test message to an entry point in WireTapRoute
+ String[] stringArray = {"Test item #1", "Test item #2", "Test item #3"};
+ camelContext.createProducerTemplate().sendBody("{{entry}}", stringArray);
+
+ SpringApplication.exit(context);
+ }
+}
diff --git a/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/AggregatorRoute.java b/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/AggregatorRoute.java
new file mode 100644
index 000000000..536565339
--- /dev/null
+++ b/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/AggregatorRoute.java
@@ -0,0 +1,60 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.aggregator.routes;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Sample aggregator route definition.
+ *
+ *
+ * It consumes messages out of the direct:entry entry point and forwards them to direct:endpoint.
+ * Route accepts messages containing String as a body, it aggregates the messages based on the settings and forwards
+ * them as CSV to the output chanel.
+ *
+ * Settings for the aggregation are: aggregate until 3 messages are bundled or wait 2000ms before sending bundled
+ * messages further.
+ *
+ *
+ * In this example input/output endpoints names are stored in application.properties file.
+ */
+@Component
+public class AggregatorRoute extends RouteBuilder {
+
+ @Autowired
+ private MessageAggregationStrategy aggregator;
+
+ /**
+ * Configures the route
+ * @throws Exception in case of exception during configuration
+ */
+ @Override
+ public void configure() throws Exception {
+ // Main route
+ from("{{entry}}").aggregate(constant(true), aggregator)
+ .completionSize(3).completionInterval(2000)
+ .to("{{endpoint}}");
+ }
+}
diff --git a/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategy.java b/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategy.java
new file mode 100644
index 000000000..4b5e4cb2f
--- /dev/null
+++ b/eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategy.java
@@ -0,0 +1,49 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.aggregator.routes;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.springframework.stereotype.Component;
+
+/**
+ * Aggregation strategy joining bodies of messages. If message is first one oldMessage is null. All changes are
+ * made on IN messages.
+ */
+@Component
+public class MessageAggregationStrategy implements AggregationStrategy {
+
+ @Override
+ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+ if (oldExchange == null) {
+ return newExchange;
+ }
+
+ String in1 = (String) oldExchange.getIn().getBody();
+ String in2 = (String) newExchange.getIn().getBody();
+
+ oldExchange.getIn().setBody(in1 + ";" + in2);
+
+ return oldExchange;
+ }
+}
diff --git a/eip-aggregator/src/main/resources/application.properties b/eip-aggregator/src/main/resources/application.properties
new file mode 100644
index 000000000..044833fc1
--- /dev/null
+++ b/eip-aggregator/src/main/resources/application.properties
@@ -0,0 +1,25 @@
+#
+# The MIT License
+# Copyright (c) 2014 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+entry=direct:entry
+endpoint=direct:endpoint
diff --git a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/AppTest.java b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/AppTest.java
new file mode 100644
index 000000000..40a336786
--- /dev/null
+++ b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/AppTest.java
@@ -0,0 +1,37 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.aggregator;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for App class
+ */
+public class AppTest {
+
+ @Test
+ public void testMain() throws Exception {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java
new file mode 100644
index 000000000..2c7d207d6
--- /dev/null
+++ b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java
@@ -0,0 +1,84 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.aggregator.routes;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Test class for AggregatorRoute.
+ *
+ * In order for it to work we have to mock endpoints we want to read/write to. To mock those we need to substitute
+ * original endpoint names to mocks.
+ *
+ */
+@ExtendWith(SpringExtension.class)
+@SpringApplicationConfiguration(classes = AggregatorRouteTest.class)
+@ActiveProfiles("test")
+@EnableAutoConfiguration
+@ComponentScan
+public class AggregatorRouteTest {
+
+ @EndpointInject(uri = "{{entry}}")
+ private ProducerTemplate entry;
+
+ @EndpointInject(uri = "{{endpoint}}")
+ private MockEndpoint endpoint;
+
+ /**
+ * Test if endpoint receives three separate messages.
+ * @throws Exception in case of en exception during the test
+ */
+ @Test
+ @DirtiesContext
+ public void testSplitter() throws Exception {
+
+ // Three items in one entry message
+ entry.sendBody("TEST1");
+ entry.sendBody("TEST2");
+ entry.sendBody("TEST3");
+ entry.sendBody("TEST4");
+ entry.sendBody("TEST5");
+
+ // Endpoint should have three different messages in the end order of the messages is not important
+ endpoint.expectedMessageCount(2);
+ endpoint.assertIsSatisfied();
+
+ String body = (String) endpoint.getReceivedExchanges().get(0).getIn().getBody();
+ assertEquals(3, body.split(";").length);
+
+ String body2 = (String) endpoint.getReceivedExchanges().get(1).getIn().getBody();
+ assertEquals(2, body2.split(";").length);
+ }
+}
diff --git a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java
new file mode 100644
index 000000000..7a7a15154
--- /dev/null
+++ b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java
@@ -0,0 +1,64 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.aggregator.routes;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests MessageAggregationStrategy
+ */
+public class MessageAggregationStrategyTest {
+
+ @Test
+ public void testAggregate() {
+ MessageAggregationStrategy mas = new MessageAggregationStrategy();
+ Exchange oldExchange = new DefaultExchange((CamelContext) null);
+ oldExchange.getIn().setBody("TEST1");
+
+ Exchange newExchange = new DefaultExchange((CamelContext) null);
+ newExchange.getIn().setBody("TEST2");
+
+ Exchange output = mas.aggregate(oldExchange, newExchange);
+ String outputBody = (String) output.getIn().getBody();
+ assertEquals("TEST1;TEST2", outputBody);
+ }
+
+ @Test
+ public void testAggregateOldNull() {
+ MessageAggregationStrategy mas = new MessageAggregationStrategy();
+
+ Exchange newExchange = new DefaultExchange((CamelContext) null);
+ newExchange.getIn().setBody("TEST2");
+
+ Exchange output = mas.aggregate(null, newExchange);
+ String outputBody = (String) output.getIn().getBody();
+
+ assertEquals(newExchange, output);
+ assertEquals("TEST2", outputBody);
+ }
+}
diff --git a/eip-aggregator/src/test/resources/application-test.properties b/eip-aggregator/src/test/resources/application-test.properties
new file mode 100644
index 000000000..8d6ecbbd3
--- /dev/null
+++ b/eip-aggregator/src/test/resources/application-test.properties
@@ -0,0 +1,25 @@
+#
+# The MIT License
+# Copyright (c) 2014 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+entry=direct:entry
+endpoint=mock:endpoint
diff --git a/eip-splitter/README.md b/eip-splitter/README.md
new file mode 100644
index 000000000..51a917bad
--- /dev/null
+++ b/eip-splitter/README.md
@@ -0,0 +1,32 @@
+---
+layout: pattern
+title: EIP Splitter
+folder: eip-splitter
+permalink: /patterns/eip-splitter/
+categories: Integration
+tags:
+ - Java
+ - Difficulty-Intermittent
+ - EIP
+---
+
+## Intent
+It is very common in integration systems that incoming messages consists of many items bundled together. For example
+an invoice document contains multiple invoice lines describing transaction (quantity, name of provided
+service/sold goods, price etc.). Such bundled messages may not be accepted by other systems. This is where splitter
+pattern comes in handy. It will take the whole document, split it based on given criteria and send individual
+items to the endpoint.
+
+
+
+## Applicability
+Use the Splitter pattern when
+
+* You need to split received data into smaller pieces to process them individually
+* You need to control the size of data batches you are able to process
+
+## Credits
+
+* [Gregor Hohpe, Bobby Woolf - Enterprise Integration Patterns](http://www.enterpriseintegrationpatterns.com/patterns/messaging/Sequencer.html)
+* [Apache Camel - Documentation](http://camel.apache.org/splitter.html)
+
diff --git a/eip-splitter/etc/sequencer.gif b/eip-splitter/etc/sequencer.gif
new file mode 100644
index 000000000..a925fa209
Binary files /dev/null and b/eip-splitter/etc/sequencer.gif differ
diff --git a/eip-splitter/pom.xml b/eip-splitter/pom.xml
new file mode 100644
index 000000000..54661f946
--- /dev/null
+++ b/eip-splitter/pom.xml
@@ -0,0 +1,78 @@
+
+
+
+ 4.0.0
+ eip-splitter
+
+ com.iluwatar
+ java-design-patterns
+ 1.19.0-SNAPSHOT
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.apache.camel
+ camel-core
+ ${camel.version}
+
+
+
+ org.apache.camel
+ camel-spring-boot
+ ${camel.version}
+
+
+
+
+ com.github.sbrannen
+ spring-test-junit5
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+
+ org.apache.camel
+ camel-test-spring
+ ${camel.version}
+
+
+
+
\ No newline at end of file
diff --git a/eip-splitter/src/main/java/com/iluwatar/eip/splitter/App.java b/eip-splitter/src/main/java/com/iluwatar/eip/splitter/App.java
new file mode 100644
index 000000000..ceadb5f8d
--- /dev/null
+++ b/eip-splitter/src/main/java/com/iluwatar/eip/splitter/App.java
@@ -0,0 +1,75 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.splitter;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ * It is very common in integration systems that incoming messages consists of many items bundled together. For example
+ * an invoice document contains multiple invoice lines describing transaction (quantity, name of provided
+ * service/sold goods, price etc.). Such bundled messages may not be accepted by other systems. This is where splitter
+ * pattern comes in handy. It will take the whole document, split it based on given criteria and send individual
+ * items to the endpoint.
+ *
+ *
+ * Splitter allows you to split messages based on defined criteria. It takes original message, process it and send
+ * multiple parts to the output channel. It is not defined if it should keep the order of items though.
+ *
+ *
+ */
+@SpringBootApplication
+public class App {
+
+ /**
+ * Program entry point. It starts Spring Boot application and using Apache Camel it auto-configures routes.
+ *
+ * @param args command line args
+ */
+ public static void main(String[] args) throws Exception {
+ // Run Spring Boot application and obtain ApplicationContext
+ ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
+
+ // Get CamelContext from ApplicationContext
+ CamelContext camelContext = (CamelContext) context.getBean("camelContext");
+
+ // Add a new routes that will handle endpoints form SplitterRoute class.
+ camelContext.addRoutes(new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ from("{{endpoint}}").log("ENDPOINT: ${body}");
+ }
+
+ });
+
+ // Add producer that will send test message to an entry point in WireTapRoute
+ String[] stringArray = {"Test item #1", "Test item #2", "Test item #3"};
+ camelContext.createProducerTemplate().sendBody("{{entry}}", stringArray);
+
+ SpringApplication.exit(context);
+ }
+}
diff --git a/eip-splitter/src/main/java/com/iluwatar/eip/splitter/routes/SplitterRoute.java b/eip-splitter/src/main/java/com/iluwatar/eip/splitter/routes/SplitterRoute.java
new file mode 100644
index 000000000..f7eb28dea
--- /dev/null
+++ b/eip-splitter/src/main/java/com/iluwatar/eip/splitter/routes/SplitterRoute.java
@@ -0,0 +1,51 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.splitter.routes;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+/**
+ * Sample splitter route definition.
+ *
+ *
+ * It consumes messages out of the direct:entry entry point and forwards them to direct:endpoint.
+ * Route accepts messages having body of array or collection of objects. Splitter component split message body and
+ * forwards single objects to the endpoint.
+ *
+ *
+ * In this example input/output endpoints names are stored in application.properties file.
+ */
+@Component
+public class SplitterRoute extends RouteBuilder {
+
+ /**
+ * Configures the route
+ * @throws Exception in case of exception during configuration
+ */
+ @Override
+ public void configure() throws Exception {
+ // Main route
+ from("{{entry}}").split().body().to("{{endpoint}}");
+ }
+}
diff --git a/eip-splitter/src/main/resources/application.properties b/eip-splitter/src/main/resources/application.properties
new file mode 100644
index 000000000..044833fc1
--- /dev/null
+++ b/eip-splitter/src/main/resources/application.properties
@@ -0,0 +1,25 @@
+#
+# The MIT License
+# Copyright (c) 2014 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+entry=direct:entry
+endpoint=direct:endpoint
diff --git a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java
new file mode 100644
index 000000000..fe3eca01e
--- /dev/null
+++ b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java
@@ -0,0 +1,37 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.splitter;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for App class
+ */
+public class AppTest {
+
+ @Test
+ public void testMain() throws Exception {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java
new file mode 100644
index 000000000..9257a4410
--- /dev/null
+++ b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java
@@ -0,0 +1,72 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.splitter.routes;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+/**
+ * Test class for SplitterRoute.
+ *
+ * In order for it to work we have to mock endpoints we want to read/write to. To mock those we need to substitute
+ * original endpoint names to mocks.
+ *
+ */
+@ExtendWith(SpringExtension.class)
+@SpringApplicationConfiguration(classes = SplitterRouteTest.class)
+@ActiveProfiles("test")
+@EnableAutoConfiguration
+@ComponentScan
+public class SplitterRouteTest {
+
+ @EndpointInject(uri = "{{entry}}")
+ private ProducerTemplate entry;
+
+ @EndpointInject(uri = "{{endpoint}}")
+ private MockEndpoint endpoint;
+
+ /**
+ * Test if endpoint receives three separate messages.
+ * @throws Exception in case of en exception during the test
+ */
+ @Test
+ @DirtiesContext
+ public void testSplitter() throws Exception {
+
+ // Three items in one entry message
+ entry.sendBody(new String[] {"TEST1", "TEST2", "TEST3"});
+
+ // Endpoint should have three different messages in the end order of the messages is not important
+ endpoint.expectedMessageCount(3);
+ endpoint.assertIsSatisfied();
+ }
+}
diff --git a/eip-splitter/src/test/resources/application-test.properties b/eip-splitter/src/test/resources/application-test.properties
new file mode 100644
index 000000000..8d6ecbbd3
--- /dev/null
+++ b/eip-splitter/src/test/resources/application-test.properties
@@ -0,0 +1,25 @@
+#
+# The MIT License
+# Copyright (c) 2014 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+entry=direct:entry
+endpoint=mock:endpoint
diff --git a/eip-wire-tap/README.md b/eip-wire-tap/README.md
new file mode 100644
index 000000000..31cbd9123
--- /dev/null
+++ b/eip-wire-tap/README.md
@@ -0,0 +1,29 @@
+---
+layout: pattern
+title: EIP Wire Tap
+folder: eip-wire-tap
+permalink: /patterns/eip-wire-tap/
+categories: Integration
+tags:
+ - Java
+ - Difficulty-Intermittent
+ - EIP
+---
+
+## Intent
+In most integration cases there is a need to monitor the messages flowing through the system. It is usually achieved
+by intercepting the message and redirecting it to a different location like console, filesystem or the database.
+It is important that such functionality should not modify the original message and influence the processing path.
+
+
+
+## Applicability
+Use the Wire Tap pattern when
+
+* You need to monitor messages flowing through the system
+* You need to redirect the same, unchanged message to two different endpoints/paths
+
+## Credits
+
+* [Gregor Hohpe, Bobby Woolf - Enterprise Integration Patterns](http://www.enterpriseintegrationpatterns.com/patterns/messaging/WireTap.html)
+* [Apache Camel - Documentation](http://camel.apache.org/wire-tap.html)
diff --git a/eip-wire-tap/etc/wiretap.gif b/eip-wire-tap/etc/wiretap.gif
new file mode 100644
index 000000000..414173716
Binary files /dev/null and b/eip-wire-tap/etc/wiretap.gif differ
diff --git a/eip-wire-tap/pom.xml b/eip-wire-tap/pom.xml
new file mode 100644
index 000000000..688f4ad6d
--- /dev/null
+++ b/eip-wire-tap/pom.xml
@@ -0,0 +1,78 @@
+
+
+
+ 4.0.0
+ eip-wire-tap
+
+ com.iluwatar
+ java-design-patterns
+ 1.19.0-SNAPSHOT
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.apache.camel
+ camel-core
+ ${camel.version}
+
+
+
+ org.apache.camel
+ camel-spring-boot
+ ${camel.version}
+
+
+
+
+ com.github.sbrannen
+ spring-test-junit5
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+
+ org.apache.camel
+ camel-test-spring
+ ${camel.version}
+
+
+
+
\ No newline at end of file
diff --git a/eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/App.java b/eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/App.java
new file mode 100644
index 000000000..ca605cb78
--- /dev/null
+++ b/eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/App.java
@@ -0,0 +1,73 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.wiretap;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ * In most integration cases there is a need to monitor the messages flowing through the system. It is usually achieved
+ * by intercepting the message and redirecting it to a different location like console, filesystem or the database.
+ * It is important that such functionality should not modify the original message and influence the processing path.
+ *
+ *
+ * Wire Tap allows you to route messages to a separate location while they are being forwarded to the ultimate
+ * destination. It basically consumes messages of the input channel and publishes the unmodified message to both
+ * output channels.
+ *
+ */
+@SpringBootApplication
+public class App {
+
+ /**
+ * Program entry point. It starts Spring Boot application and using Apache Camel it auto-configures routes.
+ *
+ * @param args command line args
+ */
+ public static void main(String[] args) throws Exception {
+ // Run Spring Boot application and obtain ApplicationContext
+ ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
+
+ // Get CamelContext from ApplicationContext
+ CamelContext camelContext = (CamelContext) context.getBean("camelContext");
+
+ // Add a new routes that will handle endpoints form WireTapRoute class.
+ camelContext.addRoutes(new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ from("{{endpoint}}").log("ENDPOINT: ${body}");
+ from("{{wireTapEndpoint}}").log("WIRETAPPED ENDPOINT: ${body}");
+ }
+
+ });
+
+ // Add producer that will send test message to an entry point in WireTapRoute
+ camelContext.createProducerTemplate().sendBody("{{entry}}", "Test message");
+
+ SpringApplication.exit(context);
+ }
+}
diff --git a/eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/routes/WireTapRoute.java b/eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/routes/WireTapRoute.java
new file mode 100644
index 000000000..994ceacdb
--- /dev/null
+++ b/eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/routes/WireTapRoute.java
@@ -0,0 +1,54 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.wiretap.routes;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+/**
+ * Sample wire tap route definition.
+ *
+ *
+ * It consumes messages out of the direct:entry entry point and forwards them to direct:endpoint.
+ * Wire Tap intercepts the message and sends it to direct:wireTap, which in turn forwards it to
+ * direct:wireTapEndpoint.
+ *
+ *
+ * In this example input/output endpoints names are stored in application.properties file.
+ */
+@Component
+public class WireTapRoute extends RouteBuilder {
+
+ /**
+ * Configures the route
+ * @throws Exception in case of exception during configuration
+ */
+ @Override
+ public void configure() throws Exception {
+ // Main route
+ from("{{entry}}").wireTap("direct:wireTap").to("{{endpoint}}");
+
+ // Wire tap route
+ from("direct:wireTap").log("Message: ${body}").to("{{wireTapEndpoint}}");
+ }
+}
diff --git a/eip-wire-tap/src/main/resources/application.properties b/eip-wire-tap/src/main/resources/application.properties
new file mode 100644
index 000000000..90a152425
--- /dev/null
+++ b/eip-wire-tap/src/main/resources/application.properties
@@ -0,0 +1,26 @@
+#
+# The MIT License
+# Copyright (c) 2014 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+entry=direct:entry
+endpoint=direct:endpoint
+wireTapEndpoint=direct:wireTapEndpoint
\ No newline at end of file
diff --git a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java
new file mode 100644
index 000000000..673803df7
--- /dev/null
+++ b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java
@@ -0,0 +1,37 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.wiretap;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for App class
+ */
+public class AppTest {
+
+ @Test
+ public void testMain() throws Exception {
+ String[] args = {};
+ App.main(args);
+ }
+}
diff --git a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java
new file mode 100644
index 000000000..449f86208
--- /dev/null
+++ b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java
@@ -0,0 +1,84 @@
+/**
+ * The MIT License
+ * Copyright (c) 2014 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.eip.wiretap.routes;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Message;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Test class for WireTapRoute.
+ *
+ * In order for it to work we have to mock endpoints we want to read/write to. To mock those we need to substitute
+ * original endpoint names to mocks.
+ *
+ */
+@ExtendWith(SpringExtension.class)
+@SpringApplicationConfiguration(classes = WireTapRouteTest.class)
+@ActiveProfiles("test")
+@EnableAutoConfiguration
+@ComponentScan
+public class WireTapRouteTest {
+
+ @EndpointInject(uri = "{{entry}}")
+ private ProducerTemplate entry;
+
+ @EndpointInject(uri = "{{endpoint}}")
+ private MockEndpoint endpoint;
+
+ @EndpointInject(uri = "{{wireTapEndpoint}}")
+ private MockEndpoint wireTapEndpoint;
+
+ /**
+ * Test if both endpoints receive exactly one message containing the same, unchanged body.
+ * @throws Exception in case of en exception during the test
+ */
+ @Test
+ @DirtiesContext
+ public void testWireTap() throws Exception {
+ entry.sendBody("TEST");
+
+ endpoint.expectedMessageCount(1);
+ wireTapEndpoint.expectedMessageCount(1);
+
+ endpoint.assertIsSatisfied();
+ wireTapEndpoint.assertIsSatisfied();
+
+ Message endpointIn = endpoint.getExchanges().get(0).getIn();
+ Message wireTapEndpointIn = wireTapEndpoint.getExchanges().get(0).getIn();
+
+ assertEquals("TEST", endpointIn.getBody());
+ assertEquals("TEST", wireTapEndpointIn.getBody());
+ }
+}
diff --git a/eip-wire-tap/src/test/resources/application-test.properties b/eip-wire-tap/src/test/resources/application-test.properties
new file mode 100644
index 000000000..e76faa1fc
--- /dev/null
+++ b/eip-wire-tap/src/test/resources/application-test.properties
@@ -0,0 +1,26 @@
+#
+# The MIT License
+# Copyright (c) 2014 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+entry=direct:entry
+endpoint=mock:endpoint
+wireTapEndpoint=mock:wireTapEndpoint
\ No newline at end of file
diff --git a/event-aggregator/README.md b/event-aggregator/README.md
index ce7f358de..ac07869e7 100644
--- a/event-aggregator/README.md
+++ b/event-aggregator/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Event Aggregator
folder: event-aggregator
permalink: /patterns/event-aggregator/
-pumlid: PSf13iCW30NHgxG70Ezx6uTOX0eCih-JwvTzTwEdUJSjFKu9wwyBMFuXCdvoRRZY21ShKo6ANEQWrkDXiD6NRqwdUAkQ5WDYwZJOTv3SUqzSgqbbp0qeVvZ3Hbun-Wy0
categories: Structural
tags:
- Java
diff --git a/event-aggregator/etc/event-aggregator.urm.puml b/event-aggregator/etc/event-aggregator.urm.puml
deleted file mode 100644
index 341d7d65e..000000000
--- a/event-aggregator/etc/event-aggregator.urm.puml
+++ /dev/null
@@ -1,74 +0,0 @@
-@startuml
-package com.iluwatar.event.aggregator {
- class App {
- + App()
- + main(args : String[]) {static}
- }
- enum Event {
- + STARK_SIGHTED {static}
- + TRAITOR_DETECTED {static}
- + WARSHIPS_APPROACHING {static}
- - description : String
- + toString() : String
- + valueOf(name : String) : Event {static}
- + values() : Event[] {static}
- }
- abstract class EventEmitter {
- - observers : List
- + EventEmitter()
- + EventEmitter(obs : EventObserver)
- # notifyObservers(e : Event)
- + registerObserver(obs : EventObserver)
- + timePasses(Weekday) {abstract}
- }
- interface EventObserver {
- + onEvent(Event) {abstract}
- }
- class KingJoffrey {
- - LOGGER : Logger {static}
- + KingJoffrey()
- + onEvent(e : Event)
- }
- class KingsHand {
- + KingsHand()
- + KingsHand(obs : EventObserver)
- + onEvent(e : Event)
- + timePasses(day : Weekday)
- }
- class LordBaelish {
- + LordBaelish()
- + LordBaelish(obs : EventObserver)
- + timePasses(day : Weekday)
- }
- class LordVarys {
- + LordVarys()
- + LordVarys(obs : EventObserver)
- + timePasses(day : Weekday)
- }
- class Scout {
- + Scout()
- + Scout(obs : EventObserver)
- + timePasses(day : Weekday)
- }
- enum Weekday {
- + FRIDAY {static}
- + MONDAY {static}
- + SATURDAY {static}
- + SUNDAY {static}
- + THURSDAY {static}
- + TUESDAY {static}
- + WEDNESDAY {static}
- - description : String
- + toString() : String
- + valueOf(name : String) : Weekday {static}
- + values() : Weekday[] {static}
- }
-}
-EventEmitter --> "-observers" EventObserver
-KingJoffrey ..|> EventObserver
-KingsHand ..|> EventObserver
-KingsHand --|> EventEmitter
-LordBaelish --|> EventEmitter
-LordVarys --|> EventEmitter
-Scout --|> EventEmitter
-@enduml
\ No newline at end of file
diff --git a/event-aggregator/pom.xml b/event-aggregator/pom.xml
index 19e76af84..c28fded6f 100644
--- a/event-aggregator/pom.xml
+++ b/event-aggregator/pom.xml
@@ -28,13 +28,18 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
event-aggregator
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java
index 2de7021b3..0d4f6af2d 100644
--- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java
+++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java
@@ -30,7 +30,6 @@ package com.iluwatar.event.aggregator;
public class KingsHand extends EventEmitter implements EventObserver {
public KingsHand() {
- super();
}
public KingsHand(EventObserver obs) {
diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordBaelish.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordBaelish.java
index 9204aa572..50b7d501a 100644
--- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordBaelish.java
+++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordBaelish.java
@@ -30,7 +30,6 @@ package com.iluwatar.event.aggregator;
public class LordBaelish extends EventEmitter {
public LordBaelish() {
- super();
}
public LordBaelish(EventObserver obs) {
diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordVarys.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordVarys.java
index dc6009b8c..6248c4446 100644
--- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordVarys.java
+++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/LordVarys.java
@@ -30,7 +30,6 @@ package com.iluwatar.event.aggregator;
public class LordVarys extends EventEmitter {
public LordVarys() {
- super();
}
public LordVarys(EventObserver obs) {
diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Scout.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Scout.java
index c8dcf5ba3..a1095640a 100644
--- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Scout.java
+++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/Scout.java
@@ -30,7 +30,6 @@ package com.iluwatar.event.aggregator;
public class Scout extends EventEmitter {
public Scout() {
- super();
}
public Scout(EventObserver obs) {
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
index 6cd678704..09548e384 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java
index a67272789..c2f457e28 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java
@@ -22,6 +22,8 @@
*/
package com.iluwatar.event.aggregator;
+import org.junit.jupiter.api.Test;
+
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -32,7 +34,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
-import org.junit.Test;
/**
* Date: 12/12/15 - 10:58 PM
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java
index 54c511f8c..28062c613 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 2:52 PM
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java
index 1743c3211..3f3296c57 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java
@@ -25,15 +25,15 @@ package com.iluwatar.event.aggregator;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/12/15 - 3:04 PM
@@ -44,12 +44,12 @@ public class KingJoffreyTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(KingJoffrey.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java
index ba1327182..3a5ae8f68 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java
index ab25d7ccc..df2d8ac79 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 2:12 PM
diff --git a/event-asynchronous/etc/event-asynchronous.png b/event-asynchronous/etc/event-asynchronous.png
index a46ffe1c5..76cb1b626 100644
Binary files a/event-asynchronous/etc/event-asynchronous.png and b/event-asynchronous/etc/event-asynchronous.png differ
diff --git a/event-asynchronous/etc/event-asynchronous.ucls b/event-asynchronous/etc/event-asynchronous.ucls
index df09fc28d..1327b7104 100644
--- a/event-asynchronous/etc/event-asynchronous.ucls
+++ b/event-asynchronous/etc/event-asynchronous.ucls
@@ -1,63 +1,62 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -65,49 +64,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/event-asynchronous/etc/event-asynchronous.urm.puml b/event-asynchronous/etc/event-asynchronous.urm.puml
deleted file mode 100644
index 0d683d27d..000000000
--- a/event-asynchronous/etc/event-asynchronous.urm.puml
+++ /dev/null
@@ -1,66 +0,0 @@
-@startuml
-package com.iluwatar.event.asynchronous {
- class App {
- - LOGGER : Logger {static}
- + PROP_FILE_NAME : String {static}
- ~ interactiveMode : boolean
- + App()
- + main(args : String[]) {static}
- + quickRun()
- + run()
- + runInteractiveMode()
- + setUp()
- }
- class Event {
- - LOGGER : Logger {static}
- - eventId : int
- - eventListener : ThreadCompleteListener
- - eventTime : int
- - isComplete : boolean
- - isSynchronous : boolean
- - thread : Thread
- + Event(eventId : int, eventTime : int, isSynchronous : boolean)
- + addListener(listener : ThreadCompleteListener)
- - completed()
- + isSynchronous() : boolean
- + removeListener(listener : ThreadCompleteListener)
- + run()
- + start()
- + status()
- + stop()
- }
- class EventManager {
- + MAX_EVENT_TIME : int {static}
- + MAX_ID : int {static}
- + MAX_RUNNING_EVENTS : int {static}
- + MIN_ID : int {static}
- - currentlyRunningSyncEvent : int
- - eventPool : Map
- - rand : Random
- + EventManager()
- + cancel(eventId : int)
- + completedEventHandler(eventId : int)
- + create(eventTime : int) : int
- + createAsync(eventTime : int) : int
- - createEvent(eventTime : int, isSynchronous : boolean) : int
- - generateId() : int
- + getEventPool() : Map
- + numOfCurrentlyRunningSyncEvent() : int
- + shutdown()
- + start(eventId : int)
- + status(eventId : int)
- + statusOfAllEvents()
- }
- interface IEvent {
- + start() {abstract}
- + status() {abstract}
- + stop() {abstract}
- }
- interface ThreadCompleteListener {
- + completedEventHandler(int) {abstract}
- }
-}
-Event --> "-eventListener" ThreadCompleteListener
-Event ..|> IEvent
-EventManager ..|> ThreadCompleteListener
-@enduml
\ No newline at end of file
diff --git a/event-asynchronous/pom.xml b/event-asynchronous/pom.xml
index 5a2d65bfe..3c07f47bc 100644
--- a/event-asynchronous/pom.xml
+++ b/event-asynchronous/pom.xml
@@ -29,13 +29,18 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
event-asynchronous
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java
index 2056dcf18..372bc2f58 100644
--- a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java
+++ b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java
@@ -16,9 +16,9 @@
*/
package com.iluwatar.event.asynchronous;
-import java.io.IOException;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import java.io.IOException;
/**
* Tests that EventAsynchronous example runs without errors.
diff --git a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java
index 8e0860286..aa2c644cb 100644
--- a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java
+++ b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java
@@ -16,12 +16,13 @@
*/
package com.iluwatar.event.asynchronous;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@@ -33,7 +34,7 @@ public class EventAsynchronousTest {
private static final Logger LOGGER = LoggerFactory.getLogger(EventAsynchronousTest.class);
- @Before
+ @BeforeEach
public void setUp() {
app = new App();
}
@@ -71,17 +72,19 @@ public class EventAsynchronousTest {
}
}
- @Test(expected = InvalidOperationException.class)
+ @Test
public void testUnsuccessfulSynchronousEvent() throws InvalidOperationException {
- EventManager eventManager = new EventManager();
- try {
- int sEventId = eventManager.create(60);
- eventManager.start(sEventId);
- sEventId = eventManager.create(60);
- eventManager.start(sEventId);
- } catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
- LOGGER.error(e.getMessage());
- }
+ assertThrows(InvalidOperationException.class, () -> {
+ EventManager eventManager = new EventManager();
+ try {
+ int sEventId = eventManager.create(60);
+ eventManager.start(sEventId);
+ sEventId = eventManager.create(60);
+ eventManager.start(sEventId);
+ } catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
+ LOGGER.error(e.getMessage());
+ }
+ });
}
@Test
diff --git a/event-driven-architecture/README.md b/event-driven-architecture/README.md
index a263defec..e2f06cf5a 100644
--- a/event-driven-architecture/README.md
+++ b/event-driven-architecture/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Event Driven Architecture
folder: event-driven-architecture
permalink: /patterns/event-driven-architecture/
-pumlid: TOhH3SCW30LNQGS0_tSRnrZ15H1adfFromBzkfFktZQaHT7mzgh0N1yYvoUVXXf7B7Mv1dGWozN9MZmCTlhopQdeidEaoO3wMDHvRI6zzvwAssPYbsfGGRYIGlxN7DxpZDv-
categories: Architectural
tags:
- Java
diff --git a/event-driven-architecture/etc/event-driven-architecture.urm.puml b/event-driven-architecture/etc/event-driven-architecture.urm.puml
deleted file mode 100644
index 2eb79e438..000000000
--- a/event-driven-architecture/etc/event-driven-architecture.urm.puml
+++ /dev/null
@@ -1,64 +0,0 @@
-@startuml
-package com.iluwatar.eda.handler {
- class UserCreatedEventHandler {
- - LOGGER : Logger {static}
- + UserCreatedEventHandler()
- + onEvent(event : UserCreatedEvent)
- }
- class UserUpdatedEventHandler {
- - LOGGER : Logger {static}
- + UserUpdatedEventHandler()
- + onEvent(event : UserUpdatedEvent)
- }
-}
-package com.iluwatar.eda.event {
- abstract class AbstractEvent {
- + AbstractEvent()
- + getType() : Class extends Event>
- }
- class UserCreatedEvent {
- - user : User
- + UserCreatedEvent(user : User)
- + getUser() : User
- }
- class UserUpdatedEvent {
- - user : User
- + UserUpdatedEvent(user : User)
- + getUser() : User
- }
-}
-package com.iluwatar.eda.framework {
- interface Event {
- + getType() : Class extends Event> {abstract}
- }
- class EventDispatcher {
- - handlers : Map, Handler extends Event>>
- + EventDispatcher()
- + dispatch(event : E extends Event)
- + registerHandler(eventType : Class, handler : Handler)
- }
- interface Handler {
- + onEvent(E extends Event) {abstract}
- }
-}
-package com.iluwatar.eda.model {
- class User {
- - username : String
- + User(username : String)
- + getUsername() : String
- }
-}
-package com.iluwatar.eda {
- class App {
- + App()
- + main(args : String[]) {static}
- }
-}
-UserUpdatedEvent --> "-user" User
-UserCreatedEvent --> "-user" User
-AbstractEvent ..|> Event
-UserCreatedEvent --|> AbstractEvent
-UserUpdatedEvent --|> AbstractEvent
-UserCreatedEventHandler ..|> Handler
-UserUpdatedEventHandler ..|> Handler
-@enduml
\ No newline at end of file
diff --git a/event-driven-architecture/pom.xml b/event-driven-architecture/pom.xml
index 4f2c34b5e..4eb2a6946 100644
--- a/event-driven-architecture/pom.xml
+++ b/event-driven-architecture/pom.xml
@@ -31,15 +31,20 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
event-driven-architecture
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java
index e7d642b95..f74232ac1 100644
--- a/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java
+++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.eda;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java
index 6e95f5fd2..823605e9d 100644
--- a/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java
+++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java
@@ -23,10 +23,9 @@
package com.iluwatar.eda.event;
import com.iluwatar.eda.model.User;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* {@link UserCreatedEventTest} tests and verifies {@link AbstractEvent} behaviour.
diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java
index 7501653f6..6f647245d 100644
--- a/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java
+++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java
@@ -27,8 +27,7 @@ import com.iluwatar.eda.event.UserUpdatedEvent;
import com.iluwatar.eda.handler.UserCreatedEventHandler;
import com.iluwatar.eda.handler.UserUpdatedEventHandler;
import com.iluwatar.eda.model.User;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
diff --git a/event-queue/etc/event-queue.urm.puml b/event-queue/etc/event-queue.urm.puml
deleted file mode 100644
index e2aabee31..000000000
--- a/event-queue/etc/event-queue.urm.puml
+++ /dev/null
@@ -1,26 +0,0 @@
-@startuml
-package com.iluwatar.event.queue {
- class App {
- + App()
- + getAudioStream(filePath : String) : AudioInputStream {static}
- + main(args : String[]) {static}
- }
- class Audio {
- - MAX_PENDING : int {static}
- - headIndex : int {static}
- - pendingAudio : PlayMessage[] {static}
- - tailIndex : int {static}
- - updateThread : Thread {static}
- + Audio()
- + init() {static}
- + playSound(stream : AudioInputStream, volume : float) {static}
- + stopService() {static}
- + update() {static}
- }
- class PlayMessage {
- ~ stream : AudioInputStream
- ~ volume : float
- + PlayMessage()
- }
-}
-@enduml
\ No newline at end of file
diff --git a/event-queue/pom.xml b/event-queue/pom.xml
index 59dfa9119..1ef8e28af 100644
--- a/event-queue/pom.xml
+++ b/event-queue/pom.xml
@@ -30,13 +30,18 @@
java-design-patterns
com.iluwatar
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
event-queue
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java b/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java
index f8f1b1e3c..6534b563e 100644
--- a/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java
+++ b/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java
@@ -59,7 +59,7 @@ public class Audio {
}
/**
- * This method stops the Update Method's thread.
+ * This method check the Update Method's thread is started.
* @return boolean
*/
public static synchronized boolean isServiceRunning() {
diff --git a/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java b/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java
index 8e31ec6c3..47f332526 100644
--- a/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java
+++ b/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java
@@ -22,13 +22,15 @@
*/
package com.iluwatar.event.queue;
-import static org.junit.Assert.*;
-import java.io.IOException;
+import org.junit.jupiter.api.Test;
import javax.sound.sampled.UnsupportedAudioFileException;
+import java.io.IOException;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
/**
* Testing the Audio service of the Queue
@@ -53,7 +55,7 @@ public class AudioTest {
// test that service is finished
assertFalse(!Audio.isServiceRunning());
}
-
+
/**
* Test here that the Queue
* @throws UnsupportedAudioFileException when the audio file is not supported
diff --git a/event-sourcing/etc/event-sourcing.urm.puml b/event-sourcing/etc/event-sourcing.urm.puml
deleted file mode 100644
index 207d238e6..000000000
--- a/event-sourcing/etc/event-sourcing.urm.puml
+++ /dev/null
@@ -1,184 +0,0 @@
-@startuml
-package com.iluwatar.event.sourcing.journal {
- class JsonFileJournal {
- - aFile : File
- - events : List
- - index : int
- + JsonFileJournal()
- + readNext() : DomainEvent
- + reset()
- + write(domainEvent : DomainEvent)
- }
-}
-package com.iluwatar.event.sourcing.processor {
- class DomainEventProcessor {
- - precessorJournal : ProcessorJournal
- + DomainEventProcessor()
- + process(domainEvent : DomainEvent)
- + recover()
- + setPrecessorJournal(precessorJournal : ProcessorJournal)
- }
-}
-package com.iluwatar.event.sourcing.service {
- class AccountService {
- - eventProcessor : EventProcessor
- + AccountService(eventProcessor : EventProcessor)
- + createAccount(accountNo : int, owner : String)
- }
- class MoneyTransactionService {
- - eventProcessor : EventProcessor
- + MoneyTransactionService(eventProcessor : EventProcessor)
- + depositMoney(accountNo : int, money : BigDecimal)
- + transferMoney(accountNoFrom : int, accountNoTo : int, money : BigDecimal)
- + withdrawalMoney(accountNo : int, money : BigDecimal)
- }
- class SequenceIdGenerator {
- - sequenceId : long {static}
- + SequenceIdGenerator()
- + nextSequenceId() : long {static}
- }
-}
-package com.iluwatar.event.sourcing.event {
- class AccountCreateEvent {
- - accountNo : int
- - owner : String
- + AccountCreateEvent(sequenceId : long, createdTime : long, accountNo : int, owner : String)
- + getAccountNo() : int
- + getOwner() : String
- + process()
- }
- class MoneyDepositEvent {
- - accountNo : int
- - money : BigDecimal
- + MoneyDepositEvent(sequenceId : long, createdTime : long, accountNo : int, money : BigDecimal)
- + getAccountNo() : int
- + getMoney() : BigDecimal
- + process()
- }
- class MoneyTransferEvent {
- - accountNoFrom : int
- - accountNoTo : int
- - money : BigDecimal
- + MoneyTransferEvent(sequenceId : long, createdTime : long, money : BigDecimal, accountNoFrom : int, accountNoTo : int)
- + getAccountNoFrom() : int
- + getAccountNoTo() : int
- + getMoney() : BigDecimal
- + process()
- }
- class MoneyWithdrawalEvent {
- - accountNo : int
- - money : BigDecimal
- + MoneyWithdrawalEvent(sequenceId : long, createdTime : long, accountNo : int, money : BigDecimal)
- + getAccountNo() : int
- + getMoney() : BigDecimal
- + process()
- }
-}
-package com.iluwatar.event.sourcing.gateway {
- class AccountCreateContractSender {
- + AccountCreateContractSender()
- + sendContractInfo(account : Account)
- }
- class Gateways {
- - accountCreateContractSender : AccountCreateContractSender {static}
- - transactionLogger : TransactionLogger {static}
- + Gateways()
- + getAccountCreateContractSender() : AccountCreateContractSender {static}
- + getTransactionLogger() : TransactionLogger {static}
- }
- class TransactionLogger {
- + TransactionLogger()
- + log(transaction : Transaction)
- }
-}
-package com.iluwatar.event.sourcing.app {
- class App {
- + App()
- + main(args : String[]) {static}
- }
-}
-package com.iluwatar.event.sourcing.state {
- class AccountAggregate {
- - accounts : Map {static}
- + AccountAggregate()
- + getAccount(accountNo : int) : Account {static}
- + putAccount(account : Account) {static}
- + resetState() {static}
- }
-}
-package com.iluwatar.event.sourcing.domain {
- class Account {
- - accountNo : int
- - money : BigDecimal
- - owner : String
- - transactions : List
- + Account(accountNo : int, owner : String)
- + copy() : Account
- - depositMoney(money : BigDecimal) : Transaction
- + getAccountNo() : int
- + getMoney() : BigDecimal
- + getOwner() : String
- + getTransactions() : List
- - handleDeposit(money : BigDecimal, realTime : boolean)
- + handleEvent(accountCreateEvent : AccountCreateEvent)
- + handleEvent(moneyDepositEvent : MoneyDepositEvent)
- + handleEvent(moneyWithdrawalEvent : MoneyWithdrawalEvent)
- + handleTransferFromEvent(moneyTransferEvent : MoneyTransferEvent)
- + handleTransferToEvent(moneyTransferEvent : MoneyTransferEvent)
- - handleWithdrawal(money : BigDecimal, realTime : boolean)
- + setMoney(money : BigDecimal)
- + setTransactions(transactions : List)
- + toString() : String
- - withdrawMoney(money : BigDecimal) : Transaction
- }
- class Transaction {
- - accountNo : int
- - lastBalance : BigDecimal
- - moneyIn : BigDecimal
- - moneyOut : BigDecimal
- + Transaction(accountNo : int, moneyIn : BigDecimal, moneyOut : BigDecimal, lastBalance : BigDecimal)
- + getAccountNo() : int
- + getLastBalance() : BigDecimal
- + getMoneyIn() : BigDecimal
- + getMoneyOut() : BigDecimal
- + toString() : String
- }
-}
-package com.iluwatar.event.sourcing.api {
- abstract class DomainEvent {
- - createdTime : long
- - eventClassName : String
- - realTime : boolean
- - sequenceId : long
- + DomainEvent(sequenceId : long, createdTime : long, eventClassName : String)
- + getCreatedTime() : long
- + getEventClassName() : String
- + getSequenceId() : long
- + isRealTime() : boolean
- + process() {abstract}
- + setRealTime(realTime : boolean)
- }
- interface EventProcessor {
- + process(DomainEvent) {abstract}
- + recover() {abstract}
- + setPrecessorJournal(ProcessorJournal) {abstract}
- }
- interface ProcessorJournal {
- + readNext() : DomainEvent {abstract}
- + reset() {abstract}
- + write(DomainEvent) {abstract}
- }
-}
-Gateways --> "-accountCreateContractSender" AccountCreateContractSender
-DomainEventProcessor --> "-precessorJournal" ProcessorJournal
-Account --> "-transactions" Transaction
-Gateways --> "-transactionLogger" TransactionLogger
-AccountService --> "-eventProcessor" EventProcessor
-MoneyTransactionService --> "-eventProcessor" EventProcessor
-AccountCreateEvent --|> DomainEvent
-MoneyDepositEvent --|> DomainEvent
-MoneyTransferEvent --|> DomainEvent
-MoneyWithdrawalEvent --|> DomainEvent
-JsonFileJournal ..|> ProcessorJournal
-DomainEventProcessor ..|> EventProcessor
-@enduml
\ No newline at end of file
diff --git a/event-sourcing/pom.xml b/event-sourcing/pom.xml
index 35d462cb1..a17d02379 100644
--- a/event-sourcing/pom.xml
+++ b/event-sourcing/pom.xml
@@ -30,13 +30,18 @@
java-design-patterns
com.iluwatar
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
event-sourcing
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-sourcing/src/test/java/IntegrationTest.java b/event-sourcing/src/test/java/IntegrationTest.java
index 5a3f5718a..aab1ea7ea 100644
--- a/event-sourcing/src/test/java/IntegrationTest.java
+++ b/event-sourcing/src/test/java/IntegrationTest.java
@@ -21,20 +21,21 @@
* THE SOFTWARE.
*/
-import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_DAENERYS;
-import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_JON;
-
import com.iluwatar.event.sourcing.domain.Account;
import com.iluwatar.event.sourcing.event.AccountCreateEvent;
import com.iluwatar.event.sourcing.event.MoneyDepositEvent;
import com.iluwatar.event.sourcing.event.MoneyTransferEvent;
import com.iluwatar.event.sourcing.processor.DomainEventProcessor;
import com.iluwatar.event.sourcing.state.AccountAggregate;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.math.BigDecimal;
import java.util.Date;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+
+import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_DAENERYS;
+import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_JON;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Intergartion Test for Event Sourcing state recovery
@@ -51,7 +52,7 @@ public class IntegrationTest {
/**
* Initialize.
*/
- @Before
+ @BeforeEach
public void initialize() {
eventProcessor = new DomainEventProcessor();
}
@@ -90,10 +91,9 @@ public class IntegrationTest {
Account accountOfDaenerysAfterShotDown = AccountAggregate.getAccount(ACCOUNT_OF_DAENERYS);
Account accountOfJonAfterShotDown = AccountAggregate.getAccount(ACCOUNT_OF_JON);
- Assert.assertEquals(accountOfDaenerysBeforeShotDown.getMoney(),
+ assertEquals(accountOfDaenerysBeforeShotDown.getMoney(),
accountOfDaenerysAfterShotDown.getMoney());
- Assert
- .assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
+ assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
}
}
\ No newline at end of file
diff --git a/execute-around/README.md b/execute-around/README.md
index e0ae128b5..f669f18ff 100644
--- a/execute-around/README.md
+++ b/execute-around/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Execute Around
folder: execute-around
permalink: /patterns/execute-around/
-pumlid: NSZ14G8n20NGLhI0XBlT865suoGa0n_NylNixSsxTvEHJTF7xGHsF8YShtfqdFdCK9TbK4ELDQcFl1ZizE8tbwRH3okR0NKBcXm_a7vK4bhOLreZXVnLJPzrvnnV
categories: Other
tags:
- Java
diff --git a/execute-around/etc/execute-around.urm.puml b/execute-around/etc/execute-around.urm.puml
deleted file mode 100644
index fd01a5fe1..000000000
--- a/execute-around/etc/execute-around.urm.puml
+++ /dev/null
@@ -1,14 +0,0 @@
-@startuml
-package com.iluwatar.execute.around {
- class App {
- + App()
- + main(args : String[]) {static}
- }
- interface FileWriterAction {
- + writeFile(FileWriter) {abstract}
- }
- class SimpleFileWriter {
- + SimpleFileWriter(filename : String, action : FileWriterAction)
- }
-}
-@enduml
\ No newline at end of file
diff --git a/execute-around/pom.xml b/execute-around/pom.xml
index c4b3ac504..2e43c3e4b 100644
--- a/execute-around/pom.xml
+++ b/execute-around/pom.xml
@@ -29,13 +29,23 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
execute-around
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-migrationsupport
test
diff --git a/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java b/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java
index 7604db16d..298f7e0d7 100644
--- a/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java
+++ b/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.execute.around;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -42,8 +42,8 @@ public class AppTest {
App.main(args);
}
- @Before
- @After
+ @BeforeEach
+ @AfterEach
public void cleanup() {
File file = new File("testfile.txt");
file.delete();
diff --git a/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java b/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java
index fd13a92a9..22bdf68f7 100644
--- a/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java
+++ b/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java
@@ -22,23 +22,26 @@
*/
package com.iluwatar.execute.around;
-import org.junit.Assert;
import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/12/15 - 3:21 PM
*
* @author Jeroen Meulemeester
*/
+@EnableRuleMigrationSupport
public class SimpleFileWriterTest {
/**
@@ -53,7 +56,7 @@ public class SimpleFileWriterTest {
@Test
public void testWriterNotNull() throws Exception {
final File temporaryFile = this.testFolder.newFile();
- new SimpleFileWriter(temporaryFile.getPath(), Assert::assertNotNull);
+ new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
}
/**
@@ -64,7 +67,7 @@ public class SimpleFileWriterTest {
final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
assertFalse(nonExistingFile.exists());
- new SimpleFileWriter(nonExistingFile.getPath(), Assert::assertNotNull);
+ new SimpleFileWriter(nonExistingFile.getPath(), Assertions::assertNotNull);
assertTrue(nonExistingFile.exists());
}
@@ -85,11 +88,13 @@ public class SimpleFileWriterTest {
/**
* Verify if an {@link IOException} during the write ripples through
*/
- @Test(expected = IOException.class)
+ @Test
public void testIoException() throws Exception {
- final File temporaryFile = this.testFolder.newFile();
- new SimpleFileWriter(temporaryFile.getPath(), writer -> {
- throw new IOException("");
+ assertThrows(IOException.class, () -> {
+ final File temporaryFile = this.testFolder.newFile();
+ new SimpleFileWriter(temporaryFile.getPath(), writer -> {
+ throw new IOException("");
+ });
});
}
diff --git a/extension-objects/etc/extension-objects.urm.puml b/extension-objects/etc/extension-objects.urm.puml
deleted file mode 100644
index 02af47ddf..000000000
--- a/extension-objects/etc/extension-objects.urm.puml
+++ /dev/null
@@ -1,2 +0,0 @@
-@startuml
-@enduml
\ No newline at end of file
diff --git a/extension-objects/pom.xml b/extension-objects/pom.xml
index c5ee535fe..bd68a2758 100644
--- a/extension-objects/pom.xml
+++ b/extension-objects/pom.xml
@@ -29,15 +29,20 @@
java-design-patterns
com.iluwatar
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
4.0.0
extension-objects
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/extension-objects/src/test/java/AppTest.java b/extension-objects/src/test/java/AppTest.java
index 485788112..f3111bebb 100644
--- a/extension-objects/src/test/java/AppTest.java
+++ b/extension-objects/src/test/java/AppTest.java
@@ -20,7 +20,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/concreteextensions/CommanderTest.java b/extension-objects/src/test/java/concreteextensions/CommanderTest.java
index 11f0cc60e..5dac551f4 100644
--- a/extension-objects/src/test/java/concreteextensions/CommanderTest.java
+++ b/extension-objects/src/test/java/concreteextensions/CommanderTest.java
@@ -22,7 +22,7 @@
*/
package concreteextensions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import units.CommanderUnit;
/**
diff --git a/extension-objects/src/test/java/concreteextensions/SergeantTest.java b/extension-objects/src/test/java/concreteextensions/SergeantTest.java
index 2deddca90..f26830e2c 100644
--- a/extension-objects/src/test/java/concreteextensions/SergeantTest.java
+++ b/extension-objects/src/test/java/concreteextensions/SergeantTest.java
@@ -22,7 +22,7 @@
*/
package concreteextensions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import units.SergeantUnit;
/**
diff --git a/extension-objects/src/test/java/concreteextensions/SoldierTest.java b/extension-objects/src/test/java/concreteextensions/SoldierTest.java
index affc6ee8b..a9a6c4768 100644
--- a/extension-objects/src/test/java/concreteextensions/SoldierTest.java
+++ b/extension-objects/src/test/java/concreteextensions/SoldierTest.java
@@ -22,7 +22,7 @@
*/
package concreteextensions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import units.SoldierUnit;
/**
diff --git a/extension-objects/src/test/java/units/CommanderUnitTest.java b/extension-objects/src/test/java/units/CommanderUnitTest.java
index 8f4c1ca8d..536c3ae3f 100644
--- a/extension-objects/src/test/java/units/CommanderUnitTest.java
+++ b/extension-objects/src/test/java/units/CommanderUnitTest.java
@@ -23,10 +23,10 @@
package units;
import abstractextensions.CommanderExtension;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/units/SergeantUnitTest.java b/extension-objects/src/test/java/units/SergeantUnitTest.java
index de773b59e..ac518b488 100644
--- a/extension-objects/src/test/java/units/SergeantUnitTest.java
+++ b/extension-objects/src/test/java/units/SergeantUnitTest.java
@@ -23,10 +23,10 @@
package units;
import abstractextensions.SergeantExtension;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/units/SoldierUnitTest.java b/extension-objects/src/test/java/units/SoldierUnitTest.java
index 06a1f7611..1aeb9a3cd 100644
--- a/extension-objects/src/test/java/units/SoldierUnitTest.java
+++ b/extension-objects/src/test/java/units/SoldierUnitTest.java
@@ -23,10 +23,10 @@
package units;
import abstractextensions.SoldierExtension;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/units/UnitTest.java b/extension-objects/src/test/java/units/UnitTest.java
index a7d530032..389c9f753 100644
--- a/extension-objects/src/test/java/units/UnitTest.java
+++ b/extension-objects/src/test/java/units/UnitTest.java
@@ -22,10 +22,10 @@
*/
package units;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/facade/README.md b/facade/README.md
index 66ca84256..7caa89d94 100644
--- a/facade/README.md
+++ b/facade/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Facade
folder: facade
permalink: /patterns/facade/
-pumlid: BSP15eCm20N0gxG7CEoz3ILKqvTW7dpq-hhehERTJ7fMJU-l7PYn4ZbVPMlOyvEXBeT13KMEGQtdnM2d7v-yL8sssJ8PKBUWmV64lYnSbHJoRqaVPUReDm00
categories: Structural
tags:
- Java
@@ -203,7 +202,7 @@ Use the Facade pattern when
* you want to provide a simple interface to a complex subsystem. Subsystems often get more complex as they evolve. Most patterns, when applied, result in more and smaller classes. This makes the subsystem more reusable and easier to customize, but it also becomes harder to use for clients that don't need to customize it. A facade can provide a simple default view of the subsystem that is good enough for most clients. Only clients needing more customizability will need to look beyond the facade.
* there are many dependencies between clients and the implementation classes of an abstraction. Introduce a facade to decouple the subsystem from clients and other subsystems, thereby promoting subsystem independence and portability.
-* you want to layer your subsystems. Use a facade to define an entry point to each subsystem level. If subsystems are dependent, the you can simplify the dependencies between them by making them communicate with each other solely through their facades
+* you want to layer your subsystems. Use a facade to define an entry point to each subsystem level. If subsystems are dependent, then you can simplify the dependencies between them by making them communicate with each other solely through their facades.
## Credits
diff --git a/facade/pom.xml b/facade/pom.xml
index d699ac8fe..deb56a382 100644
--- a/facade/pom.xml
+++ b/facade/pom.xml
@@ -29,18 +29,18 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
facade
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/facade/src/test/java/com/iluwatar/facade/AppTest.java b/facade/src/test/java/com/iluwatar/facade/AppTest.java
index e890f42d4..366315e9e 100644
--- a/facade/src/test/java/com/iluwatar/facade/AppTest.java
+++ b/facade/src/test/java/com/iluwatar/facade/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.facade;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java b/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java
index 6457307cf..19987acbc 100644
--- a/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java
+++ b/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java
@@ -25,16 +25,16 @@ package com.iluwatar.facade;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/9/15 - 9:40 PM
@@ -45,12 +45,12 @@ public class DwarvenGoldmineFacadeTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/factory-kit/README.md b/factory-kit/README.md
index b47cbff76..c25701047 100644
--- a/factory-kit/README.md
+++ b/factory-kit/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Factory Kit
folder: factory-kit
permalink: /patterns/factory-kit/
-pumlid: JST15i8m20N0g-W14lRU1YcsQ4BooCS-RwzBTpDNSscvQKQx7C1SDwBWi-w68--vD6Gur55bTBAM9uE3dlpcikcotSjaGCCNTLu_q8C58pxbPI25_Bzcz3gpjoy0
categories: Creational
tags:
- Java
diff --git a/factory-kit/etc/factory-kit.urm.puml b/factory-kit/etc/factory-kit.urm.puml
deleted file mode 100644
index 23cf658f4..000000000
--- a/factory-kit/etc/factory-kit.urm.puml
+++ /dev/null
@@ -1,46 +0,0 @@
-@startuml
-package com.iluwatar.factorykit {
- class App {
- - LOGGER : Logger {static}
- + App()
- + main(args : String[]) {static}
- }
- class Axe {
- + Axe()
- + toString() : String
- }
- class Bow {
- + Bow()
- + toString() : String
- }
- interface Builder {
- + add(WeaponType, Supplier) {abstract}
- }
- class Spear {
- + Spear()
- + toString() : String
- }
- class Sword {
- + Sword()
- + toString() : String
- }
- interface Weapon {
- }
- interface WeaponFactory {
- + create(WeaponType) : Weapon {abstract}
- + factory(consumer : Consumer) : WeaponFactory {static}
- }
- enum WeaponType {
- + AXE {static}
- + BOW {static}
- + SPEAR {static}
- + SWORD {static}
- + valueOf(name : String) : WeaponType {static}
- + values() : WeaponType[] {static}
- }
-}
-Axe ..|> Weapon
-Bow ..|> Weapon
-Spear ..|> Weapon
-Sword ..|> Weapon
-@enduml
\ No newline at end of file
diff --git a/factory-kit/pom.xml b/factory-kit/pom.xml
index 50942b3a0..71973928f 100644
--- a/factory-kit/pom.xml
+++ b/factory-kit/pom.xml
@@ -30,18 +30,18 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
factory-kit
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java b/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java
index 4d8691ef0..0be22b9b0 100644
--- a/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java
+++ b/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java
@@ -23,7 +23,7 @@
package com.iluwatar.factorykit.app;
import com.iluwatar.factorykit.App;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application Test Entrypoint
diff --git a/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java b/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java
index 3f732546d..f15223feb 100644
--- a/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java
+++ b/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java
@@ -22,24 +22,25 @@
*/
package com.iluwatar.factorykit.factorykit;
-import static org.junit.Assert.assertTrue;
-
import com.iluwatar.factorykit.Axe;
import com.iluwatar.factorykit.Spear;
import com.iluwatar.factorykit.Sword;
import com.iluwatar.factorykit.Weapon;
import com.iluwatar.factorykit.WeaponFactory;
import com.iluwatar.factorykit.WeaponType;
-import org.junit.Before;
-import org.junit.Test;
-/**
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+ /**
* Test Factory Kit Pattern
*/
public class FactoryKitTest {
private WeaponFactory factory;
- @Before
+ @BeforeEach
public void init() {
factory = WeaponFactory.factory(builder -> {
builder.add(WeaponType.SPEAR, Spear::new);
@@ -83,6 +84,6 @@ public class FactoryKitTest {
* @param clazz expected class of the weapon
*/
private void verifyWeapon(Weapon weapon, Class clazz) {
- assertTrue("Weapon must be an object of: " + clazz.getName(), clazz.isInstance(weapon));
+ assertTrue(clazz.isInstance(weapon), "Weapon must be an object of: " + clazz.getName());
}
}
diff --git a/factory-method/README.md b/factory-method/README.md
index 07c92d0e5..ab3739ac3 100644
--- a/factory-method/README.md
+++ b/factory-method/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Factory Method
folder: factory-method
permalink: /patterns/factory-method/
-pumlid: NSZB3G8n30N0Lg20n7UwCOxPP9MVx6TMT0zdRgEvjoazYeRrMmMsFuYChtmqr7Y6gycQq8aiQr3hSJ7OwEGtfwBUZfas0shJQR3_G2yMBFkaeQYha4B-AeUDl6FqBm00
categories: Creational
tags:
- Java
@@ -70,7 +69,11 @@ Use the Factory Method pattern when
* a class wants its subclasses to specify the objects it creates
* classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate
-## Known uses
+## Presentations
+
+* [Factory Method Pattern](etc/presentation.html)
+
+## Real world examples
* [java.util.Calendar](http://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getInstance--)
* [java.util.ResourceBundle](http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html#getBundle-java.lang.String-)
diff --git a/factory-method/etc/diagram1.png b/factory-method/etc/diagram1.png
new file mode 100644
index 000000000..fa325edf0
Binary files /dev/null and b/factory-method/etc/diagram1.png differ
diff --git a/factory-method/etc/presentation.html b/factory-method/etc/presentation.html
new file mode 100644
index 000000000..a78057836
--- /dev/null
+++ b/factory-method/etc/presentation.html
@@ -0,0 +1,185 @@
+
+
+
+
+ Design Patterns - Factory Method Presentation
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/factory-method/pom.xml b/factory-method/pom.xml
index 61d0058ae..4cad86fdd 100644
--- a/factory-method/pom.xml
+++ b/factory-method/pom.xml
@@ -29,18 +29,18 @@
com.iluwatar
java-design-patterns
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
factory-method
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java b/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
index 88b40d4fe..4a73077c1 100644
--- a/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
+++ b/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.factory.method;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java b/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java
index 4f3a5930d..75d8e4677 100644
--- a/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java
+++ b/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.factory.method;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The Factory Method is a creational design pattern which uses factory methods to deal with the
@@ -53,7 +53,7 @@ public class FactoryMethodTest {
}
/**
- * Testing {@link OrcBlacksmith} to produce a AXE asserting that the Weapon is an instance
+ * Testing {@link OrcBlacksmith} to produce an AXE asserting that the Weapon is an instance
* of {@link OrcWeapon}.
*/
@Test
@@ -94,8 +94,7 @@ public class FactoryMethodTest {
* @param clazz expected class of the weapon
*/
private void verifyWeapon(Weapon weapon, WeaponType expectedWeaponType, Class> clazz) {
- assertTrue("Weapon must be an object of: " + clazz.getName(), clazz.isInstance(weapon));
- assertEquals("Weapon must be of weaponType: " + clazz.getName(), expectedWeaponType,
- weapon.getWeaponType());
+ assertTrue(clazz.isInstance(weapon), "Weapon must be an object of: " + clazz.getName());
+ assertEquals(expectedWeaponType, weapon.getWeaponType(), "Weapon must be of weaponType: " + expectedWeaponType);
}
}
diff --git a/feature-toggle/README.md b/feature-toggle/README.md
index 06d956178..c466b8a94 100644
--- a/feature-toggle/README.md
+++ b/feature-toggle/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Feature Toggle
folder: feature-toggle
permalink: /patterns/feature-toggle/
-pumlid: NSZ14G8X30NGLhG0oDrk8XjPd12OvCTjNy_UthpxiAPvIBhUJc37WyZvgdtWp6U6U5i6CTIs9WtDYy5ER_vmEIH6jx8P4BUWoV43lOIHBWMhTnKIjB-gwRFkdFe5
categories: Behavioral
tags:
- Java
diff --git a/feature-toggle/etc/feature-toggle.urm.puml b/feature-toggle/etc/feature-toggle.urm.puml
deleted file mode 100644
index 0febb2631..000000000
--- a/feature-toggle/etc/feature-toggle.urm.puml
+++ /dev/null
@@ -1,48 +0,0 @@
-@startuml
-package com.iluwatar.featuretoggle.pattern {
- interface Service {
- + getWelcomeMessage(User) : String {abstract}
- + isEnhanced() : boolean {abstract}
- }
-}
-package com.iluwatar.featuretoggle.user {
- class User {
- - name : String
- + User(name : String)
- + toString() : String
- }
- class UserGroup {
- - freeGroup : List {static}
- - paidGroup : List {static}
- + UserGroup()
- + addUserToFreeGroup(user : User) {static}
- + addUserToPaidGroup(user : User) {static}
- + isPaid(user : User) : boolean {static}
- }
-}
-package com.iluwatar.featuretoggle.pattern.tieredversion {
- class TieredFeatureToggleVersion {
- + TieredFeatureToggleVersion()
- + getWelcomeMessage(user : User) : String
- + isEnhanced() : boolean
- }
-}
-package com.iluwatar.featuretoggle.pattern.propertiesversion {
- class PropertiesFeatureToggleVersion {
- - isEnhanced : boolean
- + PropertiesFeatureToggleVersion(properties : Properties)
- + getWelcomeMessage(user : User) : String
- + isEnhanced() : boolean
- }
-}
-package com.iluwatar.featuretoggle {
- class App {
- - LOGGER : Logger {static}
- + App()
- + main(args : String[]) {static}
- }
-}
-UserGroup --> "-freeGroup" User
-PropertiesFeatureToggleVersion ..|> Service
-TieredFeatureToggleVersion ..|> Service
-@enduml
\ No newline at end of file
diff --git a/feature-toggle/pom.xml b/feature-toggle/pom.xml
index b8201aa4f..665847e5e 100644
--- a/feature-toggle/pom.xml
+++ b/feature-toggle/pom.xml
@@ -30,7 +30,7 @@
java-design-patterns
com.iluwatar
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
4.0.0
@@ -39,10 +39,14 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
-
\ No newline at end of file
diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java
index 846b46bcf..9f0d377fa 100644
--- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java
+++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java
@@ -23,30 +23,36 @@
package com.iluwatar.featuretoggle.pattern.propertiesversion;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import com.iluwatar.featuretoggle.pattern.Service;
import com.iluwatar.featuretoggle.user.User;
+import org.junit.jupiter.api.Test;
+
import java.util.Properties;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Properties Toggle
*/
public class PropertiesFeatureToggleVersionTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullPropertiesPassed() throws Exception {
- new PropertiesFeatureToggleVersion(null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new PropertiesFeatureToggleVersion(null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNonBooleanProperty() throws Exception {
- final Properties properties = new Properties();
- properties.setProperty("enhancedWelcome", "Something");
- new PropertiesFeatureToggleVersion(properties);
+ assertThrows(IllegalArgumentException.class, () -> {
+ final Properties properties = new Properties();
+ properties.setProperty("enhancedWelcome", "Something");
+ new PropertiesFeatureToggleVersion(properties);
+ });
}
@Test
diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java
index 3966032d5..0ed0afea9 100644
--- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java
+++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java
@@ -22,14 +22,14 @@
*/
package com.iluwatar.featuretoggle.pattern.tieredversion;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import com.iluwatar.featuretoggle.pattern.Service;
import com.iluwatar.featuretoggle.user.User;
import com.iluwatar.featuretoggle.user.UserGroup;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Tiered Feature Toggle
@@ -40,7 +40,7 @@ public class TieredFeatureToggleVersionTest {
final User freeUser = new User("Alan Defect");
final Service service = new TieredFeatureToggleVersion();
- @Before
+ @BeforeEach
public void setUp() throws Exception {
UserGroup.addUserToPaidGroup(paidUser);
UserGroup.addUserToFreeGroup(freeUser);
diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java
index b2c6e5859..2771655dd 100644
--- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java
+++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java
@@ -22,10 +22,11 @@
*/
package com.iluwatar.featuretoggle.user;
-import static junit.framework.TestCase.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test User Group specific feature
@@ -46,17 +47,21 @@ public class UserGroupTest {
assertTrue(UserGroup.isPaid(user));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAddUserToPaidWhenOnFree() throws Exception {
User user = new User("Paid User");
UserGroup.addUserToFreeGroup(user);
- UserGroup.addUserToPaidGroup(user);
+ assertThrows(IllegalArgumentException.class, () -> {
+ UserGroup.addUserToPaidGroup(user);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAddUserToFreeWhenOnPaid() throws Exception {
User user = new User("Free User");
UserGroup.addUserToPaidGroup(user);
- UserGroup.addUserToFreeGroup(user);
+ assertThrows(IllegalArgumentException.class, () -> {
+ UserGroup.addUserToFreeGroup(user);
+ });
}
}
diff --git a/fluentinterface/README.md b/fluentinterface/README.md
index 8bf43d974..767792da7 100644
--- a/fluentinterface/README.md
+++ b/fluentinterface/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Fluent Interface
folder: fluentinterface
permalink: /patterns/fluentinterface/
-pumlid: NOj93eCm302_KXv0VEzlN6F0bMCYB_3zvjpRQ3IpY97MnkNwEZD7l04SdtP8dlMfOAVBaYqRNHr4wy54Xo_Uk6uSSjWwC9FT0Zh61DYrPY_pyXs9WPF-NIllRLJN7m00
categories: Other
tags:
- Java
diff --git a/fluentinterface/etc/fluentinterface.urm.puml b/fluentinterface/etc/fluentinterface.urm.puml
deleted file mode 100644
index ef71a0f4b..000000000
--- a/fluentinterface/etc/fluentinterface.urm.puml
+++ /dev/null
@@ -1,72 +0,0 @@
-@startuml
-package com.iluwatar.fluentinterface.fluentiterable.simple {
- class SimpleFluentIterable {
- - iterable : Iterable
- # SimpleFluentIterable(iterable : Iterable)
- + asList() : List
- + filter(predicate : Predicate super E>) : FluentIterable
- + first() : Optional
- + first(count : int) : FluentIterable
- + forEach(action : Consumer super E>)
- + from(iterable : Iterable) : FluentIterable {static}
- + fromCopyOf(iterable : Iterable) : FluentIterable {static}
- + getRemainingElementsCount() : int
- + iterator() : Iterator
- + last() : Optional
- + last(count : int) : FluentIterable
- + map(function : Function super E, T>) : FluentIterable
- + spliterator() : Spliterator
- + toList(iterator : Iterator) : List {static}
- }
-}
-package com.iluwatar.fluentinterface.app {
- class App {
- - LOGGER : Logger {static}
- + App()
- + main(args : String[]) {static}
- - negatives() : Predicate super Integer> {static}
- - positives() : Predicate super Integer> {static}
- - prettyPrint(delimiter : String, prefix : String, iterable : Iterable) {static}
- - prettyPrint(prefix : String, iterable : Iterable) {static}
- - transformToString() : Function {static}
- }
-}
-package com.iluwatar.fluentinterface.fluentiterable.lazy {
- abstract class DecoratingIterator {
- # fromIterator : Iterator
- - next : E
- + DecoratingIterator(fromIterator : Iterator)
- + computeNext() : E {abstract}
- + hasNext() : boolean
- + next() : E
- }
- class LazyFluentIterable {
- - iterable : Iterable
- # LazyFluentIterable()
- # LazyFluentIterable(iterable : Iterable)
- + asList() : List
- + filter(predicate : Predicate super E>) : FluentIterable
- + first() : Optional
- + first(count : int) : FluentIterable
- + from(iterable : Iterable) : FluentIterable {static}
- + iterator() : Iterator
- + last() : Optional
- + last(count : int) : FluentIterable
- + map(function : Function super E, T>) : FluentIterable
- }
-}
-package com.iluwatar.fluentinterface.fluentiterable {
- interface FluentIterable {
- + asList() : List {abstract}
- + copyToList(iterable : Iterable) : List {static}
- + filter(Predicate super E>) : FluentIterable {abstract}
- + first() : Optional {abstract}
- + first(int) : FluentIterable {abstract}
- + last() : Optional {abstract}
- + last(int) : FluentIterable {abstract}
- + map(Function super E, T>) : FluentIterable {abstract}
- }
-}
-LazyFluentIterable ..|> FluentIterable
-SimpleFluentIterable ..|> FluentIterable
-@enduml
\ No newline at end of file
diff --git a/fluentinterface/pom.xml b/fluentinterface/pom.xml
index 9c352f1a9..234504396 100644
--- a/fluentinterface/pom.xml
+++ b/fluentinterface/pom.xml
@@ -29,15 +29,20 @@
java-design-patterns
com.iluwatar
- 1.17.0-SNAPSHOT
+ 1.19.0-SNAPSHOT
4.0.0
fluentinterface
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java
index 11740bf1a..6e21bd8e4 100644
--- a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java
+++ b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java
@@ -22,7 +22,8 @@
*/
package com.iluwatar.fluentinterface.app;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
/**
* Application Test Entry
*/
diff --git a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java
index 4cc2b1a7a..0eb9e003a 100644
--- a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java
+++ b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java
@@ -22,13 +22,23 @@
*/
package com.iluwatar.fluentinterface.fluentiterable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Spliterator;
import java.util.function.Consumer;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Date: 12/12/15 - 7:00 PM
@@ -56,7 +66,7 @@ public abstract class FluentIterableTest {
@Test
public void testFirstEmptyCollection() throws Exception {
- final List integers = Collections.emptyList();
+ final List integers = Collections.emptyList();
final Optional first = createFluentIterable(integers).first();
assertNotNull(first);
assertFalse(first.isPresent());
diff --git a/flux/README.md b/flux/README.md
index e36b73900..7ac312c44 100644
--- a/flux/README.md
+++ b/flux/README.md
@@ -3,7 +3,6 @@ layout: pattern
title: Flux
folder: flux
permalink: /patterns/flux/
-pumlid: 7SP14eCm20NGg-W13FlU1YFLE0GpyAazVZk-rPkRLSrDqdKwW14l8kUxx0r7hXdYzJA8eTIhKzEy6UnqyeUNJQBjjWm6n2seS_n3Ryql2UgJajxBoAu_
categories: Presentation Tier
tags:
- Java
diff --git a/flux/etc/flux.urm.puml b/flux/etc/flux.urm.puml
deleted file mode 100644
index 11ac26d60..000000000
--- a/flux/etc/flux.urm.puml
+++ /dev/null
@@ -1,117 +0,0 @@
-@startuml
-package com.iluwatar.flux.view {
- class ContentView {
- - LOGGER : Logger {static}
- - content : Content
- + ContentView()
- + render()
- + storeChanged(store : Store)
- }
- class MenuView {
- - LOGGER : Logger {static}
- - selected : MenuItem
- + MenuView()
- + itemClicked(item : MenuItem)
- + render()
- + storeChanged(store : Store)
- }
- interface View {
- + render() {abstract}
- + storeChanged(Store) {abstract}
- }
-}
-package com.iluwatar.flux.action {
- abstract class Action {
- - type : ActionType
- + Action(type : ActionType)
- + getType() : ActionType
- }
- enum ActionType {
- + CONTENT_CHANGED {static}
- + MENU_ITEM_SELECTED {static}
- + valueOf(name : String) : ActionType {static}
- + values() : ActionType[] {static}
- }
- enum Content {
- + COMPANY {static}
- + PRODUCTS {static}
- - title : String
- + toString() : String
- + valueOf(name : String) : Content {static}
- + values() : Content[] {static}
- }
- class ContentAction {
- - content : Content
- + ContentAction(content : Content)
- + getContent() : Content
- }
- class MenuAction {
- - menuItem : MenuItem
- + MenuAction(menuItem : MenuItem)
- + getMenuItem() : MenuItem
- }
- enum MenuItem {
- + COMPANY {static}
- + HOME {static}
- + PRODUCTS {static}
- - title : String
- + toString() : String
- + valueOf(name : String) : MenuItem {static}
- + values() : MenuItem[] {static}
- }
-}
-package com.iluwatar.flux.app {
- class App {
- + App()
- + main(args : String[]) {static}
- }
-}
-package com.iluwatar.flux.store {
- class ContentStore {
- - content : Content
- + ContentStore()
- + getContent() : Content
- + onAction(action : Action)
- }
- class MenuStore {
- - selected : MenuItem
- + MenuStore()
- + getSelected() : MenuItem
- + onAction(action : Action)
- }
- abstract class Store {
- - views : List