Skip to content

Commit

Permalink
Merge pull request #1532 from SpineEventEngine/delivery-test-overrida…
Browse files Browse the repository at this point in the history
…ble-again

 Make some of `CatchUpTest` tests overridable again (again!)
  • Loading branch information
armiol authored Aug 27, 2023
2 parents 866df5f + f9ff03f commit 91934d6
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 58 deletions.
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.156`
# Dependencies of `io.spine:spine-client:2.0.0-SNAPSHOT.157`

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

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

This report was generated on **Tue Aug 22 21:20:20 WEST 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 **Sat Aug 26 16:31:38 WEST 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.156`
# Dependencies of `io.spine:spine-core:2.0.0-SNAPSHOT.157`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -1573,12 +1573,12 @@ This report was generated on **Tue Aug 22 21:20:20 WEST 2023** using [Gradle-Lic

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

This report was generated on **Tue Aug 22 21:20:20 WEST 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 **Sat Aug 26 16:31:39 WEST 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.156`
# Dependencies of `io.spine:spine-server:2.0.0-SNAPSHOT.157`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -2390,12 +2390,12 @@ This report was generated on **Tue Aug 22 21:20:20 WEST 2023** using [Gradle-Lic

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

This report was generated on **Tue Aug 22 21:20:21 WEST 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 **Sat Aug 26 16:31:39 WEST 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.156`
# Dependencies of `io.spine.tools:spine-testutil-client:2.0.0-SNAPSHOT.157`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -3327,12 +3327,12 @@ This report was generated on **Tue Aug 22 21:20:21 WEST 2023** using [Gradle-Lic

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

This report was generated on **Tue Aug 22 21:20:21 WEST 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 **Sat Aug 26 16:31:39 WEST 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.156`
# Dependencies of `io.spine.tools:spine-testutil-core:2.0.0-SNAPSHOT.157`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -4264,12 +4264,12 @@ This report was generated on **Tue Aug 22 21:20:21 WEST 2023** using [Gradle-Lic

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

This report was generated on **Tue Aug 22 21:20:22 WEST 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 **Sat Aug 26 16:31:40 WEST 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.156`
# Dependencies of `io.spine.tools:spine-testutil-server:2.0.0-SNAPSHOT.157`

## Runtime
1. **Group** : com.google.android. **Name** : annotations. **Version** : 4.1.1.4.
Expand Down Expand Up @@ -5249,4 +5249,4 @@ This report was generated on **Tue Aug 22 21:20:22 WEST 2023** using [Gradle-Lic

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

This report was generated on **Tue Aug 22 21:20:22 WEST 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 **Sat Aug 26 16:31:40 WEST 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.156</version>
<version>2.0.0-SNAPSHOT.157</version>

<inceptionYear>2015</inceptionYear>

Expand Down
99 changes: 55 additions & 44 deletions server/src/test/java/io/spine/server/delivery/CatchUpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import io.spine.testing.SlowTest;
import io.spine.testing.server.blackbox.BlackBox;
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;
Expand Down Expand Up @@ -104,45 +103,56 @@ private static void clearCatchUps() {
.clear();
}

@Nested
@DisplayName("given the time is provided with nanosecond resolution")
class NanosecondsResolution {

@Test
@DisplayName("catch up only particular instances by their IDs")
public void withNanosByIds() throws InterruptedException {
testCatchUpByIds();
}

@Test
@DisplayName("catch up all of projection instances " +
"and respect the order of the delivered events")
public void withNanosAllInOrder() throws InterruptedException {
testCatchUpAll();
}
/**
* This test is intentionally left {@code public}.
*
* <p>See the class-level docs.
*/
@Test
@DisplayName("given the time is provided with nanosecond resolution " +
"catch up only particular instances by their IDs")
public void withNanosByIds() throws InterruptedException {
testCatchUpByIds();
}

@Nested
@DisplayName("given the time is provided with millisecond resolution")
class MillisecondResolution {

@BeforeEach
void useMillis() {
setupMillis();
}
/**
* This test is intentionally left {@code public}.
*
* <p>See the class-level docs.
*/
@Test
@DisplayName("given the time is provided with nanosecond resolution" +
" catch up all of projection instances " +
"and respect the order of the delivered events")
public void withNanosAllInOrder() throws InterruptedException {
testCatchUpAll();
}

@Test
@DisplayName("catch up only particular instances by their IDs")
public void withMillisByIds() throws InterruptedException {
testCatchUpByIds();
}
/**
* This test is intentionally left {@code public}.
*
* <p>See the class-level docs.
*/
@Test
@DisplayName("given the time is provided with millisecond resolution" +
" catch up only particular instances by their IDs")
public void withMillisByIds() throws InterruptedException {
setupMillis();
testCatchUpByIds();
}

@Test
@DisplayName("catch up all of projection instances and " +
"respect the order of the delivered events")
public void withMillisAllInOrder() throws InterruptedException {
testCatchUpAll();
}
/**
* This test is intentionally left {@code public}.
*
* <p>See the class-level docs.
*/
@Test
@DisplayName("given the time is provided with millisecond resolution " +
"catch up all of projection instances and " +
"respect the order of the delivered events")
public void withMillisAllInOrder() throws InterruptedException {
setupMillis();
testCatchUpAll();
}

@Test
Expand Down Expand Up @@ -333,7 +343,8 @@ private static void testCatchUpAll() throws InterruptedException {
var maybeState = projectionRepo.find(identifier);
assertThat(maybeState).isPresent();

var state = maybeState.get().state();
var state = maybeState.get()
.state();
assertThat(state.getLastValue()).isEqualTo(negativeExpected);
}
}
Expand All @@ -345,9 +356,9 @@ private static Timestamp aMinuteAgo() {
private static List<Integer> readLastValues(ConsecutiveProjection.Repo repo,
String[] ids) {
return Arrays.stream(ids)
.map((id) -> findView(repo, id).state()
.getLastValue())
.collect(toList());
.map((id) -> findView(repo, id).state()
.getLastValue())
.collect(toList());
}

private static List<EmitNextNumber> generateEmissionCommands(int howMany, String[] ids) {
Expand All @@ -364,17 +375,17 @@ private static List<EmitNextNumber> generateEmissionCommands(int howMany, String
private static List<Callable<Object>>
asPostCommandJobs(BlackBox ctx, List<EmitNextNumber> commands) {
return commands.stream()
.map(cmd -> (Callable<Object>) () -> ctx.receivesCommand(cmd))
.collect(toList());
.map(cmd -> (Callable<Object>) () -> ctx.receivesCommand(cmd))
.collect(toList());
}

private static void setupMillis() {
Time.setProvider(new WithMillisOnlyResolution());
}

/**
* A time provider which provides the current time based upon JDK's wall clock, i.e. without
* the emulated nanoseconds.
* A time provider which provides the current time based upon JDK's wall clock,
* i.e. without the emulated nanoseconds.
*/
private static class WithMillisOnlyResolution implements Time.Provider {

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.156")
val versionToPublish: String by extra("2.0.0-SNAPSHOT.157")

0 comments on commit 91934d6

Please sign in to comment.