From 7b692a94acdbfd5c02f12e46966682e0417eae94 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 21 Feb 2020 17:47:44 +0200 Subject: [PATCH 01/32] Implement HandlerMethodSite --- .../server/entity/HandlerMethodSite.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 server/src/main/java/io/spine/server/entity/HandlerMethodSite.java diff --git a/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java b/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java new file mode 100644 index 00000000000..ecfe4759e14 --- /dev/null +++ b/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java @@ -0,0 +1,90 @@ +/* + * 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.entity; + +import com.google.common.base.Objects; +import com.google.common.flogger.LogSite; +import com.google.errorprone.annotations.Immutable; +import io.spine.code.java.ClassName; + +import java.lang.reflect.Method; +import java.util.stream.Stream; + +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; +import static java.util.stream.Collectors.joining; + +@Immutable +final class HandlerMethodSite extends LogSite { + + private final String fileName; + private final ClassName name; + private final String methodName; + + HandlerMethodSite(Method method) { + checkNotNull(method); + this.name = ClassName.of(method.getDeclaringClass()); + this.fileName = name.topLevelClass().value(); + String params = Stream.of(method.getParameterTypes()) + .map(Class::getSimpleName) + .collect(joining(", ")); + this.methodName = format("%s(%s)", method.getName(), params); + } + + @Override + public String getClassName() { + return name.canonicalName(); + } + + @Override + public String getMethodName() { + return methodName; + } + + @Override + public int getLineNumber() { + return UNKNOWN_LINE; + } + + @Override + public String getFileName() { + return fileName; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof HandlerMethodSite)) { + return false; + } + HandlerMethodSite site = (HandlerMethodSite) o; + return Objects.equal(getFileName(), site.getFileName()) && + Objects.equal(name, site.name) && + Objects.equal(getMethodName(), site.getMethodName()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getFileName(), name, getMethodName()); + } +} From 1f8febf636bbb803865f78c71bbc9ebfd44f9450 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 24 Feb 2020 18:38:36 +0200 Subject: [PATCH 02/32] Implement `LoggingEntity` --- .../spine/server/entity/AbstractEntity.java | 24 +++- .../server/entity/HandlerMethodSite.java | 8 +- .../io/spine/server/entity/LoggingEntity.java | 117 ++++++++++++++++++ .../server/model/AbstractHandlerMethod.java | 39 +++++- 4 files changed, 180 insertions(+), 8 deletions(-) create mode 100644 server/src/main/java/io/spine/server/entity/LoggingEntity.java diff --git a/server/src/main/java/io/spine/server/entity/AbstractEntity.java b/server/src/main/java/io/spine/server/entity/AbstractEntity.java index b2d732854b3..60df3ab970f 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -22,6 +22,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; +import com.google.common.flogger.LogSite; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.protobuf.Any; import com.google.protobuf.Message; @@ -34,13 +35,16 @@ import io.spine.server.entity.model.EntityClass; import io.spine.server.entity.rejection.CannotModifyArchivedEntity; import io.spine.server.entity.rejection.CannotModifyDeletedEntity; +import io.spine.server.model.HandlerMethod; import io.spine.string.Stringifiers; import io.spine.validate.ConstraintViolation; import io.spine.validate.Validate; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.function.Function; import static com.google.common.base.Preconditions.checkNotNull; @@ -61,7 +65,7 @@ fields. See Effective Java 2nd Ed. Item #71. */, "AbstractClassWithoutAbstractMethods", "ClassWithTooManyMethods"}) -public abstract class AbstractEntity implements Entity { +public abstract class AbstractEntity implements Entity, LoggingEntity { /** * Lazily initialized reference to the model class of this entity. @@ -108,6 +112,8 @@ public abstract class AbstractEntity implements Entity */ private volatile boolean lifecycleFlagsChanged; + private @Nullable LogSite logSite; + /** * Creates a new instance with the zero version and cleared lifecycle flags. * @@ -508,6 +514,22 @@ public Timestamp whenModified() { return version.getTimestamp(); } + @Override + public void resetLog() { + this.logSite = null; + } + + @Override + public Optional handlerSite() { + return Optional.ofNullable(logSite); + } + + @Override + public void enter(HandlerMethod method) { + checkNotNull(method); + this.logSite = new HandlerMethodSite(method); + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java b/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java index ecfe4759e14..9d6f5d080ef 100644 --- a/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java +++ b/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java @@ -24,6 +24,7 @@ import com.google.common.flogger.LogSite; import com.google.errorprone.annotations.Immutable; import io.spine.code.java.ClassName; +import io.spine.server.model.HandlerMethod; import java.lang.reflect.Method; import java.util.stream.Stream; @@ -39,7 +40,12 @@ final class HandlerMethodSite extends LogSite { private final ClassName name; private final String methodName; - HandlerMethodSite(Method method) { + HandlerMethodSite(HandlerMethod method) { + this(method.rawMethod()); + } + + private HandlerMethodSite(Method method) { + super(); checkNotNull(method); this.name = ClassName.of(method.getDeclaringClass()); this.fileName = name.topLevelClass().value(); diff --git a/server/src/main/java/io/spine/server/entity/LoggingEntity.java b/server/src/main/java/io/spine/server/entity/LoggingEntity.java new file mode 100644 index 00000000000..5e49664d778 --- /dev/null +++ b/server/src/main/java/io/spine/server/entity/LoggingEntity.java @@ -0,0 +1,117 @@ +/* + * 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.entity; + +import com.google.common.flogger.FluentLogger; +import com.google.common.flogger.LogSite; +import io.spine.logging.Logging; +import io.spine.server.model.HandlerMethod; + +import java.util.Optional; + +public interface LoggingEntity extends Logging { + + Optional handlerSite(); + + void enter(HandlerMethod method); + + void resetLog(); + + @Override + default FluentLogger.Api _severe() { + FluentLogger.Api log = Logging.super._severe(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _error() { + FluentLogger.Api log = Logging.super._error(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _warn() { + FluentLogger.Api log = Logging.super._warn(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _info() { + FluentLogger.Api log = Logging.super._info(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _config() { + FluentLogger.Api log = Logging.super._config(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _fine() { + FluentLogger.Api log = Logging.super._fine(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _debug() { + FluentLogger.Api log = Logging.super._debug(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _finer() { + FluentLogger.Api log = Logging.super._finer(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _finest() { + FluentLogger.Api log = Logging.super._finest(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } + + @Override + default FluentLogger.Api _trace() { + FluentLogger.Api log = Logging.super._trace(); + return handlerSite() + .map(log::withInjectedLogSite) + .orElse(log); + } +} diff --git a/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java b/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java index 4645ea0a2e6..522cd80ee49 100644 --- a/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java +++ b/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java @@ -29,6 +29,7 @@ import io.spine.core.Signal; import io.spine.server.dispatch.DispatchOutcome; import io.spine.server.dispatch.Success; +import io.spine.server.entity.LoggingEntity; import io.spine.server.type.MessageEnvelope; import io.spine.type.MessageClass; import org.checkerframework.checker.nullness.qual.Nullable; @@ -250,13 +251,12 @@ public DispatchOutcome invoke(T target, E envelope) { checkNotNull(envelope); checkAttributesMatch(envelope); MessageId signal = envelope.outerObject().messageId(); + configureLog(target); DispatchOutcome.Builder outcome = DispatchOutcome .newBuilder() .setPropagatedSignal(signal); try { - Object[] arguments = parameterSpec.extractArguments(envelope); - Object rawOutput = method.invoke(target, arguments); - Success success = toSuccessfulOutcome(rawOutput, target, envelope); + Success success = doInvoke(target, envelope); outcome.setSuccess(success); } catch (IllegalOutcomeException e) { Error error = fromThrowable(e); @@ -265,9 +265,7 @@ public DispatchOutcome invoke(T target, E envelope) { Throwable cause = e.getCause(); checkNotNull(cause); if (cause instanceof ThrowableMessage) { - ThrowableMessage throwable = (ThrowableMessage) cause; - Optional maybeSuccess = handleRejection(throwable, target, envelope); - Success success = maybeSuccess.orElseThrow(this::cannotThrowRejections); + Success success = asRejection(target, envelope, cause); outcome.setSuccess(success); } else { Error error = causeOf(cause); @@ -275,10 +273,39 @@ public DispatchOutcome invoke(T target, E envelope) { } } catch (IllegalArgumentException | IllegalAccessException e) { throw illegalStateWithCauseOf(e); + } finally { + resetLog(target); } return outcome.build(); } + private Success doInvoke(T target, E envelope) + throws IllegalAccessException, InvocationTargetException { + Object[] arguments = parameterSpec.extractArguments(envelope); + Object rawOutput = method.invoke(target, arguments); + return toSuccessfulOutcome(rawOutput, target, envelope); + } + + private Success asRejection(T target, E envelope, Throwable cause) { + ThrowableMessage throwable = (ThrowableMessage) cause; + Optional maybeSuccess = handleRejection(throwable, target, envelope); + return maybeSuccess.orElseThrow(this::cannotThrowRejections); + } + + private void configureLog(T target) { + if (target instanceof LoggingEntity) { + LoggingEntity logging = (LoggingEntity) target; + logging.enter(this); + } + } + + private void resetLog(T target) { + if (target instanceof LoggingEntity) { + LoggingEntity logging = (LoggingEntity) target; + logging.resetLog(); + } + } + private RuntimeException cannotThrowRejections() { String errorMessage = format("`%s` may not throw rejections.", this); return new IllegalOutcomeException(errorMessage); From 0e930c6564fe883928ab2f03455c6ff2a9c70591 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 24 Feb 2020 18:56:04 +0200 Subject: [PATCH 03/32] Update config --- config | 2 +- license-report.md | 32 ++++++++++++++++---------------- pom.xml | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/config b/config index 2f239bb2534..d1b59186a3d 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 2f239bb25349e117902a8a0d0b1df57d2a7d48f9 +Subproject commit d1b59186a3d2b4c0cfcc0a5f55c1578909d2e931 diff --git a/license-report.md b/license-report.md index c1e95d419c7..63d88726d9b 100644 --- a/license-report.md +++ b/license-report.md @@ -191,7 +191,7 @@ * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:16 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). +This report was generated on **Mon Feb 24 18:36:48 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). @@ -567,7 +567,7 @@ This report was generated on **Wed Feb 19 16:08:16 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -791,7 +791,7 @@ This report was generated on **Wed Feb 19 16:08:16 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:16 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). +This report was generated on **Mon Feb 24 18:36:48 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). @@ -987,7 +987,7 @@ This report was generated on **Wed Feb 19 16:08:16 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -1206,7 +1206,7 @@ This report was generated on **Wed Feb 19 16:08:16 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:17 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). +This report was generated on **Mon Feb 24 18:36:49 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). @@ -1438,7 +1438,7 @@ This report was generated on **Wed Feb 19 16:08:17 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -1681,7 +1681,7 @@ This report was generated on **Wed Feb 19 16:08:17 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:17 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). +This report was generated on **Mon Feb 24 18:36:49 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). @@ -1885,7 +1885,7 @@ This report was generated on **Wed Feb 19 16:08:17 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -2113,7 +2113,7 @@ This report was generated on **Wed Feb 19 16:08:17 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:18 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). +This report was generated on **Mon Feb 24 18:36:50 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). @@ -2367,7 +2367,7 @@ This report was generated on **Wed Feb 19 16:08:18 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -2586,7 +2586,7 @@ This report was generated on **Wed Feb 19 16:08:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:21 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). +This report was generated on **Mon Feb 24 18:36:52 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). @@ -2848,7 +2848,7 @@ This report was generated on **Wed Feb 19 16:08:21 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -3067,7 +3067,7 @@ This report was generated on **Wed Feb 19 16:08:21 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:22 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). +This report was generated on **Mon Feb 24 18:36:53 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). @@ -3321,7 +3321,7 @@ This report was generated on **Wed Feb 19 16:08:22 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -3584,4 +3584,4 @@ This report was generated on **Wed Feb 19 16:08:22 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Feb 19 16:08:26 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 +This report was generated on **Mon Feb 24 18:36:56 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 436f588c7e0..5b5b069f33b 100644 --- a/pom.xml +++ b/pom.xml @@ -200,7 +200,7 @@ all modules and does not describe the project structure per-subproject. com.google.protobuf protoc - 3.11.3 + 3.11.1 io.grpc From 4b454f2623cf4d3805b3316057eadfb3c630f62f Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 25 Feb 2020 15:10:33 +0200 Subject: [PATCH 04/32] Remove unnecessary stack trace --- .../io/spine/testing/server/blackbox/DiagnosticLog.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/DiagnosticLog.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/DiagnosticLog.java index 91241e27e61..1de167fb8d6 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/DiagnosticLog.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/DiagnosticLog.java @@ -20,7 +20,8 @@ package io.spine.testing.server.blackbox; -import com.google.common.flogger.FluentLogger; +import com.google.common.flogger.FluentLogger.Api; +import com.google.common.flogger.StackSize; import com.google.errorprone.annotations.FormatMethod; import com.google.errorprone.annotations.FormatString; import io.spine.base.EventMessage; @@ -128,7 +129,9 @@ void on(AggregateHistoryCorrupted event) { @FormatMethod private void log(EventMessage event, @FormatString String errorMessage, Object... formatArgs) { String msg = format(errorMessage, formatArgs); - FluentLogger.Api severeLogger = logger().atSevere(); + Api severeLogger = logger() + .atSevere() + .withStackTrace(StackSize.NONE); boolean loggingEnabled = severeLogger.isEnabled(); if (loggingEnabled) { severeLogger.log(msg); From eb726f4778a03a284fdb0e478512ae439cc614df Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 25 Feb 2020 17:49:35 +0200 Subject: [PATCH 05/32] Update base version --- license-report.md | 48 +++++++++++++++++++++++------------------------ pom.xml | 20 ++++++++++---------- version.gradle | 4 ++-- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/license-report.md b/license-report.md index 63d88726d9b..2c47aa95113 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.4.7` +# Dependencies of `io.spine:spine-client:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -191,7 +191,7 @@ * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -415,12 +415,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:48 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). +This report was generated on **Tue Feb 25 17:48:18 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.4.7` +# Dependencies of `io.spine:spine-core:1.4.8` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -567,7 +567,7 @@ This report was generated on **Mon Feb 24 18:36:48 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -791,12 +791,12 @@ This report was generated on **Mon Feb 24 18:36:48 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:48 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). +This report was generated on **Tue Feb 25 17:48:18 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.4.7` +# Dependencies of `io.spine.tools:spine-model-assembler:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -987,7 +987,7 @@ This report was generated on **Mon Feb 24 18:36:48 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -1206,12 +1206,12 @@ This report was generated on **Mon Feb 24 18:36:48 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:49 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). +This report was generated on **Tue Feb 25 17:48:19 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.4.7` +# Dependencies of `io.spine.tools:spine-model-verifier:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1438,7 +1438,7 @@ This report was generated on **Mon Feb 24 18:36:49 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -1681,12 +1681,12 @@ This report was generated on **Mon Feb 24 18:36:49 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:49 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). +This report was generated on **Tue Feb 25 17:48:19 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.4.7` +# Dependencies of `io.spine:spine-server:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1885,7 +1885,7 @@ This report was generated on **Mon Feb 24 18:36:49 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -2113,12 +2113,12 @@ This report was generated on **Mon Feb 24 18:36:49 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:50 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). +This report was generated on **Tue Feb 25 17:48:20 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.4.7` +# Dependencies of `io.spine:spine-testutil-client:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2367,7 +2367,7 @@ This report was generated on **Mon Feb 24 18:36:50 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -2586,12 +2586,12 @@ This report was generated on **Mon Feb 24 18:36:50 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:52 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). +This report was generated on **Tue Feb 25 17:48:22 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.4.7` +# Dependencies of `io.spine:spine-testutil-core:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2848,7 +2848,7 @@ This report was generated on **Mon Feb 24 18:36:52 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -3067,12 +3067,12 @@ This report was generated on **Mon Feb 24 18:36:52 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:53 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). +This report was generated on **Tue Feb 25 17:48:24 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.4.7` +# Dependencies of `io.spine:spine-testutil-server:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3321,7 +3321,7 @@ This report was generated on **Mon Feb 24 18:36:53 EET 2020** using [Gradle-Lice * **Manifest Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) -1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.1 +1. **Group:** com.google.protobuf **Name:** protoc **Version:** 3.11.3 * **POM Project URL:** [https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/) * **POM License: 3-Clause BSD License** - [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) * **POM License: The Apache Software License, Version 2.0** - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -3584,4 +3584,4 @@ This report was generated on **Mon Feb 24 18:36:53 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 18:36:56 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 +This report was generated on **Tue Feb 25 17:48:26 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 5b5b069f33b..3f384c614a1 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.4.7 +1.4.8 2015 @@ -70,7 +70,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base - 1.4.5 + 1.4.8 compile @@ -82,13 +82,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-model-compiler - 1.4.5 + 1.4.8 compile io.spine.tools spine-plugin-base - 1.4.5 + 1.4.8 compile @@ -130,7 +130,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-testlib - 1.4.5 + 1.4.8 test @@ -142,13 +142,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-mute-logging - 1.4.5 + 1.4.8 test io.spine.tools spine-plugin-testlib - 1.4.5 + 1.4.8 test @@ -200,7 +200,7 @@ all modules and does not describe the project structure per-subproject. com.google.protobuf protoc - 3.11.1 + 3.11.3 io.grpc @@ -210,12 +210,12 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-javadoc-filter - 1.4.5 + 1.4.8 io.spine.tools spine-protoc-plugin - 1.4.5 + 1.4.8 net.sourceforge.pmd diff --git a/version.gradle b/version.gradle index 750a6a31893..dac82b689e0 100644 --- a/version.gradle +++ b/version.gradle @@ -25,14 +25,14 @@ * as we want to manage the versions in a single source. */ -final def spineVersion = '1.4.7' +final def spineVersion = '1.4.8' ext { // The version of the modules in this project. versionToPublish = spineVersion // Depend on `base` for the general definitions and a model compiler. - spineBaseVersion = '1.4.5' + spineBaseVersion = '1.4.8' // Depend on `time` for `ZoneId`, `ZoneOffset` and other date/time types and utilities. spineTimeVersion = '1.4.1' From b6beb0600548e8fcbf829a972a701a68e016b569 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 27 Feb 2020 19:30:31 +0200 Subject: [PATCH 06/32] Extract handler logging into a separate API --- license-report.md | 16 +++---- .../spine/server/entity/AbstractEntity.java | 38 +++++++++------ .../java/io/spine/server/log/HandlerLog.java | 46 +++++++++++++++++++ .../{entity => log}/HandlerMethodSite.java | 42 ++++++++--------- .../server/log/LogAwareMessageHandler.java | 34 ++++++++++++++ .../io/spine/server/log/package-info.java | 27 +++++++++++ .../server/model/AbstractHandlerMethod.java | 27 ++++------- 7 files changed, 170 insertions(+), 60 deletions(-) create mode 100644 server/src/main/java/io/spine/server/log/HandlerLog.java rename server/src/main/java/io/spine/server/{entity => log}/HandlerMethodSite.java (73%) create mode 100644 server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java create mode 100644 server/src/main/java/io/spine/server/log/package-info.java diff --git a/license-report.md b/license-report.md index 2c47aa95113..ba3d10413f4 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:18 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). +This report was generated on **Thu Feb 27 19:27:33 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). @@ -791,7 +791,7 @@ This report was generated on **Tue Feb 25 17:48:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:18 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). +This report was generated on **Thu Feb 27 19:27:34 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). @@ -1206,7 +1206,7 @@ This report was generated on **Tue Feb 25 17:48:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:19 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). +This report was generated on **Thu Feb 27 19:27:35 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). @@ -1681,7 +1681,7 @@ This report was generated on **Tue Feb 25 17:48:19 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:19 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). +This report was generated on **Thu Feb 27 19:27:35 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). @@ -2113,7 +2113,7 @@ This report was generated on **Tue Feb 25 17:48:19 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:20 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). +This report was generated on **Thu Feb 27 19:27:36 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). @@ -2586,7 +2586,7 @@ This report was generated on **Tue Feb 25 17:48:20 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:22 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). +This report was generated on **Thu Feb 27 19:27: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). @@ -3067,7 +3067,7 @@ This report was generated on **Tue Feb 25 17:48:22 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:24 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). +This report was generated on **Thu Feb 27 19:27: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). @@ -3584,4 +3584,4 @@ This report was generated on **Tue Feb 25 17:48:24 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Feb 25 17:48:26 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 +This report was generated on **Thu Feb 27 19:27: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). \ No newline at end of file diff --git a/server/src/main/java/io/spine/server/entity/AbstractEntity.java b/server/src/main/java/io/spine/server/entity/AbstractEntity.java index 60df3ab970f..92ee4f0fe5b 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -22,7 +22,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; -import com.google.common.flogger.LogSite; +import com.google.common.flogger.FluentLogger; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.protobuf.Any; import com.google.protobuf.Message; @@ -32,9 +32,13 @@ import io.spine.base.Identifier; import io.spine.core.Version; import io.spine.core.Versions; +import io.spine.logging.Logging; import io.spine.server.entity.model.EntityClass; import io.spine.server.entity.rejection.CannotModifyArchivedEntity; import io.spine.server.entity.rejection.CannotModifyDeletedEntity; +import io.spine.server.log.HandlerLog; +import io.spine.server.log.HandlerMethodSite; +import io.spine.server.log.LogAwareMessageHandler; import io.spine.server.model.HandlerMethod; import io.spine.string.Stringifiers; import io.spine.validate.ConstraintViolation; @@ -44,11 +48,11 @@ import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.function.Function; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import static io.spine.logging.Logging.loggerFor; import static io.spine.util.Exceptions.newIllegalArgumentException; import static io.spine.validate.Validate.checkValid; @@ -63,9 +67,8 @@ @SuppressWarnings({ "SynchronizeOnThis" /* This class uses double-check idiom for lazy init of some fields. See Effective Java 2nd Ed. Item #71. */, - "AbstractClassWithoutAbstractMethods", "ClassWithTooManyMethods"}) -public abstract class AbstractEntity implements Entity, LoggingEntity { +public abstract class AbstractEntity implements Entity, LogAwareMessageHandler { /** * Lazily initialized reference to the model class of this entity. @@ -112,7 +115,7 @@ public abstract class AbstractEntity implements Entity */ private volatile boolean lifecycleFlagsChanged; - private @Nullable LogSite logSite; + private @Nullable HandlerLog handlerLog; /** * Creates a new instance with the zero version and cleared lifecycle flags. @@ -515,19 +518,28 @@ public Timestamp whenModified() { } @Override - public void resetLog() { - this.logSite = null; + @Internal + public final void enter(HandlerMethod method) { + checkNotNull(method); + FluentLogger logger = loggerFor(getClass()); + HandlerMethodSite site = new HandlerMethodSite(method); + this.handlerLog = new HandlerLog(logger, site); } + @Internal @Override - public Optional handlerSite() { - return Optional.ofNullable(logSite); + public void resetLog() { + this.handlerLog = null; } - @Override - public void enter(HandlerMethod method) { - checkNotNull(method); - this.logSite = new HandlerMethodSite(method); + protected final HandlerLog log() { + checkState(handlerLog != null, + "Unable to get a handler log for `%s`." + + "A handler log is available only in message handler methods. " + + "Use `%s` instead.", + getClass().getSimpleName(), + Logging.class.getName()); + return handlerLog; } @Override diff --git a/server/src/main/java/io/spine/server/log/HandlerLog.java b/server/src/main/java/io/spine/server/log/HandlerLog.java new file mode 100644 index 00000000000..87461bd34ec --- /dev/null +++ b/server/src/main/java/io/spine/server/log/HandlerLog.java @@ -0,0 +1,46 @@ +/* + * 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.log; + +import com.google.common.flogger.FluentLogger; +import com.google.common.flogger.LogSite; + +import java.util.logging.Level; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.flogger.StackSize.SMALL; + +public final class HandlerLog { + + private final FluentLogger logger; + private final LogSite logSite; + + public HandlerLog(FluentLogger logger, LogSite logSite) { + this.logger = checkNotNull(logger); + this.logSite = checkNotNull(logSite); + } + + public FluentLogger.Api at(Level level) { + return logger.at(level) + .withStackTrace(SMALL) + .withInjectedLogSite(logSite); + } +} diff --git a/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java b/server/src/main/java/io/spine/server/log/HandlerMethodSite.java similarity index 73% rename from server/src/main/java/io/spine/server/entity/HandlerMethodSite.java rename to server/src/main/java/io/spine/server/log/HandlerMethodSite.java index 9d6f5d080ef..46d75e57fb4 100644 --- a/server/src/main/java/io/spine/server/entity/HandlerMethodSite.java +++ b/server/src/main/java/io/spine/server/log/HandlerMethodSite.java @@ -18,12 +18,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.server.entity; +package io.spine.server.log; import com.google.common.base.Objects; import com.google.common.flogger.LogSite; import com.google.errorprone.annotations.Immutable; +import io.spine.annotation.Internal; import io.spine.code.java.ClassName; +import io.spine.code.java.SimpleClassName; import io.spine.server.model.HandlerMethod; import java.lang.reflect.Method; @@ -33,35 +35,31 @@ import static java.lang.String.format; import static java.util.stream.Collectors.joining; +@Internal @Immutable -final class HandlerMethodSite extends LogSite { +public final class HandlerMethodSite extends LogSite { - private final String fileName; - private final ClassName name; - private final String methodName; + @SuppressWarnings("Immutable") + private final Method method; - HandlerMethodSite(HandlerMethod method) { - this(method.rawMethod()); - } - - private HandlerMethodSite(Method method) { + public HandlerMethodSite(HandlerMethod method) { super(); checkNotNull(method); - this.name = ClassName.of(method.getDeclaringClass()); - this.fileName = name.topLevelClass().value(); - String params = Stream.of(method.getParameterTypes()) - .map(Class::getSimpleName) - .collect(joining(", ")); - this.methodName = format("%s(%s)", method.getName(), params); + this.method = method.rawMethod(); } @Override public String getClassName() { - return name.canonicalName(); + return method.getDeclaringClass() + .getName(); } @Override public String getMethodName() { + String params = Stream.of(method.getParameterTypes()) + .map(Class::getSimpleName) + .collect(joining(", ")); + String methodName = format("%s(%s)", method.getName(), params); return methodName; } @@ -72,7 +70,9 @@ public int getLineNumber() { @Override public String getFileName() { - return fileName; + SimpleClassName className = ClassName.of(method.getDeclaringClass()) + .topLevelClass(); + return className.value() + ".java"; } @Override @@ -84,13 +84,11 @@ public boolean equals(Object o) { return false; } HandlerMethodSite site = (HandlerMethodSite) o; - return Objects.equal(getFileName(), site.getFileName()) && - Objects.equal(name, site.name) && - Objects.equal(getMethodName(), site.getMethodName()); + return Objects.equal(method, site.method); } @Override public int hashCode() { - return Objects.hashCode(getFileName(), name, getMethodName()); + return Objects.hashCode(method); } } diff --git a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java new file mode 100644 index 00000000000..9e272b5e12d --- /dev/null +++ b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java @@ -0,0 +1,34 @@ +/* + * 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.log; + +import io.spine.annotation.Internal; +import io.spine.server.model.HandlerMethod; + +@Internal +public interface LogAwareMessageHandler { + + @Internal + void enter(HandlerMethod method); + + @Internal + void resetLog(); +} diff --git a/server/src/main/java/io/spine/server/log/package-info.java b/server/src/main/java/io/spine/server/log/package-info.java new file mode 100644 index 00000000000..bb1efee08e6 --- /dev/null +++ b/server/src/main/java/io/spine/server/log/package-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +@CheckReturnValue +@ParametersAreNonnullByDefault +package io.spine.server.log; + +import com.google.errorprone.annotations.CheckReturnValue; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java b/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java index 522cd80ee49..e3cf686c482 100644 --- a/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java +++ b/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java @@ -29,7 +29,7 @@ import io.spine.core.Signal; import io.spine.server.dispatch.DispatchOutcome; import io.spine.server.dispatch.Success; -import io.spine.server.entity.LoggingEntity; +import io.spine.server.log.LogAwareMessageHandler; import io.spine.server.type.MessageEnvelope; import io.spine.type.MessageClass; import org.checkerframework.checker.nullness.qual.Nullable; @@ -251,10 +251,15 @@ public DispatchOutcome invoke(T target, E envelope) { checkNotNull(envelope); checkAttributesMatch(envelope); MessageId signal = envelope.outerObject().messageId(); - configureLog(target); DispatchOutcome.Builder outcome = DispatchOutcome .newBuilder() .setPropagatedSignal(signal); + LogAwareMessageHandler asLogAware = target instanceof LogAwareMessageHandler + ? (LogAwareMessageHandler) target + : null; + if (asLogAware != null) { + asLogAware.enter(this); + } try { Success success = doInvoke(target, envelope); outcome.setSuccess(success); @@ -274,7 +279,9 @@ public DispatchOutcome invoke(T target, E envelope) { } catch (IllegalArgumentException | IllegalAccessException e) { throw illegalStateWithCauseOf(e); } finally { - resetLog(target); + if (asLogAware != null) { + asLogAware.resetLog(); + } } return outcome.build(); } @@ -292,20 +299,6 @@ private Success asRejection(T target, E envelope, Throwable cause) { return maybeSuccess.orElseThrow(this::cannotThrowRejections); } - private void configureLog(T target) { - if (target instanceof LoggingEntity) { - LoggingEntity logging = (LoggingEntity) target; - logging.enter(this); - } - } - - private void resetLog(T target) { - if (target instanceof LoggingEntity) { - LoggingEntity logging = (LoggingEntity) target; - logging.resetLog(); - } - } - private RuntimeException cannotThrowRejections() { String errorMessage = format("`%s` may not throw rejections.", this); return new IllegalOutcomeException(errorMessage); From 7b51242b948131242c492f6355d67ebdb2008bd5 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 28 Feb 2020 13:00:00 +0200 Subject: [PATCH 07/32] Update Gradle --- gradle/wrapper/gradle-wrapper.jar | Bin 58702 -> 58695 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index cc4fdc293d0e50b0ad9b65c16e7ddd1db2f6025b..f3d88b1c2faf2fc91d853cd5d4242b5547257070 100644 GIT binary patch delta 12333 zcmY*N`gDT(+fr{UJPom)#((gw! zU-CHk3-^LZ_lBZ@A$vbluV?7CUFE5dHieFI{=8(z{qnkbDZ%R%H;icGKCsi$F9Yo$5CIWt`Fj)-@T;=q&f@zR zutiZy-S^y%g$q=yF^V&)(XR7!@iX@9b&~LO6Q3%56G{!xi&zx)*$WHVX@XK^*&)RD z_AElJW?bm3;&JWy(h5go+0)K?%=>A{v1(&(LUae=M-~hmU|6C8QxB5za`gLbm^A%z z8I|tk`D=UD41xSSUz~r@;sDlMA|welTD0A)WOE$VoXR(l18^NJvn^~vyX~Wlo*KVL zRuj!#g%rD>o9ak$nVL*$L%5stmcvjGrDv3?o{_=E#sC<^FsJ^4heJsy5Dv5PXm?W+ zSjK!Kl)LXsv0K^gNkj$V@*k5vT69Y!u=$Rie#s%_%+b8i+;Ue_|}#!OQZC_$c&^=3(j|qX>Oaz zxs-meR{03@vpV+sr(wEI1J>O%qE+-#JBH>FzAZgf*mT{!665Hx{OQ9dH$L&7Sy|+E zn!yd#)&@HE&cg&)v4GiN#N3?Q<1HP`Tp44OP?^DVZgzWv){TGNk z&u}SU$*{BS}0JgzH1pq%!Wiu)GkEb4Jz9B)7_ zRtJ_7brZ6CkSB`FfIXU!8FINnE&r0V53#P`qL__$m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2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 08745a6e4f52d44ed58ee73699a96fd942d59d86 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 28 Feb 2020 15:45:07 +0200 Subject: [PATCH 08/32] Add a test env for the handler log tests --- license-report.md | 16 +-- .../java/io/spine/server/log/given/Books.java | 77 +++++++++++ .../spine/server/log/given/CardAggregate.java | 126 ++++++++++++++++++ .../server/log/given/CardRepository.java | 39 ++++++ .../server/log/given/TestLogHandler.java | 50 +++++++ .../spine/server/log/given/package-info.java | 27 ++++ .../test/proto/spine/test/library/card.proto | 40 ++++++ .../proto/spine/test/library/commands.proto | 21 +++ .../proto/spine/test/library/events.proto | 22 +++ .../proto/spine/test/library/rejections.proto | 15 +++ 10 files changed, 425 insertions(+), 8 deletions(-) create mode 100644 server/src/test/java/io/spine/server/log/given/Books.java create mode 100644 server/src/test/java/io/spine/server/log/given/CardAggregate.java create mode 100644 server/src/test/java/io/spine/server/log/given/CardRepository.java create mode 100644 server/src/test/java/io/spine/server/log/given/TestLogHandler.java create mode 100644 server/src/test/java/io/spine/server/log/given/package-info.java create mode 100644 server/src/test/proto/spine/test/library/card.proto create mode 100644 server/src/test/proto/spine/test/library/commands.proto create mode 100644 server/src/test/proto/spine/test/library/events.proto create mode 100644 server/src/test/proto/spine/test/library/rejections.proto diff --git a/license-report.md b/license-report.md index ba3d10413f4..44471d803ea 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27:33 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). +This report was generated on **Fri Feb 28 15:09:56 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). @@ -791,7 +791,7 @@ This report was generated on **Thu Feb 27 19:27:33 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27:34 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). +This report was generated on **Fri Feb 28 15:09:57 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). @@ -1206,7 +1206,7 @@ This report was generated on **Thu Feb 27 19:27:34 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27:35 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). +This report was generated on **Fri Feb 28 15:09:57 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). @@ -1681,7 +1681,7 @@ This report was generated on **Thu Feb 27 19:27:35 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27:35 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). +This report was generated on **Fri Feb 28 15:09:58 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). @@ -2113,7 +2113,7 @@ This report was generated on **Thu Feb 27 19:27:35 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27:36 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). +This report was generated on **Fri Feb 28 15:09:58 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). @@ -2586,7 +2586,7 @@ This report was generated on **Thu Feb 27 19:27:36 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27: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). +This report was generated on **Fri Feb 28 15:10:01 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). @@ -3067,7 +3067,7 @@ This report was generated on **Thu Feb 27 19:27:39 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27: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). +This report was generated on **Fri Feb 28 15:10:03 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). @@ -3584,4 +3584,4 @@ This report was generated on **Thu Feb 27 19:27:40 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Feb 27 19:27: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). \ No newline at end of file +This report was generated on **Fri Feb 28 15:10:07 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/server/src/test/java/io/spine/server/log/given/Books.java b/server/src/test/java/io/spine/server/log/given/Books.java new file mode 100644 index 00000000000..9bb565c5ca2 --- /dev/null +++ b/server/src/test/java/io/spine/server/log/given/Books.java @@ -0,0 +1,77 @@ +/* + * 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.log.given; + +import io.spine.people.PersonName; +import io.spine.server.log.Book; +import io.spine.server.log.Isbn; + +public final class Books { + + public static final Isbn BIG_BLUE_BOOK = isbn("978-0321125217"); + public static final Isbn BIG_RED_BOOK = isbn("978-0321834577"); + public static final Isbn SMALL_GREEN_BOOK = isbn("978-0134434421"); + + private static final String PUBLISHER = "A-W"; + + /** + * Prevents the utility class instantiation. + */ + private Books() { + } + + public static Book domainDrivenDesign() { + return Book + .newBuilder() + .setIsbn(BIG_BLUE_BOOK) + .setTitle("Domain-Driven Design") + .addAuthor(PersonName.newBuilder().setGivenName("Eric")) + .setPublisher(PUBLISHER) + .vBuild(); + } + + public static Book implementingDdd() { + return Book + .newBuilder() + .setIsbn(BIG_BLUE_BOOK) + .setTitle("Implementing DDD") + .addAuthor(PersonName.newBuilder().setGivenName("Vaughn")) + .setPublisher(PUBLISHER) + .vBuild(); + } + + public static Book dddDistilled() { + return Book + .newBuilder() + .setIsbn(BIG_BLUE_BOOK) + .setTitle("DDD Distilled") + .addAuthor(PersonName.newBuilder().setGivenName("Vaughn")) + .setPublisher(PUBLISHER) + .vBuild(); + } + + private static Isbn isbn(String value) { + return Isbn + .newBuilder() + .setValue(value) + .build(); + } +} diff --git a/server/src/test/java/io/spine/server/log/given/CardAggregate.java b/server/src/test/java/io/spine/server/log/given/CardAggregate.java new file mode 100644 index 00000000000..d48b39d7bc7 --- /dev/null +++ b/server/src/test/java/io/spine/server/log/given/CardAggregate.java @@ -0,0 +1,126 @@ +/* + * 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.log.given; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.spine.people.PersonName; +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; +import io.spine.server.command.Assign; +import io.spine.server.log.Book; +import io.spine.server.log.BookReturned; +import io.spine.server.log.BooksBorrowed; +import io.spine.server.log.BorrowBooks; +import io.spine.server.log.Isbn; +import io.spine.server.log.LibraryCard; +import io.spine.server.log.LibraryCardId; +import io.spine.server.log.ReturnBook; +import io.spine.server.log.UnknownBook; + +import java.util.ArrayList; +import java.util.List; + +import static io.spine.server.log.given.Books.BIG_BLUE_BOOK; +import static io.spine.server.log.given.Books.BIG_RED_BOOK; +import static io.spine.server.log.given.Books.SMALL_GREEN_BOOK; +import static io.spine.server.log.given.Books.dddDistilled; +import static io.spine.server.log.given.Books.domainDrivenDesign; +import static io.spine.server.log.given.Books.implementingDdd; +import static java.util.logging.Level.FINE; +import static java.util.logging.Level.SEVERE; +import static java.util.logging.Level.WARNING; + +public final class CardAggregate + extends Aggregate { + + private static final ImmutableMap knownBooks = ImmutableMap.of( + BIG_BLUE_BOOK, domainDrivenDesign(), + BIG_RED_BOOK, implementingDdd(), + SMALL_GREEN_BOOK, dddDistilled() + ); + + @Assign + BooksBorrowed handle(BorrowBooks command) throws UnknownBook { + BooksBorrowed.Builder event = BooksBorrowed + .newBuilder() + .setCard(id()); + List unknownBooks = new ArrayList<>(); + for (Isbn bookId : command.getBookIdList()) { + Book book = knownBooks.get(bookId); + if (book != null) { + event.addBook(book); + List authors = book.getAuthorList(); + PersonName firstAuthor = authors.get(0); + log().at(FINE) + .log("Adding to order: %s by %s %s", + book.getTitle(), firstAuthor.getGivenName(), firstAuthor.getFamilyName()); + } else { + log().at(WARNING) + .log("Cannot lend an unknown book. ISBN: `%s`", bookId.getValue()); + unknownBooks.add(bookId); + } + } + if (!unknownBooks.isEmpty()) { + throw UnknownBook + .newBuilder() + .addAllBook(unknownBooks) + .build(); + } else { + return event.vBuild(); + } + } + + @Assign + BookReturned handle(ReturnBook command) throws UnknownBook { + Isbn isbn = command.getBook(); + Book book = knownBooks.get(isbn); + if (book != null) { + UnknownBook rejection = UnknownBook + .newBuilder() + .addAllBook(ImmutableList.of(isbn)) + .build(); + log().at(SEVERE) + .withCause(rejection) + .log("Cannot return an unknown book. ISBN: `%s`", isbn.getValue()); + throw rejection; + } else { + return BookReturned + .newBuilder() + .setCard(id()) + .setBook(book) + .vBuild(); + } + } + + @Apply + private void on(BooksBorrowed event) { + builder().addAllBook(event.getBookList()); + } + + @Apply + private void on(BookReturned event) { + List list = builder().getBookList(); + Book book = event.getBook(); + int bookIndex = list.indexOf(book); + builder().removeBook(bookIndex); + } +} diff --git a/server/src/test/java/io/spine/server/log/given/CardRepository.java b/server/src/test/java/io/spine/server/log/given/CardRepository.java new file mode 100644 index 00000000000..0f37a5a8c2b --- /dev/null +++ b/server/src/test/java/io/spine/server/log/given/CardRepository.java @@ -0,0 +1,39 @@ +/* + * 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.log.given; + +import io.spine.server.aggregate.AggregateRepository; +import io.spine.server.log.BorrowBooks; +import io.spine.server.log.LibraryCardId; +import io.spine.server.route.CommandRouting; + +public final class CardRepository extends AggregateRepository { + + @Override + protected void setupCommandRouting(CommandRouting routing) { + super.setupCommandRouting(routing); + routing.route(BorrowBooks.class, + (message, context) -> LibraryCardId + .newBuilder() + .setReader(context.getActorContext().getActor()) + .build()); + } +} diff --git a/server/src/test/java/io/spine/server/log/given/TestLogHandler.java b/server/src/test/java/io/spine/server/log/given/TestLogHandler.java new file mode 100644 index 00000000000..6bb09bbe1a3 --- /dev/null +++ b/server/src/test/java/io/spine/server/log/given/TestLogHandler.java @@ -0,0 +1,50 @@ +/* + * 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.log.given; + +import com.google.common.collect.ImmutableList; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +public class TestLogHandler extends Handler { + + private final List records = new ArrayList<>(); + + public ImmutableList records() { + return ImmutableList.copyOf(records); + } + + @Override + public void publish(LogRecord record) { + records.add(record); + } + + @Override + public void flush() { + } + + @Override + public void close() throws SecurityException { + } +} diff --git a/server/src/test/java/io/spine/server/log/given/package-info.java b/server/src/test/java/io/spine/server/log/given/package-info.java new file mode 100644 index 00000000000..a82ffd855f6 --- /dev/null +++ b/server/src/test/java/io/spine/server/log/given/package-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +@CheckReturnValue +@ParametersAreNonnullByDefault +package io.spine.server.log.given; + +import com.google.errorprone.annotations.CheckReturnValue; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/src/test/proto/spine/test/library/card.proto b/server/src/test/proto/spine/test/library/card.proto new file mode 100644 index 00000000000..d839db4e064 --- /dev/null +++ b/server/src/test/proto/spine/test/library/card.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package spine.test.server.log; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.server.log"; +option java_outer_classname = "LibraryProto"; +option java_multiple_files = true; + +import "spine/people/person_name.proto"; +import "spine/time/time.proto"; +import "spine/core/user_id.proto"; + +message Isbn { + string value = 1; +} + +message Book { + + Isbn isbn = 1; + string title = 2; + repeated people.PersonName author = 3; + int32 year_when_published = 4; + string publisher = 5; +} + +message LibraryCardId { + + core.UserId reader = 1; +} + +message LibraryCard { + option (entity).kind = AGGREGATE; + + LibraryCardId id = 1; + + repeated Book book = 2; +} diff --git a/server/src/test/proto/spine/test/library/commands.proto b/server/src/test/proto/spine/test/library/commands.proto new file mode 100644 index 00000000000..8de16c7032a --- /dev/null +++ b/server/src/test/proto/spine/test/library/commands.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package spine.test.server.log; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.server.log"; +option java_outer_classname = "LibraryCommandsProto"; +option java_multiple_files = true; + +import "spine/test/library/card.proto"; + +message BorrowBooks { + repeated Isbn book_id = 1 [(required) = true, (validate) = true]; +} + +message ReturnBook { + LibraryCardId card = 1 [(required) = true, (validate) = true]; + Isbn book = 2 [(required) = true, (validate) = true]; +} diff --git a/server/src/test/proto/spine/test/library/events.proto b/server/src/test/proto/spine/test/library/events.proto new file mode 100644 index 00000000000..83b80f70d72 --- /dev/null +++ b/server/src/test/proto/spine/test/library/events.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package spine.test.server.log; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.server.log"; +option java_outer_classname = "LibraryEventsProto"; +option java_multiple_files = true; + +import "spine/test/library/card.proto"; + +message BooksBorrowed { + LibraryCardId card = 1; + repeated Book book = 2 [(required) = true]; +} + +message BookReturned { + LibraryCardId card = 1; + Book book = 2 [(required) = true]; +} diff --git a/server/src/test/proto/spine/test/library/rejections.proto b/server/src/test/proto/spine/test/library/rejections.proto new file mode 100644 index 00000000000..f2d29809539 --- /dev/null +++ b/server/src/test/proto/spine/test/library/rejections.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package spine.test.server.log; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.server.log"; +option java_outer_classname = "LibraryRejections"; + +import "spine/test/library/card.proto"; + +message UnknownBook { + repeated Isbn book = 1 [(required) = true]; +} From f12ccf6934c6bedad7e2d72ff15db4a196fa0925 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 28 Feb 2020 19:03:51 +0200 Subject: [PATCH 09/32] Post signals to BlackBoxBoundedContext with a pre-set actor --- .../spine/testing/server/blackbox/Actor.java | 74 +++++++++++++++++++ .../blackbox/BlackBoxBoundedContext.java | 25 +++++++ .../blackbox/MultitenantBlackBoxContext.java | 7 +- .../blackbox/SingleTenantBlackBoxContext.java | 10 ++- 4 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java new file mode 100644 index 00000000000..0b0b3134fe3 --- /dev/null +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java @@ -0,0 +1,74 @@ +/* + * 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.testing.server.blackbox; + +import io.spine.core.ActorContext; +import io.spine.core.UserId; + +import java.util.function.Supplier; + +import static com.google.common.base.Preconditions.checkNotNull; +import static io.spine.base.Time.currentTime; +import static io.spine.util.Preconditions2.checkNotEmptyOrBlank; +import static io.spine.validate.Validate.checkValid; + +final class Actor { + + private static final Actor defaultActor = from(BlackBoxBoundedContext.class.getName()); + + private final Supplier context; + + private Actor(Supplier context) { + this.context = context; + } + + public static Actor from(String userId) { + checkNotEmptyOrBlank(userId); + UserId id = UserId + .newBuilder() + .setValue(userId) + .build(); + return from(id); + } + + public static Actor from(UserId userId) { + checkNotNull(userId); + return new Actor(() -> ActorContext + .newBuilder() + .setActor(userId) + .setTimestamp(currentTime()) + .vBuild()); + } + + public static Actor with(ActorContext context) { + checkNotNull(context); + checkValid(context); + return new Actor(() -> context); + } + + public static Actor defaultActor() { + return defaultActor; + } + + public ActorContext context() { + return context.get(); + } +} diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java index 67839b215d2..81e5e7c20eb 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java @@ -37,9 +37,11 @@ import io.spine.client.Subscription; import io.spine.client.Topic; import io.spine.core.Ack; +import io.spine.core.ActorContext; import io.spine.core.BoundedContextName; import io.spine.core.Command; import io.spine.core.Event; +import io.spine.core.UserId; import io.spine.grpc.MemoizingObserver; import io.spine.logging.Logging; import io.spine.protobuf.AnyPacker; @@ -90,6 +92,7 @@ import static io.spine.core.BoundedContextNames.assumingTestsValue; import static io.spine.grpc.StreamObservers.memoizingObserver; import static io.spine.server.entity.model.EntityClass.stateClassOf; +import static io.spine.testing.server.blackbox.Actor.defaultActor; import static io.spine.util.Exceptions.illegalStateWithCauseOf; import static java.util.Collections.singletonList; import static java.util.Collections.synchronizedSet; @@ -120,6 +123,11 @@ public abstract class BlackBoxBoundedContext extends AbstractEventSubscriber implements Logging { + private static final UserId DEFAULT_ACTOR = UserId + .newBuilder() + .setValue(BlackBoxBoundedContext.class.getName()) + .build(); + private final BoundedContext context; /** @@ -162,6 +170,8 @@ public abstract class BlackBoxBoundedContext private final Map, Repository> repositories; + private Actor actor; + @SuppressWarnings("ThisEscapedInObjectConstruction") // to inject self as event dispatcher. protected BlackBoxBoundedContext(boolean multitenant, EventEnricher enricher, @@ -185,6 +195,7 @@ protected BlackBoxBoundedContext(boolean multitenant, this.repositories = newHashMap(); this.context.registerEventDispatcher(this); this.context.registerEventDispatcher(DiagnosticLog.instance()); + this.actor = defaultActor(); } /** @@ -323,6 +334,20 @@ public BoundedContextName name() { return context.name(); } + public final T withActor(UserId user) { + this.actor = Actor.from(user); + return thisRef(); + } + + public final T withActor(ActorContext context) { + this.actor = Actor.with(context); + return thisRef(); + } + + protected final ActorContext context() { + return actor.context(); + } + /** * Obtains set of type names of entities known to this Bounded Context. */ diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java index bd6b65fc854..6568eb39395 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java @@ -22,6 +22,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; +import io.spine.core.ActorContext; import io.spine.core.Command; import io.spine.core.Event; import io.spine.core.TenantId; @@ -66,7 +67,11 @@ public MultitenantBlackBoxContext withTenant(TenantId tenant) { @Override protected TestActorRequestFactory requestFactory() { - return new TestActorRequestFactory(MultitenantBlackBoxContext.class, tenantId()); + ActorContext context = context(); + return new TestActorRequestFactory(tenantId(), + context.getActor(), + context.getZoneOffset(), + context.getZoneId()); } @Override diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java index f9eafa23736..297a98e5395 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java @@ -22,6 +22,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; +import io.spine.core.ActorContext; import io.spine.core.Command; import io.spine.core.Event; import io.spine.server.event.EventEnricher; @@ -34,9 +35,6 @@ public final class SingleTenantBlackBoxContext extends BlackBoxBoundedContext { - private final TestActorRequestFactory requestFactory = - new TestActorRequestFactory(SingleTenantBlackBoxContext.class); - SingleTenantBlackBoxContext(String name, EventEnricher enricher) { super(false, enricher, name); } @@ -53,6 +51,10 @@ protected ImmutableList select(EventCollector collector) { @Override protected TestActorRequestFactory requestFactory() { - return requestFactory; + ActorContext context = context(); + return new TestActorRequestFactory(null, + context.getActor(), + context.getZoneOffset(), + context.getZoneId()); } } From 75f31fdca2cd07f7ecc8f8dfb07a41c42b16800d Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 28 Feb 2020 19:04:03 +0200 Subject: [PATCH 10/32] Add tests for HandlerLog --- .../io/spine/server/log/HandlerLogTest.java | 108 ++++++++++++++++++ .../proto/spine/test/library/commands.proto | 3 +- version.gradle | 4 +- 3 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 server/src/test/java/io/spine/server/log/HandlerLogTest.java diff --git a/server/src/test/java/io/spine/server/log/HandlerLogTest.java b/server/src/test/java/io/spine/server/log/HandlerLogTest.java new file mode 100644 index 00000000000..6dc6d02b135 --- /dev/null +++ b/server/src/test/java/io/spine/server/log/HandlerLogTest.java @@ -0,0 +1,108 @@ +/* + * 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.log; + +import com.google.common.collect.ImmutableList; +import com.google.common.flogger.FluentLogger; +import com.google.common.flogger.LoggerConfig; +import io.spine.core.UserId; +import io.spine.logging.Logging; +import io.spine.server.log.given.Books; +import io.spine.server.log.given.CardAggregate; +import io.spine.server.log.given.CardRepository; +import io.spine.server.log.given.TestLogHandler; +import io.spine.testing.core.given.GivenUserId; +import io.spine.testing.logging.LogRecordSubject; +import io.spine.testing.server.blackbox.BlackBoxBoundedContext; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.logging.LogRecord; + +import static com.google.common.truth.Truth.assertThat; +import static io.spine.testing.logging.LogTruth.assertThat; +import static java.util.logging.Level.ALL; +import static java.util.logging.Level.FINE; + +@DisplayName("`HandlerLog` should") +class HandlerLogTest { + + private FluentLogger logger; + private TestLogHandler handler; + + @BeforeEach + void setUpLog() { + logger = Logging.loggerFor(CardAggregate.class); + handler = new TestLogHandler(); + LoggerConfig config = LoggerConfig.of(logger); + config.addHandler(handler); + config.setLevel(ALL); + } + + @AfterEach + void resetLog() { + LoggerConfig.of(logger).removeHandler(handler); + handler.close(); + } + + @Test + @DisplayName("log handler method name and parameters") + void includeSignalName() { + UserId user = GivenUserId.generated(); + LibraryCardId id = LibraryCardId + .newBuilder() + .setReader(user) + .build(); + BorrowBooks command = BorrowBooks + .newBuilder() + .setCard(id) + .addBookId(Books.BIG_RED_BOOK) + .addBookId(Books.BIG_BLUE_BOOK) + .vBuild(); + BlackBoxBoundedContext + .singleTenant() + .withActor(user) + .with(new CardRepository()) + .receivesCommand(command); + ImmutableList records = handler.records(); + + assertThat(records) + .hasSize(2); + + LogRecordSubject firstLog = assertThat(records.get(0)); + firstLog.hasLevelThat() + .isEqualTo(FINE); + firstLog.hasMessageThat() + .contains(Books.implementingDdd().getTitle()); + firstLog.hasMethodNameThat() + .contains(command.getClass().getSimpleName()); + + LogRecordSubject secondLog = assertThat(records.get(1)); + secondLog.hasLevelThat() + .isEqualTo(FINE); + secondLog.hasMessageThat() + .contains(Books.domainDrivenDesign().getTitle()); + secondLog.hasMethodNameThat() + .contains(command.getClass().getSimpleName()); + } +} diff --git a/server/src/test/proto/spine/test/library/commands.proto b/server/src/test/proto/spine/test/library/commands.proto index 8de16c7032a..240948da4c6 100644 --- a/server/src/test/proto/spine/test/library/commands.proto +++ b/server/src/test/proto/spine/test/library/commands.proto @@ -12,7 +12,8 @@ option java_multiple_files = true; import "spine/test/library/card.proto"; message BorrowBooks { - repeated Isbn book_id = 1 [(required) = true, (validate) = true]; + LibraryCardId card = 1 [(required) = true, (validate) = true]; + repeated Isbn book_id = 2 [(required) = true, (validate) = true]; } message ReturnBook { diff --git a/version.gradle b/version.gradle index dac82b689e0..e38531d25dd 100644 --- a/version.gradle +++ b/version.gradle @@ -25,14 +25,14 @@ * as we want to manage the versions in a single source. */ -final def spineVersion = '1.4.8' +final def spineVersion = '1.4.9' ext { // The version of the modules in this project. versionToPublish = spineVersion // Depend on `base` for the general definitions and a model compiler. - spineBaseVersion = '1.4.8' + spineBaseVersion = '1.4.9' // Depend on `time` for `ZoneId`, `ZoneOffset` and other date/time types and utilities. spineTimeVersion = '1.4.1' From 6cf86dccdd0c8fa8003b7ef8a5c17103e3e32912 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 28 Feb 2020 19:09:42 +0200 Subject: [PATCH 11/32] Add more tests for HandlerLog --- .../io/spine/server/log/HandlerLogTest.java | 61 +++++++++++++------ 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/server/src/test/java/io/spine/server/log/HandlerLogTest.java b/server/src/test/java/io/spine/server/log/HandlerLogTest.java index 6dc6d02b135..9f75a152cad 100644 --- a/server/src/test/java/io/spine/server/log/HandlerLogTest.java +++ b/server/src/test/java/io/spine/server/log/HandlerLogTest.java @@ -69,16 +69,7 @@ void resetLog() { @DisplayName("log handler method name and parameters") void includeSignalName() { UserId user = GivenUserId.generated(); - LibraryCardId id = LibraryCardId - .newBuilder() - .setReader(user) - .build(); - BorrowBooks command = BorrowBooks - .newBuilder() - .setCard(id) - .addBookId(Books.BIG_RED_BOOK) - .addBookId(Books.BIG_BLUE_BOOK) - .vBuild(); + BorrowBooks command = borrowBooks(user); BlackBoxBoundedContext .singleTenant() .withActor(user) @@ -89,20 +80,54 @@ void includeSignalName() { assertThat(records) .hasSize(2); - LogRecordSubject firstLog = assertThat(records.get(0)); - firstLog.hasLevelThat() + LogRecordSubject assertFirstLog = assertThat(records.get(0)); + assertFirstLog.hasLevelThat() .isEqualTo(FINE); - firstLog.hasMessageThat() + assertFirstLog.hasMessageThat() .contains(Books.implementingDdd().getTitle()); - firstLog.hasMethodNameThat() + assertFirstLog.hasMethodNameThat() .contains(command.getClass().getSimpleName()); - LogRecordSubject secondLog = assertThat(records.get(1)); - secondLog.hasLevelThat() + LogRecordSubject assertSecondLog = assertThat(records.get(1)); + assertSecondLog.hasLevelThat() .isEqualTo(FINE); - secondLog.hasMessageThat() + assertSecondLog.hasMessageThat() .contains(Books.domainDrivenDesign().getTitle()); - secondLog.hasMethodNameThat() + assertSecondLog.hasMethodNameThat() .contains(command.getClass().getSimpleName()); } + + @Test + @DisplayName("log handler class name") + void includeClassName() { + UserId user = GivenUserId.generated(); + BorrowBooks command = borrowBooks(user); + BlackBoxBoundedContext + .singleTenant() + .withActor(user) + .with(new CardRepository()) + .receivesCommand(command); + ImmutableList records = handler.records(); + + assertThat(records) + .hasSize(2); + for (LogRecord record : records) { + assertThat(record).hasClassNameThat() + .isEqualTo(CardAggregate.class.getName()); + } + } + + private static BorrowBooks borrowBooks(UserId reader) { + LibraryCardId id = LibraryCardId + .newBuilder() + .setReader(reader) + .build(); + BorrowBooks command = BorrowBooks + .newBuilder() + .setCard(id) + .addBookId(Books.BIG_RED_BOOK) + .addBookId(Books.BIG_BLUE_BOOK) + .vBuild(); + return command; + } } From ea7291747f300f68c76b4dd2116a6704669edbf5 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 14:35:24 +0200 Subject: [PATCH 12/32] Remove an unused constant --- license-report.md | 32 +++++++++---------- pom.xml | 18 +++++------ .../blackbox/BlackBoxBoundedContext.java | 5 --- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/license-report.md b/license-report.md index 44471d803ea..384622bc981 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.4.8` +# Dependencies of `io.spine:spine-client:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -415,12 +415,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:09:56 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). +This report was generated on **Mon Mar 02 14:33: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-core:1.4.8` +# Dependencies of `io.spine:spine-core:1.4.9` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -791,12 +791,12 @@ This report was generated on **Fri Feb 28 15:09:56 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:09:57 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). +This report was generated on **Mon Mar 02 14:33: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.tools:spine-model-assembler:1.4.8` +# Dependencies of `io.spine.tools:spine-model-assembler:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1206,12 +1206,12 @@ This report was generated on **Fri Feb 28 15:09:57 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:09:57 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). +This report was generated on **Mon Mar 02 14:33: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.tools:spine-model-verifier:1.4.8` +# Dependencies of `io.spine.tools:spine-model-verifier:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1681,12 +1681,12 @@ This report was generated on **Fri Feb 28 15:09:57 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:09:58 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). +This report was generated on **Mon Mar 02 14:33:45 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.4.8` +# Dependencies of `io.spine:spine-server:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2113,12 +2113,12 @@ This report was generated on **Fri Feb 28 15:09:58 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:09:58 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). +This report was generated on **Mon Mar 02 14:33:45 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.4.8` +# Dependencies of `io.spine:spine-testutil-client:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2586,12 +2586,12 @@ This report was generated on **Fri Feb 28 15:09:58 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:10:01 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). +This report was generated on **Mon Mar 02 14:33:48 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.4.8` +# Dependencies of `io.spine:spine-testutil-core:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3067,12 +3067,12 @@ This report was generated on **Fri Feb 28 15:10:01 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:10:03 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). +This report was generated on **Mon Mar 02 14:33:50 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.4.8` +# Dependencies of `io.spine:spine-testutil-server:1.4.9` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3584,4 +3584,4 @@ This report was generated on **Fri Feb 28 15:10:03 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Feb 28 15:10:07 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 +This report was generated on **Mon Mar 02 14:33:54 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 3f384c614a1..83f6a16cfee 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.4.8 +1.4.9 2015 @@ -70,7 +70,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base - 1.4.8 + 1.4.9 compile @@ -82,13 +82,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-model-compiler - 1.4.8 + 1.4.9 compile io.spine.tools spine-plugin-base - 1.4.8 + 1.4.9 compile @@ -130,7 +130,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-testlib - 1.4.8 + 1.4.9 test @@ -142,13 +142,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-mute-logging - 1.4.8 + 1.4.9 test io.spine.tools spine-plugin-testlib - 1.4.8 + 1.4.9 test @@ -210,12 +210,12 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-javadoc-filter - 1.4.8 + 1.4.9 io.spine.tools spine-protoc-plugin - 1.4.8 + 1.4.9 net.sourceforge.pmd diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java index 81e5e7c20eb..18f98018883 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java @@ -123,11 +123,6 @@ public abstract class BlackBoxBoundedContext extends AbstractEventSubscriber implements Logging { - private static final UserId DEFAULT_ACTOR = UserId - .newBuilder() - .setValue(BlackBoxBoundedContext.class.getName()) - .build(); - private final BoundedContext context; /** From dfe203106c85674ce202bbd381e7229ee7b41d53 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 14:37:06 +0200 Subject: [PATCH 13/32] Fix `core` version --- version.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle b/version.gradle index e38531d25dd..b95a029b1c3 100644 --- a/version.gradle +++ b/version.gradle @@ -25,7 +25,7 @@ * as we want to manage the versions in a single source. */ -final def spineVersion = '1.4.9' +final def spineVersion = '1.4.8' ext { // The version of the modules in this project. From 4a97afeb4c25a9a3654710c490eb455daed5fbe5 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 14:48:53 +0200 Subject: [PATCH 14/32] Update reports --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 83f6a16cfee..46cb51b5902 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.4.9 +1.4.8 2015 From 276376f03e420d82923653b9f7a06e404ff1956e Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 15:08:08 +0200 Subject: [PATCH 15/32] Delete an unused class --- .../io/spine/server/entity/LoggingEntity.java | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 server/src/main/java/io/spine/server/entity/LoggingEntity.java diff --git a/server/src/main/java/io/spine/server/entity/LoggingEntity.java b/server/src/main/java/io/spine/server/entity/LoggingEntity.java deleted file mode 100644 index 5e49664d778..00000000000 --- a/server/src/main/java/io/spine/server/entity/LoggingEntity.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.entity; - -import com.google.common.flogger.FluentLogger; -import com.google.common.flogger.LogSite; -import io.spine.logging.Logging; -import io.spine.server.model.HandlerMethod; - -import java.util.Optional; - -public interface LoggingEntity extends Logging { - - Optional handlerSite(); - - void enter(HandlerMethod method); - - void resetLog(); - - @Override - default FluentLogger.Api _severe() { - FluentLogger.Api log = Logging.super._severe(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _error() { - FluentLogger.Api log = Logging.super._error(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _warn() { - FluentLogger.Api log = Logging.super._warn(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _info() { - FluentLogger.Api log = Logging.super._info(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _config() { - FluentLogger.Api log = Logging.super._config(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _fine() { - FluentLogger.Api log = Logging.super._fine(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _debug() { - FluentLogger.Api log = Logging.super._debug(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _finer() { - FluentLogger.Api log = Logging.super._finer(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _finest() { - FluentLogger.Api log = Logging.super._finest(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } - - @Override - default FluentLogger.Api _trace() { - FluentLogger.Api log = Logging.super._trace(); - return handlerSite() - .map(log::withInjectedLogSite) - .orElse(log); - } -} From da0a678099c8c5a0ef1ef53e8f336d50c1c0e20f Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 15:08:23 +0200 Subject: [PATCH 16/32] Add doc --- .../io/spine/server/entity/AbstractEntity.java | 5 +++-- .../spine/server/log/LogAwareMessageHandler.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/spine/server/entity/AbstractEntity.java b/server/src/main/java/io/spine/server/entity/AbstractEntity.java index 92ee4f0fe5b..7021519700c 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -68,7 +68,8 @@ "SynchronizeOnThis" /* This class uses double-check idiom for lazy init of some fields. See Effective Java 2nd Ed. Item #71. */, "ClassWithTooManyMethods"}) -public abstract class AbstractEntity implements Entity, LogAwareMessageHandler { +public abstract class AbstractEntity + implements Entity, LogAwareMessageHandler { /** * Lazily initialized reference to the model class of this entity. @@ -517,8 +518,8 @@ public Timestamp whenModified() { return version.getTimestamp(); } - @Override @Internal + @Override public final void enter(HandlerMethod method) { checkNotNull(method); FluentLogger logger = loggerFor(getClass()); diff --git a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java index 9e272b5e12d..6b52899f7c8 100644 --- a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java +++ b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java @@ -23,12 +23,27 @@ import io.spine.annotation.Internal; import io.spine.server.model.HandlerMethod; +/** + * A message handler which, depending on the handled message, alters its own log output. + */ @Internal public interface LogAwareMessageHandler { + /** + * Enters the handler method invocation. + * + *

After calling this method, the message handler should start including the handler method + * info into the log. + */ @Internal void enter(HandlerMethod method); + /** + * Exists the current handler method invocation. + * + *

After calling this method, the message handler should not include any handler method info + * into the log. + */ @Internal void resetLog(); } From ac9fce7b3c10339810089ff8360b7dcd5c652a60 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 15:08:36 +0200 Subject: [PATCH 17/32] Update report --- license-report.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/license-report.md b/license-report.md index 384622bc981..79aaef7a6bf 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.4.9` +# Dependencies of `io.spine:spine-client:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -415,12 +415,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33: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). +This report was generated on **Mon Mar 02 14:42:30 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.4.9` +# Dependencies of `io.spine:spine-core:1.4.8` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -791,12 +791,12 @@ This report was generated on **Mon Mar 02 14:33:43 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33: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). +This report was generated on **Mon Mar 02 14:42:30 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.4.9` +# Dependencies of `io.spine.tools:spine-model-assembler:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1206,12 +1206,12 @@ This report was generated on **Mon Mar 02 14:33:43 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33: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). +This report was generated on **Mon Mar 02 14:42:31 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.4.9` +# Dependencies of `io.spine.tools:spine-model-verifier:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1681,12 +1681,12 @@ This report was generated on **Mon Mar 02 14:33:44 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33:45 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). +This report was generated on **Mon Mar 02 14:42:32 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.4.9` +# Dependencies of `io.spine:spine-server:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2113,12 +2113,12 @@ This report was generated on **Mon Mar 02 14:33:45 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33:45 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). +This report was generated on **Mon Mar 02 14:42:32 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.4.9` +# Dependencies of `io.spine:spine-testutil-client:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2586,12 +2586,12 @@ This report was generated on **Mon Mar 02 14:33:45 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33:48 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). +This report was generated on **Mon Mar 02 14:42:34 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.4.9` +# Dependencies of `io.spine:spine-testutil-core:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3067,12 +3067,12 @@ This report was generated on **Mon Mar 02 14:33:48 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33:50 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). +This report was generated on **Mon Mar 02 14:42:36 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.4.9` +# Dependencies of `io.spine:spine-testutil-server:1.4.8` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 14:33:50 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:33:54 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 +This report was generated on **Mon Mar 02 14:42: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). \ No newline at end of file From fcda1ade83ba35537715d7b9df72ba6cb897f882 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 16:12:42 +0200 Subject: [PATCH 18/32] Add another test and remove stack trace shortening --- license-report.md | 16 ++--- .../spine/server/entity/AbstractEntity.java | 4 +- .../java/io/spine/server/log/HandlerLog.java | 22 ++++-- .../spine/server/log/HandlerMethodSite.java | 2 +- .../io/spine/server/log/HandlerLogTest.java | 72 ++++++++++++++++--- .../java/io/spine/server/log/given/Books.java | 2 + .../spine/server/log/given/CardAggregate.java | 2 +- 7 files changed, 92 insertions(+), 28 deletions(-) diff --git a/license-report.md b/license-report.md index 79aaef7a6bf..46f30ecf9c3 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:30 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). +This report was generated on **Mon Mar 02 16:11:17 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). @@ -791,7 +791,7 @@ This report was generated on **Mon Mar 02 14:42:30 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:30 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). +This report was generated on **Mon Mar 02 16:11:17 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). @@ -1206,7 +1206,7 @@ This report was generated on **Mon Mar 02 14:42:30 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:31 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). +This report was generated on **Mon Mar 02 16:11:18 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). @@ -1681,7 +1681,7 @@ This report was generated on **Mon Mar 02 14:42:31 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:32 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). +This report was generated on **Mon Mar 02 16:11:18 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). @@ -2113,7 +2113,7 @@ This report was generated on **Mon Mar 02 14:42:32 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:32 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). +This report was generated on **Mon Mar 02 16:11:19 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). @@ -2586,7 +2586,7 @@ This report was generated on **Mon Mar 02 14:42:32 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:34 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). +This report was generated on **Mon Mar 02 16:11:21 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). @@ -3067,7 +3067,7 @@ This report was generated on **Mon Mar 02 14:42:34 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42:36 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). +This report was generated on **Mon Mar 02 16:11:22 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). @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 14:42:36 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 14:42: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). \ No newline at end of file +This report was generated on **Mon Mar 02 16:11:25 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/server/src/main/java/io/spine/server/entity/AbstractEntity.java b/server/src/main/java/io/spine/server/entity/AbstractEntity.java index 7021519700c..43f6e6ca4f4 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -37,7 +37,6 @@ import io.spine.server.entity.rejection.CannotModifyArchivedEntity; import io.spine.server.entity.rejection.CannotModifyDeletedEntity; import io.spine.server.log.HandlerLog; -import io.spine.server.log.HandlerMethodSite; import io.spine.server.log.LogAwareMessageHandler; import io.spine.server.model.HandlerMethod; import io.spine.string.Stringifiers; @@ -523,8 +522,7 @@ public Timestamp whenModified() { public final void enter(HandlerMethod method) { checkNotNull(method); FluentLogger logger = loggerFor(getClass()); - HandlerMethodSite site = new HandlerMethodSite(method); - this.handlerLog = new HandlerLog(logger, site); + this.handlerLog = new HandlerLog(logger, method); } @Internal diff --git a/server/src/main/java/io/spine/server/log/HandlerLog.java b/server/src/main/java/io/spine/server/log/HandlerLog.java index 87461bd34ec..9e544f362e2 100644 --- a/server/src/main/java/io/spine/server/log/HandlerLog.java +++ b/server/src/main/java/io/spine/server/log/HandlerLog.java @@ -22,25 +22,39 @@ import com.google.common.flogger.FluentLogger; import com.google.common.flogger.LogSite; +import io.spine.annotation.Internal; +import io.spine.server.model.HandlerMethod; import java.util.logging.Level; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.flogger.StackSize.SMALL; +/** + * A log for handler methods. + * + *

The log is set up with a {@link HandlerMethod} from which it should be accessed. By default, + * the log will include the given method as the logging {@linkplain LogSite site}. + */ public final class HandlerLog { private final FluentLogger logger; private final LogSite logSite; - public HandlerLog(FluentLogger logger, LogSite logSite) { + @Internal + public HandlerLog(FluentLogger logger, HandlerMethod method) { this.logger = checkNotNull(logger); - this.logSite = checkNotNull(logSite); + checkNotNull(method); + this.logSite = new HandlerMethodSite(method); } + /** + * Returns a fluent logging API appropriate for the specified log level. + * + *

By default, the log produced by this API will include the name of the handler method, as + * well as its parameter types. + */ public FluentLogger.Api at(Level level) { return logger.at(level) - .withStackTrace(SMALL) .withInjectedLogSite(logSite); } } diff --git a/server/src/main/java/io/spine/server/log/HandlerMethodSite.java b/server/src/main/java/io/spine/server/log/HandlerMethodSite.java index 46d75e57fb4..e19f92e09b5 100644 --- a/server/src/main/java/io/spine/server/log/HandlerMethodSite.java +++ b/server/src/main/java/io/spine/server/log/HandlerMethodSite.java @@ -42,7 +42,7 @@ public final class HandlerMethodSite extends LogSite { @SuppressWarnings("Immutable") private final Method method; - public HandlerMethodSite(HandlerMethod method) { + HandlerMethodSite(HandlerMethod method) { super(); checkNotNull(method); this.method = method.rawMethod(); diff --git a/server/src/test/java/io/spine/server/log/HandlerLogTest.java b/server/src/test/java/io/spine/server/log/HandlerLogTest.java index 9f75a152cad..432d5d65fd5 100644 --- a/server/src/test/java/io/spine/server/log/HandlerLogTest.java +++ b/server/src/test/java/io/spine/server/log/HandlerLogTest.java @@ -31,38 +31,56 @@ import io.spine.server.log.given.TestLogHandler; import io.spine.testing.core.given.GivenUserId; import io.spine.testing.logging.LogRecordSubject; +import io.spine.testing.logging.MuteLogging; import io.spine.testing.server.blackbox.BlackBoxBoundedContext; +import org.checkerframework.checker.nullness.qual.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import java.util.logging.Handler; +import java.util.logging.Level; import java.util.logging.LogRecord; import static com.google.common.truth.Truth.assertThat; +import static io.spine.server.log.given.Books.THE_HOBBIT; import static io.spine.testing.logging.LogTruth.assertThat; import static java.util.logging.Level.ALL; import static java.util.logging.Level.FINE; +@MuteLogging @DisplayName("`HandlerLog` should") class HandlerLogTest { private FluentLogger logger; private TestLogHandler handler; + private Handler[] defaultHandlers; + private @Nullable Level defaultLevel; @BeforeEach void setUpLog() { logger = Logging.loggerFor(CardAggregate.class); handler = new TestLogHandler(); LoggerConfig config = LoggerConfig.of(logger); + defaultHandlers = config.getHandlers(); + for (Handler defaultHandler : defaultHandlers) { + config.removeHandler(defaultHandler); + } config.addHandler(handler); + defaultLevel = config.getLevel(); config.setLevel(ALL); } @AfterEach void resetLog() { - LoggerConfig.of(logger).removeHandler(handler); + LoggerConfig config = LoggerConfig.of(logger); + config.removeHandler(handler); handler.close(); + for (Handler defaultHandler : defaultHandlers) { + config.addHandler(defaultHandler); + } + config.setLevel(defaultLevel); } @Test @@ -82,19 +100,23 @@ void includeSignalName() { LogRecordSubject assertFirstLog = assertThat(records.get(0)); assertFirstLog.hasLevelThat() - .isEqualTo(FINE); + .isEqualTo(FINE); assertFirstLog.hasMessageThat() - .contains(Books.implementingDdd().getTitle()); + .contains(Books.implementingDdd() + .getTitle()); assertFirstLog.hasMethodNameThat() - .contains(command.getClass().getSimpleName()); + .contains(command.getClass() + .getSimpleName()); LogRecordSubject assertSecondLog = assertThat(records.get(1)); assertSecondLog.hasLevelThat() - .isEqualTo(FINE); + .isEqualTo(FINE); assertSecondLog.hasMessageThat() - .contains(Books.domainDrivenDesign().getTitle()); + .contains(Books.domainDrivenDesign() + .getTitle()); assertSecondLog.hasMethodNameThat() - .contains(command.getClass().getSimpleName()); + .contains(command.getClass() + .getSimpleName()); } @Test @@ -117,11 +139,32 @@ void includeClassName() { } } - private static BorrowBooks borrowBooks(UserId reader) { - LibraryCardId id = LibraryCardId + @Test + @DisplayName("pass the throwable unchanged") + void withCause() { + UserId user = GivenUserId.generated(); + ReturnBook command = ReturnBook .newBuilder() - .setReader(reader) - .build(); + .setCard(cardId(user)) + .setBook(THE_HOBBIT) + .vBuild(); + BlackBoxBoundedContext + .singleTenant() + .withActor(user) + .with(new CardRepository()) + .receivesCommand(command); + ImmutableList records = handler.records(); + assertThat(records) + .hasSize(1); + LogRecord record = records.get(0); + LogRecordSubject assertRecord = assertThat(record); + assertRecord.isError(); + assertRecord.hasThrowableThat() + .isInstanceOf(UnknownBook.class); + } + + private static BorrowBooks borrowBooks(UserId reader) { + LibraryCardId id = cardId(reader); BorrowBooks command = BorrowBooks .newBuilder() .setCard(id) @@ -130,4 +173,11 @@ private static BorrowBooks borrowBooks(UserId reader) { .vBuild(); return command; } + + private static LibraryCardId cardId(UserId reader) { + return LibraryCardId + .newBuilder() + .setReader(reader) + .build(); + } } diff --git a/server/src/test/java/io/spine/server/log/given/Books.java b/server/src/test/java/io/spine/server/log/given/Books.java index 9bb565c5ca2..f02d28d084d 100644 --- a/server/src/test/java/io/spine/server/log/given/Books.java +++ b/server/src/test/java/io/spine/server/log/given/Books.java @@ -30,6 +30,8 @@ public final class Books { public static final Isbn BIG_RED_BOOK = isbn("978-0321834577"); public static final Isbn SMALL_GREEN_BOOK = isbn("978-0134434421"); + public static final Isbn THE_HOBBIT = isbn("978-0547928241"); + private static final String PUBLISHER = "A-W"; /** diff --git a/server/src/test/java/io/spine/server/log/given/CardAggregate.java b/server/src/test/java/io/spine/server/log/given/CardAggregate.java index d48b39d7bc7..50241764a1e 100644 --- a/server/src/test/java/io/spine/server/log/given/CardAggregate.java +++ b/server/src/test/java/io/spine/server/log/given/CardAggregate.java @@ -93,7 +93,7 @@ BooksBorrowed handle(BorrowBooks command) throws UnknownBook { BookReturned handle(ReturnBook command) throws UnknownBook { Isbn isbn = command.getBook(); Book book = knownBooks.get(isbn); - if (book != null) { + if (book == null) { UnknownBook rejection = UnknownBook .newBuilder() .addAllBook(ImmutableList.of(isbn)) From b1f3f5c491941c4456eb2962a1c817278458f295 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 16:19:29 +0200 Subject: [PATCH 19/32] Add doc --- .../java/io/spine/server/log/HandlerMethodSite.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/io/spine/server/log/HandlerMethodSite.java b/server/src/main/java/io/spine/server/log/HandlerMethodSite.java index e19f92e09b5..fa9d0416e50 100644 --- a/server/src/main/java/io/spine/server/log/HandlerMethodSite.java +++ b/server/src/main/java/io/spine/server/log/HandlerMethodSite.java @@ -23,7 +23,6 @@ import com.google.common.base.Objects; import com.google.common.flogger.LogSite; import com.google.errorprone.annotations.Immutable; -import io.spine.annotation.Internal; import io.spine.code.java.ClassName; import io.spine.code.java.SimpleClassName; import io.spine.server.model.HandlerMethod; @@ -35,9 +34,14 @@ import static java.lang.String.format; import static java.util.stream.Collectors.joining; -@Internal +/** + * A {@link LogSite} of a signal handler method. + * + *

The site provides the name of the class and the name of the method with its parameter types. + * The site never provides a line number or a file name. + */ @Immutable -public final class HandlerMethodSite extends LogSite { +final class HandlerMethodSite extends LogSite { @SuppressWarnings("Immutable") private final Method method; From fe37072d320e2777870abca7723e8d523bc967d7 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 16:19:38 +0200 Subject: [PATCH 20/32] Update report --- license-report.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/license-report.md b/license-report.md index 46f30ecf9c3..6d7bf2b3aa3 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:17 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). +This report was generated on **Mon Mar 02 16:18:04 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). @@ -791,7 +791,7 @@ This report was generated on **Mon Mar 02 16:11:17 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:17 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). +This report was generated on **Mon Mar 02 16:18:05 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). @@ -1206,7 +1206,7 @@ This report was generated on **Mon Mar 02 16:11:17 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:18 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). +This report was generated on **Mon Mar 02 16:18:05 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). @@ -1681,7 +1681,7 @@ This report was generated on **Mon Mar 02 16:11:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:18 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). +This report was generated on **Mon Mar 02 16:18:06 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). @@ -2113,7 +2113,7 @@ This report was generated on **Mon Mar 02 16:11:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:19 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). +This report was generated on **Mon Mar 02 16:18:07 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). @@ -2586,7 +2586,7 @@ This report was generated on **Mon Mar 02 16:11:19 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:21 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). +This report was generated on **Mon Mar 02 16:18:10 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). @@ -3067,7 +3067,7 @@ This report was generated on **Mon Mar 02 16:11:21 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:22 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). +This report was generated on **Mon Mar 02 16:18:11 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). @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 16:11:22 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:11:25 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 +This report was generated on **Mon Mar 02 16:18:15 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 From bc229c9a7d2a915ac19e9d8fe953d277a073b734 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 16:26:32 +0200 Subject: [PATCH 21/32] Clean up doc --- .../java/io/spine/server/log/LogAwareMessageHandler.java | 8 ++++---- .../src/main/java/io/spine/server/log/package-info.java | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java index 6b52899f7c8..7c6c193b67c 100644 --- a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java +++ b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java @@ -24,7 +24,7 @@ import io.spine.server.model.HandlerMethod; /** - * A message handler which, depending on the handled message, alters its own log output. + * A message handler which, depending on the message, alters its own log output. */ @Internal public interface LogAwareMessageHandler { @@ -32,7 +32,7 @@ public interface LogAwareMessageHandler { /** * Enters the handler method invocation. * - *

After calling this method, the message handler should start including the handler method + *

After this method is called, the message handler should start including the handler method * info into the log. */ @Internal @@ -41,8 +41,8 @@ public interface LogAwareMessageHandler { /** * Exists the current handler method invocation. * - *

After calling this method, the message handler should not include any handler method info - * into the log. + *

After this method is called, the message handler should not include any handler method + * info into the log. */ @Internal void resetLog(); diff --git a/server/src/main/java/io/spine/server/log/package-info.java b/server/src/main/java/io/spine/server/log/package-info.java index bb1efee08e6..f3998d0f18c 100644 --- a/server/src/main/java/io/spine/server/log/package-info.java +++ b/server/src/main/java/io/spine/server/log/package-info.java @@ -18,6 +18,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/** + * Contains utilities which work with server-side logs. + */ + @CheckReturnValue @ParametersAreNonnullByDefault package io.spine.server.log; From 6d8abff03d71615a9f7edc2c295195fd19b817e6 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 16:26:41 +0200 Subject: [PATCH 22/32] Clean up test env --- .../io/spine/server/log/HandlerLogTest.java | 27 ++++++------- .../server/log/given/CardRepository.java | 39 ------------------- 2 files changed, 11 insertions(+), 55 deletions(-) delete mode 100644 server/src/test/java/io/spine/server/log/given/CardRepository.java diff --git a/server/src/test/java/io/spine/server/log/HandlerLogTest.java b/server/src/test/java/io/spine/server/log/HandlerLogTest.java index 432d5d65fd5..13d46171221 100644 --- a/server/src/test/java/io/spine/server/log/HandlerLogTest.java +++ b/server/src/test/java/io/spine/server/log/HandlerLogTest.java @@ -25,14 +25,15 @@ import com.google.common.flogger.LoggerConfig; import io.spine.core.UserId; import io.spine.logging.Logging; +import io.spine.server.DefaultRepository; import io.spine.server.log.given.Books; import io.spine.server.log.given.CardAggregate; -import io.spine.server.log.given.CardRepository; import io.spine.server.log.given.TestLogHandler; import io.spine.testing.core.given.GivenUserId; import io.spine.testing.logging.LogRecordSubject; import io.spine.testing.logging.MuteLogging; import io.spine.testing.server.blackbox.BlackBoxBoundedContext; +import io.spine.testing.server.blackbox.SingleTenantBlackBoxContext; import org.checkerframework.checker.nullness.qual.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -88,11 +89,7 @@ void resetLog() { void includeSignalName() { UserId user = GivenUserId.generated(); BorrowBooks command = borrowBooks(user); - BlackBoxBoundedContext - .singleTenant() - .withActor(user) - .with(new CardRepository()) - .receivesCommand(command); + context().receivesCommand(command); ImmutableList records = handler.records(); assertThat(records) @@ -124,11 +121,7 @@ void includeSignalName() { void includeClassName() { UserId user = GivenUserId.generated(); BorrowBooks command = borrowBooks(user); - BlackBoxBoundedContext - .singleTenant() - .withActor(user) - .with(new CardRepository()) - .receivesCommand(command); + context().receivesCommand(command); ImmutableList records = handler.records(); assertThat(records) @@ -148,11 +141,7 @@ void withCause() { .setCard(cardId(user)) .setBook(THE_HOBBIT) .vBuild(); - BlackBoxBoundedContext - .singleTenant() - .withActor(user) - .with(new CardRepository()) - .receivesCommand(command); + context().receivesCommand(command); ImmutableList records = handler.records(); assertThat(records) .hasSize(1); @@ -163,6 +152,12 @@ void withCause() { .isInstanceOf(UnknownBook.class); } + private static SingleTenantBlackBoxContext context() { + return BlackBoxBoundedContext + .singleTenant() + .with(DefaultRepository.of(CardAggregate.class)); + } + private static BorrowBooks borrowBooks(UserId reader) { LibraryCardId id = cardId(reader); BorrowBooks command = BorrowBooks diff --git a/server/src/test/java/io/spine/server/log/given/CardRepository.java b/server/src/test/java/io/spine/server/log/given/CardRepository.java deleted file mode 100644 index 0f37a5a8c2b..00000000000 --- a/server/src/test/java/io/spine/server/log/given/CardRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.log.given; - -import io.spine.server.aggregate.AggregateRepository; -import io.spine.server.log.BorrowBooks; -import io.spine.server.log.LibraryCardId; -import io.spine.server.route.CommandRouting; - -public final class CardRepository extends AggregateRepository { - - @Override - protected void setupCommandRouting(CommandRouting routing) { - super.setupCommandRouting(routing); - routing.route(BorrowBooks.class, - (message, context) -> LibraryCardId - .newBuilder() - .setReader(context.getActorContext().getActor()) - .build()); - } -} From 86289f37ebca2b024ea5262e60dc818921b3b7f7 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 16:31:59 +0200 Subject: [PATCH 23/32] Use a library test API instead of an own fixture --- .../io/spine/server/log/HandlerLogTest.java | 10 ++-- .../server/log/given/TestLogHandler.java | 50 ------------------- 2 files changed, 5 insertions(+), 55 deletions(-) delete mode 100644 server/src/test/java/io/spine/server/log/given/TestLogHandler.java diff --git a/server/src/test/java/io/spine/server/log/HandlerLogTest.java b/server/src/test/java/io/spine/server/log/HandlerLogTest.java index 13d46171221..484d6801830 100644 --- a/server/src/test/java/io/spine/server/log/HandlerLogTest.java +++ b/server/src/test/java/io/spine/server/log/HandlerLogTest.java @@ -20,15 +20,14 @@ package io.spine.server.log; -import com.google.common.collect.ImmutableList; import com.google.common.flogger.FluentLogger; import com.google.common.flogger.LoggerConfig; +import com.google.common.testing.TestLogHandler; import io.spine.core.UserId; import io.spine.logging.Logging; import io.spine.server.DefaultRepository; import io.spine.server.log.given.Books; import io.spine.server.log.given.CardAggregate; -import io.spine.server.log.given.TestLogHandler; import io.spine.testing.core.given.GivenUserId; import io.spine.testing.logging.LogRecordSubject; import io.spine.testing.logging.MuteLogging; @@ -40,6 +39,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import java.util.List; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -90,7 +90,7 @@ void includeSignalName() { UserId user = GivenUserId.generated(); BorrowBooks command = borrowBooks(user); context().receivesCommand(command); - ImmutableList records = handler.records(); + List records = handler.getStoredLogRecords(); assertThat(records) .hasSize(2); @@ -122,7 +122,7 @@ void includeClassName() { UserId user = GivenUserId.generated(); BorrowBooks command = borrowBooks(user); context().receivesCommand(command); - ImmutableList records = handler.records(); + List records = handler.getStoredLogRecords(); assertThat(records) .hasSize(2); @@ -142,7 +142,7 @@ void withCause() { .setBook(THE_HOBBIT) .vBuild(); context().receivesCommand(command); - ImmutableList records = handler.records(); + List records = handler.getStoredLogRecords(); assertThat(records) .hasSize(1); LogRecord record = records.get(0); diff --git a/server/src/test/java/io/spine/server/log/given/TestLogHandler.java b/server/src/test/java/io/spine/server/log/given/TestLogHandler.java deleted file mode 100644 index 6bb09bbe1a3..00000000000 --- a/server/src/test/java/io/spine/server/log/given/TestLogHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.log.given; - -import com.google.common.collect.ImmutableList; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Handler; -import java.util.logging.LogRecord; - -public class TestLogHandler extends Handler { - - private final List records = new ArrayList<>(); - - public ImmutableList records() { - return ImmutableList.copyOf(records); - } - - @Override - public void publish(LogRecord record) { - records.add(record); - } - - @Override - public void flush() { - } - - @Override - public void close() throws SecurityException { - } -} From 1857a23901cd095778f76ea6c7adeaf6452d4ab8 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 17:46:53 +0200 Subject: [PATCH 24/32] Separate parameters from `ActorContext` and add tests --- license-report.md | 16 +-- .../java/io/spine/server/log/given/Books.java | 3 + .../spine/testing/server/blackbox/Actor.java | 83 ++++++++++---- .../blackbox/BlackBoxBoundedContext.java | 29 ++++- .../blackbox/MultitenantBlackBoxContext.java | 7 +- .../blackbox/SingleTenantBlackBoxContext.java | 7 +- .../blackbox/BlackBoxBoundedContextTest.java | 102 ++++++++++++++++-- .../blackbox/given/BbProjectAggregate.java | 12 +++ .../testing/server/blackbox/given/Given.java | 8 ++ .../testing/server/blackbox/commands.proto | 4 + 10 files changed, 218 insertions(+), 53 deletions(-) diff --git a/license-report.md b/license-report.md index 6d7bf2b3aa3..2f03e3fbdfa 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:04 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). +This report was generated on **Mon Mar 02 17:39:14 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). @@ -791,7 +791,7 @@ This report was generated on **Mon Mar 02 16:18:04 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:05 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). +This report was generated on **Mon Mar 02 17:39:14 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). @@ -1206,7 +1206,7 @@ This report was generated on **Mon Mar 02 16:18:05 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:05 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). +This report was generated on **Mon Mar 02 17:39:15 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). @@ -1681,7 +1681,7 @@ This report was generated on **Mon Mar 02 16:18:05 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:06 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). +This report was generated on **Mon Mar 02 17:39:15 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). @@ -2113,7 +2113,7 @@ This report was generated on **Mon Mar 02 16:18:06 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:07 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). +This report was generated on **Mon Mar 02 17:39:16 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). @@ -2586,7 +2586,7 @@ This report was generated on **Mon Mar 02 16:18:07 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:10 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). +This report was generated on **Mon Mar 02 17:39:18 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). @@ -3067,7 +3067,7 @@ This report was generated on **Mon Mar 02 16:18:10 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:11 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). +This report was generated on **Mon Mar 02 17:39:20 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). @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 16:18:11 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 16:18:15 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 +This report was generated on **Mon Mar 02 17:39:23 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/server/src/test/java/io/spine/server/log/given/Books.java b/server/src/test/java/io/spine/server/log/given/Books.java index f02d28d084d..58a2a9294f1 100644 --- a/server/src/test/java/io/spine/server/log/given/Books.java +++ b/server/src/test/java/io/spine/server/log/given/Books.java @@ -24,6 +24,9 @@ import io.spine.server.log.Book; import io.spine.server.log.Isbn; +/** + * A test factory for instances of {@code Book} and {@code Isbn}. + */ public final class Books { public static final Isbn BIG_BLUE_BOOK = isbn("978-0321125217"); diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java index 0b0b3134fe3..532e1a419e0 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/Actor.java @@ -20,27 +20,43 @@ package io.spine.testing.server.blackbox; -import io.spine.core.ActorContext; +import com.google.common.annotations.VisibleForTesting; +import io.spine.core.TenantId; import io.spine.core.UserId; - -import java.util.function.Supplier; +import io.spine.testing.client.TestActorRequestFactory; +import io.spine.time.ZoneId; +import io.spine.time.ZoneOffset; import static com.google.common.base.Preconditions.checkNotNull; -import static io.spine.base.Time.currentTime; import static io.spine.util.Preconditions2.checkNotEmptyOrBlank; import static io.spine.validate.Validate.checkValid; +/** + * A factory of test actor request factories. + */ +@VisibleForTesting final class Actor { private static final Actor defaultActor = from(BlackBoxBoundedContext.class.getName()); - private final Supplier context; + private final UserId id; + private final ZoneId zoneId; + private final ZoneOffset zoneOffset; - private Actor(Supplier context) { - this.context = context; + private Actor(UserId id, ZoneId zoneId, ZoneOffset zoneOffset) { + this.id = id; + this.zoneId = zoneId; + this.zoneOffset = zoneOffset; + } + + /** + * Obtains the default actor. + */ + static Actor defaultActor() { + return defaultActor; } - public static Actor from(String userId) { + private static Actor from(String userId) { checkNotEmptyOrBlank(userId); UserId id = UserId .newBuilder() @@ -49,26 +65,49 @@ public static Actor from(String userId) { return from(id); } - public static Actor from(UserId userId) { + /** + * Creates a new actor with the given actor ID and the default time zone. + */ + static Actor from(UserId userId) { checkNotNull(userId); - return new Actor(() -> ActorContext - .newBuilder() - .setActor(userId) - .setTimestamp(currentTime()) - .vBuild()); + checkValid(userId); + return new Actor(userId, + ZoneId.getDefaultInstance(), + ZoneOffset.getDefaultInstance()); } - public static Actor with(ActorContext context) { - checkNotNull(context); - checkValid(context); - return new Actor(() -> context); + /** + * Creates a new actor with the given time zone and the default actor ID. + */ + static Actor from(ZoneId zoneId, ZoneOffset zoneOffset) { + checkNotNull(zoneId); + checkNotNull(zoneOffset); + return new Actor(defaultActor.id, zoneId, zoneOffset); } - public static Actor defaultActor() { - return defaultActor; + /** + * Creates a new actor with the given actor ID and time zone. + */ + static Actor from(UserId userId, ZoneId zoneId, ZoneOffset zoneOffset) { + checkNotNull(userId); + checkNotNull(zoneId); + checkNotNull(zoneOffset); + return new Actor(userId, zoneId, zoneOffset); + } + + /** + * Creates a new factory for requests of the single tenant. + */ + TestActorRequestFactory requests() { + return new TestActorRequestFactory(null, id, zoneOffset, zoneId); } - public ActorContext context() { - return context.get(); + /** + * Creates a new factory for requests of the given tenant. + */ + TestActorRequestFactory requestsFor(TenantId tenant) { + checkNotNull(tenant); + checkValid(tenant); + return new TestActorRequestFactory(tenant, id, zoneOffset, zoneId); } } diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java index 18f98018883..31638a10aa8 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxBoundedContext.java @@ -37,7 +37,6 @@ import io.spine.client.Subscription; import io.spine.client.Topic; import io.spine.core.Ack; -import io.spine.core.ActorContext; import io.spine.core.BoundedContextName; import io.spine.core.Command; import io.spine.core.Event; @@ -73,6 +72,8 @@ import io.spine.testing.server.blackbox.verify.state.VerifyState; import io.spine.testing.server.blackbox.verify.subscription.ToProtoSubjects; import io.spine.testing.server.entity.EntitySubject; +import io.spine.time.ZoneId; +import io.spine.time.ZoneOffset; import io.spine.type.TypeName; import org.checkerframework.checker.nullness.qual.Nullable; @@ -329,18 +330,36 @@ public BoundedContextName name() { return context.name(); } + /** + * Sets the given {@link UserId} as the actor ID for the requests produced by this context. + */ public final T withActor(UserId user) { this.actor = Actor.from(user); return thisRef(); } - public final T withActor(ActorContext context) { - this.actor = Actor.with(context); + /** + * Sets the given time zone parameters for the actor requests produced by this context. + */ + public final T in(ZoneId zoneId, ZoneOffset zoneOffset) { + this.actor = Actor.from(zoneId, zoneOffset); return thisRef(); } - protected final ActorContext context() { - return actor.context(); + /** + * Sets the given actor ID and time zone parameters for the actor requests produced by this + * context. + */ + public final T withActorIn(UserId userId, ZoneId zoneId, ZoneOffset zoneOffset) { + this.actor = Actor.from(userId, zoneId, zoneOffset); + return thisRef(); + } + + /** + * Obtains the current {@link Actor}. + */ + protected final Actor actor() { + return this.actor; } /** diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java index 6568eb39395..85f76c10ab9 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/MultitenantBlackBoxContext.java @@ -22,7 +22,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import io.spine.core.ActorContext; import io.spine.core.Command; import io.spine.core.Event; import io.spine.core.TenantId; @@ -67,11 +66,7 @@ public MultitenantBlackBoxContext withTenant(TenantId tenant) { @Override protected TestActorRequestFactory requestFactory() { - ActorContext context = context(); - return new TestActorRequestFactory(tenantId(), - context.getActor(), - context.getZoneOffset(), - context.getZoneId()); + return actor().requestsFor(tenantId()); } @Override diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java index 297a98e5395..fcd0ebf84c4 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/SingleTenantBlackBoxContext.java @@ -22,7 +22,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import io.spine.core.ActorContext; import io.spine.core.Command; import io.spine.core.Event; import io.spine.server.event.EventEnricher; @@ -51,10 +50,6 @@ protected ImmutableList select(EventCollector collector) { @Override protected TestActorRequestFactory requestFactory() { - ActorContext context = context(); - return new TestActorRequestFactory(null, - context.getActor(), - context.getZoneOffset(), - context.getZoneId()); + return actor().requests(); } } diff --git a/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java b/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java index 12fc4bf79c2..c9f4eaba0c8 100644 --- a/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java +++ b/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java @@ -24,11 +24,13 @@ import com.google.common.collect.ImmutableSet; import com.google.common.truth.IterableSubject; import com.google.common.truth.Subject; +import com.google.common.truth.Truth; import com.google.protobuf.Message; import io.spine.client.Query; import io.spine.client.QueryFactory; import io.spine.client.Topic; import io.spine.client.TopicFactory; +import io.spine.core.ActorContext; import io.spine.core.Event; import io.spine.core.UserId; import io.spine.server.BoundedContextBuilder; @@ -41,10 +43,12 @@ import io.spine.server.event.EventEnricher; import io.spine.server.projection.ProjectionRepository; import io.spine.server.type.CommandClass; +import io.spine.testing.core.given.GivenUserId; import io.spine.testing.logging.MuteLogging; import io.spine.testing.server.BlackBoxId; import io.spine.testing.server.EventSubject; import io.spine.testing.server.VerifyingCounter; +import io.spine.testing.server.blackbox.command.BbAssignSelf; import io.spine.testing.server.blackbox.command.BbCreateProject; import io.spine.testing.server.blackbox.command.BbFinalizeProject; import io.spine.testing.server.blackbox.command.BbRegisterCommandDispatcher; @@ -67,6 +71,10 @@ import io.spine.testing.server.blackbox.given.RepositoryThrowingExceptionOnClose; import io.spine.testing.server.blackbox.rejection.Rejections; import io.spine.testing.server.entity.EntitySubject; +import io.spine.time.ZoneId; +import io.spine.time.ZoneIds; +import io.spine.time.ZoneOffset; +import io.spine.time.ZoneOffsets; import io.spine.type.TypeName; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -79,10 +87,12 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; +import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; import static io.spine.protobuf.AnyPacker.unpack; import static io.spine.testing.core.given.GivenUserId.newUuid; import static io.spine.testing.server.blackbox.given.Given.addProjectAssignee; import static io.spine.testing.server.blackbox.given.Given.addTask; +import static io.spine.testing.server.blackbox.given.Given.assignSelf; import static io.spine.testing.server.blackbox.given.Given.createProject; import static io.spine.testing.server.blackbox.given.Given.createReport; import static io.spine.testing.server.blackbox.given.Given.createdProjectState; @@ -366,10 +376,10 @@ void defaultProducer() { BbProjectId projectId = newProjectId(); context.receivesEvent(taskAdded(projectId)); ImmutableList events = context.allEvents(); - assertThat(events).hasSize(1); + Truth.assertThat(events).hasSize(1); Message producer = unpack(getOnlyElement(events).getContext() .getProducerId()); - Subject assertProducer = assertThat(producer); + Subject assertProducer = Truth.assertThat(producer); assertProducer.isInstanceOf(BlackBoxId.class); BlackBoxId expectedId = BlackBoxId .newBuilder() @@ -384,10 +394,10 @@ void customProducer() { BbProjectId projectId = newProjectId(); context.receivesEventsProducedBy(projectId, taskAdded(projectId)); ImmutableList events = context.allEvents(); - assertThat(events).hasSize(1); + Truth.assertThat(events).hasSize(1); Message producer = unpack(getOnlyElement(events).getContext() .getProducerId()); - Subject assertProducer = assertThat(producer); + Subject assertProducer = Truth.assertThat(producer); assertProducer.isInstanceOf(BbProjectId.class); assertProducer.isEqualTo(projectId); } @@ -688,7 +698,7 @@ void postCommands() { @Test @DisplayName("event messages") void eventMessages() { - IterableSubject assertEventMessages = assertThat(context.eventMessages()); + IterableSubject assertEventMessages = Truth.assertThat(context.eventMessages()); assertEventMessages.isNotEmpty(); assertEventMessages.hasSize(context.events() .size()); @@ -697,10 +707,90 @@ void eventMessages() { @Test @DisplayName("command messages") void commandMessages() { - IterableSubject assertCommandMessages = assertThat(context.commandMessages()); + IterableSubject assertCommandMessages = Truth.assertThat(context.commandMessages()); assertCommandMessages.isNotEmpty(); assertCommandMessages.hasSize(context.commands() .size()); } } + + @Nested + @DisplayName("produce requests with the given actor") + class WithGivenActor { + + @Test + @DisplayName("ID") + void id() { + UserId actor = GivenUserId.of("my-actor"); + BbCreateProject createProject = createProject(); + BbProjectId id = createProject.getProjectId(); + BbAssignSelf assignSelf = assignSelf(id); + context.withActor(actor) + .receivesCommands(createProject, assignSelf) + .assertEntityWithState(BbProject.class, id) + .hasStateThat() + .comparingExpectedFieldsOnly() + .isEqualTo(BbProject + .newBuilder() + .setId(id) + .addAssignee(actor) + .buildPartial()); + } + + @Test + @DisplayName("time zone") + void timeZone() { + UserId actor = GivenUserId.of("my-other-actor"); + BbCreateProject createProject = createProject(); + BbProjectId id = createProject.getProjectId(); + ZoneId zoneId = ZoneIds.of("UTC+1"); + ZoneOffset zoneOffset = ZoneOffsets.ofHours(1); + context.withActorIn(actor, zoneId, zoneOffset) + .receivesCommand(createProject) + .assertEntityWithState(BbProject.class, id) + .exists(); + EventSubject events = context.assertEvents() + .withType(BbProjectCreated.class); + events.hasSize(1); + ActorContext context = events.actual() + .get(0) + .context() + .actorContext(); + assertThat(context) + .comparingExpectedFieldsOnly() + .isEqualTo(ActorContext + .newBuilder() + .setActor(actor) + .setZoneId(zoneId) + .setZoneOffset(zoneOffset) + .buildPartial()); + } + + @Test + @DisplayName("ID and time zone") + void idAndTimeZone() { + BbCreateProject createProject = createProject(); + BbProjectId id = createProject.getProjectId(); + ZoneId zoneId = ZoneIds.of("UTC-1"); + ZoneOffset zoneOffset = ZoneOffsets.ofHours(-1); + context.in(zoneId, zoneOffset) + .receivesCommand(createProject) + .assertEntityWithState(BbProject.class, id) + .exists(); + EventSubject events = context.assertEvents() + .withType(BbProjectCreated.class); + events.hasSize(1); + ActorContext context = events.actual() + .get(0) + .context() + .actorContext(); + assertThat(context) + .comparingExpectedFieldsOnly() + .isEqualTo(ActorContext + .newBuilder() + .setZoneId(zoneId) + .setZoneOffset(zoneOffset) + .buildPartial()); + } + } } diff --git a/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/BbProjectAggregate.java b/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/BbProjectAggregate.java index fc8b868e80d..8e2b0cf8a45 100644 --- a/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/BbProjectAggregate.java +++ b/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/BbProjectAggregate.java @@ -20,6 +20,7 @@ package io.spine.testing.server.blackbox.given; +import io.spine.core.CommandContext; import io.spine.core.UserId; import io.spine.server.aggregate.Aggregate; import io.spine.server.aggregate.Apply; @@ -30,6 +31,7 @@ import io.spine.testing.server.blackbox.BbTask; import io.spine.testing.server.blackbox.command.BbAddTask; import io.spine.testing.server.blackbox.command.BbAssignProject; +import io.spine.testing.server.blackbox.command.BbAssignSelf; import io.spine.testing.server.blackbox.command.BbCreateProject; import io.spine.testing.server.blackbox.command.BbStartProject; import io.spine.testing.server.blackbox.event.BbAssigneeAdded; @@ -101,6 +103,16 @@ BbAssigneeAdded handle(BbAssignProject command) { .build(); } + @Assign + BbAssigneeAdded handle(BbAssignSelf command, CommandContext context) { + UserId assignee = context.getActorContext().getActor(); + return BbAssigneeAdded + .newBuilder() + .setId(id()) + .setUserId(assignee) + .build(); + } + @React(external = true) Optional on(BbUserDeleted event) { List assignees = state().getAssigneeList(); diff --git a/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/Given.java b/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/Given.java index a7e57148e7e..a10b80bd624 100644 --- a/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/Given.java +++ b/testutil-server/src/test/java/io/spine/testing/server/blackbox/given/Given.java @@ -30,6 +30,7 @@ import io.spine.testing.server.blackbox.BbTask; import io.spine.testing.server.blackbox.command.BbAddTask; import io.spine.testing.server.blackbox.command.BbAssignProject; +import io.spine.testing.server.blackbox.command.BbAssignSelf; import io.spine.testing.server.blackbox.command.BbCreateProject; import io.spine.testing.server.blackbox.command.BbCreateReport; import io.spine.testing.server.blackbox.command.BbFinalizeProject; @@ -129,6 +130,13 @@ public static BbCreateProject createProject(BbProjectId id) { .build(); } + public static BbAssignSelf assignSelf(BbProjectId id) { + return BbAssignSelf + .newBuilder() + .setProjectId(id) + .build(); + } + public static BbInitProject initProject(BbProjectId id, boolean scrum) { BbInitProject.Builder builder = BbInitProject .newBuilder() diff --git a/testutil-server/src/test/proto/spine/testing/server/blackbox/commands.proto b/testutil-server/src/test/proto/spine/testing/server/blackbox/commands.proto index 714b3a827b6..6a2df5dc589 100644 --- a/testutil-server/src/test/proto/spine/testing/server/blackbox/commands.proto +++ b/testutil-server/src/test/proto/spine/testing/server/blackbox/commands.proto @@ -51,6 +51,10 @@ message BbAssignTeam { repeated spine.core.UserId member = 2 [(required) = true]; } +message BbAssignSelf { + BbProjectId project_id = 1; +} + message BbAssignScrumMaster { BbProjectId project_id = 1; spine.core.UserId scrum_master = 2 [(required) = true]; From d37465a03da5ed3f1b11d69b4bd0e958e4f6b5f5 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 17:51:06 +0200 Subject: [PATCH 25/32] Clean up static API usage --- .../server/blackbox/BlackBoxBoundedContextTest.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java b/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java index c9f4eaba0c8..cd53a697356 100644 --- a/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java +++ b/testutil-server/src/test/java/io/spine/testing/server/blackbox/BlackBoxBoundedContextTest.java @@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.truth.IterableSubject; import com.google.common.truth.Subject; -import com.google.common.truth.Truth; import com.google.protobuf.Message; import io.spine.client.Query; import io.spine.client.QueryFactory; @@ -376,10 +375,10 @@ void defaultProducer() { BbProjectId projectId = newProjectId(); context.receivesEvent(taskAdded(projectId)); ImmutableList events = context.allEvents(); - Truth.assertThat(events).hasSize(1); + assertThat(events).hasSize(1); Message producer = unpack(getOnlyElement(events).getContext() .getProducerId()); - Subject assertProducer = Truth.assertThat(producer); + Subject assertProducer = assertThat(producer); assertProducer.isInstanceOf(BlackBoxId.class); BlackBoxId expectedId = BlackBoxId .newBuilder() @@ -394,10 +393,10 @@ void customProducer() { BbProjectId projectId = newProjectId(); context.receivesEventsProducedBy(projectId, taskAdded(projectId)); ImmutableList events = context.allEvents(); - Truth.assertThat(events).hasSize(1); + assertThat(events).hasSize(1); Message producer = unpack(getOnlyElement(events).getContext() .getProducerId()); - Subject assertProducer = Truth.assertThat(producer); + Subject assertProducer = assertThat(producer); assertProducer.isInstanceOf(BbProjectId.class); assertProducer.isEqualTo(projectId); } @@ -698,7 +697,7 @@ void postCommands() { @Test @DisplayName("event messages") void eventMessages() { - IterableSubject assertEventMessages = Truth.assertThat(context.eventMessages()); + IterableSubject assertEventMessages = assertThat(context.eventMessages()); assertEventMessages.isNotEmpty(); assertEventMessages.hasSize(context.events() .size()); @@ -707,7 +706,7 @@ void eventMessages() { @Test @DisplayName("command messages") void commandMessages() { - IterableSubject assertCommandMessages = Truth.assertThat(context.commandMessages()); + IterableSubject assertCommandMessages = assertThat(context.commandMessages()); assertCommandMessages.isNotEmpty(); assertCommandMessages.hasSize(context.commands() .size()); From 0413d0ebface25753b4a89930db936987bc0a7d1 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 19:09:10 +0200 Subject: [PATCH 26/32] Update version to 1.4.10 --- license-report.md | 32 ++++++++++++++++---------------- pom.xml | 6 +++--- version.gradle | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/license-report.md b/license-report.md index 2f03e3fbdfa..5cd75871a05 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.4.8` +# Dependencies of `io.spine:spine-client:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -415,12 +415,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:14 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). +This report was generated on **Mon Mar 02 18:43:48 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.4.8` +# Dependencies of `io.spine:spine-core:1.4.10` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -791,12 +791,12 @@ This report was generated on **Mon Mar 02 17:39:14 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:14 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). +This report was generated on **Mon Mar 02 18:43:48 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.4.8` +# Dependencies of `io.spine.tools:spine-model-assembler:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1206,12 +1206,12 @@ This report was generated on **Mon Mar 02 17:39:14 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:15 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). +This report was generated on **Mon Mar 02 18:43:49 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.4.8` +# Dependencies of `io.spine.tools:spine-model-verifier:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1681,12 +1681,12 @@ This report was generated on **Mon Mar 02 17:39:15 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:15 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). +This report was generated on **Mon Mar 02 18:43:49 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.4.8` +# Dependencies of `io.spine:spine-server:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2113,12 +2113,12 @@ This report was generated on **Mon Mar 02 17:39:15 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:16 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). +This report was generated on **Mon Mar 02 18:43:50 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.4.8` +# Dependencies of `io.spine:spine-testutil-client:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2586,12 +2586,12 @@ This report was generated on **Mon Mar 02 17:39:16 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:18 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). +This report was generated on **Mon Mar 02 18:43:52 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.4.8` +# Dependencies of `io.spine:spine-testutil-core:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3067,12 +3067,12 @@ This report was generated on **Mon Mar 02 17:39:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:20 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). +This report was generated on **Mon Mar 02 18:43:54 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.4.8` +# Dependencies of `io.spine:spine-testutil-server:1.4.10` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 17:39:20 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 17:39:23 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 +This report was generated on **Mon Mar 02 18:43:58 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 46cb51b5902..0e9f7dccadb 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.4.8 +1.4.10 2015 @@ -76,7 +76,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-time - 1.4.1 + 1.4.7 compile @@ -136,7 +136,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-testutil-time - 1.4.1 + 1.4.7 test diff --git a/version.gradle b/version.gradle index e88da1ee018..545519294b3 100644 --- a/version.gradle +++ b/version.gradle @@ -25,7 +25,7 @@ * as we want to manage the versions in a single source. */ -final def spineVersion = '1.4.8' +final def spineVersion = '1.4.10' ext { // The version of the modules in this project. From b57f243d0a40b3d685432a3a9ab1f225c09257ed Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 2 Mar 2020 20:55:45 +0200 Subject: [PATCH 27/32] Rename `LogAwareMessageHandler` to `HandlerLifecycle` --- license-report.md | 16 ++-- .../spine/server/entity/AbstractEntity.java | 13 ++-- .../io/spine/server/log/HandlerLifecycle.java | 74 +++++++++++++++++++ .../java/io/spine/server/log/HandlerLog.java | 2 - .../server/log/LogAwareMessageHandler.java | 49 ------------ .../server/model/AbstractHandlerMethod.java | 14 ++-- 6 files changed, 96 insertions(+), 72 deletions(-) create mode 100644 server/src/main/java/io/spine/server/log/HandlerLifecycle.java delete mode 100644 server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java diff --git a/license-report.md b/license-report.md index 5cd75871a05..a668e0c271f 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:48 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). +This report was generated on **Mon Mar 02 20:54:12 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). @@ -791,7 +791,7 @@ This report was generated on **Mon Mar 02 18:43:48 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:48 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). +This report was generated on **Mon Mar 02 20:54:13 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). @@ -1206,7 +1206,7 @@ This report was generated on **Mon Mar 02 18:43:48 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:49 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). +This report was generated on **Mon Mar 02 20:54:13 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). @@ -1681,7 +1681,7 @@ This report was generated on **Mon Mar 02 18:43:49 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:49 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). +This report was generated on **Mon Mar 02 20:54:13 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). @@ -2113,7 +2113,7 @@ This report was generated on **Mon Mar 02 18:43:49 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:50 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). +This report was generated on **Mon Mar 02 20:54:14 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). @@ -2586,7 +2586,7 @@ This report was generated on **Mon Mar 02 18:43:50 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:52 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). +This report was generated on **Mon Mar 02 20:54:16 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). @@ -3067,7 +3067,7 @@ This report was generated on **Mon Mar 02 18:43:52 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:54 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). +This report was generated on **Mon Mar 02 20:54:18 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). @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 18:43:54 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 18:43:58 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 +This report was generated on **Mon Mar 02 20:54:21 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/server/src/main/java/io/spine/server/entity/AbstractEntity.java b/server/src/main/java/io/spine/server/entity/AbstractEntity.java index 43f6e6ca4f4..c3f6e029f5f 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.flogger.FluentLogger; +import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper; import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.protobuf.Any; import com.google.protobuf.Message; @@ -36,8 +37,8 @@ import io.spine.server.entity.model.EntityClass; import io.spine.server.entity.rejection.CannotModifyArchivedEntity; import io.spine.server.entity.rejection.CannotModifyDeletedEntity; +import io.spine.server.log.HandlerLifecycle; import io.spine.server.log.HandlerLog; -import io.spine.server.log.LogAwareMessageHandler; import io.spine.server.model.HandlerMethod; import io.spine.string.Stringifiers; import io.spine.validate.ConstraintViolation; @@ -68,7 +69,7 @@ fields. See Effective Java 2nd Ed. Item #71. */, "ClassWithTooManyMethods"}) public abstract class AbstractEntity - implements Entity, LogAwareMessageHandler { + implements Entity, HandlerLifecycle { /** * Lazily initialized reference to the model class of this entity. @@ -517,17 +518,17 @@ public Timestamp whenModified() { return version.getTimestamp(); } - @Internal + @OverridingMethodsMustInvokeSuper @Override - public final void enter(HandlerMethod method) { + public void beforeInvoke(HandlerMethod method) { checkNotNull(method); FluentLogger logger = loggerFor(getClass()); this.handlerLog = new HandlerLog(logger, method); } - @Internal + @OverridingMethodsMustInvokeSuper @Override - public void resetLog() { + public void afterInvoke(HandlerMethod method) { this.handlerLog = null; } diff --git a/server/src/main/java/io/spine/server/log/HandlerLifecycle.java b/server/src/main/java/io/spine/server/log/HandlerLifecycle.java new file mode 100644 index 00000000000..bfeec8efeb2 --- /dev/null +++ b/server/src/main/java/io/spine/server/log/HandlerLifecycle.java @@ -0,0 +1,74 @@ +/* + * 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.log; + +import io.spine.server.model.HandlerMethod; + +/** + * Callbacks for a {@link HandlerMethod} invocation. + * + *

If the target of the method implements {@code HandlerLifecycle}, it is invoked alongside + * handler method. For example: + *

+ * class SignUpSubscriber extends AbstractEventSubscriber implements HandlerLifecycle {
+ *
+ *    {@literal @Subscribe}
+ *     void on(UserSignedUp event) {
+ *         // ...
+ *     }
+ *
+ *    {@literal @Override}
+ *     public void beforeInvoke(HandlerMethod method) {
+ *         // ...
+ *     }
+ *
+ *    {@literal @Override}
+ *     public void afterInvoke(HandlerMethod method) {
+ *         // ...
+ *     }
+ * }
+ * 
+ * + *

When a {@code UserSignedUp} event is dispatched to the {@code SignUpSubscriber}, + * the invocation order goes as follows: + *

    + *
  1. {@code beforeInvoke([instance representing on(UserSignedUp) method])}. + *
  2. {@code on(UserSignedUp)}. + *
  3. {@code afterInvoke([instance representing on(UserSignedUp) method])}. + *
+ */ +public interface HandlerLifecycle { + + /** + * A callback for a handler method invocation start. + * + *

The handler method is invoked immediately after this method. + */ + void beforeInvoke(HandlerMethod method); + + /** + * A callback for a handler method invocation end. + * + *

This method is invoked immediately after the handler method, even if it has thrown + * an exception. + */ + void afterInvoke(HandlerMethod method); +} diff --git a/server/src/main/java/io/spine/server/log/HandlerLog.java b/server/src/main/java/io/spine/server/log/HandlerLog.java index 9e544f362e2..e48caea7017 100644 --- a/server/src/main/java/io/spine/server/log/HandlerLog.java +++ b/server/src/main/java/io/spine/server/log/HandlerLog.java @@ -22,7 +22,6 @@ import com.google.common.flogger.FluentLogger; import com.google.common.flogger.LogSite; -import io.spine.annotation.Internal; import io.spine.server.model.HandlerMethod; import java.util.logging.Level; @@ -40,7 +39,6 @@ public final class HandlerLog { private final FluentLogger logger; private final LogSite logSite; - @Internal public HandlerLog(FluentLogger logger, HandlerMethod method) { this.logger = checkNotNull(logger); checkNotNull(method); diff --git a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java b/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java deleted file mode 100644 index 7c6c193b67c..00000000000 --- a/server/src/main/java/io/spine/server/log/LogAwareMessageHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.log; - -import io.spine.annotation.Internal; -import io.spine.server.model.HandlerMethod; - -/** - * A message handler which, depending on the message, alters its own log output. - */ -@Internal -public interface LogAwareMessageHandler { - - /** - * Enters the handler method invocation. - * - *

After this method is called, the message handler should start including the handler method - * info into the log. - */ - @Internal - void enter(HandlerMethod method); - - /** - * Exists the current handler method invocation. - * - *

After this method is called, the message handler should not include any handler method - * info into the log. - */ - @Internal - void resetLog(); -} diff --git a/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java b/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java index e3cf686c482..f5cd37b4189 100644 --- a/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java +++ b/server/src/main/java/io/spine/server/model/AbstractHandlerMethod.java @@ -29,7 +29,7 @@ import io.spine.core.Signal; import io.spine.server.dispatch.DispatchOutcome; import io.spine.server.dispatch.Success; -import io.spine.server.log.LogAwareMessageHandler; +import io.spine.server.log.HandlerLifecycle; import io.spine.server.type.MessageEnvelope; import io.spine.type.MessageClass; import org.checkerframework.checker.nullness.qual.Nullable; @@ -254,11 +254,11 @@ public DispatchOutcome invoke(T target, E envelope) { DispatchOutcome.Builder outcome = DispatchOutcome .newBuilder() .setPropagatedSignal(signal); - LogAwareMessageHandler asLogAware = target instanceof LogAwareMessageHandler - ? (LogAwareMessageHandler) target + HandlerLifecycle lifecycle = target instanceof HandlerLifecycle + ? (HandlerLifecycle) target : null; - if (asLogAware != null) { - asLogAware.enter(this); + if (lifecycle != null) { + lifecycle.beforeInvoke(this); } try { Success success = doInvoke(target, envelope); @@ -279,8 +279,8 @@ public DispatchOutcome invoke(T target, E envelope) { } catch (IllegalArgumentException | IllegalAccessException e) { throw illegalStateWithCauseOf(e); } finally { - if (asLogAware != null) { - asLogAware.resetLog(); + if (lifecycle != null) { + lifecycle.afterInvoke(this); } } return outcome.build(); From 12ea5672516460372e36d670cbbf762c9716085a Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 3 Mar 2020 16:21:22 +0200 Subject: [PATCH 28/32] Improve validation in a test domain --- license-report.md | 16 ++++++++-------- .../src/test/proto/spine/test/library/card.proto | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/license-report.md b/license-report.md index a668e0c271f..6a3b50ee814 100644 --- a/license-report.md +++ b/license-report.md @@ -415,7 +415,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:12 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). +This report was generated on **Tue Mar 03 16:17:23 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). @@ -791,7 +791,7 @@ This report was generated on **Mon Mar 02 20:54:12 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:13 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). +This report was generated on **Tue Mar 03 16:17:24 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). @@ -1206,7 +1206,7 @@ This report was generated on **Mon Mar 02 20:54:13 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:13 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). +This report was generated on **Tue Mar 03 16:17:24 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). @@ -1681,7 +1681,7 @@ This report was generated on **Mon Mar 02 20:54:13 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:13 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). +This report was generated on **Tue Mar 03 16:17:25 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). @@ -2113,7 +2113,7 @@ This report was generated on **Mon Mar 02 20:54:13 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:14 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). +This report was generated on **Tue Mar 03 16:17:25 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). @@ -2586,7 +2586,7 @@ This report was generated on **Mon Mar 02 20:54:14 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:16 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). +This report was generated on **Tue Mar 03 16:17:28 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). @@ -3067,7 +3067,7 @@ This report was generated on **Mon Mar 02 20:54:16 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:18 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). +This report was generated on **Tue Mar 03 16:17:29 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). @@ -3584,4 +3584,4 @@ This report was generated on **Mon Mar 02 20:54:18 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Mar 02 20:54:21 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 +This report was generated on **Tue Mar 03 16:17:32 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/server/src/test/proto/spine/test/library/card.proto b/server/src/test/proto/spine/test/library/card.proto index d839db4e064..d8b40285f05 100644 --- a/server/src/test/proto/spine/test/library/card.proto +++ b/server/src/test/proto/spine/test/library/card.proto @@ -14,7 +14,7 @@ import "spine/time/time.proto"; import "spine/core/user_id.proto"; message Isbn { - string value = 1; + string value = 1 [(required) = true]; } message Book { @@ -28,7 +28,7 @@ message Book { message LibraryCardId { - core.UserId reader = 1; + core.UserId reader = 1 [(required) = true]; } message LibraryCard { From de0281ca0deb6d26e8cae512f26d67b34f560a51 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 3 Mar 2020 16:51:58 +0200 Subject: [PATCH 29/32] Add `LoggingEntity` --- .../spine/server/entity/AbstractEntity.java | 30 +++++-- .../io/spine/server/log/LoggingEntity.java | 82 +++++++++++++++++++ .../spine/server/log/given/CardAggregate.java | 22 +++-- 3 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 server/src/main/java/io/spine/server/log/LoggingEntity.java diff --git a/server/src/main/java/io/spine/server/entity/AbstractEntity.java b/server/src/main/java/io/spine/server/entity/AbstractEntity.java index c3f6e029f5f..42c87d48e75 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -33,7 +33,6 @@ import io.spine.base.Identifier; import io.spine.core.Version; import io.spine.core.Versions; -import io.spine.logging.Logging; import io.spine.server.entity.model.EntityClass; import io.spine.server.entity.rejection.CannotModifyArchivedEntity; import io.spine.server.entity.rejection.CannotModifyDeletedEntity; @@ -49,6 +48,7 @@ import java.util.List; import java.util.Objects; import java.util.function.Function; +import java.util.logging.Level; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; @@ -532,14 +532,26 @@ public void afterInvoke(HandlerMethod method) { this.handlerLog = null; } - protected final HandlerLog log() { - checkState(handlerLog != null, - "Unable to get a handler log for `%s`." + - "A handler log is available only in message handler methods. " + - "Use `%s` instead.", - getClass().getSimpleName(), - Logging.class.getName()); - return handlerLog; + /** + * Obtains a new fluent logging API at the given level. + * + *

If called from within a handler method, the resulting log will reference the handler + * method as the log site. Otherwise, equivalent to + * {@code Logging.loggerFor(getClass()).at(logLevel)}. + * + * @param logLevel + * the log level + * @return new fluent logging API + * @apiNote This method mirrors the declaration of + * {@link io.spine.server.log.LoggingEntity#at(Level)}. It is recommended to implement + * the {@link io.spine.server.log.LoggingEntity} interface and use the underscore + * logging methods instead of calling {@code at(..)} directly. + * @see io.spine.server.log.LoggingEntity + */ + public final FluentLogger.Api at(Level logLevel) { + return handlerLog != null + ? handlerLog.at(logLevel) + : loggerFor(getClass()).at(logLevel); } @Override diff --git a/server/src/main/java/io/spine/server/log/LoggingEntity.java b/server/src/main/java/io/spine/server/log/LoggingEntity.java new file mode 100644 index 00000000000..1b330fbd66d --- /dev/null +++ b/server/src/main/java/io/spine/server/log/LoggingEntity.java @@ -0,0 +1,82 @@ +/* + * 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.log; + +import com.google.common.flogger.FluentLogger; +import io.spine.logging.Logging; + +import java.util.logging.Level; + +/** + * A {@link Logging} trait for entities. + * + *

When adding logs in an entity, use this interface over {@link Logging}. + */ +public interface LoggingEntity extends Logging { + + /** + * Creates a {@code FluentLogger.Api} with the given level. + * + * @param level + * the log level + * @return new fluent logging API + * @apiNote This method mirrors the declaration of + * {@link io.spine.server.entity.AbstractEntity#at(Level)}. When a concrete entity + * implements this interface, the underscore logging methods will have the same + * behaviour regarding the log site as does the {@code AbstractEntity.at(Level)} method. + */ + FluentLogger.Api at(Level level); + + @Override + default FluentLogger.Api _severe() { + return at(Level.SEVERE); + } + + @Override + default FluentLogger.Api _warn() { + return at(Level.WARNING); + } + + @Override + default FluentLogger.Api _info() { + return at(Level.INFO); + } + + @Override + default FluentLogger.Api _config() { + return at(Level.CONFIG); + } + + @Override + default FluentLogger.Api _fine() { + return at(Level.FINE); + } + + @Override + default FluentLogger.Api _finer() { + return at(Level.FINER); + } + + @Override + default FluentLogger.Api _finest() { + return at(Level.FINEST); + } +} diff --git a/server/src/test/java/io/spine/server/log/given/CardAggregate.java b/server/src/test/java/io/spine/server/log/given/CardAggregate.java index 50241764a1e..22594b74545 100644 --- a/server/src/test/java/io/spine/server/log/given/CardAggregate.java +++ b/server/src/test/java/io/spine/server/log/given/CardAggregate.java @@ -33,6 +33,7 @@ import io.spine.server.log.Isbn; import io.spine.server.log.LibraryCard; import io.spine.server.log.LibraryCardId; +import io.spine.server.log.LoggingEntity; import io.spine.server.log.ReturnBook; import io.spine.server.log.UnknownBook; @@ -45,12 +46,10 @@ import static io.spine.server.log.given.Books.dddDistilled; import static io.spine.server.log.given.Books.domainDrivenDesign; import static io.spine.server.log.given.Books.implementingDdd; -import static java.util.logging.Level.FINE; -import static java.util.logging.Level.SEVERE; -import static java.util.logging.Level.WARNING; public final class CardAggregate - extends Aggregate { + extends Aggregate + implements LoggingEntity { private static final ImmutableMap knownBooks = ImmutableMap.of( BIG_BLUE_BOOK, domainDrivenDesign(), @@ -70,12 +69,12 @@ BooksBorrowed handle(BorrowBooks command) throws UnknownBook { event.addBook(book); List authors = book.getAuthorList(); PersonName firstAuthor = authors.get(0); - log().at(FINE) - .log("Adding to order: %s by %s %s", - book.getTitle(), firstAuthor.getGivenName(), firstAuthor.getFamilyName()); + _fine().log("Adding to order: %s by %s %s", + book.getTitle(), + firstAuthor.getGivenName(), + firstAuthor.getFamilyName()); } else { - log().at(WARNING) - .log("Cannot lend an unknown book. ISBN: `%s`", bookId.getValue()); + _warn().log("Cannot lend an unknown book. ISBN: `%s`", bookId.getValue()); unknownBooks.add(bookId); } } @@ -98,9 +97,8 @@ BookReturned handle(ReturnBook command) throws UnknownBook { .newBuilder() .addAllBook(ImmutableList.of(isbn)) .build(); - log().at(SEVERE) - .withCause(rejection) - .log("Cannot return an unknown book. ISBN: `%s`", isbn.getValue()); + _error().withCause(rejection) + .log("Cannot return an unknown book. ISBN: `%s`", isbn.getValue()); throw rejection; } else { return BookReturned From 700739a9aa94e8ffaf25f1e084b2d862edfb916b Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 3 Mar 2020 17:02:18 +0200 Subject: [PATCH 30/32] Add more tests --- ...lerLogTest.java => LoggingEntityTest.java} | 99 ++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) rename server/src/test/java/io/spine/server/log/{HandlerLogTest.java => LoggingEntityTest.java} (71%) diff --git a/server/src/test/java/io/spine/server/log/HandlerLogTest.java b/server/src/test/java/io/spine/server/log/LoggingEntityTest.java similarity index 71% rename from server/src/test/java/io/spine/server/log/HandlerLogTest.java rename to server/src/test/java/io/spine/server/log/LoggingEntityTest.java index 484d6801830..95e8e81cc22 100644 --- a/server/src/test/java/io/spine/server/log/HandlerLogTest.java +++ b/server/src/test/java/io/spine/server/log/LoggingEntityTest.java @@ -37,22 +37,31 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import java.util.List; +import java.util.function.Function; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; import static com.google.common.truth.Truth.assertThat; +import static io.spine.base.Identifier.newUuid; import static io.spine.server.log.given.Books.THE_HOBBIT; import static io.spine.testing.logging.LogTruth.assertThat; import static java.util.logging.Level.ALL; +import static java.util.logging.Level.CONFIG; import static java.util.logging.Level.FINE; +import static java.util.logging.Level.FINER; +import static java.util.logging.Level.FINEST; +import static java.util.logging.Level.INFO; +import static java.util.logging.Level.SEVERE; +import static java.util.logging.Level.WARNING; @MuteLogging -@DisplayName("`HandlerLog` should") -class HandlerLogTest { +@DisplayName("`LoggingEntity` should") +class LoggingEntityTest { private FluentLogger logger; private TestLogHandler handler; @@ -175,4 +184,90 @@ private static LibraryCardId cardId(UserId reader) { .setReader(reader) .build(); } + + @Nested + @DisplayName("support method") + class Support { + + private String message; + + @BeforeEach + void randomizeMessage() { + message = newUuid(); + } + + @Test + @DisplayName("_severe") + void severe() { + testLevel(Logging::_severe, SEVERE); + } + + @Test + @DisplayName("_warn") + void warn() { + testLevel(Logging::_warn, WARNING); + } + + @Test + @DisplayName("_info") + void info() { + testLevel(Logging::_info, INFO); + } + + @Test + @DisplayName("_config") + void config() { + testLevel(Logging::_config, CONFIG); + } + + @Test + @DisplayName("_fine") + void fine() { + testLevel(Logging::_fine, FINE); + } + + @Test + @DisplayName("_finer") + void finer() { + testLevel(Logging::_finer, FINER); + } + + @Test + @DisplayName("_finest") + void finest() { + testLevel(Logging::_finest, FINEST); + } + + @Test + @DisplayName("_error") + void error() { + testLevel(Logging::_error, Logging.errorLevel()); + } + + @Test + @DisplayName("_debug") + void debug() { + testLevel(Logging::_debug, Logging.debugLevel()); + } + + @Test + @DisplayName("_trace") + void trace() { + testLevel(Logging::_trace, FINEST); + } + + private void testLevel(Function underscoreFunc, + Level expectedLevel) { + CardAggregate aggregate = new CardAggregate(); + underscoreFunc.apply(aggregate).log(message); + List records = handler.getStoredLogRecords(); + assertThat(records) + .hasSize(1); + LogRecordSubject assertLog = assertThat(records.get(0)); + assertLog.hasLevelThat() + .isEqualTo(expectedLevel); + assertLog.hasMessageThat() + .isEqualTo(message); + } + } } From c2b85b1b2b7350cd5b98280872a9eca2594de82d Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 3 Mar 2020 17:03:33 +0200 Subject: [PATCH 31/32] Document a package --- .../test/java/io/spine/server/log/given/package-info.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/test/java/io/spine/server/log/given/package-info.java b/server/src/test/java/io/spine/server/log/given/package-info.java index a82ffd855f6..896d16703e2 100644 --- a/server/src/test/java/io/spine/server/log/given/package-info.java +++ b/server/src/test/java/io/spine/server/log/given/package-info.java @@ -18,6 +18,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/** + * Contains a small test domain and utilities for testing entity logs. + */ + + @CheckReturnValue @ParametersAreNonnullByDefault package io.spine.server.log.given; From 0037fc0e21b12612837c034c7bb910c345efe43a Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Tue, 3 Mar 2020 17:06:08 +0200 Subject: [PATCH 32/32] Remove an empty line --- server/src/test/java/io/spine/server/log/given/package-info.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/io/spine/server/log/given/package-info.java b/server/src/test/java/io/spine/server/log/given/package-info.java index 896d16703e2..dd802753176 100644 --- a/server/src/test/java/io/spine/server/log/given/package-info.java +++ b/server/src/test/java/io/spine/server/log/given/package-info.java @@ -22,7 +22,6 @@ * Contains a small test domain and utilities for testing entity logs. */ - @CheckReturnValue @ParametersAreNonnullByDefault package io.spine.server.log.given;