From e71bbe9ce5450701d7ebb3b8f5c31f127e26adfe Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sat, 24 Oct 2020 02:02:17 +0300 Subject: [PATCH 01/12] Simplify unicast event routing --- license-report.md | 16 ++--- .../io/spine/server/route/EventFnRoute.java | 60 +++++++++++++++++++ .../io/spine/server/route/EventRouting.java | 50 ++++++++++++++++ .../aggregate/IgTestAggregateRepository.java | 8 +-- .../server/delivery/given/CounterView.java | 5 +- .../given/airport/TimetableRepository.java | 11 +--- 6 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 server/src/main/java/io/spine/server/route/EventFnRoute.java diff --git a/license-report.md b/license-report.md index d70eb2dd467..12bfd0908d7 100644 --- a/license-report.md +++ b/license-report.md @@ -406,7 +406,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:44 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:26 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -777,7 +777,7 @@ This report was generated on **Thu Oct 22 19:37:44 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:45 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:27 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1183,7 +1183,7 @@ This report was generated on **Thu Oct 22 19:37:45 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:27 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1659,7 +1659,7 @@ This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:28 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2082,7 +2082,7 @@ This report was generated on **Thu Oct 22 19:37:46 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:47 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:28 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2542,7 +2542,7 @@ This report was generated on **Thu Oct 22 19:37:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:49 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:30 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -3010,7 +3010,7 @@ This report was generated on **Thu Oct 22 19:37:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:51 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 01:41:31 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -3514,4 +3514,4 @@ This report was generated on **Thu Oct 22 19:37:51 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 22 19:37:54 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Sat Oct 24 01:41:34 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/server/src/main/java/io/spine/server/route/EventFnRoute.java b/server/src/main/java/io/spine/server/route/EventFnRoute.java new file mode 100644 index 00000000000..80d572e58f9 --- /dev/null +++ b/server/src/main/java/io/spine/server/route/EventFnRoute.java @@ -0,0 +1,60 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.server.route; + +import io.spine.base.EventMessage; +import io.spine.core.EventContext; + +import java.util.Set; +import java.util.function.BiFunction; +import java.util.function.Function; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * An event route with one target entity which ID is obtained as a function + * on an event message. + * + * @param + * the type of the target entity ID + * @param + * the type of the event message + */ +final class EventFnRoute implements EventRoute { + + private static final long serialVersionUID = 0L; + private final BiFunction fn; + + EventFnRoute(Function fn) { + checkNotNull(fn); + this.fn = (e, ctx) -> fn.apply(e); + } + + EventFnRoute(BiFunction fn) { + this.fn = checkNotNull(fn); + } + + @Override + public Set apply(E message, EventContext context) { + I id = fn.apply(message, context); + return EventRoute.withId(id); + } +} diff --git a/server/src/main/java/io/spine/server/route/EventRouting.java b/server/src/main/java/io/spine/server/route/EventRouting.java index 373e909cd52..dd00010ec5c 100644 --- a/server/src/main/java/io/spine/server/route/EventRouting.java +++ b/server/src/main/java/io/spine/server/route/EventRouting.java @@ -28,6 +28,8 @@ import java.util.Optional; import java.util.Set; +import java.util.function.BiFunction; +import java.util.function.Function; import static com.google.common.base.Preconditions.checkNotNull; @@ -151,6 +153,54 @@ EventRouting route(Class eventType, EventRoute via) return this; } + /** + * Sets a custom route for the passed event type by obtaining the target entity + * ID from the passed function. + * + *

This is a convenience method for configuring routing when an event is to be delivered + * to only one entity which ID is calculated from the event message. A simplest case of that + * would be passing a method reference for an accessor of a field of the event message + * which contains the ID of interest. + * + * @param eventType + * the type of the event to route + * @param via + * the function for obtaining the target entity ID + * @param + * the type of the event message + * @return {@code this} to allow chained calls when configuring routing + * @see #route(Class, EventRoute) + * @see #unicast(Class, BiFunction) + */ + @CanIgnoreReturnValue + public + EventRouting unicast(Class eventType, Function via) { + return route(eventType, new EventFnRoute<>(via)); + } + + /** + * Sets a custom route for the passed event type by obtaining the target entity + * ID from the passed function over event message and its context. + * + *

This is a convenience method for configuring routing when an event is to be delivered + * to only one entity which ID is calculated from the event message and its context. + * + * @param eventType + * the type of the event to route + * @param via + * the supplier of the target entity ID + * @param + * the type of the event message + * @return {@code this} to allow chained calls when configuring routing + * @see #route(Class, EventRoute) + * @see #unicast(Class, Function) + */ + @CanIgnoreReturnValue + public + EventRouting unicast(Class eventType, BiFunction via) { + return route(eventType, new EventFnRoute<>(via)); + } + /** * Sets a custom routing schema for entity state updates. * diff --git a/server/src/test/java/io/spine/server/aggregate/given/aggregate/IgTestAggregateRepository.java b/server/src/test/java/io/spine/server/aggregate/given/aggregate/IgTestAggregateRepository.java index 0b9bb5442db..5a2c573451e 100644 --- a/server/src/test/java/io/spine/server/aggregate/given/aggregate/IgTestAggregateRepository.java +++ b/server/src/test/java/io/spine/server/aggregate/given/aggregate/IgTestAggregateRepository.java @@ -25,8 +25,6 @@ import io.spine.test.aggregate.event.AggProjectPaused; import io.spine.test.aggregate.event.AggTaskStarted; -import static io.spine.server.route.EventRoute.withId; - /** * Test environment repository for {@linkplain io.spine.server.aggregate.IdempotencyGuardTest * IdempotencyGuard tests}. @@ -37,9 +35,7 @@ public final class IgTestAggregateRepository @Override protected void setupEventRouting(EventRouting routing) { super.setupEventRouting(routing); - routing.route(AggTaskStarted.class, - (message, ctx) -> withId(message.getProjectId())) - .route(AggProjectPaused.class, - (message, ctx) -> withId(message.getProjectId())); + routing.unicast(AggTaskStarted.class, AggTaskStarted::getProjectId) + .unicast(AggProjectPaused.class, AggProjectPaused::getProjectId); } } diff --git a/server/src/test/java/io/spine/server/delivery/given/CounterView.java b/server/src/test/java/io/spine/server/delivery/given/CounterView.java index cb51a780f4e..47ca869322c 100644 --- a/server/src/test/java/io/spine/server/delivery/given/CounterView.java +++ b/server/src/test/java/io/spine/server/delivery/given/CounterView.java @@ -30,8 +30,6 @@ import io.spine.test.delivery.NumberAdded; import io.spine.type.TypeUrl; -import static io.spine.server.route.EventRoute.withId; - /** * Counts the incoming events. * @@ -65,8 +63,7 @@ public static final class Repository @Override protected void setupEventRouting(EventRouting routing) { super.setupEventRouting(routing); - routing.route(NumberAdded.class, - (message, context) -> withId(message.getCalculatorId())); + routing.unicast(NumberAdded.class, NumberAdded::getCalculatorId); } } } diff --git a/server/src/test/java/io/spine/server/trace/given/airport/TimetableRepository.java b/server/src/test/java/io/spine/server/trace/given/airport/TimetableRepository.java index a0293e6d247..8e703afdf1f 100644 --- a/server/src/test/java/io/spine/server/trace/given/airport/TimetableRepository.java +++ b/server/src/test/java/io/spine/server/trace/given/airport/TimetableRepository.java @@ -29,8 +29,6 @@ import io.spine.test.trace.FlightScheduled; import io.spine.test.trace.Timetable; -import static io.spine.server.route.EventRoute.withId; - public final class TimetableRepository extends ProjectionRepository { @@ -38,11 +36,8 @@ public final class TimetableRepository @Override protected void setupEventRouting(EventRouting routing) { super.setupEventRouting(routing); - routing.route(FlightScheduled.class, - (message, context) -> withId(message.getFrom().getId())) - .route(FlightRescheduled.class, - (message, context) -> withId(context.get(AirportId.class))) - .route(FlightCanceled.class, - (message, context) -> withId(context.get(AirportId.class))); + routing.unicast(FlightScheduled.class, (e) -> e.getFrom().getId()) + .unicast(FlightRescheduled.class, (e, ctx) -> ctx.get(AirportId.class)) + .unicast(FlightCanceled.class, (e, ctx) -> ctx.get(AirportId.class)); } } From 6668f9fc502556e2676b3082eae34adb4f582e6a Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sat, 24 Oct 2020 19:01:28 +0300 Subject: [PATCH 02/12] Update version to support JDK11 --- README.md | 4 ++-- license-report.md | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fe253c3725e..f5aac66263d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ the [Spine Examples][spine-examples] GitHub organization. Building Spine modules and libraries requires JDK 8. -The support of JDK 11 is planned for the [version 2.0.0][v2] of the framework. +The support of JDK 11 is planned for the [version 3.0][v3] of the framework. Gradle is used as a build and dependency management system. @@ -64,5 +64,5 @@ If you need to use API with one of these annotations, please [contact us][email- [quick-start]: https://spine.io/docs/quick-start [spine-examples]: https://github.com/spine-examples [todo-list]: https://github.com/spine-examples/todo-list -[v2]: https://github.com/orgs/SpineEventEngine/projects/11 +[v3]: https://github.com/orgs/SpineEventEngine/projects/11 [config]: https://github.com/SpineEventEngine/config/ diff --git a/license-report.md b/license-report.md index 12bfd0908d7..a39790c8314 100644 --- a/license-report.md +++ b/license-report.md @@ -406,7 +406,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:26 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:53 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -777,7 +777,7 @@ This report was generated on **Sat Oct 24 01:41:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:27 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:53 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1183,7 +1183,7 @@ This report was generated on **Sat Oct 24 01:41:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:27 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:54 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -1659,7 +1659,7 @@ This report was generated on **Sat Oct 24 01:41:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:28 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:54 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2082,7 +2082,7 @@ This report was generated on **Sat Oct 24 01:41:28 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:28 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:55 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -2542,7 +2542,7 @@ This report was generated on **Sat Oct 24 01:41:28 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:30 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:57 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -3010,7 +3010,7 @@ This report was generated on **Sat Oct 24 01:41:30 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:31 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Sat Oct 24 18:58:58 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). @@ -3514,4 +3514,4 @@ This report was generated on **Sat Oct 24 01:41:31 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 01:41:34 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Sat Oct 24 18:59:00 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file From 28c4fe163b7e26f1b56b861aba9800c27aab2117 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sat, 24 Oct 2020 19:03:07 +0300 Subject: [PATCH 03/12] Bump version --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index e54a28673d1..c37136232e8 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -34,7 +34,7 @@ /** * Version of this library. */ -val coreJava = "1.6.5" +val coreJava = "1.6.6" /** * Versions of the Spine libraries that `core-java` depends on. From d41b7ae717cc75d7370eb3e39a748603f1f4da26 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 16:28:01 +0200 Subject: [PATCH 04/12] Unify construction and document --- .../main/java/io/spine/server/route/EventFnRoute.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/spine/server/route/EventFnRoute.java b/server/src/main/java/io/spine/server/route/EventFnRoute.java index 80d572e58f9..656e9ccaa20 100644 --- a/server/src/main/java/io/spine/server/route/EventFnRoute.java +++ b/server/src/main/java/io/spine/server/route/EventFnRoute.java @@ -43,11 +43,17 @@ final class EventFnRoute implements EventRoute private static final long serialVersionUID = 0L; private final BiFunction fn; + /** + * Creates a new event route which obtains target entity ID from an event message. + */ EventFnRoute(Function fn) { - checkNotNull(fn); - this.fn = (e, ctx) -> fn.apply(e); + this((e, ctx) -> fn.apply(e)); } + /** + * Creates an event route which obtains target entity ID from an event message and + * a its context. + */ EventFnRoute(BiFunction fn) { this.fn = checkNotNull(fn); } From 000e77f1716e92bb94be45f63ac37771f04e244d Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 16:30:39 +0200 Subject: [PATCH 05/12] Improve Javadoc --- server/src/main/java/io/spine/server/route/EventFnRoute.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/spine/server/route/EventFnRoute.java b/server/src/main/java/io/spine/server/route/EventFnRoute.java index 656e9ccaa20..6588649bf41 100644 --- a/server/src/main/java/io/spine/server/route/EventFnRoute.java +++ b/server/src/main/java/io/spine/server/route/EventFnRoute.java @@ -30,8 +30,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** - * An event route with one target entity which ID is obtained as a function - * on an event message. + * An event route with one target entity ID of which is obtained as a function + * on an event message or {@code BiFunction} on an event message and its context. * * @param * the type of the target entity ID From 95cdb1b26802ae974cf8b562642766592b65e086 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 18:49:18 +0200 Subject: [PATCH 06/12] Use generic param --- .../src/main/java/io/spine/testing/server/Assertions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testutil-server/src/main/java/io/spine/testing/server/Assertions.java b/testutil-server/src/main/java/io/spine/testing/server/Assertions.java index cac07155468..bd346e1ad87 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/Assertions.java +++ b/testutil-server/src/main/java/io/spine/testing/server/Assertions.java @@ -63,7 +63,7 @@ public static void assertEventClasses(Collection eventClasses, } @SafeVarargs - private static + private static , M extends Message> void assertContains(Collection collection, Function, C> func, Class...classes) { From 3acea45db82c72316435263ddc9b76b9741f6735 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 18:49:38 +0200 Subject: [PATCH 07/12] Check null args --- server/src/main/java/io/spine/server/route/EventRouting.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main/java/io/spine/server/route/EventRouting.java b/server/src/main/java/io/spine/server/route/EventRouting.java index dd00010ec5c..327b85129eb 100644 --- a/server/src/main/java/io/spine/server/route/EventRouting.java +++ b/server/src/main/java/io/spine/server/route/EventRouting.java @@ -175,6 +175,7 @@ EventRouting route(Class eventType, EventRoute via) @CanIgnoreReturnValue public EventRouting unicast(Class eventType, Function via) { + checkNotNull(via); return route(eventType, new EventFnRoute<>(via)); } @@ -198,6 +199,7 @@ EventRouting unicast(Class eventType, Function via) { @CanIgnoreReturnValue public EventRouting unicast(Class eventType, BiFunction via) { + checkNotNull(via); return route(eventType, new EventFnRoute<>(via)); } From 9afeaedf25d669ad50dd74b882ee48a09434457e Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 18:50:42 +0200 Subject: [PATCH 08/12] Migrate to new utility class tests --- .../java/io/spine/change/IntMismatchTest.java | 17 ----------------- .../io/spine/server/delivery/InboxIdsTest.java | 13 +------------ .../entity/storage/EntityQueriesTest.java | 5 ++--- 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/core/src/test/java/io/spine/change/IntMismatchTest.java b/core/src/test/java/io/spine/change/IntMismatchTest.java index f0961d3ce92..a6d896991d2 100644 --- a/core/src/test/java/io/spine/change/IntMismatchTest.java +++ b/core/src/test/java/io/spine/change/IntMismatchTest.java @@ -20,7 +20,6 @@ package io.spine.change; -import com.google.common.testing.NullPointerTester; import io.spine.testing.UtilityClassTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -33,9 +32,6 @@ import static io.spine.change.IntMismatch.unpackActual; import static io.spine.change.IntMismatch.unpackExpected; import static io.spine.change.IntMismatch.unpackNewValue; -import static io.spine.testing.DisplayNames.HAVE_PARAMETERLESS_CTOR; -import static io.spine.testing.DisplayNames.NOT_ACCEPT_NULLS; -import static io.spine.testing.Tests.assertHasPrivateParameterlessCtor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -51,19 +47,6 @@ class IntMismatchTest extends UtilityClassTest { super(IntMismatch.class); } - @Test - @DisplayName(HAVE_PARAMETERLESS_CTOR) - void haveUtilityConstructor() { - assertHasPrivateParameterlessCtor(IntMismatch.class); - } - - @Test - @DisplayName(NOT_ACCEPT_NULLS) - void passNullToleranceCheck() { - new NullPointerTester() - .testAllPublicStaticMethods(IntMismatch.class); - } - @Nested @DisplayName("create ValueMismatch instance") class Create { diff --git a/server/src/test/java/io/spine/server/delivery/InboxIdsTest.java b/server/src/test/java/io/spine/server/delivery/InboxIdsTest.java index e05d0742f8e..31a7b54553a 100644 --- a/server/src/test/java/io/spine/server/delivery/InboxIdsTest.java +++ b/server/src/test/java/io/spine/server/delivery/InboxIdsTest.java @@ -25,7 +25,6 @@ import io.spine.testing.UtilityClassTest; import io.spine.type.TypeUrl; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; /** * Tests of the {@link InboxIds} utility. @@ -34,7 +33,7 @@ class InboxIdsTest extends UtilityClassTest { InboxIdsTest() { - super(InboxIds.class); + super(InboxIds.class, NullPointerTester.Visibility.PACKAGE); } @Override @@ -43,14 +42,4 @@ protected void configure(NullPointerTester tester) { tester.setDefault(InboxId.class, InboxId.getDefaultInstance()) .setDefault(TypeUrl.class, TypeUrl.of(Calc.class)); } - - @Test - @DisplayName("not accept nulls in package-private static methods if the arg is non-Nullable") - @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert") - /* This test does assert via `NullPointerTester. */ - void nullCheckPublicStaticMethods() { - NullPointerTester tester = new NullPointerTester(); - configure(tester); - tester.testStaticMethods(getUtilityClass(), NullPointerTester.Visibility.PACKAGE); - } } diff --git a/server/src/test/java/io/spine/server/entity/storage/EntityQueriesTest.java b/server/src/test/java/io/spine/server/entity/storage/EntityQueriesTest.java index 7ff9c7845f3..e7064529cb0 100644 --- a/server/src/test/java/io/spine/server/entity/storage/EntityQueriesTest.java +++ b/server/src/test/java/io/spine/server/entity/storage/EntityQueriesTest.java @@ -63,7 +63,7 @@ class EntityQueriesTest extends UtilityClassTest { private EntityQueriesTest() { - super(EntityQueries.class); + super(EntityQueries.class, NullPointerTester.Visibility.PACKAGE); } @Override @@ -76,8 +76,7 @@ protected void configure(NullPointerTester tester) { tester.setDefault(OrderBy.class, OrderBy.getDefaultInstance()) .setDefault(TargetFilters.class, TargetFilters.getDefaultInstance()) .setDefault(RecordStorage.class, storage) - .setDefault(Columns.class, Columns.of(TestEntity.class)) - .testStaticMethods(getUtilityClass(), NullPointerTester.Visibility.PACKAGE); + .setDefault(Columns.class, Columns.of(TestEntity.class)); } private static EntityQuery createEntityQuery(TargetFilters filters, From 04513b75a2ae3c260199fd400ced2929926fd14e Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 18:50:48 +0200 Subject: [PATCH 09/12] Bump base --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index c37136232e8..da397d468d7 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -39,7 +39,7 @@ val coreJava = "1.6.6" /** * Versions of the Spine libraries that `core-java` depends on. */ -val base = "1.6.5" +val base = "1.6.6" val time = "1.6.0" project.extra.apply { From 6324626647e4a469fc7152ac29960065533c8b77 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 20:04:58 +0200 Subject: [PATCH 10/12] Remove redundant method --- .../io/spine/testing/core/given/GivenVersionTest.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/testutil-core/src/test/java/io/spine/testing/core/given/GivenVersionTest.java b/testutil-core/src/test/java/io/spine/testing/core/given/GivenVersionTest.java index 8ca0e153db4..98f666d228a 100644 --- a/testutil-core/src/test/java/io/spine/testing/core/given/GivenVersionTest.java +++ b/testutil-core/src/test/java/io/spine/testing/core/given/GivenVersionTest.java @@ -25,9 +25,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import static io.spine.testing.DisplayNames.HAVE_PARAMETERLESS_CTOR; import static io.spine.testing.TestValues.random; -import static io.spine.testing.Tests.assertHasPrivateParameterlessCtor; import static org.junit.jupiter.api.Assertions.assertEquals; @DisplayName("GivenVersion should") @@ -37,12 +35,6 @@ class GivenVersionTest extends UtilityClassTest { super(GivenVersion.class); } - @Test - @DisplayName(HAVE_PARAMETERLESS_CTOR) - void haveUtilityConstructor() { - assertHasPrivateParameterlessCtor(GivenVersion.class); - } - @Test @DisplayName("generate version by number") void generateByNumber() { From 51fecc6daeaf807709c8eabe1022be576cc43cc3 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 20:06:56 +0200 Subject: [PATCH 11/12] Migrate to new API --- .../java/io/spine/server/type/EmptyClassTest.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/server/src/test/java/io/spine/server/type/EmptyClassTest.java b/server/src/test/java/io/spine/server/type/EmptyClassTest.java index 3d7e9d9cec5..30f4ebdcbe2 100644 --- a/server/src/test/java/io/spine/server/type/EmptyClassTest.java +++ b/server/src/test/java/io/spine/server/type/EmptyClassTest.java @@ -21,23 +21,20 @@ package io.spine.server.type; import com.google.common.testing.SerializableTester; +import io.spine.testing.SingletonTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertSame; - @DisplayName("EmptyClass should") -class EmptyClassTest { +class EmptyClassTest extends SingletonTest { + + EmptyClassTest() { + super(EmptyClass.class, EmptyClass::instance); + } @Test @DisplayName("be serializable") void serialize() { SerializableTester.reserializeAndAssert(EmptyClass.instance()); } - - @Test - @DisplayName("return the same instance") - void sameInstance() { - assertSame(EmptyClass.instance(), EmptyClass.instance()); - } } From 6afa48d94b7855a0ea641203468cf65546980499 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Mon, 26 Oct 2020 20:21:59 +0200 Subject: [PATCH 12/12] Update dependency reports --- license-report.md | 32 ++++++++++++++++---------------- pom.xml | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/license-report.md b/license-report.md index a39790c8314..900464b906b 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.6.5` +# Dependencies of `io.spine:spine-client:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -406,12 +406,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:53 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:39 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-core:1.6.5` +# Dependencies of `io.spine:spine-core:1.6.6` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -777,12 +777,12 @@ This report was generated on **Sat Oct 24 18:58:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:53 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:40 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-assembler:1.6.5` +# Dependencies of `io.spine.tools:spine-model-assembler:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1183,12 +1183,12 @@ This report was generated on **Sat Oct 24 18:58:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:54 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:40 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-model-verifier:1.6.5` +# Dependencies of `io.spine.tools:spine-model-verifier:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1659,12 +1659,12 @@ This report was generated on **Sat Oct 24 18:58:54 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:54 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:41 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-server:1.6.5` +# Dependencies of `io.spine:spine-server:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2082,12 +2082,12 @@ This report was generated on **Sat Oct 24 18:58:54 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:55 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:41 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-client:1.6.5` +# Dependencies of `io.spine:spine-testutil-client:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2542,12 +2542,12 @@ This report was generated on **Sat Oct 24 18:58:55 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:57 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:43 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-core:1.6.5` +# Dependencies of `io.spine:spine-testutil-core:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3010,12 +3010,12 @@ This report was generated on **Sat Oct 24 18:58:57 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:58:58 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Oct 26 20:11:44 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-server:1.6.5` +# Dependencies of `io.spine:spine-testutil-server:1.6.6` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3514,4 +3514,4 @@ This report was generated on **Sat Oct 24 18:58:58 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sat Oct 24 18:59:00 EEST 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Mon Oct 26 20:11:46 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index b573fcacd41..63f5be69e2e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,24 @@ + + 4.0.0 @@ -12,7 +32,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.6.5 +1.6.6 2015 @@ -70,7 +90,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base - 1.6.5 + 1.6.6 compile @@ -82,13 +102,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-model-compiler - 1.6.5 + 1.6.6 compile io.spine.tools spine-plugin-base - 1.6.5 + 1.6.6 compile @@ -130,7 +150,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-testlib - 1.6.5 + 1.6.6 test @@ -142,13 +162,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-mute-logging - 1.6.5 + 1.6.6 test io.spine.tools spine-plugin-testlib - 1.6.5 + 1.6.6 test @@ -204,12 +224,12 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-javadoc-filter - 1.6.5 + 1.6.6 io.spine.tools spine-protoc-plugin - 1.6.5 + 1.6.6 net.sourceforge.pmd