diff --git a/build.gradle b/build.gradle index 004b0aface5..ccc3eb5b121 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,6 @@ ext { } allprojects { - apply plugin: 'maven' apply plugin: 'jacoco' apply plugin: 'idea' apply plugin: 'project-report' @@ -105,6 +104,10 @@ subprojects { apply from: deps.scripts.modelCompiler apply from: deps.scripts.projectLicenseReport + modelCompiler { + generateValidation = true + } + // Specific setup for a Travis build, // which prevents appearing of warning messages in build logs. // diff --git a/config b/config index 649b73fcefd..f726030ece5 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 649b73fcefdb1ae40953126fd6534f0e7140dd5f +Subproject commit f726030ece549e5aae9082ead7a72c73e4feaa52 diff --git a/core/src/test/proto/spine/test/core/events.proto b/core/src/test/proto/spine/test/core/events.proto index 8eec734c704..2abe7426c84 100644 --- a/core/src/test/proto/spine/test/core/events.proto +++ b/core/src/test/proto/spine/test/core/events.proto @@ -43,5 +43,5 @@ message TaskAssigned { ProjectId project_id = 2 [(required) = true]; - string user_name = 3 [(pattern).regex = ".{3,}"]; + string user_name = 3 [(required) = true, (pattern).regex = ".{3,}"]; } diff --git a/license-report.md b/license-report.md index 5a0006c5c6f..abd8330c8b5 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.3.1` +# Dependencies of `io.spine:spine-client:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -401,12 +401,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:56 EET 2019** 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 **Sun Jan 05 13:26: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-core:1.3.1` +# Dependencies of `io.spine:spine-core:1.3.2` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -763,12 +763,12 @@ This report was generated on **Tue Dec 24 15:51:56 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:57 EET 2019** 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 **Sun Jan 05 13:26: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). -# Dependencies of `io.spine.tools:spine-model-assembler:1.3.1` +# Dependencies of `io.spine.tools:spine-model-assembler:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1164,12 +1164,12 @@ This report was generated on **Tue Dec 24 15:51:57 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:57 EET 2019** 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 **Sun Jan 05 13:26: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.tools:spine-model-verifier:1.3.1` +# Dependencies of `io.spine.tools:spine-model-verifier:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1625,12 +1625,12 @@ This report was generated on **Tue Dec 24 15:51:57 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:57 EET 2019** 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 **Sun Jan 05 13:26:37 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.3.1` +# Dependencies of `io.spine:spine-server:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2043,12 +2043,12 @@ This report was generated on **Tue Dec 24 15:51:57 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:58 EET 2019** 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 **Sun Jan 05 13:26:37 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.3.1` +# Dependencies of `io.spine:spine-testutil-client:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2502,12 +2502,12 @@ This report was generated on **Tue Dec 24 15:51:58 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:58 EET 2019** 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 **Sun Jan 05 13:26:40 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-core:1.3.1` +# Dependencies of `io.spine:spine-testutil-core:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2969,12 +2969,12 @@ This report was generated on **Tue Dec 24 15:51:58 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:58 EET 2019** 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 **Sun Jan 05 13:26:41 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-testutil-server:1.3.1` +# Dependencies of `io.spine:spine-testutil-server:1.3.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3472,4 +3472,4 @@ This report was generated on **Tue Dec 24 15:51:58 EET 2019** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Dec 24 15:51:59 EET 2019** 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 **Sun Jan 05 13:26: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). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3198c7ac675..80502311d59 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.3.1 +1.3.2 2015 @@ -70,25 +70,25 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base - 1.3.0 + 1.3.2 compile io.spine spine-time - 1.3.0 + 1.3.2 compile io.spine.tools spine-model-compiler - 1.3.0 + 1.3.2 compile io.spine.tools spine-plugin-base - 1.3.0 + 1.3.2 compile @@ -130,25 +130,25 @@ all modules and does not describe the project structure per-subproject. io.spine spine-testlib - 1.3.0 + 1.3.2 test io.spine spine-testutil-time - 1.3.0 + 1.3.2 test io.spine.tools spine-mute-logging - 1.3.0 + 1.3.2 test io.spine.tools spine-plugin-testlib - 1.3.0 + 1.3.2 test @@ -210,12 +210,12 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-javadoc-filter - 1.3.0 + 1.3.2 io.spine.tools spine-protoc-plugin - 1.3.0 + 1.3.2 net.sourceforge.pmd diff --git a/server/src/main/java/io/spine/server/aggregate/ImportValidator.java b/server/src/main/java/io/spine/server/aggregate/ImportValidator.java index bb192393bf3..fe420e1dacb 100644 --- a/server/src/main/java/io/spine/server/aggregate/ImportValidator.java +++ b/server/src/main/java/io/spine/server/aggregate/ImportValidator.java @@ -25,7 +25,7 @@ import io.spine.server.bus.EnvelopeValidator; import io.spine.server.type.EventEnvelope; import io.spine.validate.ConstraintViolation; -import io.spine.validate.MessageValidator; +import io.spine.validate.Validate; import java.util.List; import java.util.Optional; @@ -42,7 +42,7 @@ final class ImportValidator implements EnvelopeValidator { public Optional validate(EventEnvelope event) { checkNotNull(event); EventMessage eventMessage = event.message(); - List violations = MessageValidator.validate(eventMessage); + List violations = Validate.violationsOf(eventMessage); if (violations.isEmpty()) { return Optional.empty(); } diff --git a/server/src/main/java/io/spine/server/commandbus/CommandValidator.java b/server/src/main/java/io/spine/server/commandbus/CommandValidator.java index ffb00e23672..eb89af20643 100644 --- a/server/src/main/java/io/spine/server/commandbus/CommandValidator.java +++ b/server/src/main/java/io/spine/server/commandbus/CommandValidator.java @@ -34,7 +34,7 @@ import io.spine.server.route.DefaultCommandRoute; import io.spine.server.type.CommandEnvelope; import io.spine.validate.ConstraintViolation; -import io.spine.validate.MessageValidator; +import io.spine.validate.Validate; import java.util.List; import java.util.Optional; @@ -139,7 +139,7 @@ private ViolationCheck(CommandEnvelope commandEnvelope) { */ @Internal private static List validateId(CommandId id) { - List violations = MessageValidator.validate(id); + List violations = Validate.violationsOf(id); if (id.getUuid().isEmpty()) { return ImmutableList.builder() .addAll(violations) @@ -172,7 +172,7 @@ private void validateMessage() { if (isDefault(message)) { addViolation("Non-default command message must be set."); } - List messageViolations = MessageValidator.validate(message); + List messageViolations = Validate.violationsOf(message); result.addAll(messageViolations); } 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 d520e711a6e..10b27a89986 100644 --- a/server/src/main/java/io/spine/server/entity/AbstractEntity.java +++ b/server/src/main/java/io/spine/server/entity/AbstractEntity.java @@ -36,7 +36,7 @@ import io.spine.server.entity.rejection.CannotModifyDeletedEntity; import io.spine.string.Stringifiers; import io.spine.validate.ConstraintViolation; -import io.spine.validate.MessageValidator; +import io.spine.validate.Validate; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import java.util.List; @@ -246,7 +246,7 @@ final void updateState(S state) { /** * Verifies the new entity state and returns {@link ConstraintViolation}s, if any. * - *

Default implementation uses the {@linkplain MessageValidator#validate(Message) message + *

Default implementation uses the {@linkplain Validate#violationsOf(Message) message * validation}. * * @param newState @@ -255,7 +255,7 @@ final void updateState(S state) { */ protected final List checkEntityState(S newState) { checkNotNull(newState); - return MessageValidator.validate(newState); + return Validate.violationsOf(newState); } /** diff --git a/server/src/main/java/io/spine/server/entity/IdField.java b/server/src/main/java/io/spine/server/entity/IdField.java index 263da0ea945..f253a5eeb32 100644 --- a/server/src/main/java/io/spine/server/entity/IdField.java +++ b/server/src/main/java/io/spine/server/entity/IdField.java @@ -87,7 +87,7 @@ void initBuilder(B builder, I id) { } FieldDescriptor idField = declaration.descriptor(); @SuppressWarnings("Immutable") // all supported types of IDs are immutable. - Required required = Required.create(false); + Required required = Required.create(false); boolean isRequired = required.valueFrom(idField) .orElse(true); // assume required, if not set to false if (isRequired) { diff --git a/server/src/main/java/io/spine/server/entity/Repository.java b/server/src/main/java/io/spine/server/entity/Repository.java index d3aaec4bf42..1218938bfe7 100644 --- a/server/src/main/java/io/spine/server/entity/Repository.java +++ b/server/src/main/java/io/spine/server/entity/Repository.java @@ -47,7 +47,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; -import java.util.Collection; import java.util.Iterator; import java.util.Optional; import java.util.function.Predicate; @@ -384,13 +383,12 @@ public final boolean isOpen() { *

An {@code IllegalStateException} is thrown otherwise. * * @param result the result of routing - * @param the type of the result */ - private void checkMatchesIdType(R result) { + private void checkMatchesIdType(Object result) { Class routingResultType = null; - if (result instanceof Collection) { - Collection asCollection = (Collection) result; - Object element = getFirst(asCollection, null); + if (result instanceof Iterable) { + Iterable asIterable = (Iterable) result; + Object element = getFirst(asIterable, null); if (element != null) { routingResultType = element.getClass(); } @@ -477,7 +475,7 @@ public EventFilter eventFilter() { /** * Enumeration of generic type parameters of this class. */ - enum GenericParameter implements GenericTypeIndex { + private enum GenericParameter implements GenericTypeIndex { /** The index of the generic type {@code }. */ ID(0), diff --git a/server/src/main/java/io/spine/server/event/EventValidator.java b/server/src/main/java/io/spine/server/event/EventValidator.java index d2b42c56387..3532b3f99d8 100644 --- a/server/src/main/java/io/spine/server/event/EventValidator.java +++ b/server/src/main/java/io/spine/server/event/EventValidator.java @@ -26,7 +26,7 @@ import io.spine.server.bus.EnvelopeValidator; import io.spine.server.type.EventEnvelope; import io.spine.validate.ConstraintViolation; -import io.spine.validate.MessageValidator; +import io.spine.validate.Validate; import java.util.List; import java.util.Optional; @@ -43,7 +43,7 @@ final class EventValidator implements EnvelopeValidator { public Optional validate(EventEnvelope event) { checkNotNull(event); Event outerObject = event.outerObject(); - List violations = MessageValidator.validate(outerObject); + List violations = Validate.violationsOf(outerObject); if (violations.isEmpty()) { return Optional.empty(); } diff --git a/server/src/main/java/io/spine/server/stand/RequestValidator.java b/server/src/main/java/io/spine/server/stand/RequestValidator.java index 62089233b72..6ce94f5afa9 100644 --- a/server/src/main/java/io/spine/server/stand/RequestValidator.java +++ b/server/src/main/java/io/spine/server/stand/RequestValidator.java @@ -24,7 +24,7 @@ import io.spine.base.Error; import io.spine.type.TypeName; import io.spine.validate.ConstraintViolation; -import io.spine.validate.MessageValidator; +import io.spine.validate.Validate; import io.spine.validate.ValidationError; import io.spine.validate.diags.ViolationText; import org.checkerframework.checker.nullness.qual.Nullable; @@ -142,7 +142,7 @@ private static void handleValidationResult(@Nullable InvalidRequestException exc * @return an instance of exception or null if the request message is valid. */ private @Nullable InvalidRequestException validateMessage(M request) { - List violations = MessageValidator.validate(request); + List violations = Validate.violationsOf(request); if (violations.isEmpty()) { return null; } diff --git a/server/src/main/java/io/spine/server/storage/memory/TenantAggregateRecords.java b/server/src/main/java/io/spine/server/storage/memory/TenantAggregateRecords.java index 1ffbb6e3a96..d41c9c515c0 100644 --- a/server/src/main/java/io/spine/server/storage/memory/TenantAggregateRecords.java +++ b/server/src/main/java/io/spine/server/storage/memory/TenantAggregateRecords.java @@ -152,7 +152,7 @@ record -> Timestamps.compare(date, record.getTimestamp()) > 0; if (snapshotsHit > snapshotIndex && predicate.test(record)) { this.records.remove(id, record); } - if (AggregateStorageRecordReverseComparator.isSnapshot(record)) { + if (record.hasSnapshot()) { snapshotsHit++; } } @@ -193,7 +193,7 @@ public int compare(AggregateEventRecord first, AggregateEventRecord second) { // In case the wall-clock isn't accurate enough, the timestamps may be the same. // In this case, compare the record type in a similar fashion. - if(result == 0) { + if (result == 0) { result = compareSimilarRecords(first, second); } } @@ -208,29 +208,32 @@ public int compare(AggregateEventRecord first, AggregateEventRecord second) { * is a snapshot. From a snapshot and an event with the same version and timestamp, * a snapshot is considered "newer". * - * @param first the first record - * @param second the second record + * @param first + * the first record + * @param second + * the second record * @return {@code -1}, {@code 1} or {@code 0} according to - * {@linkplain Comparator#compare(Object, Object) compare(..) specification} + * {@linkplain Comparator#compare(Object, Object) compare(..) specification} */ private static int compareSimilarRecords(AggregateEventRecord first, AggregateEventRecord second) { - boolean firstIsSnapshot = isSnapshot(first); - boolean secondIsSnapshot = isSnapshot(second); + boolean firstIsSnapshot = first.hasSnapshot(); + boolean secondIsSnapshot = second.hasSnapshot(); if (firstIsSnapshot && !secondIsSnapshot) { return -1; } else if (secondIsSnapshot && !firstIsSnapshot) { return 1; - } else { + } else if (!first.equals(second)) { // Both are of the same kind and have the same versions and timestamps. + // We cannot allow 2 nonidentical records to be equal in terms of `compare(..)`, + // so compare by hash codes. + return Integer.compare(first.hashCode(), second.hashCode()); + } else { + // Two records are equal in terms of both `equals(..)` and `compare(..)`. return 0; } } - private static boolean isSnapshot(AggregateEventRecord record) { - return !isDefault(record.getSnapshot()); - } - private static int compareVersions(AggregateEventRecord first, AggregateEventRecord second) { int result; diff --git a/server/src/test/java/io/spine/server/aggregate/AggregateRepositoryTest.java b/server/src/test/java/io/spine/server/aggregate/AggregateRepositoryTest.java index fb72a80faf2..7726672274e 100644 --- a/server/src/test/java/io/spine/server/aggregate/AggregateRepositoryTest.java +++ b/server/src/test/java/io/spine/server/aggregate/AggregateRepositoryTest.java @@ -395,11 +395,12 @@ void throwWhenCorrupted() { ProjectAggregate aggregate = givenStoredAggregate(); RecentHistory history = aggregate.recentHistory(); Event.Builder eventBuilder = history.stream() - .findFirst() - .orElseGet(Assertions::fail) - .toBuilder(); + .findFirst() + .orElseGet(Assertions::fail) + .toBuilder(); eventBuilder.setId(Events.generateId()); - eventBuilder.getContextBuilder().setTimestamp(currentTime()); + eventBuilder.getContextBuilder() + .setTimestamp(currentTime()); Event duplicateEvent = eventBuilder.build(); AggregateHistory corruptedHistory = AggregateHistory .newBuilder() diff --git a/server/src/test/java/io/spine/server/delivery/DeliveryTest.java b/server/src/test/java/io/spine/server/delivery/DeliveryTest.java index 5fd1c17dddd..5119dd4fb03 100644 --- a/server/src/test/java/io/spine/server/delivery/DeliveryTest.java +++ b/server/src/test/java/io/spine/server/delivery/DeliveryTest.java @@ -165,7 +165,7 @@ public void singleTarget_singleShard_singleThread() { } @Test - @DisplayName("a single shard to mutiple targets in a single-threaded env") + @DisplayName("a single shard to multiple targets in a single-threaded env") public void manyTargets_singleShard_singleThread() { changeShardCountTo(1); ImmutableSet targets = manyTargets(11); diff --git a/server/src/test/java/io/spine/server/entity/TransactionTest.java b/server/src/test/java/io/spine/server/entity/TransactionTest.java index 321b5cda89c..91828db3add 100644 --- a/server/src/test/java/io/spine/server/entity/TransactionTest.java +++ b/server/src/test/java/io/spine/server/entity/TransactionTest.java @@ -34,9 +34,7 @@ import io.spine.server.entity.given.tx.event.TxCreated; import io.spine.server.entity.given.tx.event.TxErrorRequested; import io.spine.server.entity.given.tx.event.TxStateErrorRequested; -import io.spine.test.validation.FakeOptionFactory; import io.spine.testing.server.model.ModelTests; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -129,11 +127,6 @@ void setUp() { ModelTests.dropAllModels(); } - @AfterEach - void tearDown() { - FakeOptionFactory.shouldNotFail(); - } - @Nested @DisplayName("initialize") class Initialize { diff --git a/server/src/test/java/io/spine/system/server/ConstraintViolatedTest.java b/server/src/test/java/io/spine/system/server/ConstraintViolatedTest.java index 67bb62a2756..139387a844e 100644 --- a/server/src/test/java/io/spine/system/server/ConstraintViolatedTest.java +++ b/server/src/test/java/io/spine/system/server/ConstraintViolatedTest.java @@ -83,7 +83,7 @@ void afterCommand() { .isEqualTo(InvalidText .newBuilder() .setId(DEFAULT) - .setErrorMessage("Value must be set.") + .setErrorMessage("A value must be set.") .buildPartial()); } } diff --git a/server/src/test/java/io/spine/test/validation/FakeOption.java b/server/src/test/java/io/spine/test/validation/FakeOption.java deleted file mode 100644 index d88ca36eba6..00000000000 --- a/server/src/test/java/io/spine/test/validation/FakeOption.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019, 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.test.validation; - -import com.google.common.collect.ImmutableList; -import com.google.protobuf.DescriptorProtos.FieldOptions; -import com.google.protobuf.GeneratedMessage.GeneratedExtension; -import io.spine.option.OptionsProto; -import io.spine.validate.FieldValue; -import io.spine.validate.option.Constraint; -import io.spine.validate.option.FieldValidatingOption; - -/** - * A test-only implementation of a validating option. - * - *

It is sometimes required for tests that a call to validation fails with a predictable - * exception. In such cases, the test authors may set up the fake option to fail validation. - * - *

This option is applied to any given field. Although the {@link #extension()} method returns - * the {@code beta} extension, the option is not bound to any real Protobuf option. - * - *

If the {@link FakeOptionFactory#plannedException()} is non-null, the planned exception is - * thrown by the constraint produced by this option. Otherwise, the constraint never discovers any - * violations. - */ -@SuppressWarnings("Immutable") // effectively the 2nd type argument is an immutable Object. -public final class FakeOption extends FieldValidatingOption { - - FakeOption() { - super(createExtension()); - } - - @SuppressWarnings("unchecked") // OK for tests. - private static GeneratedExtension createExtension() { - GeneratedExtension beta = OptionsProto.beta; - return (GeneratedExtension) beta; - } - - @Override - public Constraint> constraintFor(FieldValue value) { - RuntimeException exception = FakeOptionFactory.plannedException(); - if (exception != null) { - return v -> { throw exception; }; - } else { - return v -> ImmutableList.of(); - } - } - - @Override - public boolean shouldValidate(FieldValue value) { - return true; - } -} diff --git a/server/src/test/java/io/spine/test/validation/FakeOptionFactory.java b/server/src/test/java/io/spine/test/validation/FakeOptionFactory.java deleted file mode 100644 index 411d3133536..00000000000 --- a/server/src/test/java/io/spine/test/validation/FakeOptionFactory.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2019, 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.test.validation; - -import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; -import com.google.protobuf.ByteString; -import com.google.protobuf.Descriptors; -import com.google.protobuf.Message; -import io.spine.validate.option.FieldValidatingOption; -import io.spine.validate.option.ValidatingOptionFactory; -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.util.Set; - -/** - * A test-only implementation of {@link ValidatingOptionFactory}. - * - *

If a message validation should fail for the testing purposes, specify the expected exception - * via {@link #shouldFailWith(RuntimeException)}. When the test is over, call - * {@link #shouldNotFail()} in order to fix validation. - */ -@AutoService(ValidatingOptionFactory.class) -@SuppressWarnings("Immutable") -public final class FakeOptionFactory implements ValidatingOptionFactory { - - private static @Nullable RuntimeException exception = null; - - /** - * Sets the exception to throw at any message validation. - */ - public static void shouldFailWith(RuntimeException e) { - exception = e; - } - - /** - * Resets the message validation. - * - * @see #shouldFailWith(RuntimeException) - */ - public static void shouldNotFail() { - exception = null; - } - - /** - * Obtains the exception to throw on validation. - */ - static @Nullable RuntimeException plannedException() { - return exception; - } - - @Override - public Set> forBoolean() { - return fakeOption(); - } - - @Override - public Set> forByteString() { - return fakeOption(); - } - - @Override - public Set> forDouble() { - return fakeOption(); - } - - @Override - public Set> forEnum() { - return fakeOption(); - } - - @Override - public Set> forFloat() { - return fakeOption(); - } - - @Override - public Set> forInt() { - return fakeOption(); - } - - @Override - public Set> forLong() { - return fakeOption(); - } - - @Override - public Set> forMessage() { - return fakeOption(); - } - - @Override - public Set> forString() { - return fakeOption(); - } - - private static Set> fakeOption() { - FakeOption option = new FakeOption(); - @SuppressWarnings("unchecked") // OK for tests. - FieldValidatingOption castOption = (FieldValidatingOption) option; - return ImmutableSet.of(castOption); - } -} diff --git a/server/src/test/java/io/spine/test/validation/package-info.java b/server/src/test/java/io/spine/test/validation/package-info.java deleted file mode 100644 index 3d9bd682895..00000000000 --- a/server/src/test/java/io/spine/test/validation/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019, 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.test.validation; - -import com.google.errorprone.annotations.CheckReturnValue; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/verify/query/QueryResultSubject.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/verify/query/QueryResultSubject.java index 0b829985426..11bfad827e7 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/verify/query/QueryResultSubject.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/verify/query/QueryResultSubject.java @@ -122,7 +122,7 @@ private void initChildSubjects(QueryResponse queryResponse) { /** * Obtains the actually queried entity states. */ - public ImmutableList actual(){ + public ImmutableList actual() { return actual; } diff --git a/version.gradle b/version.gradle index e80211f2603..9f6c6bf359c 100644 --- a/version.gradle +++ b/version.gradle @@ -19,21 +19,21 @@ */ /** - * The versions of the libraries used. + * The versions of the libraries used. * - * This file is used in both module `build.gradle` scripts and in the integration tests, - * as we want to manage the versions in a single source. + * This file is used in both module `build.gradle` scripts and in the integration tests, + * as we want to manage the versions in a single source. */ -final def spineVersion = '1.3.1' +final def spineVersion = '1.3.2' ext { // The version of the modules in this project. versionToPublish = spineVersion // Depend on `base` for the general definitions and a model compiler. - spineBaseVersion = '1.3.0' + spineBaseVersion = '1.3.2' // Depend on `time` for `ZoneId`, `ZoneOffset` and other date/time types and utilities. - spineTimeVersion = '1.3.0' + spineTimeVersion = '1.3.2' }