Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid MIN_VALUE and MAX_VALUE from Timestamps #1544

Merged
merged 3 commits into from
Nov 14, 2023
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
24 changes: 12 additions & 12 deletions license-report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-client:2.0.0-SNAPSHOT.174`
# Dependencies of `io.spine:spine-client:2.0.0-SNAPSHOT.175`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -817,12 +817,12 @@

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Nov 08 14:13:56 WET 2023** 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 Nov 13 17:56:28 WET 2023** 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:2.0.0-SNAPSHOT.174`
# Dependencies of `io.spine:spine-core:2.0.0-SNAPSHOT.175`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -1591,12 +1591,12 @@ This report was generated on **Wed Nov 08 14:13:56 WET 2023** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Nov 08 14:13:56 WET 2023** 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 Nov 13 17:56:28 WET 2023** 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:2.0.0-SNAPSHOT.174`
# Dependencies of `io.spine:spine-server:2.0.0-SNAPSHOT.175`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -2421,12 +2421,12 @@ This report was generated on **Wed Nov 08 14:13:56 WET 2023** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Nov 08 14:13:57 WET 2023** 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 Nov 13 17:56:29 WET 2023** 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-testutil-client:2.0.0-SNAPSHOT.174`
# Dependencies of `io.spine.tools:spine-testutil-client:2.0.0-SNAPSHOT.175`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -3358,12 +3358,12 @@ This report was generated on **Wed Nov 08 14:13:57 WET 2023** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Nov 08 14:13:57 WET 2023** 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 Nov 13 17:56:29 WET 2023** 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-testutil-core:2.0.0-SNAPSHOT.174`
# Dependencies of `io.spine.tools:spine-testutil-core:2.0.0-SNAPSHOT.175`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -4295,12 +4295,12 @@ This report was generated on **Wed Nov 08 14:13:57 WET 2023** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Nov 08 14:13:57 WET 2023** 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 Nov 13 17:56:30 WET 2023** 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-testutil-server:2.0.0-SNAPSHOT.174`
# Dependencies of `io.spine.tools:spine-testutil-server:2.0.0-SNAPSHOT.175`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -5280,4 +5280,4 @@ This report was generated on **Wed Nov 08 14:13:57 WET 2023** using [Gradle-Lice

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Wed Nov 08 14:13:58 WET 2023** 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 Nov 13 17:56:30 WET 2023** 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).
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
<groupId>io.spine</groupId>
<artifactId>spine-core-java</artifactId>
<version>2.0.0-SNAPSHOT.174</version>
<version>2.0.0-SNAPSHOT.175</version>

<inceptionYear>2015</inceptionYear>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Any;
import com.google.protobuf.Timestamp;
import com.google.protobuf.util.Timestamps;
import com.google.protobuf.util.Durations;
import io.spine.base.EntityState;
import io.spine.base.Time;
import io.spine.core.ActorContext;
Expand Down Expand Up @@ -381,8 +381,8 @@ void sortByVersionFirstly() {
var state = AggProject.getDefaultInstance();
var minVersion = zero();
var maxVersion = increment(minVersion);
var minTimestamp = Timestamps.MIN_VALUE;
var maxTimestamp = Timestamps.MAX_VALUE;
var minTimestamp = currentTime();
var maxTimestamp = add(minTimestamp, Durations.fromHours(1));

// The first event is an event, which is the oldest, i.e. with the minimal version.
var expectedFirst = eventFactory.createEvent(event(state), minVersion, maxTimestamp);
Expand Down
35 changes: 32 additions & 3 deletions server/src/test/java/io/spine/server/event/store/QueriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
package io.spine.server.event.store;

import com.google.common.collect.ImmutableList;
import com.google.protobuf.Timestamp;
import com.google.protobuf.util.Timestamps;
import io.spine.core.Event;
import io.spine.query.Column;
import io.spine.query.ComparisonOperator;
import io.spine.query.SubjectParameter;
import io.spine.server.event.EventFilter;
import io.spine.server.event.EventStreamQuery;
Expand All @@ -37,8 +41,12 @@

import static com.google.common.testing.NullPointerTester.Visibility.PACKAGE;
import static com.google.common.truth.Truth.assertThat;
import static io.spine.base.Time.currentTime;
import static io.spine.query.ComparisonOperator.GREATER_THAN;
import static io.spine.query.ComparisonOperator.LESS_THAN;
import static io.spine.query.LogicalOperator.AND;
import static io.spine.query.LogicalOperator.OR;
import static io.spine.server.event.store.EventColumn.created;
import static io.spine.server.event.store.Queries.convert;

@DisplayName("`Queries` should")
Expand All @@ -65,17 +73,38 @@ void convertEmptyQuery() {
@Test
@DisplayName("convert the time-constrained query to the corresponding `RecordQuery`")
void convertTimeConstrainedQuery() {
var startTime = Timestamps.fromSeconds(0);
var endTime = currentTime();
var query = EventStreamQuery.newBuilder()
.setAfter(Timestamps.MIN_VALUE)
.setBefore(Timestamps.MAX_VALUE)
.setAfter(startTime)
.setBefore(endTime)
.build();
var result = convert(query);
var subject = result.subject();
var rootPredicate = subject.predicate();
assertThat(rootPredicate.children()).isEmpty();

assertThat(rootPredicate.operator()).isEqualTo(AND);
assertThat(rootPredicate.parameters()).hasSize(2);
var params = rootPredicate.parameters();
assertThat(params).hasSize(2);

var greaterThanParam = params.get(0);
assertCreatedColumnQueried(greaterThanParam, GREATER_THAN, startTime);

var lessThanParam = params.get(1);
assertCreatedColumnQueried(lessThanParam, LESS_THAN, endTime);

}

private static void assertCreatedColumnQueried(
SubjectParameter<Event, ? extends Column<Event, ?>, ?> parameter,
ComparisonOperator operator, Timestamp value) {
assertThat(parameter.operator())
.isEqualTo(operator);
assertThat(parameter.column().name())
.isEqualTo(created.name());
assertThat(parameter.value())
.isEqualTo(value);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@

package io.spine.testing.server.entity.given;

import com.google.protobuf.util.Timestamps;
import com.google.protobuf.Duration;
import com.google.protobuf.util.Durations;
import io.spine.core.Version;

import static com.google.protobuf.util.Timestamps.add;
import static com.google.protobuf.util.Timestamps.subtract;
import static io.spine.base.Time.currentTime;

public final class GivenEntityVersion {

private static final Duration TEN_DAYS = Durations.fromDays(10);

/** Prevents instantiation of this test env class. */
private GivenEntityVersion() {
}
Expand All @@ -48,15 +53,15 @@ public static Version version() {
public static Version olderVersion() {
var version = Version.newBuilder()
.setNumber(15)
.setTimestamp(Timestamps.MIN_VALUE)
.setTimestamp(subtract(currentTime(), TEN_DAYS))
.build();
return version;
}

public static Version newerVersion() {
var version = Version.newBuilder()
.setNumber(125)
.setTimestamp(Timestamps.MAX_VALUE)
.setTimestamp(add(currentTime(), TEN_DAYS))
.build();
return version;
}
Expand Down
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
*
* For versions of Spine-based dependencies, please see [io.spine.internal.dependency.Spine].
*/
val versionToPublish: String by extra("2.0.0-SNAPSHOT.174")
val versionToPublish: String by extra("2.0.0-SNAPSHOT.175")
Loading