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

Improvements for testing utilities (part 2) #1251

Merged
merged 21 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
01b8a94
Hide impl. details of tracking of unsupported commands
alexander-yevsyukov Mar 17, 2020
74cf940
Config. change caused by updated IDEA
alexander-yevsyukov Mar 17, 2020
6e68cec
Deprecate redundant factory methods in `BlackBoxBoundedContext`
alexander-yevsyukov Mar 17, 2020
42473fc
Improve tests of black box contexts
alexander-yevsyukov Mar 17, 2020
7b8d72a
Fix code layout
alexander-yevsyukov Mar 17, 2020
a01f3f2
Improve code layout
alexander-yevsyukov Mar 17, 2020
d0c998a
Improve code layout
alexander-yevsyukov Mar 17, 2020
4dc624f
Fix code layout
alexander-yevsyukov Mar 17, 2020
a52916d
Merge remote-tracking branch 'remotes/origin/master' into testing-uti…
alexander-yevsyukov Mar 17, 2020
d75b13f
Advance Spine version
alexander-yevsyukov Mar 17, 2020
5278eb2
Fix base version
alexander-yevsyukov Mar 17, 2020
5b1efcf
Start eliminating `assumingTests()` methods
alexander-yevsyukov Mar 17, 2020
97b2139
Remove `assumingTests()`, deprecate `with(Repository)`
alexander-yevsyukov Mar 17, 2020
2604e81
Deprecate `withXxx()`
alexander-yevsyukov Mar 17, 2020
094f6b0
Simplify creating test `BlackBoxBoundedContext` in the hierarchy
alexander-yevsyukov Mar 17, 2020
3b5f439
Update dependency reports
alexander-yevsyukov Mar 17, 2020
177e5c1
Fix missing tenant in multi-tenant test
alexander-yevsyukov Mar 18, 2020
968c976
Address deprecation of `withXxx()` methods
alexander-yevsyukov Mar 18, 2020
e356ddf
Improve Javadoc
alexander-yevsyukov Mar 18, 2020
2ed9790
Fix generic params
alexander-yevsyukov Mar 18, 2020
f9f361a
Fix code alignment
alexander-yevsyukov Mar 18, 2020
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
26 changes: 6 additions & 20 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,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.1</version>
<version>1.5.2</version>

<inceptionYear>2015</inceptionYear>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import io.spine.testing.logging.MuteLogging;
import io.spine.testing.server.TestEventFactory;
import io.spine.testing.server.blackbox.BlackBoxBoundedContext;
import io.spine.testing.server.blackbox.SingleTenantBlackBoxContext;
import io.spine.testing.server.model.ModelTests;
import io.spine.type.TypeUrl;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -525,10 +524,10 @@ class PostEventsToBus {
@BeforeEach
void createAnotherRepository() {
resetRepository();
AggregateRepository<?, ?> repository = repository();
context = BlackBoxBoundedContext
.singleTenant()
.with(repository);
context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(repository())
);
}

@Test
Expand Down Expand Up @@ -604,11 +603,12 @@ void throughEventFilter() {
.setProjectId(parent)
.addChildProjectId(id)
.build();
SingleTenantBlackBoxContext context = BlackBoxBoundedContext
.singleTenant()
.with(new EventDiscardingAggregateRepository())
.receivesCommands(create, start)
.receivesEvent(archived);
BlackBoxBoundedContext<?> context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(new EventDiscardingAggregateRepository())
);
context.receivesCommands(create, start)
.receivesEvent(archived);
context.assertEvents()
.isEmpty();
context.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
package io.spine.server.aggregate;

import com.google.common.collect.Iterators;
import io.spine.server.BoundedContextBuilder;
import io.spine.server.aggregate.given.fibonacci.FibonacciRepository;
import io.spine.server.aggregate.given.fibonacci.SequenceId;
import io.spine.server.aggregate.given.fibonacci.command.MoveSequence;
import io.spine.server.aggregate.given.fibonacci.command.SetStartingNumbers;
import io.spine.server.aggregate.given.fibonacci.event.StartingNumbersSet;
import io.spine.server.storage.StorageFactory;
import io.spine.testing.server.blackbox.BlackBoxBoundedContext;
import io.spine.testing.server.blackbox.SingleTenantBlackBoxContext;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand All @@ -52,15 +51,14 @@ public abstract class AggregateStorageTruncationTest {
.setValue(newUuid())
.vBuild();

protected abstract StorageFactory storageFactory();

@Test
@DisplayName("restore aggregate state properly")
void restoreAggregateState() {
FibonacciRepository repo = new FibonacciRepository();
SingleTenantBlackBoxContext context = BlackBoxBoundedContext
.singleTenant()
.with(repo);
BlackBoxBoundedContext<?> context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(repo)
);

// Set the starting numbers.
SetStartingNumbers setStartingNumbers = SetStartingNumbers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.spine.base.Time;
import io.spine.core.Ack;
import io.spine.core.Command;
import io.spine.core.CommandId;
import io.spine.core.Event;
import io.spine.core.MessageId;
import io.spine.core.TenantId;
Expand Down Expand Up @@ -88,13 +87,11 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
import static io.spine.grpc.StreamObservers.noOpObserver;
import static io.spine.protobuf.AnyPacker.unpack;
Expand Down Expand Up @@ -823,9 +820,10 @@ class CreateSingleEventForPair {

@BeforeEach
void prepareContext() {
context = BlackBoxBoundedContext
.singleTenant()
.with(new TaskAggregateRepository());
context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(new TaskAggregateRepository())
);
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

package io.spine.server.aggregate;

import io.spine.server.BoundedContextBuilder;
import io.spine.server.aggregate.given.importado.DotSpace;
import io.spine.server.aggregate.given.importado.ObjectId;
import io.spine.server.aggregate.given.importado.event.Moved;
import io.spine.testing.server.blackbox.BlackBoxBoundedContext;
import io.spine.testing.server.blackbox.SingleTenantBlackBoxContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -44,13 +44,14 @@
@DisplayName("Aggregate which supports event import should")
class ApplyAllowImportTest {

private SingleTenantBlackBoxContext context;
private BlackBoxBoundedContext<?> context;

@BeforeEach
void setUp() {
context = BlackBoxBoundedContext
.singleTenant()
.with(new DotSpace());
context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(new DotSpace())
);
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package io.spine.server.aggregate;

import io.spine.base.EventMessage;
import io.spine.server.BoundedContextBuilder;
import io.spine.server.aggregate.given.klasse.EngineAggregate;
import io.spine.server.aggregate.given.klasse.EngineId;
import io.spine.server.aggregate.given.klasse.EngineRepository;
Expand All @@ -31,7 +32,6 @@
import io.spine.server.type.EventEnvelope;
import io.spine.testing.server.TestEventFactory;
import io.spine.testing.server.blackbox.BlackBoxBoundedContext;
import io.spine.testing.server.blackbox.SingleTenantBlackBoxContext;
import io.spine.testing.server.entity.EntitySubject;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -50,13 +50,14 @@
class EventImportTest {

private EngineRepository repository;
private SingleTenantBlackBoxContext context;
private BlackBoxBoundedContext<?> context;

void createRepository(boolean routeByFirstMessageField) {
repository = new EngineRepository(routeByFirstMessageField);
context = BlackBoxBoundedContext
.singleTenant()
.with(repository);
context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(repository)
);
}

@AfterEach
Expand All @@ -75,7 +76,7 @@ protected final EngineRepository repository() {
return this.repository;
}

protected final SingleTenantBlackBoxContext context() {
protected final BlackBoxBoundedContext<?> context() {
return this.context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
package io.spine.server.bus;

import com.google.common.collect.ImmutableList;
import io.spine.server.DefaultRepository;
import io.spine.server.BoundedContextBuilder;
import io.spine.server.bus.given.stock.JowDonsIndex;
import io.spine.server.bus.given.stock.ShareAggregate;
import io.spine.test.bus.Buy;
import io.spine.test.bus.Sell;
import io.spine.test.bus.ShareId;
import io.spine.testing.SlowTest;
import io.spine.testing.server.blackbox.BlackBoxBoundedContext;
import io.spine.testing.server.blackbox.SingleTenantBlackBoxContext;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand All @@ -52,10 +51,11 @@ class DispatchingQueueSynchronisationTest {
@DisplayName("Bus should not lock with its system counterpart")
void deadlock() throws InterruptedException {
ThreadPoolExecutor executor = (ThreadPoolExecutor) newFixedThreadPool(10);
SingleTenantBlackBoxContext context = BlackBoxBoundedContext
.singleTenant()
.with(DefaultRepository.of(ShareAggregate.class),
new JowDonsIndex.Repository());
BlackBoxBoundedContext<?> context = BlackBoxBoundedContext.from(
BoundedContextBuilder.assumingTests()
.add(ShareAggregate.class)
.add(new JowDonsIndex.Repository())
);
int taskCount = 10;
ImmutableList<ShareId> shares =
Stream.generate(() -> ShareId
Expand Down
Loading