Skip to content

Commit

Permalink
Use static imports for Truth8.assertThat(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrykuzmin committed Sep 3, 2020
1 parent 2b1c011 commit 1168c6a
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 88 deletions.
16 changes: 8 additions & 8 deletions license-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:44 EEST 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 Sep 03 20:06:46 EEST 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).



Expand Down Expand Up @@ -777,7 +777,7 @@ This report was generated on **Thu Sep 03 19:38:44 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:44 EEST 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 Sep 03 20:06:46 EEST 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).



Expand Down Expand Up @@ -1183,7 +1183,7 @@ This report was generated on **Thu Sep 03 19:38:44 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:45 EEST 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 Sep 03 20:06:46 EEST 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).



Expand Down Expand Up @@ -1659,7 +1659,7 @@ This report was generated on **Thu Sep 03 19:38:45 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:45 EEST 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 Sep 03 20:06:47 EEST 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).



Expand Down Expand Up @@ -2082,7 +2082,7 @@ This report was generated on **Thu Sep 03 19:38:45 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:46 EEST 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 Sep 03 20:06:47 EEST 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).



Expand Down Expand Up @@ -2542,7 +2542,7 @@ This report was generated on **Thu Sep 03 19:38:46 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:48 EEST 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 Sep 03 20:06:49 EEST 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).



Expand Down Expand Up @@ -3010,7 +3010,7 @@ This report was generated on **Thu Sep 03 19:38:48 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:50 EEST 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 Sep 03 20:06:50 EEST 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).



Expand Down Expand Up @@ -3514,4 +3514,4 @@ This report was generated on **Thu Sep 03 19:38:50 EEST 2020** using [Gradle-Lic
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Thu Sep 03 19:38:52 EEST 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 Sep 03 20:06:52 EEST 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).
8 changes: 3 additions & 5 deletions server/src/test/java/io/spine/client/ClientBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package io.spine.client;

import com.google.common.testing.NullPointerTester;
import com.google.common.truth.Truth8;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.spine.core.TenantId;
Expand All @@ -39,6 +38,7 @@
import java.util.concurrent.TimeUnit;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static io.spine.client.Client.connectTo;
import static io.spine.client.Client.usingChannel;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -175,8 +175,7 @@ class Tenant {
@DisplayName("assuming single-tenant context if not set")
void singleTenant() {
client = builder.build();
Truth8.assertThat(client.tenant())
.isEmpty();
assertThat(client.tenant()).isEmpty();
}

@Test
Expand All @@ -185,8 +184,7 @@ void correctValue() {
TenantId expected = GivenTenantId.generate();
client = builder.forTenant(expected)
.build();
Truth8.assertThat(client.tenant())
.hasValue(expected);
assertThat(client.tenant()).hasValue(expected);
}

@Test
Expand Down
5 changes: 2 additions & 3 deletions server/src/test/java/io/spine/core/CoreMixinsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

package io.spine.core;

import com.google.common.truth.Truth8;
import io.spine.core.given.CoreMixinsTestEnv;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Optional;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;

/**
* Tests of mixins for {@code core} {@code Message}s.
Expand Down Expand Up @@ -87,8 +87,7 @@ void messageIdMixin() {
void originIdMixin() {
Optional<Origin> origin = CoreMixinsTestEnv.event()
.origin();
Truth8.assertThat(origin)
.isPresent();
assertThat(origin).isPresent();
assertThat(origin.get()
.checkFieldsReachable()).isTrue();
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/test/java/io/spine/core/EnrichmentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import com.google.common.testing.NullPointerTester;
import com.google.common.truth.OptionalSubject;
import com.google.common.truth.Truth8;
import com.google.protobuf.Message;
import com.google.protobuf.StringValue;
import io.spine.base.Identifier;
Expand All @@ -43,6 +42,7 @@
import java.util.Optional;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static io.spine.base.Identifier.newUuid;
import static io.spine.core.Enrichments.containerIn;
import static io.spine.protobuf.AnyPacker.pack;
Expand Down Expand Up @@ -141,7 +141,7 @@ void returnAbsentOnNoEnrichments() {

private static
OptionalSubject assertEnrichment(EventContext ctx, Class<? extends Message> cls) {
return Truth8.assertThat(ctx.find(cls));
return assertThat(ctx.find(cls));
}

@Test
Expand Down
8 changes: 4 additions & 4 deletions server/src/test/java/io/spine/server/BoundedContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.example.ForeignContextConfig;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.truth.Truth8;
import io.spine.annotation.Internal;
import io.spine.core.BoundedContextName;
import io.spine.logging.Logging;
Expand Down Expand Up @@ -67,6 +66,7 @@
import java.util.stream.Stream;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static io.spine.core.BoundedContextNames.newName;
import static io.spine.testing.TestValues.randomString;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -379,9 +379,9 @@ void notExposeInvisibleAggregates() {

context.register(new SecretProjectRepository());

Truth8.assertThat(context.internalAccess()
.findRepository(SecretProject.class))
.isEmpty();
assertThat(context.internalAccess()
.findRepository(SecretProject.class))
.isEmpty();
}

@Test
Expand Down
5 changes: 2 additions & 3 deletions server/src/test/java/io/spine/server/GrpcContainerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package io.spine.server;

import com.google.common.collect.ImmutableSet;
import com.google.common.truth.Truth8;
import io.grpc.BindableService;
import io.grpc.Server;
import io.grpc.ServerServiceDefinition;
Expand All @@ -35,6 +34,7 @@
import java.util.Set;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static io.spine.testing.TestValues.randomString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -63,8 +63,7 @@ void setParamsInBuilder() {
GrpcContainer.Builder builder = GrpcContainer
.atPort(port);

Truth8.assertThat(builder.port())
.hasValue(port);
assertThat(builder.port()).hasValue(port);

int count = 3;
for (int i = 0; i < count; i++) {
Expand Down
10 changes: 5 additions & 5 deletions server/src/test/java/io/spine/server/bus/BusFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package io.spine.server.bus;

import com.google.common.testing.NullPointerTester;
import com.google.common.truth.Truth8;
import com.google.protobuf.Message;
import io.spine.base.Error;
import io.spine.core.Ack;
Expand All @@ -43,6 +42,7 @@
import java.util.Optional;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static io.spine.base.Identifier.newUuid;
import static io.spine.core.Status.StatusCase.ERROR;
import static io.spine.core.Status.StatusCase.OK;
Expand Down Expand Up @@ -72,15 +72,15 @@ void passNullToleranceCheck() {
void letPass() {
BusFilter<CommandEnvelope> filter = new BusFilters.Accepting();
Optional<Ack> ack = filter.filter(commandEnvelope);
Truth8.assertThat(ack).isEmpty();
assertThat(ack).isEmpty();
}

@Test
@DisplayName("reject the message with the `OK` status")
void rejectWithOk() {
BusFilter<CommandEnvelope> filter = new BusFilters.RejectingWithOk();
Optional<Ack> ack = filter.filter(commandEnvelope);
Truth8.assertThat(ack).isPresent();
assertThat(ack).isPresent();

Ack theAck = ack.get();
assertIdEquals(theAck);
Expand All @@ -97,7 +97,7 @@ void rejectWithError() {
.build();
BusFilter<CommandEnvelope> filter = new BusFilters.RejectingWithError(error);
Optional<Ack> ack = filter.filter(commandEnvelope);
Truth8.assertThat(ack).isPresent();
assertThat(ack).isPresent();

Ack theAck = ack.get();
assertIdEquals(theAck);
Expand All @@ -117,7 +117,7 @@ void rejectWithThrowableMessage() {
BusFilter<CommandEnvelope> filter =
new BusFilters.RejectingWithThrowableMessage(rejection);
Optional<Ack> ack = filter.filter(commandEnvelope);
Truth8.assertThat(ack).isPresent();
assertThat(ack).isPresent();

Ack theAck = ack.get();
assertIdEquals(theAck);
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.Iterators;
import com.google.common.truth.Truth8;
import com.google.protobuf.Timestamp;
import com.google.protobuf.util.Durations;
import io.spine.base.Time;
Expand Down Expand Up @@ -55,6 +54,7 @@
import java.util.stream.IntStream;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.protobuf.util.Timestamps.subtract;
import static io.spine.base.Time.currentTime;
import static io.spine.server.delivery.CatchUpStatus.COMPLETED;
Expand Down Expand Up @@ -288,13 +288,12 @@ private static void testCatchUpAll() throws InterruptedException {

int negativeExpected = -1 * positiveExpected * 2;

Truth8.assertThat(projectionRepo.find(excludedTarget))
.isEmpty();
assertThat(projectionRepo.find(excludedTarget))
.isEmpty();
for (int idIndex = 1; idIndex < ids.length; idIndex++) {
String identifier = ids[idIndex];
Optional<ConsecutiveProjection> maybeState = projectionRepo.find(identifier);
Truth8.assertThat(maybeState)
.isPresent();
assertThat(maybeState).isPresent();

ConsecutiveNumberView state = maybeState.get()
.state();
Expand Down
11 changes: 4 additions & 7 deletions server/src/test/java/io/spine/server/delivery/DeliveryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.truth.Truth8;
import com.google.protobuf.util.Durations;
import io.spine.base.Identifier;
import io.spine.base.Tests;
Expand Down Expand Up @@ -59,6 +58,7 @@
import java.util.concurrent.ExecutorService;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
import static io.spine.server.delivery.given.DeliveryTestEnv.manyTargets;
import static io.spine.server.delivery.given.DeliveryTestEnv.singleTarget;
Expand Down Expand Up @@ -210,8 +210,7 @@ public void returnOptionalEmptyIfPicked() {
.run(() -> assertStatsMatch(delivery, index));

Optional<ShardProcessingSession> session = registry.pickUp(index, env.nodeId());
Truth8.assertThat(session)
.isPresent();
assertThat(session).isPresent();

TenantAwareRunner.with(tenantId)
.run(() -> assertStatsEmpty(delivery, index));
Expand Down Expand Up @@ -253,8 +252,7 @@ public void notifyDeliveryMonitorOfDeliveryCompletion() {

private static void assertStatsEmpty(Delivery delivery, ShardIndex index) {
Optional<DeliveryStats> emptyStats = delivery.deliverMessagesFrom(index);
Truth8.assertThat(emptyStats)
.isEmpty();
assertThat(emptyStats).isEmpty();
}

@Test
Expand Down Expand Up @@ -370,8 +368,7 @@ public void deliverMessagesInOrderOfEmission() throws InterruptedException {
@SuppressWarnings("OptionalGetWithoutIsPresent"/* unchecked exception fails the test. */)
private static void assertStatsMatch(Delivery delivery, ShardIndex index) {
Optional<DeliveryStats> stats = delivery.deliverMessagesFrom(index);
Truth8.assertThat(stats)
.isPresent();
assertThat(stats).isPresent();
assertThat(stats.get()
.shardIndex()).isEqualTo(index);
}
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.Lists;
import com.google.common.truth.Truth8;
import io.spine.base.Time;
import io.spine.core.Command;
import io.spine.test.delivery.AddNumber;
Expand All @@ -43,6 +42,7 @@
import java.util.stream.IntStream;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
import static io.spine.server.delivery.DeliveryStrategy.newIndex;
import static io.spine.server.delivery.InboxIds.newSignalId;
Expand Down Expand Up @@ -119,12 +119,10 @@ void readRecordsPageByPage() {

Optional<Page<InboxMessage>> maybeNext = actualPage.next();
if (iterator.hasNext()) {
Truth8.assertThat(maybeNext)
.isPresent();
assertThat(maybeNext).isPresent();
actualPage = maybeNext.get();
} else {
Truth8.assertThat(maybeNext)
.isEmpty();
assertThat(maybeNext).isEmpty();
}
}
}
Expand Down Expand Up @@ -162,8 +160,7 @@ private void assertStorageEmpty(ShardIndex index) {
Page<InboxMessage> page = readContents(index);
assertThat(page.contents()
.isEmpty()).isTrue();
Truth8.assertThat(page.next())
.isEmpty();
assertThat(page.next()).isEmpty();
}

private InboxMessage newCommandInInbox(ShardIndex index, String targetId) {
Expand Down
Loading

0 comments on commit 1168c6a

Please sign in to comment.