Skip to content

Commit 8461f99

Browse files
author
yevhenii.nadtochii
committed
Polish the code
1 parent c3a0315 commit 8461f99

File tree

10 files changed

+42
-37
lines changed

10 files changed

+42
-37
lines changed

server/src/main/java/io/spine/server/BoundedContext.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import io.spine.server.security.Security;
5151
import io.spine.server.stand.Stand;
5252
import io.spine.server.tenant.TenantIndex;
53-
import io.spine.server.trace.TracerFactory;
5453
import io.spine.system.server.SystemClient;
5554
import io.spine.system.server.SystemContext;
5655
import io.spine.type.TypeName;
@@ -405,7 +404,6 @@ public boolean isMultitenant() {
405404
* <li>Closes {@link DefaultEventStore EventStore}.
406405
* <li>Closes {@link Stand}.
407406
* <li>Closes {@link ImportBus}.
408-
* <li>Closes {@link TracerFactory} if it is present.
409407
* <li>Closes all registered {@linkplain Repository repositories}.
410408
* </ol>
411409
*

server/src/main/java/io/spine/server/aggregate/AggregateRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ protected void setupEventRouting(EventRouting<I> routing) {
255255
* <p>The default routing uses {@linkplain io.spine.core.EventContext#getProducerId()
256256
* producer ID} of the event as the ID of the target aggregate.
257257
*
258-
* <p>This default routing requires that {@link Event Event} instances
258+
* <p>This default routing requires that {@link Event} instances
259259
* {@linkplain ImportBus#post(io.spine.core.Signal, io.grpc.stub.StreamObserver) posted}
260260
* for import must {@link io.spine.core.EventContext#getProducerId() contain} the ID of the
261261
* target aggregate. Not providing a valid aggregate ID would result in

server/src/main/java/io/spine/server/aggregate/UncommittedHistory.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* {@linkplain #onAggregateRestored(AggregateHistory) remembers} the event count
4545
* after the last snapshot.
4646
*
47-
* <p>If during the tracking the number of events since the last snapshot exceeds
47+
* <p>If during the dispatching of events the number of events since the last snapshot exceeds
4848
* the snapshot trigger, a snapshot is created and remembered as a part of uncommitted history.
4949
*
5050
* @see Aggregate#apply(List, int) remembering successfully applied events
@@ -68,15 +68,6 @@ final class UncommittedHistory {
6868
this.makeSnapshot = makeSnapshot;
6969
}
7070

71-
/**
72-
* Records the history loaded from the aggregate storage.
73-
*
74-
* <p>This is only required in order to know the number of events since the last snapshot.
75-
*/
76-
void onAggregateRestored(AggregateHistory history) {
77-
this.eventCountAfterLastSnapshot = history.getEventCount();
78-
}
79-
8071
/**
8172
* Tracks the events, successfully dispatched to the Aggregate's applier.
8273
*
@@ -102,13 +93,6 @@ void track(List<Event> events, int snapshotTrigger) {
10293
}
10394
}
10495

105-
private static AggregateHistory historyFrom(List<Event> events, Snapshot snapshot) {
106-
return AggregateHistory.newBuilder()
107-
.addAllEvent(events)
108-
.setSnapshot(snapshot)
109-
.vBuild();
110-
}
111-
11296
/**
11397
* Composes and obtains the collected uncommitted history.
11498
*
@@ -125,12 +109,6 @@ ImmutableList<AggregateHistory> get() {
125109
return builder.build();
126110
}
127111

128-
private static AggregateHistory historyFrom(List<Event> events) {
129-
return AggregateHistory.newBuilder()
130-
.addAllEvent(events)
131-
.vBuild();
132-
}
133-
134112
/**
135113
* Returns all tracked uncommitted events.
136114
*/
@@ -156,4 +134,26 @@ void commit() {
156134
historySegments.clear();
157135
currentSegment.clear();
158136
}
137+
138+
/**
139+
* Records the history loaded from the aggregate storage.
140+
*
141+
* <p>This is only required in order to know the number of events since the last snapshot.
142+
*/
143+
void onAggregateRestored(AggregateHistory history) {
144+
this.eventCountAfterLastSnapshot = history.getEventCount();
145+
}
146+
147+
private static AggregateHistory historyFrom(List<Event> events, Snapshot snapshot) {
148+
return AggregateHistory.newBuilder()
149+
.addAllEvent(events)
150+
.setSnapshot(snapshot)
151+
.vBuild();
152+
}
153+
154+
private static AggregateHistory historyFrom(List<Event> events) {
155+
return AggregateHistory.newBuilder()
156+
.addAllEvent(events)
157+
.vBuild();
158+
}
159159
}

server/src/main/java/io/spine/server/event/EventBus.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public EventStore eventStore() {
195195
* Posts the event for handling.
196196
*
197197
* <p>Performs the same action as the
198-
* {@linkplain io.spine.server.bus.Bus#post(Signal, StreamObserver)} parent method},
198+
* {@linkplain io.spine.server.bus.Bus#post(Signal, StreamObserver) parent method},
199199
* but does not require any response observer.
200200
*
201201
* @param event the event to be handled
@@ -209,10 +209,10 @@ public void post(Event event) {
209209
* Posts the events for handling.
210210
*
211211
* <p>Performs the same action as the
212-
* {@linkplain io.spine.server.bus.Bus#post(Iterable, StreamObserver)} parent method}
212+
* {@linkplain io.spine.server.bus.Bus#post(Iterable, StreamObserver) parent method}
213213
* but does not require any response observer.
214214
*
215-
* <p>This method should be used if the callee does not care about the events acknowledgement.
215+
* <p>This method should be used if the callee does not care about the events' acknowledgement.
216216
*
217217
* @param events the events to be handled
218218
* @see io.spine.server.bus.Bus#post(Signal, StreamObserver)

server/src/test/java/io/spine/server/aggregate/AbstractAggregateResilienceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
* @see AggregateResilienceTest
6969
* @see CachedAggregateResilienceTest
7070
*/
71+
@DisplayName("Abstract resilient `Aggregate` should")
7172
abstract class AbstractAggregateResilienceTest {
7273

7374
private final EmployeeId jack = generate();
@@ -93,7 +94,7 @@ void tearDown() throws Exception {
9394
class NotStoreAndPostEventsBundle {
9495

9596
@Nested
96-
@DisplayName("when a faulty command produced")
97+
@DisplayName("when a faulty command emitted")
9798
class WhenCommandEmitted {
9899

99100
@Test

server/src/test/java/io/spine/server/aggregate/AggregateResilienceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class AggregateResilienceTest extends AbstractAggregateResilienceTest {
4646
/**
4747
* @inheritDoc
4848
*
49-
* This method dispatches the passed commands directly to the context's
49+
* <p>This method dispatches the passed commands directly to the context's
5050
* {@code CommandBus} <i>one by one</i>.
5151
*/
5252
@Override

server/src/test/java/io/spine/server/aggregate/CachedAggregateResilienceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
* Tests how <i>cached</i> {@code Aggregate} handles the case when one of events,
4545
* emitted by a command, corrupts the {@code Aggregate}'s state.
4646
*
47-
* An {@code Aggregate} is cached when multiple messages are dispatched from `Inbox` at once.
47+
* <p>An {@code Aggregate} is cached when multiple messages are dispatched from `Inbox` at once.
4848
* Under the hood, they are processed as a "batch", which triggers the aggregate
4949
* to be cached for their processing.
5050
*
51-
* This class uses the custom {@linkplain PreparedInboxStorage InboxStorage} which allow
51+
* <p>This class uses the custom {@linkplain PreparedInboxStorage InboxStorage} which allow
5252
* writing messages there directly. This storage is "fed" to the delivery which then is triggered
5353
* to perform dispatching.
5454
*
@@ -82,7 +82,7 @@ void tearDown() throws Exception {
8282
/**
8383
* @inheritDoc
8484
*
85-
* This method fills the custom {@linkplain PreparedInboxStorage InboxStorage} with the passed
85+
* <p>This method fills the custom {@linkplain PreparedInboxStorage InboxStorage} with the passed
8686
* commands and then runs delivery. The commands, dispatched this way, will be processed
8787
* withing a single "batch" which would cause an {@code Aggregate} to be cached.
8888
*/

server/src/test/java/io/spine/server/aggregate/given/AbstractAggregateResilienceTestEnv.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,25 @@
3434
import static com.google.common.truth.Truth.assertThat;
3535

3636
/**
37-
* Environment for {@link io.spine.server.aggregate.AggregateResilienceTest AggregateResilienceTest}.
37+
* Environment for {@link io.spine.server.aggregate.AbstractAggregateResilienceTest}.
3838
*/
3939
public final class AbstractAggregateResilienceTestEnv {
4040

4141
private AbstractAggregateResilienceTestEnv() {
4242
}
4343

44+
/**
45+
* Wraps the "varargs-passed" event messages into a {@code List}.
46+
*/
4447
@SafeVarargs
4548
public static List<Class<? extends EventMessage>>
4649
eventTypes(Class<? extends EventMessage>... types) {
4750
return List.of(types);
4851
}
4952

53+
/**
54+
* Assert that the passed events correspond to the passed types.
55+
*/
5056
public static void assertEvents(List<Event> events, List<Class<? extends EventMessage>> types) {
5157
assertThat(events.size()).isEqualTo(types.size());
5258
for (var i = 0; i < types.size(); i++) {

server/src/test/java/io/spine/server/aggregate/given/employee/DispatchExhaust.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* <li>updated {@code Aggregate}'s state.</li>
4242
* </ul>
4343
*
44-
* <p>A healthy {@code Aggregate} usually stores and posts the same set of events withing a command
44+
* <p>A healthy {@code Aggregate} usually stores and posts the same set of events within
4545
* dispatching. That consequently causes its state to be updated.
4646
*/
4747
public final class DispatchExhaust {

server/src/test/java/io/spine/server/aggregate/given/employee/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
/**
28-
* Test environment classes for the {@link io.spine.server.aggregate.AggregateCachingTest}.
28+
* Environment classes for {@link io.spine.server.aggregate.AbstractAggregateResilienceTest}.
2929
*/
3030
@CheckReturnValue
3131
@ParametersAreNonnullByDefault

0 commit comments

Comments
 (0)