Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
265 changes: 163 additions & 102 deletions license-report.md

Large diffs are not rendered by default.

38 changes: 9 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

Expand All @@ -32,7 +12,7 @@ all modules and does not describe the project structure per-subproject.

<groupId>io.spine</groupId>
<artifactId>spine-core-java</artifactId>
<version>1.5.8</version>
<version>1.5.9</version>

<inceptionYear>2015</inceptionYear>

Expand Down Expand Up @@ -90,7 +70,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-base</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -102,13 +82,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-model-compiler</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-plugin-base</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -150,7 +130,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-testlib</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -162,13 +142,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mute-logging</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-plugin-testlib</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -230,12 +210,12 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-javadoc-filter</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-protoc-plugin</artifactId>
<version>1.5.8</version>
<version>1.5.10</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger;
import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
import com.google.errorprone.annotations.concurrent.LazyInit;
Expand Down Expand Up @@ -55,6 +56,8 @@
import static io.spine.logging.Logging.loggerFor;
import static io.spine.util.Exceptions.newIllegalArgumentException;
import static io.spine.validate.Validate.checkValid;
import static io.spine.validate.Validate.validateChange;
import static io.spine.validate.Validate.violationsOf;

/**
* Abstract base for entities.
Expand Down Expand Up @@ -265,7 +268,10 @@ final void updateState(S state) {
*/
protected final List<ConstraintViolation> checkEntityState(S newState) {
checkNotNull(newState);
return Validate.violationsOf(newState);
ImmutableList.Builder<ConstraintViolation> violations = ImmutableList.builder();
violations.addAll(violationsOf(newState));
violations.addAll(validateChange(state(), newState));
return violations.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Streams;
import com.google.common.flogger.FluentLogger;
import com.google.common.flogger.LoggerConfig;
import com.google.protobuf.TextFormat;
import io.grpc.stub.StreamObserver;
import io.spine.client.OrderBy;
Expand All @@ -42,7 +41,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.logging.Level;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down Expand Up @@ -224,13 +222,7 @@ private void store(Iterable<Event> events) {
final class Log {

private final FluentLogger.Api debug = logger().atFine();
private final boolean debugEnabled = debugEnabled();

private boolean debugEnabled() {
Level level = LoggerConfig.getConfig(getClass())
.getLevel();
return level != null && level.intValue() <= Level.FINE.intValue();
}
private final boolean debugEnabled = debug.isEnabled();

private void stored(Event event) {
debug.log("Stored: %s.", lazy(() -> TextFormat.shortDebugString(event)));
Expand Down
2 changes: 2 additions & 0 deletions server/src/test/java/io/spine/client/CommandRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
import io.spine.test.client.event.UserLoggedIn;
import io.spine.test.client.rejection.Rejections.UserAlreadyLoggedIn;
import io.spine.testing.core.given.GivenUserId;
import io.spine.testing.logging.MuteLogging;
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 static com.google.common.truth.Truth.assertThat;

@MuteLogging
@DisplayName("`CommandRequest` should")
class CommandRequestTest extends AbstractClientTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.spine.test.client.command.LogInUser;
import io.spine.test.client.event.UserLoggedIn;
import io.spine.testing.core.given.GivenUserId;
import io.spine.testing.logging.MuteLogging;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -76,6 +77,7 @@ void clearCounter() {
counter.clear();
}

@MuteLogging
@Test
@DisplayName("allow to receive event messages")
void observeEventMessage() {
Expand All @@ -89,6 +91,7 @@ void observeEventMessage() {
.isTrue();
}

@MuteLogging
@Nested
@DisplayName("allow to receive event messages and contexts, filtering by")
class Filtering {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void eventTopic() {
checkSubscribesTo(AggProjectCreated.class);
}

@MuteLogging
@Test
@DisplayName("events from abstract reactors")
void eventsFromReactors() {
Expand Down
48 changes: 48 additions & 0 deletions server/src/test/java/io/spine/server/entity/EntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@
import com.google.common.collect.Range;
import com.google.common.truth.LongSubject;
import com.google.protobuf.StringValue;
import io.spine.core.UserId;
import io.spine.core.Version;
import io.spine.core.Versions;
import io.spine.server.BoundedContextBuilder;
import io.spine.server.entity.given.entity.EntityWithMessageId;
import io.spine.server.entity.given.entity.TestAggregate;
import io.spine.server.entity.given.entity.TestEntityWithIdInteger;
import io.spine.server.entity.given.entity.TestEntityWithIdLong;
import io.spine.server.entity.given.entity.TestEntityWithIdMessage;
import io.spine.server.entity.given.entity.TestEntityWithIdString;
import io.spine.server.entity.given.entity.UserAggregate;
import io.spine.server.entity.rejection.CannotModifyArchivedEntity;
import io.spine.server.entity.rejection.CannotModifyDeletedEntity;
import io.spine.test.entity.Project;
import io.spine.test.user.ChooseDayOfBirth;
import io.spine.test.user.SignUpUser;
import io.spine.test.user.User;
import io.spine.testdata.Sample;
import io.spine.testing.Tests;
import io.spine.testing.logging.MuteLogging;
import io.spine.testing.server.blackbox.BlackBoxContext;
import io.spine.time.LocalDates;
import io.spine.time.testing.TimeTests;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -46,6 +55,8 @@
import static io.spine.base.Identifier.newUuid;
import static io.spine.base.Time.currentTime;
import static io.spine.testing.Tests.nullRef;
import static io.spine.time.Month.FEBRUARY;
import static io.spine.time.Month.JANUARY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand Down Expand Up @@ -170,6 +181,43 @@ void updateState() {
assertEquals(state, entityNew.state());
}

@MuteLogging
@Test
@DisplayName("check `(set_once)` on state update")
void setOnce() {
BoundedContextBuilder context = BoundedContextBuilder
.assumingTests()
.add(UserAggregate.class);
UserId id = UserId.newBuilder()
.setValue(newUuid())
.build();
SignUpUser signUpUser = SignUpUser
.newBuilder()
.setId(id)
.vBuild();
ChooseDayOfBirth chooseInitial = ChooseDayOfBirth
.newBuilder()
.setId(id)
.setDayOfBirth(LocalDates.of(2000, JANUARY, 1))
.vBuild();
ChooseDayOfBirth chooseAgain = ChooseDayOfBirth
.newBuilder()
.setId(id)
.setDayOfBirth(LocalDates.of(1988, FEBRUARY, 29))
.vBuild();
BlackBoxContext bbc = BlackBoxContext
.from(context)
.receivesCommand(signUpUser)
.receivesCommand(chooseInitial);
bbc.receivesCommand(chooseAgain);
bbc.assertEntity(id, UserAggregate.class)
.hasStateThat()
.comparingExpectedFieldsOnly()
.isEqualTo(User.newBuilder()
.setDateOfBirth(chooseInitial.getDayOfBirth())
.buildPartial());
}

@Test
@DisplayName("have zero version by default")
void haveZeroVersionByDefault() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.given.entity;

import io.spine.core.UserId;
import io.spine.server.aggregate.Aggregate;
import io.spine.server.aggregate.Apply;
import io.spine.server.command.Assign;
import io.spine.test.user.ChooseDayOfBirth;
import io.spine.test.user.DayOfBirthChosen;
import io.spine.test.user.SignUpUser;
import io.spine.test.user.User;
import io.spine.test.user.UserSignedUp;

public final class UserAggregate extends Aggregate<UserId, User, User.Builder> {

@Assign
UserSignedUp handle(SignUpUser command) {
return UserSignedUp
.newBuilder()
.setId(command.getId())
.vBuild();
}

@Assign
DayOfBirthChosen handle(ChooseDayOfBirth command) {
return DayOfBirthChosen
.newBuilder()
.setId(command.getId())
.setDayOfBirth(command.getDayOfBirth())
.vBuild();
}

@Apply
private void on(UserSignedUp event) {
builder().setId(event.getId());
}

@Apply
private void on(DayOfBirthChosen event) {
builder().setDateOfBirth(event.getDayOfBirth());
}
}
Loading