From 381b0df13dfe4e9c16aaccefc4d6994f08af5a74 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Tue, 12 Oct 2021 18:26:22 +0300 Subject: [PATCH 01/26] Make register* methods of BoundedContext.InternalAccess chainable --- .../main/java/io/spine/server/BoundedContext.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/io/spine/server/BoundedContext.java b/server/src/main/java/io/spine/server/BoundedContext.java index c064d89ef01..9ef504b3cff 100644 --- a/server/src/main/java/io/spine/server/BoundedContext.java +++ b/server/src/main/java/io/spine/server/BoundedContext.java @@ -25,6 +25,7 @@ */ package io.spine.server; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.spine.annotation.Internal; import io.spine.base.EntityState; import io.spine.core.BoundedContextName; @@ -482,7 +483,7 @@ public final InternalAccess internalAccess() { * Provides access to features of {@link BoundedContext} used internally by the framework. */ @Internal - public class InternalAccess { + public final class InternalAccess { /** Prevents instantiation from outside. */ private InternalAccess() { @@ -493,8 +494,10 @@ private InternalAccess() { * * @see BoundedContext#register(Repository) */ - public void register(Repository repository) { + @CanIgnoreReturnValue + public InternalAccess register(Repository repository) { self().register(checkNotNull(repository)); + return this; } /** @@ -502,8 +505,10 @@ public void register(Repository repository) { * * @see BoundedContext#registerCommandDispatcher(CommandDispatcher) */ - public void registerCommandDispatcher(CommandDispatcher dispatcher) { + @CanIgnoreReturnValue + public InternalAccess registerCommandDispatcher(CommandDispatcher dispatcher) { self().registerCommandDispatcher(checkNotNull(dispatcher)); + return this; } /** @@ -511,8 +516,10 @@ public void registerCommandDispatcher(CommandDispatcher dispatcher) { * * @see BoundedContext#registerEventDispatcher(EventDispatcher) */ - public void registerEventDispatcher(EventDispatcher dispatcher) { + @CanIgnoreReturnValue + public InternalAccess registerEventDispatcher(EventDispatcher dispatcher) { self().registerEventDispatcher(dispatcher); + return this; } /** From f563537c44832ff68d16868de0494edad3b7bd78 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Tue, 12 Oct 2021 18:29:00 +0300 Subject: [PATCH 02/26] Allow ignoring of BlackBoxContext.assertEvent() return value --- .../java/io/spine/testing/server/blackbox/BlackBoxContext.java | 1 + 1 file changed, 1 insertion(+) diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java index 5a3954d87ee..0b457af0333 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java @@ -640,6 +640,7 @@ public final EventSubject assertEvents() { * the type of the event to assert * @return the subject for further assertions */ + @CanIgnoreReturnValue public final ProtoFluentAssertion assertEvent(Class eventClass) { EventSubject assertEvents = assertEvents().withType(eventClass); From d0d8c4e2c7504a79fe2504364f237cf523f38422 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Tue, 12 Oct 2021 18:33:09 +0300 Subject: [PATCH 03/26] Prototype new structure of IntegrationBrokerTest --- .../integration/IntegrationBrokerTest.java | 355 +++++++++--------- .../given/IntegrationBrokerTestEnv.java | 99 ++++- 2 files changed, 263 insertions(+), 191 deletions(-) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index e46cdf949ae..c7ca9da25dd 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -27,7 +27,6 @@ import com.google.protobuf.Message; import io.spine.base.Error; -import io.spine.base.EventMessage; import io.spine.core.Ack; import io.spine.core.Event; import io.spine.core.EventValidationError; @@ -36,18 +35,18 @@ import io.spine.server.BoundedContext; import io.spine.server.ServerEnvironment; import io.spine.server.event.EventBus; -import io.spine.server.integration.given.BillingAggregate; +import io.spine.server.integration.given.IntegrationBrokerTestEnv; import io.spine.server.integration.given.MemoizingProjectDetails1Repository; import io.spine.server.integration.given.MemoizingProjectDetails2Repository; import io.spine.server.integration.given.MemoizingProjection; -import io.spine.server.integration.given.PhotosProcMan; import io.spine.server.integration.given.ProjectCommander; import io.spine.server.integration.given.ProjectCountAggregate; import io.spine.server.integration.given.ProjectDetails; import io.spine.server.integration.given.ProjectEventsSubscriber; import io.spine.server.integration.given.ProjectStartedExtSubscriber; import io.spine.server.integration.given.ProjectWizard; -import io.spine.testing.logging.MuteLogging; +import io.spine.test.integration.event.ItgProjectCreated; +import io.spine.testing.server.TestEventFactory; import io.spine.testing.server.blackbox.BlackBoxContext; import io.spine.testing.server.model.ModelTests; import org.junit.jupiter.api.AfterEach; @@ -57,16 +56,26 @@ import org.junit.jupiter.api.Test; import static com.google.common.truth.Truth.assertThat; +import static io.spine.base.Identifier.pack; import static io.spine.core.EventValidationError.UNSUPPORTED_EVENT_VALUE; import static io.spine.protobuf.AnyPacker.unpack; import static io.spine.protobuf.Messages.isDefault; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithExtEntitySubscribers; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv._projectCreated; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithExternalEntitySubscribers; import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithExternalSubscribers; import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithProjectCreatedNeeds; import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithProjectStartedNeeds; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createBillingBcWithSubscribers; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createEmptyBc; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createPhotosBcWithSubscribers; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createProjectsBc; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createProjectsBcWithSubscribers; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createUsersBc; import static io.spine.server.integration.given.IntegrationBrokerTestEnv.newContext; import static io.spine.server.integration.given.IntegrationBrokerTestEnv.projectCreated; +import static io.spine.server.integration.given.IntegrationBrokerTestEnv.projectId; import static io.spine.server.integration.given.IntegrationBrokerTestEnv.projectStarted; +import static io.spine.testing.server.TestEventFactory.newInstance; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; @@ -96,109 +105,184 @@ void tearDown() { } @Nested - @DisplayName("dispatch events from one BC") + @DisplayName("dispatch events") class DispatchEvents { - @Test - @DisplayName("to entities with external subscribers of another BC") - void toEntitiesOfBc() throws Exception { - BoundedContext sourceContext = newContext(); - contextWithExtEntitySubscribers(); + @Nested + @DisplayName("from a BC to subscribers of external events in") + class FromOneBc { + + @Test + @DisplayName("another BC") + void toAnotherBc() { + BlackBoxContext publishingUsersBc = createUsersBc(); + BlackBoxContext subscribedProjectsBc = createProjectsBc(); + + + } + + @Test + @DisplayName("multiple other BCs") + void toMultipleOtherBc() throws Exception { + BoundedContext sourceContext = newContext(); + + BoundedContext destination1 = newContext(); + destination1.internalAccess() + .register(new MemoizingProjectDetails1Repository()); + + BoundedContext destination2 = newContext(); + destination2.internalAccess() + .register(new MemoizingProjectDetails2Repository()); + + assertTrue(MemoizingProjection.events() + .isEmpty()); + Event event = projectCreated(); + sourceContext.eventBus() + .post(event); + assertEquals(2, MemoizingProjection.events() + .size()); + sourceContext.close(); + destination1.close(); + destination2.close(); + } + + @Test + @DisplayName("multiple other BCs with different needs") + void toMultipleOtherBcWithDifferentNeeds() throws Exception { + BoundedContext sourceContext = newContext(); + BoundedContext destA = contextWithProjectCreatedNeeds(); + BoundedContext destB = contextWithProjectStartedNeeds(); + + assertNull(ProjectStartedExtSubscriber.externalEvent()); + assertNull(ProjectEventsSubscriber.externalEvent()); + + EventBus sourceEventBus = sourceContext.eventBus(); + Event created = projectCreated(); + sourceEventBus.post(created); + Event started = projectStarted(); + sourceEventBus.post(started); + + assertThat(ProjectEventsSubscriber.externalEvent()) + .isEqualTo(created.enclosedMessage()); + assertThat(ProjectStartedExtSubscriber.externalEvent()) + .isEqualTo(started.enclosedMessage()); + + sourceContext.close(); + destA.close(); + destB.close(); + } - assertNull(ProjectDetails.externalEvent()); - assertNull(ProjectWizard.externalEvent()); - assertNull(ProjectCountAggregate.externalEvent()); + } - Event event = projectCreated(); - sourceContext.eventBus() - .post(event); + @Nested + @DisplayName("between two BCs regardless of their registration order when") + class RegardlessBcRegistrationOrder { - Message expectedMessage = unpack(event.getMessage()); - assertEquals(expectedMessage, ProjectDetails.externalEvent()); - assertEquals(expectedMessage, ProjectWizard.externalEvent()); - assertEquals(expectedMessage, ProjectCountAggregate.externalEvent()); + @Nested + @DisplayName("the subscribing BC is registered") + class WhenSubscribingBcRegistered { - sourceContext.close(); - } + @Test + @DisplayName("after the publishing one") + void afterThePublishingOne() { + BlackBoxContext publishingBc = createEmptyBc(); + BlackBoxContext subscribedProjectsBc = createProjectsBcWithSubscribers(); - @Test - @DisplayName("to external subscribers of another BC") - void toBcSubscribers() throws Exception { - BoundedContext sourceContext = newContext(); - contextWithExternalSubscribers(); + assertNull(ProjectDetails.externalEvent()); + assertNull(ProjectWizard.externalEvent()); + assertNull(ProjectCountAggregate.externalEvent()); - assertNull(ProjectEventsSubscriber.externalEvent()); - assertNull(ProjectCommander.externalEvent()); + ItgProjectCreated eventMessage = _projectCreated(); - Event event = projectCreated(); - Message expectedMsg = unpack(event.getMessage()); + TestEventFactory eventFactory = newInstance( + pack(projectId()), + IntegrationBrokerTestEnv.class + ); - sourceContext.eventBus() - .post(event); - assertThat(ProjectEventsSubscriber.externalEvent()).isEqualTo(expectedMsg); - assertThat(ProjectCommander.externalEvent()).isEqualTo(expectedMsg); + Event event = eventFactory.createEvent(eventMessage); + publishingBc.receivesEvent(eventMessage); +// assertEquals(eventMessage, ProjectDetails.externalEvent()); +// assertEquals(event, ProjectWizard.externalEvent()); +// assertEquals(event, ProjectCountAggregate.externalEvent()); - sourceContext.close(); - } +// subscribedProjectsBc.close(); +// publishingBc.close(); + } - @Test - @DisplayName("to entities with external subscribers of multiple BCs") - void toEntitiesOfMultipleBcs() throws Exception { - BoundedContext sourceContext = newContext(); + @Test + @DisplayName("before the publishing one") + void beforeThePublishingOne() throws Exception { + contextWithExternalEntitySubscribers(); + BoundedContext sourceContext = newContext(); - BoundedContext destination1 = newContext(); - destination1.internalAccess() - .register(new MemoizingProjectDetails1Repository()); + assertNull(ProjectDetails.externalEvent()); + assertNull(ProjectWizard.externalEvent()); + assertNull(ProjectCountAggregate.externalEvent()); - BoundedContext destination2 = newContext(); - destination2.internalAccess() - .register(new MemoizingProjectDetails2Repository()); + Event event = projectCreated(); + sourceContext.eventBus() + .post(event); - assertTrue(MemoizingProjection.events() - .isEmpty()); - Event event = projectCreated(); - sourceContext.eventBus() - .post(event); - assertEquals(2, MemoizingProjection.events().size()); - sourceContext.close(); - destination1.close(); - destination2.close(); - } + Message expectedMessage = event.enclosedMessage(); + assertEquals(expectedMessage, ProjectDetails.externalEvent()); + assertEquals(expectedMessage, ProjectWizard.externalEvent()); + assertEquals(expectedMessage, ProjectCountAggregate.externalEvent()); + + sourceContext.close(); + } + + } + + @Nested + @DisplayName("they are subscribed to each other and registered in") + class WhenMutuallySubscribedAndRegistered { + + @Test + @DisplayName("straight order") + void inStraightOrder() { + BlackBoxContext photosBc = createPhotosBcWithSubscribers(); + BlackBoxContext billingBc = createBillingBcWithSubscribers(); + + photosBc.receivesCommand(UploadPhotos.generate()); + + assertDispatched(photosBc, billingBc); + } + + @Test + @DisplayName("reverse order") + void inReverseOrder() { + BlackBoxContext billingBc = createBillingBcWithSubscribers(); + BlackBoxContext photosBc = createPhotosBcWithSubscribers(); + + photosBc.receivesCommand(UploadPhotos.generate()); + + assertDispatched(photosBc, billingBc); + } + + private void assertDispatched(BlackBoxContext photos, BlackBoxContext billing) { + photos.assertEvent(PhotosUploaded.class); + billing.assertEvent(CreditsHeld.class); + photos.assertEvent(PhotosProcessed.class); + + photos.close(); + billing.close(); + } + + } - @Test - @DisplayName("to two BCs with different needs") - void twoBcSubscribers() throws Exception { - BoundedContext sourceContext = newContext(); - BoundedContext destA = contextWithProjectCreatedNeeds(); - BoundedContext destB = contextWithProjectStartedNeeds(); - - assertNull(ProjectStartedExtSubscriber.externalEvent()); - assertNull(ProjectEventsSubscriber.externalEvent()); - - EventBus sourceEventBus = sourceContext.eventBus(); - Event created = projectCreated(); - sourceEventBus.post(created); - Event started = projectStarted(); - sourceEventBus.post(started); - assertThat(ProjectEventsSubscriber.externalEvent()) - .isEqualTo(created.enclosedMessage()); - assertThat(ProjectStartedExtSubscriber.externalEvent()) - .isEqualTo(started.enclosedMessage()); - sourceContext.close(); - destA.close(); - destB.close(); } + } @Nested - @DisplayName("avoid dispatching events from a BC") - class AvoidDispatching { + @DisplayName("avoid dispatching events from a BC to") + class AvoidDispatchingEvents { @Test - @DisplayName("to domestic entities subscribers of another BC") - void toDomesticEntitySubscribers() throws Exception { + @DisplayName("subscribers of domestic events in another BC") + void toSubscribersOfDomesticEventsInAnotherBc() throws Exception { BoundedContext sourceContext = newContext(); - BoundedContext destContext = contextWithExtEntitySubscribers(); + BoundedContext destContext = contextWithExternalEntitySubscribers(); assertNull(ProjectDetails.domesticEvent()); @@ -216,36 +300,8 @@ void toDomesticEntitySubscribers() throws Exception { } @Test - @DisplayName("to domestic standalone subscribers of another BC") - void toDomesticStandaloneSubscribers() throws Exception { - BoundedContext sourceContext = newContext(); - BoundedContext destContext = contextWithExternalSubscribers(); - - assertNull(ProjectEventsSubscriber.domesticEvent()); - assertNull(ProjectCommander.domesticEvent()); - - Event projectStarted = projectStarted(); - sourceContext.eventBus() - .post(projectStarted); - - Message expectedEventMsg = unpack(projectStarted.getMessage()); - - assertThat(ProjectEventsSubscriber.domesticEvent()).isNull(); - assertThat(ProjectCommander.domesticEvent()).isNull(); - - destContext.eventBus() - .post(projectStarted); - - assertThat(ProjectEventsSubscriber.domesticEvent()).isEqualTo(expectedEventMsg); - assertThat(ProjectCommander.domesticEvent()).isEqualTo(expectedEventMsg); - - sourceContext.close(); - destContext.close(); - } - - @Test - @DisplayName("to own standalone subscribers if they expect external events") - void toOwnExternalStandaloneSubscribers() throws Exception { + @DisplayName("its own subscribers of external events") + void toItsOwnSubscribersOfExternalEvents() throws Exception { BoundedContext destContext = contextWithExternalSubscribers(); assertThat(ProjectEventsSubscriber.externalEvent()).isNull(); @@ -260,79 +316,32 @@ void toOwnExternalStandaloneSubscribers() throws Exception { destContext.close(); } - } - @Test - @DisplayName("send messages between two contexts regardless of registration order") - void mutual() { - String suffix = IntegrationBrokerTest.class.getSimpleName(); - BlackBoxContext photos = BlackBoxContext.from( - BoundedContext.singleTenant("Photos-" + suffix) - .add(PhotosProcMan.class) - ); - BlackBoxContext billing = BlackBoxContext.from( - BoundedContext.singleTenant("Billing-" + suffix) - .add(BillingAggregate.class) - ); - photos.receivesCommand(UploadPhotos.generate()); - assertReceived(photos, PhotosUploaded.class); - assertReceived(billing, CreditsHeld.class); - assertReceived(photos, PhotosProcessed.class); - - photos.close(); - billing.close(); } - private static void assertReceived(BlackBoxContext context, - Class eventClass) { - context.assertEvents() - .withType(eventClass) - .hasSize(1); - } - - @MuteLogging @Test - @DisplayName("not dispatch to domestic subscribers if they requested external events") - void notDispatchDomestic() throws Exception { - BoundedContext context = contextWithExtEntitySubscribers(); - ProjectEventsSubscriber eventSubscriber = new ProjectEventsSubscriber(); - EventBus eventBus = context.eventBus(); - eventBus.register(eventSubscriber); - - assertNull(ProjectEventsSubscriber.externalEvent()); - assertNull(ProjectDetails.externalEvent()); - assertNull(ProjectWizard.externalEvent()); - assertNull(ProjectCountAggregate.externalEvent()); - - Event projectCreated = projectCreated(); - eventBus.post(projectCreated); - - assertNull(ProjectEventsSubscriber.externalEvent()); - assertNull(ProjectDetails.externalEvent()); - assertNull(ProjectWizard.externalEvent()); - assertNull(ProjectCountAggregate.externalEvent()); - - context.close(); - } - - @Test - @DisplayName("emit unsupported external message exception if message type is unknown") - void throwOnUnknownMessage() throws Exception { + @DisplayName("emit EventValidationError.UNSUPPORTED_EVENT_VALUE if an event type is unknown") + void throwOnUnknownEventPassed() throws Exception { BoundedContext context = newContext(); - Event event = projectCreated(); + MemoizingObserver observer = StreamObservers.memoizingObserver(); context.internalAccess() .broker() .dispatchLocally(event, observer); + Error error = observer.firstResponse() .getStatus() .getError(); - assertFalse(isDefault(error)); - assertEquals(EventValidationError.getDescriptor().getFullName(), - error.getType()); + + assertFalse(isDefault(error)); // what is checked here ? assertEquals(UNSUPPORTED_EVENT_VALUE, error.getCode()); + assertEquals( + EventValidationError.getDescriptor().getFullName(), + error.getType() + ); context.close(); } + } diff --git a/server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java b/server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java index 97b64dcf7e6..f81fa15ce28 100644 --- a/server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java +++ b/server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java @@ -34,6 +34,7 @@ import io.spine.test.integration.event.ItgProjectCreated; import io.spine.test.integration.event.ItgProjectStarted; import io.spine.testing.server.TestEventFactory; +import io.spine.testing.server.blackbox.BlackBoxContext; import static io.spine.base.Identifier.newUuid; import static io.spine.base.Identifier.pack; @@ -50,23 +51,23 @@ private IntegrationBrokerTestEnv() { @CanIgnoreReturnValue public static BoundedContext - contextWithExtEntitySubscribers() { + contextWithExternalEntitySubscribers() { BoundedContext context = newContext(); - BoundedContext.InternalAccess contextAccess = context.internalAccess(); - contextAccess.register(DefaultRepository.of(ProjectCountAggregate.class)); - contextAccess.register(DefaultRepository.of(ProjectWizard.class)); - contextAccess.register(DefaultRepository.of(ProjectDetails.class)); + context.internalAccess() + .register(DefaultRepository.of(ProjectCountAggregate.class)) + .register(DefaultRepository.of(ProjectWizard.class)) + .register(DefaultRepository.of(ProjectDetails.class)); return context; } @CanIgnoreReturnValue public static BoundedContext contextWithExternalSubscribers() { BoundedContext context = newContext(); - BoundedContext.InternalAccess contextAccess = context.internalAccess(); - contextAccess.registerEventDispatcher(new ProjectEventsSubscriber()); - contextAccess.register(DefaultRepository.of(ProjectCountAggregate.class)); - contextAccess.register(DefaultRepository.of(ProjectWizard.class)); - contextAccess.registerCommandDispatcher(new ProjectCommander()); + context.internalAccess() + .register(DefaultRepository.of(ProjectCountAggregate.class)) + .register(DefaultRepository.of(ProjectWizard.class)) + .registerEventDispatcher(new ProjectEventsSubscriber()) + .registerCommandDispatcher(new ProjectCommander()); return context; } @@ -94,13 +95,17 @@ public static BoundedContext contextWithProjectStartedNeeds() { } public static Event projectCreated() { - ProjectId projectId = - ProjectId.newBuilder() - .setId(Throwables.getStackTraceAsString( - new RuntimeException("Project ID"))) - .build(); - TestEventFactory eventFactory = newInstance(pack(projectId), - IntegrationBrokerTestEnv.class); + ProjectId projectId = ProjectId.newBuilder() + .setId(Throwables.getStackTraceAsString( + new RuntimeException("Project ID") + )) + .build(); + + TestEventFactory eventFactory = newInstance( + pack(projectId), + IntegrationBrokerTestEnv.class + ); + return eventFactory.createEvent( ItgProjectCreated.newBuilder() .setProjectId(projectId) @@ -119,9 +124,67 @@ public static Event projectStarted() { ); } - private static ProjectId projectId() { + public static ProjectId projectId() { return ProjectId.newBuilder() .setId(newUuid()) .build(); } + + // proof of concepts #1 + + public static ItgProjectCreated _projectCreated() { + return ItgProjectCreated.newBuilder() + .setProjectId(projectId()) + .build(); + } + + public static BlackBoxContext createProjectsBcWithSubscribers() { + return BlackBoxContext.from( + BoundedContext.singleTenant("Projects-" + newUuid()) + .add(DefaultRepository.of(ProjectCountAggregate.class)) + .add(DefaultRepository.of(ProjectWizard.class)) + .add(DefaultRepository.of(ProjectDetails.class)) + .addEventDispatcher(new ProjectEventsSubscriber()) + .addCommandDispatcher(new ProjectCommander()) + ); + } + + public static BlackBoxContext createEmptyBc() { + return BlackBoxContext.from( + BoundedContext.singleTenant("Empty-" + newUuid()) + ); + } + + public static BlackBoxContext createBillingBcWithSubscribers() { + return BlackBoxContext.from( + BoundedContext.singleTenant("Billing-" + newUuid()) + .add(BillingAggregate.class) + ); + } + + public static BlackBoxContext createPhotosBcWithSubscribers() { + return BlackBoxContext.from( + BoundedContext.singleTenant("Photos-" + newUuid()) + .add(PhotosProcMan.class) + ); + } + + // proof of concept #2 + + public static BlackBoxContext createUsersBc() { + return BlackBoxContext.from( + BoundedContext.singleTenant( + "UsersBc-" + IntegrationBrokerTestEnv.class.getSimpleName() + ) + ); + } + + public static BlackBoxContext createProjectsBc() { + return BlackBoxContext.from( + BoundedContext.singleTenant( + "ProjectsBc-" + IntegrationBrokerTestEnv.class.getSimpleName() + ) + ); + } + } From 5c2c09f1649b7eab04ff40d3e7f2525767b6b3df Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Tue, 12 Oct 2021 18:48:49 +0300 Subject: [PATCH 04/26] Make EmptyAggregate message kind be AGGREGATE --- server/src/test/proto/spine/test/shared_types.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/proto/spine/test/shared_types.proto b/server/src/test/proto/spine/test/shared_types.proto index 51b64c986fd..16fcaa9694c 100644 --- a/server/src/test/proto/spine/test/shared_types.proto +++ b/server/src/test/proto/spine/test/shared_types.proto @@ -54,7 +54,7 @@ message EmptyProcess { // A rudimentary aggregate without state data. message EmptyAggregate { - option (entity).kind = PROCESS_MANAGER; + option (entity).kind = AGGREGATE; string id = 1 [(required) = false]; } From d82000bd895d0002d04a6700bd0a853b4d8801b0 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 13:31:26 +0300 Subject: [PATCH 05/26] Polish BlackBoxContext and make it implement Closeable --- .../server/blackbox/BlackBoxContext.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java index 0b457af0333..350243d36b2 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java @@ -46,6 +46,7 @@ import io.spine.logging.Logging; import io.spine.server.BoundedContext; import io.spine.server.BoundedContextBuilder; +import io.spine.server.Closeable; import io.spine.server.QueryService; import io.spine.server.entity.Entity; import io.spine.server.entity.Repository; @@ -86,7 +87,7 @@ */ @SuppressWarnings({"ClassWithTooManyMethods", "OverlyCoupledClass"}) @VisibleForTesting -public abstract class BlackBoxContext implements Logging { +public abstract class BlackBoxContext implements Logging, Closeable { /** * The context under the test. @@ -281,18 +282,15 @@ private BlackBoxContext receivesCommands(Collection domainComman /** * Sends off a provided event to the Bounded Context. * - * @param messageOrEvent - * an event message or {@link io.spine.core.Event}. If an instance of {@code Event} is - * passed, it will be posted to {@link EventBus} as is. - * Otherwise, an instance of {@code Event} will be generated basing on the passed - * event message and posted to the bus. + * @param domainEvent + * a domain event to be dispatched to the Bounded Context. * @return current instance * @apiNote Returned value can be ignored when this method invoked for test setup. */ @CanIgnoreReturnValue - public final BlackBoxContext receivesEvent(EventMessage messageOrEvent) { - checkNotNull(messageOrEvent); - return receivesEvents(singletonList(messageOrEvent)); + public final BlackBoxContext receivesEvent(EventMessage domainEvent) { + checkNotNull(domainEvent); + return receivesEvents(singletonList(domainEvent)); } /** @@ -455,11 +453,12 @@ private BlackBoxSetup setup() { } /** - * Closes the bounded context so that it shutting down all of its repositories. + * Closes the bounded context so that it can shut down all of its repositories. * *

Instead of a checked {@link java.io.IOException IOException}, wraps any issues * that may occur while closing, into an {@link IllegalStateException}. */ + @Override public final void close() { try { context.close(); @@ -468,6 +467,11 @@ public final void close() { } } + @Override + public final boolean isOpen() { + return context.isOpen(); + } + /** * Obtains the request factory to operate with. */ @@ -634,7 +638,7 @@ public final EventSubject assertEvents() { } /** - * Asserts that the context generated only one event of the passed type. + * Asserts that the context emitted only one event of the passed type. * * @param eventClass * the type of the event to assert From 452d248463ab3c330777d3d7652790e609b2bfa5 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 13:33:01 +0300 Subject: [PATCH 06/26] Extract a package for IntegrationBrokerTest environment --- .../given/{ => broker}/BillingAggregate.java | 15 +++-- .../IntegrationBrokerTestEnv.java | 54 +++++++++++----- .../given/broker/PhotosAggregate.java | 61 +++++++++++++++++++ .../PhotosProcess.java} | 27 ++++---- .../given/broker/StatisticsAggregate.java | 49 +++++++++++++++ .../given/broker/WarehouseAggregate.java | 49 +++++++++++++++ .../given/broker/package-info.java | 37 +++++++++++ 7 files changed, 252 insertions(+), 40 deletions(-) rename server/src/test/java/io/spine/server/integration/given/{ => broker}/BillingAggregate.java (79%) rename server/src/test/java/io/spine/server/integration/given/{ => broker}/IntegrationBrokerTestEnv.java (77%) create mode 100644 server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java rename server/src/test/java/io/spine/server/integration/given/{PhotosProcMan.java => broker/PhotosProcess.java} (68%) create mode 100644 server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java create mode 100644 server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java create mode 100644 server/src/test/java/io/spine/server/integration/given/broker/package-info.java diff --git a/server/src/test/java/io/spine/server/integration/given/BillingAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java similarity index 79% rename from server/src/test/java/io/spine/server/integration/given/BillingAggregate.java rename to server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java index accd1f2a3ce..13612549b72 100644 --- a/server/src/test/java/io/spine/server/integration/given/BillingAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java @@ -24,27 +24,26 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.server.integration.given; +package io.spine.server.integration.given.broker; import io.spine.core.External; import io.spine.server.aggregate.Aggregate; import io.spine.server.aggregate.Apply; import io.spine.server.event.React; -import io.spine.server.integration.BillingAgg; -import io.spine.server.integration.CreditsHeld; -import io.spine.server.integration.PhotosUploaded; +import io.spine.server.integration.broker.BillingAgg; +import io.spine.server.integration.broker.CreditsHeld; +import io.spine.server.integration.broker.PhotosUploaded; -public class BillingAggregate extends Aggregate { +final class BillingAggregate extends Aggregate { @React CreditsHeld on(@External PhotosUploaded event) { - return CreditsHeld.newBuilder() - .setUuid(event.getUuid()) - .vBuild(); + return CreditsHeld.of(event.getUuid()); } @Apply private void on(CreditsHeld event) { builder().setId(event.getUuid()); } + } diff --git a/server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java similarity index 77% rename from server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java rename to server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java index f81fa15ce28..e8a831e0e9f 100644 --- a/server/src/test/java/io/spine/server/integration/given/IntegrationBrokerTestEnv.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java @@ -23,13 +23,19 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.server.integration.given; +package io.spine.server.integration.given.broker; import com.google.common.base.Throwables; import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.spine.core.Event; import io.spine.server.BoundedContext; import io.spine.server.DefaultRepository; +import io.spine.server.integration.given.ProjectCommander; +import io.spine.server.integration.given.ProjectCountAggregate; +import io.spine.server.integration.given.ProjectDetails; +import io.spine.server.integration.given.ProjectEventsSubscriber; +import io.spine.server.integration.given.ProjectStartedExtSubscriber; +import io.spine.server.integration.given.ProjectWizard; import io.spine.test.integration.ProjectId; import io.spine.test.integration.event.ItgProjectCreated; import io.spine.test.integration.event.ItgProjectStarted; @@ -130,7 +136,9 @@ public static ProjectId projectId() { .build(); } - // proof of concepts #1 + // ********************** + // proof of concept #1 + // ********************** public static ItgProjectCreated _projectCreated() { return ItgProjectCreated.newBuilder() @@ -155,35 +163,49 @@ public static BlackBoxContext createEmptyBc() { ); } - public static BlackBoxContext createBillingBcWithSubscribers() { + // ********************** + // proof of concept #2 + // ********************** + + // @External PhotosUploaded => CreditsHeld + public static BlackBoxContext subscribedBillingBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("Billing-" + newUuid()) + BoundedContext.singleTenant("SubscribedBillingBc-" + newUuid()) .add(BillingAggregate.class) ); } - public static BlackBoxContext createPhotosBcWithSubscribers() { + // @External PhotosUploaded => IncreaseTotalPhotosProcessed + public static BlackBoxContext subscribedStatisticsBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("Photos-" + newUuid()) - .add(PhotosProcMan.class) + BoundedContext.singleTenant("SubscribedStatisticsBc-" + newUuid()) + .add(StatisticsAggregate.class) ); } - // proof of concept #2 + // UploadPhotos => PhotosUploaded + // @External CreditsHeld => PhotosProcessed + public static BlackBoxContext subscribedPhotosBc() { + return BlackBoxContext.from( + BoundedContext.singleTenant("SubscribedPhotosBc-" + newUuid()) + .add(PhotosProcess.class) + ); + } - public static BlackBoxContext createUsersBc() { + // UploadPhotos => PhotosUploaded + // ArchivePhoto => PhotoArchived + public static BlackBoxContext publishingPhotosBc() { return BlackBoxContext.from( - BoundedContext.singleTenant( - "UsersBc-" + IntegrationBrokerTestEnv.class.getSimpleName() - ) + BoundedContext.singleTenant("PhotosBc-" + newUuid()) + .add(PhotosAggregate.class) ); } - public static BlackBoxContext createProjectsBc() { + // PhotoArchived => void + public static BlackBoxContext subscribedWarehouseBc() { return BlackBoxContext.from( - BoundedContext.singleTenant( - "ProjectsBc-" + IntegrationBrokerTestEnv.class.getSimpleName() - ) + BoundedContext.singleTenant("WarehouseBc-" + newUuid()) + .add(WarehouseAggregate.class) ); } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java new file mode 100644 index 00000000000..69e4b01f5c9 --- /dev/null +++ b/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java @@ -0,0 +1,61 @@ +/* + * Copyright 2021, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.server.integration.given.broker; + +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; +import io.spine.server.command.Assign; +import io.spine.server.integration.broker.ArchivePhotos; +import io.spine.server.integration.broker.PhotosMarkedArchived; +import io.spine.server.integration.broker.PhotosAgg; +import io.spine.server.integration.broker.PhotosUploaded; +import io.spine.server.integration.broker.UploadPhotos; + +final class PhotosAggregate extends Aggregate { + + @Assign + PhotosUploaded handler(UploadPhotos command) { + return PhotosUploaded.generate(); + } + + @Apply + private void on(PhotosUploaded event) { + builder().setId(event.getUuid()); + } + + + @Assign + PhotosMarkedArchived handler(ArchivePhotos command) { + return PhotosMarkedArchived.generate(); + } + + @Apply + private void on(PhotosMarkedArchived event) { + builder().setId(event.getUuid()); + } + +} diff --git a/server/src/test/java/io/spine/server/integration/given/PhotosProcMan.java b/server/src/test/java/io/spine/server/integration/given/broker/PhotosProcess.java similarity index 68% rename from server/src/test/java/io/spine/server/integration/given/PhotosProcMan.java rename to server/src/test/java/io/spine/server/integration/given/broker/PhotosProcess.java index 65bc0cb7bf2..30170f3da1c 100644 --- a/server/src/test/java/io/spine/server/integration/given/PhotosProcMan.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/PhotosProcess.java @@ -24,33 +24,28 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.server.integration.given; +package io.spine.server.integration.given.broker; import io.spine.core.External; import io.spine.server.command.Assign; import io.spine.server.event.React; -import io.spine.server.integration.CreditsHeld; -import io.spine.server.integration.PhotosPm; -import io.spine.server.integration.PhotosProcessed; -import io.spine.server.integration.PhotosUploaded; -import io.spine.server.integration.UploadPhotos; +import io.spine.server.integration.broker.CreditsHeld; +import io.spine.server.integration.broker.PhotosPm; +import io.spine.server.integration.broker.PhotosProcessed; +import io.spine.server.integration.broker.PhotosUploaded; +import io.spine.server.integration.broker.UploadPhotos; import io.spine.server.procman.ProcessManager; -public class PhotosProcMan extends ProcessManager { +final class PhotosProcess extends ProcessManager { @Assign - PhotosUploaded handle(UploadPhotos command) { - return PhotosUploaded - .newBuilder() - .setUuid(command.getUuid()) - .vBuild(); + PhotosUploaded handler(UploadPhotos command) { + return PhotosUploaded.of(command.getUuid()); } @React PhotosProcessed on(@External CreditsHeld event) { - return PhotosProcessed - .newBuilder() - .setUuid(event.getUuid()) - .vBuild(); + return PhotosProcessed.of(event.getUuid()); } + } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java new file mode 100644 index 00000000000..19bf7237ca8 --- /dev/null +++ b/server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java @@ -0,0 +1,49 @@ +/* + * Copyright 2021, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.server.integration.given.broker; + +import io.spine.core.External; +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; +import io.spine.server.event.React; +import io.spine.server.integration.broker.IncreasedTotalPhotosUploaded; +import io.spine.server.integration.broker.PhotosUploaded; +import io.spine.server.integration.broker.StatisticsAgg; + +final class StatisticsAggregate extends Aggregate { + + @React + IncreasedTotalPhotosUploaded on(@External PhotosUploaded event) { + return IncreasedTotalPhotosUploaded.of(event.getUuid()); + } + + @Apply + private void on(IncreasedTotalPhotosUploaded event) { + builder().setId(event.getUuid()); + } + +} diff --git a/server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java new file mode 100644 index 00000000000..7efa2717064 --- /dev/null +++ b/server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java @@ -0,0 +1,49 @@ +/* + * Copyright 2021, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.server.integration.given.broker; + +import io.spine.core.External; +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; +import io.spine.server.event.React; +import io.spine.server.integration.broker.PhotosArchived; +import io.spine.server.integration.broker.PhotosMarkedArchived; +import io.spine.server.integration.broker.WarehouseAgg; + +class WarehouseAggregate extends Aggregate { + + @React + PhotosArchived on(@External PhotosMarkedArchived event) { + return PhotosArchived.of(event.getUuid()); + } + + @Apply + private void on(PhotosArchived event) { + builder().setId(event.getUuid()); + } + +} diff --git a/server/src/test/java/io/spine/server/integration/given/broker/package-info.java b/server/src/test/java/io/spine/server/integration/given/broker/package-info.java new file mode 100644 index 00000000000..123c6c65d4f --- /dev/null +++ b/server/src/test/java/io/spine/server/integration/given/broker/package-info.java @@ -0,0 +1,37 @@ +/* + * Copyright 2021, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Test environment classes for tests of the {@code io.spine.server.integration.IntegrationBroker}. + */ + +@CheckReturnValue +@ParametersAreNonnullByDefault +package io.spine.server.integration.given.broker; + +import com.google.errorprone.annotations.CheckReturnValue; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file From f73ed4d135149b3b18bbf7d9725314026b4ae2db Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 13:33:31 +0300 Subject: [PATCH 07/26] Extract a package for IntegrationBrokerTest environment in proto --- .../test/integration/billing_events.proto | 40 ------------------- .../commands.proto} | 9 +++-- .../integration/{ => broker}/entities.proto | 33 ++++++++++++--- .../events.proto} | 25 +++++++++--- 4 files changed, 54 insertions(+), 53 deletions(-) delete mode 100644 server/src/test/proto/spine/test/integration/billing_events.proto rename server/src/test/proto/spine/test/integration/{photos_commands.proto => broker/commands.proto} (87%) rename server/src/test/proto/spine/test/integration/{ => broker}/entities.proto (75%) rename server/src/test/proto/spine/test/integration/{photos_events.proto => broker/events.proto} (79%) diff --git a/server/src/test/proto/spine/test/integration/billing_events.proto b/server/src/test/proto/spine/test/integration/billing_events.proto deleted file mode 100644 index d44c8ebcf22..00000000000 --- a/server/src/test/proto/spine/test/integration/billing_events.proto +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -syntax = "proto3"; - -package spine.server.integration; - -import "spine/options.proto"; - -option (type_url_prefix) = "type.spine.io"; -option java_package = "io.spine.server.integration"; -option java_outer_classname = "BillingEventsProto"; -option java_multiple_files = true; - -message CreditsHeld { - - string uuid = 1; -} diff --git a/server/src/test/proto/spine/test/integration/photos_commands.proto b/server/src/test/proto/spine/test/integration/broker/commands.proto similarity index 87% rename from server/src/test/proto/spine/test/integration/photos_commands.proto rename to server/src/test/proto/spine/test/integration/broker/commands.proto index 65db75b7b92..2137ff104dc 100644 --- a/server/src/test/proto/spine/test/integration/photos_commands.proto +++ b/server/src/test/proto/spine/test/integration/broker/commands.proto @@ -25,16 +25,19 @@ */ syntax = "proto3"; -package spine.server.integration; +package spine.server.integration.broker; import "spine/options.proto"; option (type_url_prefix) = "type.spine.io"; -option java_package = "io.spine.server.integration"; -option java_outer_classname = "PhotosCmdsProto"; +option java_package = "io.spine.server.integration.broker"; +option java_outer_classname = "CommandsProto"; option java_multiple_files = true; message UploadPhotos { + string uuid = 1; +} +message ArchivePhotos { string uuid = 1; } diff --git a/server/src/test/proto/spine/test/integration/entities.proto b/server/src/test/proto/spine/test/integration/broker/entities.proto similarity index 75% rename from server/src/test/proto/spine/test/integration/entities.proto rename to server/src/test/proto/spine/test/integration/broker/entities.proto index 3b45e56dace..c686f0df04d 100644 --- a/server/src/test/proto/spine/test/integration/entities.proto +++ b/server/src/test/proto/spine/test/integration/broker/entities.proto @@ -25,23 +25,46 @@ */ syntax = "proto3"; -package spine.server.integration; +package spine.server.integration.broker; import "spine/options.proto"; option (type_url_prefix) = "type.spine.io"; -option java_package = "io.spine.server.integration"; -option java_outer_classname = "ExperimentProto"; +option java_package = "io.spine.server.integration.broker"; +option java_outer_classname = "EntitiesProto"; option java_multiple_files = true; message BillingAgg { - option (entity) = {kind: AGGREGATE}; + + option (entity).kind = AGGREGATE; + + string id = 1; +} + +message PhotosAgg { + + option (entity).kind = AGGREGATE; string id = 1; } message PhotosPm { - option (entity) = {kind: PROCESS_MANAGER}; + + option (entity).kind = PROCESS_MANAGER; + + string id = 1; +} + +message StatisticsAgg { + + option (entity).kind = AGGREGATE; + + string id = 1; +} + +message WarehouseAgg { + + option (entity).kind = AGGREGATE; string id = 1; } diff --git a/server/src/test/proto/spine/test/integration/photos_events.proto b/server/src/test/proto/spine/test/integration/broker/events.proto similarity index 79% rename from server/src/test/proto/spine/test/integration/photos_events.proto rename to server/src/test/proto/spine/test/integration/broker/events.proto index d7f7b314c88..8ec99be7414 100644 --- a/server/src/test/proto/spine/test/integration/photos_events.proto +++ b/server/src/test/proto/spine/test/integration/broker/events.proto @@ -25,21 +25,36 @@ */ syntax = "proto3"; -package spine.server.integration; +package spine.server.integration.broker; import "spine/options.proto"; option (type_url_prefix) = "type.spine.io"; -option java_package = "io.spine.server.integration"; -option java_outer_classname = "PhotosEventsProto"; +option java_package = "io.spine.server.integration.broker"; +option java_outer_classname = "EventsProto"; option java_multiple_files = true; message PhotosUploaded { - string uuid = 1; } message PhotosProcessed { + string uuid = 1; +} + +message CreditsHeld { + + string uuid = 1; +} - string uuid = 2; +message IncreasedTotalPhotosUploaded { + string uuid = 1; +} + +message PhotosMarkedArchived { + string uuid = 1; +} + +message PhotosArchived { + string uuid = 1; } From fb0688d267404d3a2501c75eca1084c68f834e65 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 13:38:38 +0300 Subject: [PATCH 08/26] Re-write IntegrationBrokerTest.FromOneBc tests with BlackBoxContext --- .../integration/IntegrationBrokerTest.java | 140 ++++++++---------- 1 file changed, 61 insertions(+), 79 deletions(-) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index c7ca9da25dd..e13e3bdc391 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -34,16 +34,19 @@ import io.spine.grpc.StreamObservers; import io.spine.server.BoundedContext; import io.spine.server.ServerEnvironment; -import io.spine.server.event.EventBus; -import io.spine.server.integration.given.IntegrationBrokerTestEnv; -import io.spine.server.integration.given.MemoizingProjectDetails1Repository; -import io.spine.server.integration.given.MemoizingProjectDetails2Repository; -import io.spine.server.integration.given.MemoizingProjection; +import io.spine.server.integration.broker.ArchivePhotos; +import io.spine.server.integration.broker.CreditsHeld; +import io.spine.server.integration.broker.IncreasedTotalPhotosUploaded; +import io.spine.server.integration.broker.PhotosArchived; +import io.spine.server.integration.broker.PhotosMarkedArchived; +import io.spine.server.integration.broker.PhotosProcessed; +import io.spine.server.integration.broker.PhotosUploaded; +import io.spine.server.integration.broker.UploadPhotos; +import io.spine.server.integration.given.broker.IntegrationBrokerTestEnv; import io.spine.server.integration.given.ProjectCommander; import io.spine.server.integration.given.ProjectCountAggregate; import io.spine.server.integration.given.ProjectDetails; import io.spine.server.integration.given.ProjectEventsSubscriber; -import io.spine.server.integration.given.ProjectStartedExtSubscriber; import io.spine.server.integration.given.ProjectWizard; import io.spine.test.integration.event.ItgProjectCreated; import io.spine.testing.server.TestEventFactory; @@ -60,26 +63,24 @@ import static io.spine.core.EventValidationError.UNSUPPORTED_EVENT_VALUE; import static io.spine.protobuf.AnyPacker.unpack; import static io.spine.protobuf.Messages.isDefault; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv._projectCreated; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithExternalEntitySubscribers; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithExternalSubscribers; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithProjectCreatedNeeds; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.contextWithProjectStartedNeeds; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createBillingBcWithSubscribers; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createEmptyBc; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createPhotosBcWithSubscribers; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createProjectsBc; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createProjectsBcWithSubscribers; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.createUsersBc; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.newContext; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.projectCreated; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.projectId; -import static io.spine.server.integration.given.IntegrationBrokerTestEnv.projectStarted; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.*; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv._projectCreated; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.contextWithExternalEntitySubscribers; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.contextWithExternalSubscribers; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.publishingPhotosBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedBillingBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.createEmptyBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedPhotosBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.createProjectsBcWithSubscribers; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.newContext; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectCreated; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectId; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectStarted; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedStatisticsBc; import static io.spine.testing.server.TestEventFactory.newInstance; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; @DisplayName("IntegrationBroker should") class IntegrationBrokerTest { @@ -89,19 +90,13 @@ void setUp() { ModelTests.dropAllModels(); ServerEnvironment.instance() .reset(); - ProjectDetails.clear(); - ProjectWizard.clear(); - ProjectCountAggregate.clear(); - MemoizingProjection.clear(); - ProjectEventsSubscriber.clear(); - ProjectStartedExtSubscriber.clear(); } @AfterEach void tearDown() { + ModelTests.dropAllModels(); ServerEnvironment.instance() .reset(); - ModelTests.dropAllModels(); } @Nested @@ -115,61 +110,47 @@ class FromOneBc { @Test @DisplayName("another BC") void toAnotherBc() { - BlackBoxContext publishingUsersBc = createUsersBc(); - BlackBoxContext subscribedProjectsBc = createProjectsBc(); + try(BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc()) { + publishingPhotosBc.receivesCommand(UploadPhotos.generate()); + publishingPhotosBc.assertEvent(PhotosUploaded.class); + subscribedBillingBc.assertEvent(CreditsHeld.class); + } } @Test @DisplayName("multiple other BCs") - void toMultipleOtherBc() throws Exception { - BoundedContext sourceContext = newContext(); - - BoundedContext destination1 = newContext(); - destination1.internalAccess() - .register(new MemoizingProjectDetails1Repository()); - - BoundedContext destination2 = newContext(); - destination2.internalAccess() - .register(new MemoizingProjectDetails2Repository()); - - assertTrue(MemoizingProjection.events() - .isEmpty()); - Event event = projectCreated(); - sourceContext.eventBus() - .post(event); - assertEquals(2, MemoizingProjection.events() - .size()); - sourceContext.close(); - destination1.close(); - destination2.close(); + void toMultipleOtherBc() { + try(BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc(); + BlackBoxContext subscribedStatisticsBc = subscribedStatisticsBc()) { + + publishingPhotosBc.receivesCommand(UploadPhotos.generate()); + + publishingPhotosBc.assertEvent(PhotosUploaded.class); + subscribedBillingBc.assertEvent(CreditsHeld.class); + subscribedStatisticsBc.assertEvent(IncreasedTotalPhotosUploaded.class); + } } @Test @DisplayName("multiple other BCs with different needs") - void toMultipleOtherBcWithDifferentNeeds() throws Exception { - BoundedContext sourceContext = newContext(); - BoundedContext destA = contextWithProjectCreatedNeeds(); - BoundedContext destB = contextWithProjectStartedNeeds(); - - assertNull(ProjectStartedExtSubscriber.externalEvent()); - assertNull(ProjectEventsSubscriber.externalEvent()); - - EventBus sourceEventBus = sourceContext.eventBus(); - Event created = projectCreated(); - sourceEventBus.post(created); - Event started = projectStarted(); - sourceEventBus.post(started); - - assertThat(ProjectEventsSubscriber.externalEvent()) - .isEqualTo(created.enclosedMessage()); - assertThat(ProjectStartedExtSubscriber.externalEvent()) - .isEqualTo(started.enclosedMessage()); - - sourceContext.close(); - destA.close(); - destB.close(); + void toMultipleOtherBcWithDifferentNeeds() { + try(BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc(); + BlackBoxContext subscribedWarehouseBc = subscribedWarehouseBc()) { + + publishingPhotosBc.receivesCommand(UploadPhotos.generate()); + publishingPhotosBc.receivesCommand(ArchivePhotos.generate()); + + publishingPhotosBc.assertEvent(PhotosUploaded.class); + subscribedBillingBc.assertEvent(CreditsHeld.class); + + publishingPhotosBc.assertEvent(PhotosMarkedArchived.class); + subscribedWarehouseBc.assertEvent(PhotosArchived.class); + } } } @@ -240,8 +221,8 @@ class WhenMutuallySubscribedAndRegistered { @Test @DisplayName("straight order") void inStraightOrder() { - BlackBoxContext photosBc = createPhotosBcWithSubscribers(); - BlackBoxContext billingBc = createBillingBcWithSubscribers(); + BlackBoxContext photosBc = subscribedPhotosBc(); + BlackBoxContext billingBc = subscribedBillingBc(); photosBc.receivesCommand(UploadPhotos.generate()); @@ -251,8 +232,8 @@ void inStraightOrder() { @Test @DisplayName("reverse order") void inReverseOrder() { - BlackBoxContext billingBc = createBillingBcWithSubscribers(); - BlackBoxContext photosBc = createPhotosBcWithSubscribers(); + BlackBoxContext billingBc = subscribedBillingBc(); + BlackBoxContext photosBc = subscribedPhotosBc(); photosBc.receivesCommand(UploadPhotos.generate()); @@ -337,7 +318,8 @@ void throwOnUnknownEventPassed() throws Exception { assertFalse(isDefault(error)); // what is checked here ? assertEquals(UNSUPPORTED_EVENT_VALUE, error.getCode()); assertEquals( - EventValidationError.getDescriptor().getFullName(), + EventValidationError.getDescriptor() + .getFullName(), error.getType() ); From 1d5f5d3f564d9b240b96a8ebba95942dd851aa91 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 15:29:53 +0300 Subject: [PATCH 09/26] Fix a typo --- server/src/main/java/io/spine/server/ContextAware.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/io/spine/server/ContextAware.java b/server/src/main/java/io/spine/server/ContextAware.java index 19be2836a99..9f212d65917 100644 --- a/server/src/main/java/io/spine/server/ContextAware.java +++ b/server/src/main/java/io/spine/server/ContextAware.java @@ -31,7 +31,7 @@ import static com.google.common.base.Preconditions.checkState; /** - * An structural part of a Bounded Context which is aware of the other parts. + * A structural part of a Bounded Context which is aware of the other parts. */ @Internal public interface ContextAware { From f2d11fd5c5ea3d723831c9278790676a1e6b3816 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 15:30:35 +0300 Subject: [PATCH 10/26] Drop pointless tests from IntegrationBrokerTest --- .../integration/IntegrationBrokerTest.java | 192 ++++-------------- .../broker/IntegrationBrokerTestEnv.java | 27 --- 2 files changed, 41 insertions(+), 178 deletions(-) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index e13e3bdc391..0f193b86468 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -25,13 +25,7 @@ */ package io.spine.server.integration; -import com.google.protobuf.Message; -import io.spine.base.Error; -import io.spine.core.Ack; import io.spine.core.Event; -import io.spine.core.EventValidationError; -import io.spine.grpc.MemoizingObserver; -import io.spine.grpc.StreamObservers; import io.spine.server.BoundedContext; import io.spine.server.ServerEnvironment; import io.spine.server.integration.broker.ArchivePhotos; @@ -42,44 +36,30 @@ import io.spine.server.integration.broker.PhotosProcessed; import io.spine.server.integration.broker.PhotosUploaded; import io.spine.server.integration.broker.UploadPhotos; -import io.spine.server.integration.given.broker.IntegrationBrokerTestEnv; import io.spine.server.integration.given.ProjectCommander; -import io.spine.server.integration.given.ProjectCountAggregate; import io.spine.server.integration.given.ProjectDetails; import io.spine.server.integration.given.ProjectEventsSubscriber; -import io.spine.server.integration.given.ProjectWizard; -import io.spine.test.integration.event.ItgProjectCreated; -import io.spine.testing.server.TestEventFactory; import io.spine.testing.server.blackbox.BlackBoxContext; import io.spine.testing.server.model.ModelTests; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import static com.google.common.truth.Truth.assertThat; -import static io.spine.base.Identifier.pack; -import static io.spine.core.EventValidationError.UNSUPPORTED_EVENT_VALUE; import static io.spine.protobuf.AnyPacker.unpack; -import static io.spine.protobuf.Messages.isDefault; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.*; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv._projectCreated; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.contextWithExternalEntitySubscribers; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.contextWithExternalSubscribers; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.publishingPhotosBc; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedBillingBc; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.createEmptyBc; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedPhotosBc; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.createProjectsBcWithSubscribers; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.newContext; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectCreated; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectId; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectStarted; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.publishingPhotosBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedBillingBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedPhotosBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedStatisticsBc; -import static io.spine.testing.server.TestEventFactory.newInstance; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedWarehouseBc; import static org.junit.jupiter.api.Assertions.assertNull; @DisplayName("IntegrationBroker should") @@ -110,12 +90,13 @@ class FromOneBc { @Test @DisplayName("another BC") void toAnotherBc() { - try(BlackBoxContext publishingPhotosBc = publishingPhotosBc(); - BlackBoxContext subscribedBillingBc = subscribedBillingBc()) { + try (BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc() + ) { publishingPhotosBc.receivesCommand(UploadPhotos.generate()); - publishingPhotosBc.assertEvent(PhotosUploaded.class); + subscribedBillingBc.assertEvent(CreditsHeld.class); } } @@ -123,13 +104,14 @@ void toAnotherBc() { @Test @DisplayName("multiple other BCs") void toMultipleOtherBc() { - try(BlackBoxContext publishingPhotosBc = publishingPhotosBc(); - BlackBoxContext subscribedBillingBc = subscribedBillingBc(); - BlackBoxContext subscribedStatisticsBc = subscribedStatisticsBc()) { + try (BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc(); + BlackBoxContext subscribedStatisticsBc = subscribedStatisticsBc() + ) { publishingPhotosBc.receivesCommand(UploadPhotos.generate()); - publishingPhotosBc.assertEvent(PhotosUploaded.class); + subscribedBillingBc.assertEvent(CreditsHeld.class); subscribedStatisticsBc.assertEvent(IncreasedTotalPhotosUploaded.class); } @@ -138,127 +120,62 @@ void toMultipleOtherBc() { @Test @DisplayName("multiple other BCs with different needs") void toMultipleOtherBcWithDifferentNeeds() { - try(BlackBoxContext publishingPhotosBc = publishingPhotosBc(); - BlackBoxContext subscribedBillingBc = subscribedBillingBc(); - BlackBoxContext subscribedWarehouseBc = subscribedWarehouseBc()) { + try (BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc(); + BlackBoxContext subscribedWarehouseBc = subscribedWarehouseBc() + ) { publishingPhotosBc.receivesCommand(UploadPhotos.generate()); - publishingPhotosBc.receivesCommand(ArchivePhotos.generate()); - publishingPhotosBc.assertEvent(PhotosUploaded.class); subscribedBillingBc.assertEvent(CreditsHeld.class); + publishingPhotosBc.receivesCommand(ArchivePhotos.generate()); publishingPhotosBc.assertEvent(PhotosMarkedArchived.class); subscribedWarehouseBc.assertEvent(PhotosArchived.class); } } - } @Nested - @DisplayName("between two BCs regardless of their registration order when") - class RegardlessBcRegistrationOrder { - - @Nested - @DisplayName("the subscribing BC is registered") - class WhenSubscribingBcRegistered { - - @Test - @DisplayName("after the publishing one") - void afterThePublishingOne() { - BlackBoxContext publishingBc = createEmptyBc(); - BlackBoxContext subscribedProjectsBc = createProjectsBcWithSubscribers(); - - assertNull(ProjectDetails.externalEvent()); - assertNull(ProjectWizard.externalEvent()); - assertNull(ProjectCountAggregate.externalEvent()); - - ItgProjectCreated eventMessage = _projectCreated(); - - TestEventFactory eventFactory = newInstance( - pack(projectId()), - IntegrationBrokerTestEnv.class - ); - - Event event = eventFactory.createEvent(eventMessage); - publishingBc.receivesEvent(eventMessage); -// assertEquals(eventMessage, ProjectDetails.externalEvent()); -// assertEquals(event, ProjectWizard.externalEvent()); -// assertEquals(event, ProjectCountAggregate.externalEvent()); - -// subscribedProjectsBc.close(); -// publishingBc.close(); - } + @DisplayName("between two BCs when") + class BetweenTwoBcWhen { - @Test - @DisplayName("before the publishing one") - void beforeThePublishingOne() throws Exception { - contextWithExternalEntitySubscribers(); - BoundedContext sourceContext = newContext(); - - assertNull(ProjectDetails.externalEvent()); - assertNull(ProjectWizard.externalEvent()); - assertNull(ProjectCountAggregate.externalEvent()); - - Event event = projectCreated(); - sourceContext.eventBus() - .post(event); + @Test + @DisplayName("the subscribing BC is registered before the publishing one") + void subscribingBcRegisteredBeforePublishing() { + try (BlackBoxContext subscribedBillingBc = subscribedBillingBc(); + BlackBoxContext publishingPhotosBc = publishingPhotosBc() + ) { - Message expectedMessage = event.enclosedMessage(); - assertEquals(expectedMessage, ProjectDetails.externalEvent()); - assertEquals(expectedMessage, ProjectWizard.externalEvent()); - assertEquals(expectedMessage, ProjectCountAggregate.externalEvent()); + publishingPhotosBc.receivesCommand(UploadPhotos.generate()); + publishingPhotosBc.assertEvent(PhotosUploaded.class); - sourceContext.close(); + subscribedBillingBc.assertEvent(CreditsHeld.class); } - } - @Nested - @DisplayName("they are subscribed to each other and registered in") - class WhenMutuallySubscribedAndRegistered { - - @Test - @DisplayName("straight order") - void inStraightOrder() { - BlackBoxContext photosBc = subscribedPhotosBc(); - BlackBoxContext billingBc = subscribedBillingBc(); - - photosBc.receivesCommand(UploadPhotos.generate()); - - assertDispatched(photosBc, billingBc); - } - - @Test - @DisplayName("reverse order") - void inReverseOrder() { - BlackBoxContext billingBc = subscribedBillingBc(); - BlackBoxContext photosBc = subscribedPhotosBc(); + @Test + @DisplayName("they are subscribed to each other") + void subscribedToEachOther() { + try (BlackBoxContext photosBc = subscribedPhotosBc(); + BlackBoxContext billingBc = subscribedBillingBc() + ) { photosBc.receivesCommand(UploadPhotos.generate()); + photosBc.assertEvent(PhotosUploaded.class); - assertDispatched(photosBc, billingBc); + billingBc.assertEvent(CreditsHeld.class); + photosBc.assertEvent(PhotosProcessed.class); } - - private void assertDispatched(BlackBoxContext photos, BlackBoxContext billing) { - photos.assertEvent(PhotosUploaded.class); - billing.assertEvent(CreditsHeld.class); - photos.assertEvent(PhotosProcessed.class); - - photos.close(); - billing.close(); - } - } - } - } @Nested @DisplayName("avoid dispatching events from a BC to") class AvoidDispatchingEvents { + @Disabled @Test @DisplayName("subscribers of domestic events in another BC") void toSubscribersOfDomesticEventsInAnotherBc() throws Exception { @@ -280,6 +197,7 @@ void toSubscribersOfDomesticEventsInAnotherBc() throws Exception { destContext.close(); } + @Disabled @Test @DisplayName("its own subscribers of external events") void toItsOwnSubscribersOfExternalEvents() throws Exception { @@ -297,33 +215,5 @@ void toItsOwnSubscribersOfExternalEvents() throws Exception { destContext.close(); } - - } - - @Test - @DisplayName("emit EventValidationError.UNSUPPORTED_EVENT_VALUE if an event type is unknown") - void throwOnUnknownEventPassed() throws Exception { - BoundedContext context = newContext(); - Event event = projectCreated(); - - MemoizingObserver observer = StreamObservers.memoizingObserver(); - context.internalAccess() - .broker() - .dispatchLocally(event, observer); - - Error error = observer.firstResponse() - .getStatus() - .getError(); - - assertFalse(isDefault(error)); // what is checked here ? - assertEquals(UNSUPPORTED_EVENT_VALUE, error.getCode()); - assertEquals( - EventValidationError.getDescriptor() - .getFullName(), - error.getType() - ); - - context.close(); } - } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java index e8a831e0e9f..81d694a1260 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java @@ -136,33 +136,6 @@ public static ProjectId projectId() { .build(); } - // ********************** - // proof of concept #1 - // ********************** - - public static ItgProjectCreated _projectCreated() { - return ItgProjectCreated.newBuilder() - .setProjectId(projectId()) - .build(); - } - - public static BlackBoxContext createProjectsBcWithSubscribers() { - return BlackBoxContext.from( - BoundedContext.singleTenant("Projects-" + newUuid()) - .add(DefaultRepository.of(ProjectCountAggregate.class)) - .add(DefaultRepository.of(ProjectWizard.class)) - .add(DefaultRepository.of(ProjectDetails.class)) - .addEventDispatcher(new ProjectEventsSubscriber()) - .addCommandDispatcher(new ProjectCommander()) - ); - } - - public static BlackBoxContext createEmptyBc() { - return BlackBoxContext.from( - BoundedContext.singleTenant("Empty-" + newUuid()) - ); - } - // ********************** // proof of concept #2 // ********************** From 21fd41aefe96486ebc4c9dab4fba4a869184abc1 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 16:35:03 +0300 Subject: [PATCH 11/26] Implement IntegrationBrokerTest.AvoidDispatchingEvents tests --- .../integration/IntegrationBrokerTest.java | 93 +++++++------------ .../given/broker/BillingAggregate.java | 4 +- .../broker/IntegrationBrokerTestEnv.java | 49 ++++++---- .../given/broker/PhotosAggregate.java | 2 - .../broker/SubscribedBillingAggregate.java | 48 ++++++++++ ...ss.java => SubscribedPhotosAggregate.java} | 16 +++- ...ava => SubscribedStatisticsAggregate.java} | 3 +- ...java => SubscribedWarehouseAggregate.java} | 3 +- .../test/integration/broker/entities.proto | 15 --- .../test/integration/broker/events.proto | 1 - 10 files changed, 125 insertions(+), 109 deletions(-) create mode 100644 server/src/test/java/io/spine/server/integration/given/broker/SubscribedBillingAggregate.java rename server/src/test/java/io/spine/server/integration/given/broker/{PhotosProcess.java => SubscribedPhotosAggregate.java} (80%) rename server/src/test/java/io/spine/server/integration/given/broker/{StatisticsAggregate.java => SubscribedStatisticsAggregate.java} (94%) rename server/src/test/java/io/spine/server/integration/given/broker/{WarehouseAggregate.java => SubscribedWarehouseAggregate.java} (94%) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index 0f193b86468..f0b985638ac 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -25,8 +25,6 @@ */ package io.spine.server.integration; -import io.spine.core.Event; -import io.spine.server.BoundedContext; import io.spine.server.ServerEnvironment; import io.spine.server.integration.broker.ArchivePhotos; import io.spine.server.integration.broker.CreditsHeld; @@ -36,31 +34,21 @@ import io.spine.server.integration.broker.PhotosProcessed; import io.spine.server.integration.broker.PhotosUploaded; import io.spine.server.integration.broker.UploadPhotos; -import io.spine.server.integration.given.ProjectCommander; -import io.spine.server.integration.given.ProjectDetails; -import io.spine.server.integration.given.ProjectEventsSubscriber; import io.spine.testing.server.blackbox.BlackBoxContext; import io.spine.testing.server.model.ModelTests; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import static com.google.common.truth.Truth.assertThat; -import static io.spine.protobuf.AnyPacker.unpack; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.contextWithExternalEntitySubscribers; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.contextWithExternalSubscribers; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.newContext; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectCreated; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.projectStarted; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.publishingPhotosBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.billingBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.photosBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedBillingBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.photosBcAndSubscribedBillingBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedPhotosBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedStatisticsBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedWarehouseBc; -import static org.junit.jupiter.api.Assertions.assertNull; @DisplayName("IntegrationBroker should") class IntegrationBrokerTest { @@ -90,10 +78,9 @@ class FromOneBc { @Test @DisplayName("another BC") void toAnotherBc() { - try (BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + try (BlackBoxContext publishingPhotosBc = photosBc(); BlackBoxContext subscribedBillingBc = subscribedBillingBc() ) { - publishingPhotosBc.receivesCommand(UploadPhotos.generate()); publishingPhotosBc.assertEvent(PhotosUploaded.class); @@ -104,11 +91,10 @@ void toAnotherBc() { @Test @DisplayName("multiple other BCs") void toMultipleOtherBc() { - try (BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + try (BlackBoxContext publishingPhotosBc = photosBc(); BlackBoxContext subscribedBillingBc = subscribedBillingBc(); BlackBoxContext subscribedStatisticsBc = subscribedStatisticsBc() ) { - publishingPhotosBc.receivesCommand(UploadPhotos.generate()); publishingPhotosBc.assertEvent(PhotosUploaded.class); @@ -120,11 +106,10 @@ void toMultipleOtherBc() { @Test @DisplayName("multiple other BCs with different needs") void toMultipleOtherBcWithDifferentNeeds() { - try (BlackBoxContext publishingPhotosBc = publishingPhotosBc(); + try (BlackBoxContext publishingPhotosBc = photosBc(); BlackBoxContext subscribedBillingBc = subscribedBillingBc(); BlackBoxContext subscribedWarehouseBc = subscribedWarehouseBc() ) { - publishingPhotosBc.receivesCommand(UploadPhotos.generate()); publishingPhotosBc.assertEvent(PhotosUploaded.class); subscribedBillingBc.assertEvent(CreditsHeld.class); @@ -144,9 +129,8 @@ class BetweenTwoBcWhen { @DisplayName("the subscribing BC is registered before the publishing one") void subscribingBcRegisteredBeforePublishing() { try (BlackBoxContext subscribedBillingBc = subscribedBillingBc(); - BlackBoxContext publishingPhotosBc = publishingPhotosBc() + BlackBoxContext publishingPhotosBc = photosBc() ) { - publishingPhotosBc.receivesCommand(UploadPhotos.generate()); publishingPhotosBc.assertEvent(PhotosUploaded.class); @@ -157,15 +141,14 @@ void subscribingBcRegisteredBeforePublishing() { @Test @DisplayName("they are subscribed to each other") void subscribedToEachOther() { - try (BlackBoxContext photosBc = subscribedPhotosBc(); - BlackBoxContext billingBc = subscribedBillingBc() + try (BlackBoxContext subscribedPhotosBc = subscribedPhotosBc(); + BlackBoxContext subscribedBillingBc = subscribedBillingBc() ) { + subscribedPhotosBc.receivesCommand(UploadPhotos.generate()); + subscribedPhotosBc.assertEvent(PhotosUploaded.class); - photosBc.receivesCommand(UploadPhotos.generate()); - photosBc.assertEvent(PhotosUploaded.class); - - billingBc.assertEvent(CreditsHeld.class); - photosBc.assertEvent(PhotosProcessed.class); + subscribedBillingBc.assertEvent(CreditsHeld.class); + subscribedPhotosBc.assertEvent(PhotosProcessed.class); } } } @@ -175,45 +158,33 @@ void subscribedToEachOther() { @DisplayName("avoid dispatching events from a BC to") class AvoidDispatchingEvents { - @Disabled @Test - @DisplayName("subscribers of domestic events in another BC") - void toSubscribersOfDomesticEventsInAnotherBc() throws Exception { - BoundedContext sourceContext = newContext(); - BoundedContext destContext = contextWithExternalEntitySubscribers(); - - assertNull(ProjectDetails.domesticEvent()); - - Event event = projectStarted(); - sourceContext.eventBus() - .post(event); - assertThat(ProjectDetails.domesticEvent()).isNull(); - - destContext.eventBus() - .post(event); - assertThat(ProjectDetails.domesticEvent()).isEqualTo(unpack(event.getMessage())); + @DisplayName("subscribers of internal events in another BC") + void toSubscribersOfInternalEventsInAnotherBc() { + try (BlackBoxContext projectsBc = photosBc(); + BlackBoxContext billingBc = billingBc() + ) { + projectsBc.receivesCommand(UploadPhotos.generate()); + + projectsBc.assertEvent(PhotosUploaded.class); + billingBc.assertEvents() + .isEmpty(); + } - sourceContext.close(); - destContext.close(); } - @Disabled @Test @DisplayName("its own subscribers of external events") - void toItsOwnSubscribersOfExternalEvents() throws Exception { - BoundedContext destContext = contextWithExternalSubscribers(); + void toItsOwnSubscribersOfExternalEvents() { + try (BlackBoxContext photosBcAndBillingBc = photosBcAndSubscribedBillingBc()) { - assertThat(ProjectEventsSubscriber.externalEvent()).isNull(); - assertThat(ProjectCommander.externalEvent()).isNull(); + photosBcAndBillingBc.receivesCommand(UploadPhotos.generate()); + photosBcAndBillingBc.assertEvent(PhotosUploaded.class); - Event projectCreated = projectCreated(); - destContext.eventBus() - .post(projectCreated); - - assertThat(ProjectEventsSubscriber.externalEvent()).isNull(); - assertThat(ProjectCommander.externalEvent()).isNull(); - - destContext.close(); + photosBcAndBillingBc.assertEvents() + .withType(CreditsHeld.class) + .isEmpty(); + } } } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java index 13612549b72..dab7b029339 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java @@ -26,7 +26,6 @@ package io.spine.server.integration.given.broker; -import io.spine.core.External; import io.spine.server.aggregate.Aggregate; import io.spine.server.aggregate.Apply; import io.spine.server.event.React; @@ -37,7 +36,7 @@ final class BillingAggregate extends Aggregate { @React - CreditsHeld on(@External PhotosUploaded event) { + CreditsHeld on(PhotosUploaded event) { return CreditsHeld.of(event.getUuid()); } @@ -45,5 +44,4 @@ CreditsHeld on(@External PhotosUploaded event) { private void on(CreditsHeld event) { builder().setId(event.getUuid()); } - } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java index 81d694a1260..33247fa13f3 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java @@ -51,6 +51,8 @@ */ public class IntegrationBrokerTestEnv { + private static final String testClassName = IntegrationBrokerTestEnv.class.getSimpleName(); + /** Prevents instantiation of this utility class. */ private IntegrationBrokerTestEnv() { } @@ -140,46 +142,53 @@ public static ProjectId projectId() { // proof of concept #2 // ********************** - // @External PhotosUploaded => CreditsHeld - public static BlackBoxContext subscribedBillingBc() { + public static BlackBoxContext billingBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("SubscribedBillingBc-" + newUuid()) + BoundedContext.singleTenant("BillingBc-" + testClassName) .add(BillingAggregate.class) ); } - // @External PhotosUploaded => IncreaseTotalPhotosProcessed - public static BlackBoxContext subscribedStatisticsBc() { + public static BlackBoxContext subscribedBillingBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("SubscribedStatisticsBc-" + newUuid()) - .add(StatisticsAggregate.class) + BoundedContext.singleTenant("SubscribedBillingBc-" + testClassName) + .add(SubscribedBillingAggregate.class) ); } - // UploadPhotos => PhotosUploaded - // @External CreditsHeld => PhotosProcessed - public static BlackBoxContext subscribedPhotosBc() { + public static BlackBoxContext photosBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("SubscribedPhotosBc-" + newUuid()) - .add(PhotosProcess.class) + BoundedContext.singleTenant("PhotosBc-" + testClassName) + .add(PhotosAggregate.class) ); } - // UploadPhotos => PhotosUploaded - // ArchivePhoto => PhotoArchived - public static BlackBoxContext publishingPhotosBc() { + public static BlackBoxContext subscribedPhotosBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("PhotosBc-" + newUuid()) - .add(PhotosAggregate.class) + BoundedContext.singleTenant("SubscribedPhotosBc-" + testClassName) + .add(SubscribedPhotosAggregate.class) ); } - // PhotoArchived => void public static BlackBoxContext subscribedWarehouseBc() { return BlackBoxContext.from( - BoundedContext.singleTenant("WarehouseBc-" + newUuid()) - .add(WarehouseAggregate.class) + BoundedContext.singleTenant("SubscribedWarehouseBc-" + testClassName) + .add(SubscribedWarehouseAggregate.class) + ); + } + + public static BlackBoxContext subscribedStatisticsBc() { + return BlackBoxContext.from( + BoundedContext.singleTenant("SubscribedStatisticsBc-" + testClassName) + .add(SubscribedStatisticsAggregate.class) ); } + public static BlackBoxContext photosBcAndSubscribedBillingBc() { + return BlackBoxContext.from( + BoundedContext.singleTenant("photosBcAndSubscribedBillingBc-" + testClassName) + .add(PhotosAggregate.class) + .add(SubscribedBillingAggregate.class) + ); + } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java index 69e4b01f5c9..2845e84810b 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java @@ -47,7 +47,6 @@ private void on(PhotosUploaded event) { builder().setId(event.getUuid()); } - @Assign PhotosMarkedArchived handler(ArchivePhotos command) { return PhotosMarkedArchived.generate(); @@ -57,5 +56,4 @@ PhotosMarkedArchived handler(ArchivePhotos command) { private void on(PhotosMarkedArchived event) { builder().setId(event.getUuid()); } - } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/SubscribedBillingAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedBillingAggregate.java new file mode 100644 index 00000000000..484029e83ce --- /dev/null +++ b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedBillingAggregate.java @@ -0,0 +1,48 @@ +/* + * Copyright 2021, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.server.integration.given.broker; + +import io.spine.core.External; +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; +import io.spine.server.event.React; +import io.spine.server.integration.broker.BillingAgg; +import io.spine.server.integration.broker.CreditsHeld; +import io.spine.server.integration.broker.PhotosUploaded; + +final class SubscribedBillingAggregate extends Aggregate { + + @React + CreditsHeld on(@External PhotosUploaded event) { + return CreditsHeld.of(event.getUuid()); + } + + @Apply + private void on(CreditsHeld event) { + builder().setId(event.getUuid()); + } +} diff --git a/server/src/test/java/io/spine/server/integration/given/broker/PhotosProcess.java b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedPhotosAggregate.java similarity index 80% rename from server/src/test/java/io/spine/server/integration/given/broker/PhotosProcess.java rename to server/src/test/java/io/spine/server/integration/given/broker/SubscribedPhotosAggregate.java index 30170f3da1c..d9137fad1a9 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/PhotosProcess.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedPhotosAggregate.java @@ -27,25 +27,35 @@ package io.spine.server.integration.given.broker; import io.spine.core.External; +import io.spine.server.aggregate.Aggregate; +import io.spine.server.aggregate.Apply; import io.spine.server.command.Assign; import io.spine.server.event.React; import io.spine.server.integration.broker.CreditsHeld; -import io.spine.server.integration.broker.PhotosPm; +import io.spine.server.integration.broker.PhotosAgg; import io.spine.server.integration.broker.PhotosProcessed; import io.spine.server.integration.broker.PhotosUploaded; import io.spine.server.integration.broker.UploadPhotos; -import io.spine.server.procman.ProcessManager; -final class PhotosProcess extends ProcessManager { +final class SubscribedPhotosAggregate extends Aggregate { @Assign PhotosUploaded handler(UploadPhotos command) { return PhotosUploaded.of(command.getUuid()); } + @Apply + private void on(PhotosUploaded event) { + builder().setId(event.getUuid()); + } + @React PhotosProcessed on(@External CreditsHeld event) { return PhotosProcessed.of(event.getUuid()); } + @Apply + private void on(PhotosProcessed event) { + builder().setId(event.getUuid()); + } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java similarity index 94% rename from server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java rename to server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java index 19bf7237ca8..ea022991e24 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/StatisticsAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java @@ -34,7 +34,7 @@ import io.spine.server.integration.broker.PhotosUploaded; import io.spine.server.integration.broker.StatisticsAgg; -final class StatisticsAggregate extends Aggregate { +final class SubscribedStatisticsAggregate extends Aggregate { @React IncreasedTotalPhotosUploaded on(@External PhotosUploaded event) { @@ -45,5 +45,4 @@ IncreasedTotalPhotosUploaded on(@External PhotosUploaded event) { private void on(IncreasedTotalPhotosUploaded event) { builder().setId(event.getUuid()); } - } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java similarity index 94% rename from server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java rename to server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java index 7efa2717064..db59deea88f 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/WarehouseAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java @@ -34,7 +34,7 @@ import io.spine.server.integration.broker.PhotosMarkedArchived; import io.spine.server.integration.broker.WarehouseAgg; -class WarehouseAggregate extends Aggregate { +class SubscribedWarehouseAggregate extends Aggregate { @React PhotosArchived on(@External PhotosMarkedArchived event) { @@ -45,5 +45,4 @@ PhotosArchived on(@External PhotosMarkedArchived event) { private void on(PhotosArchived event) { builder().setId(event.getUuid()); } - } diff --git a/server/src/test/proto/spine/test/integration/broker/entities.proto b/server/src/test/proto/spine/test/integration/broker/entities.proto index c686f0df04d..ded94e23be7 100644 --- a/server/src/test/proto/spine/test/integration/broker/entities.proto +++ b/server/src/test/proto/spine/test/integration/broker/entities.proto @@ -35,36 +35,21 @@ option java_outer_classname = "EntitiesProto"; option java_multiple_files = true; message BillingAgg { - option (entity).kind = AGGREGATE; - string id = 1; } message PhotosAgg { - option (entity).kind = AGGREGATE; - - string id = 1; -} - -message PhotosPm { - - option (entity).kind = PROCESS_MANAGER; - string id = 1; } message StatisticsAgg { - option (entity).kind = AGGREGATE; - string id = 1; } message WarehouseAgg { - option (entity).kind = AGGREGATE; - string id = 1; } diff --git a/server/src/test/proto/spine/test/integration/broker/events.proto b/server/src/test/proto/spine/test/integration/broker/events.proto index 8ec99be7414..e9a09cd5ada 100644 --- a/server/src/test/proto/spine/test/integration/broker/events.proto +++ b/server/src/test/proto/spine/test/integration/broker/events.proto @@ -43,7 +43,6 @@ message PhotosProcessed { } message CreditsHeld { - string uuid = 1; } From 1040740961aa38e2f6a5b8f1aa169147310104b8 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 16:51:15 +0300 Subject: [PATCH 12/26] Polish the code --- .../integration/IntegrationBrokerTest.java | 20 ++-- .../broker/IntegrationBrokerTestEnv.java | 104 ------------------ 2 files changed, 10 insertions(+), 114 deletions(-) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index f0b985638ac..341cd245abe 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -38,6 +38,7 @@ import io.spine.testing.server.model.ModelTests; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -123,11 +124,11 @@ void toMultipleOtherBcWithDifferentNeeds() { @Nested @DisplayName("between two BCs when") - class BetweenTwoBcWhen { + class BetweenTwoBc { @Test @DisplayName("the subscribing BC is registered before the publishing one") - void subscribingBcRegisteredBeforePublishing() { + void whenSubscribingBcRegisteredBeforePublishing() { try (BlackBoxContext subscribedBillingBc = subscribedBillingBc(); BlackBoxContext publishingPhotosBc = photosBc() ) { @@ -140,7 +141,7 @@ void subscribingBcRegisteredBeforePublishing() { @Test @DisplayName("they are subscribed to each other") - void subscribedToEachOther() { + void whenSubscribedToEachOther() { try (BlackBoxContext subscribedPhotosBc = subscribedPhotosBc(); BlackBoxContext subscribedBillingBc = subscribedBillingBc() ) { @@ -155,12 +156,12 @@ void subscribedToEachOther() { } @Nested - @DisplayName("avoid dispatching events from a BC to") - class AvoidDispatchingEvents { + @DisplayName("avoid dispatching events from a BC to subscribers of") + class AvoidDispatchingEventsToSubscribers { @Test - @DisplayName("subscribers of internal events in another BC") - void toSubscribersOfInternalEventsInAnotherBc() { + @DisplayName("internal events in another BC") + void ofInternalEventsInAnotherBc() { try (BlackBoxContext projectsBc = photosBc(); BlackBoxContext billingBc = billingBc() ) { @@ -170,12 +171,11 @@ void toSubscribersOfInternalEventsInAnotherBc() { billingBc.assertEvents() .isEmpty(); } - } @Test - @DisplayName("its own subscribers of external events") - void toItsOwnSubscribersOfExternalEvents() { + @DisplayName("external events in the same BC") + void ofExternalEventInTheSameBc() { try (BlackBoxContext photosBcAndBillingBc = photosBcAndSubscribedBillingBc()) { photosBcAndBillingBc.receivesCommand(UploadPhotos.generate()); diff --git a/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java index 33247fa13f3..6bcadd0cddc 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/IntegrationBrokerTestEnv.java @@ -25,27 +25,9 @@ */ package io.spine.server.integration.given.broker; -import com.google.common.base.Throwables; -import com.google.errorprone.annotations.CanIgnoreReturnValue; -import io.spine.core.Event; import io.spine.server.BoundedContext; -import io.spine.server.DefaultRepository; -import io.spine.server.integration.given.ProjectCommander; -import io.spine.server.integration.given.ProjectCountAggregate; -import io.spine.server.integration.given.ProjectDetails; -import io.spine.server.integration.given.ProjectEventsSubscriber; -import io.spine.server.integration.given.ProjectStartedExtSubscriber; -import io.spine.server.integration.given.ProjectWizard; -import io.spine.test.integration.ProjectId; -import io.spine.test.integration.event.ItgProjectCreated; -import io.spine.test.integration.event.ItgProjectStarted; -import io.spine.testing.server.TestEventFactory; import io.spine.testing.server.blackbox.BlackBoxContext; -import static io.spine.base.Identifier.newUuid; -import static io.spine.base.Identifier.pack; -import static io.spine.testing.server.TestEventFactory.newInstance; - /** * Test environment for {@link io.spine.server.integration.IntegrationBrokerTest}. */ @@ -53,95 +35,9 @@ public class IntegrationBrokerTestEnv { private static final String testClassName = IntegrationBrokerTestEnv.class.getSimpleName(); - /** Prevents instantiation of this utility class. */ private IntegrationBrokerTestEnv() { } - @CanIgnoreReturnValue - public static BoundedContext - contextWithExternalEntitySubscribers() { - BoundedContext context = newContext(); - context.internalAccess() - .register(DefaultRepository.of(ProjectCountAggregate.class)) - .register(DefaultRepository.of(ProjectWizard.class)) - .register(DefaultRepository.of(ProjectDetails.class)); - return context; - } - - @CanIgnoreReturnValue - public static BoundedContext contextWithExternalSubscribers() { - BoundedContext context = newContext(); - context.internalAccess() - .register(DefaultRepository.of(ProjectCountAggregate.class)) - .register(DefaultRepository.of(ProjectWizard.class)) - .registerEventDispatcher(new ProjectEventsSubscriber()) - .registerCommandDispatcher(new ProjectCommander()); - return context; - } - - public static BoundedContext newContext() { - BoundedContext result = BoundedContext - .singleTenant(newUuid()) - .build(); - return result; - } - - public static BoundedContext contextWithProjectCreatedNeeds() { - BoundedContext result = BoundedContext - .singleTenant(newUuid()) - .addEventDispatcher(new ProjectEventsSubscriber()) - .build(); - return result; - } - - public static BoundedContext contextWithProjectStartedNeeds() { - BoundedContext result = BoundedContext - .singleTenant(newUuid()) - .addEventDispatcher(new ProjectStartedExtSubscriber()) - .build(); - return result; - } - - public static Event projectCreated() { - ProjectId projectId = ProjectId.newBuilder() - .setId(Throwables.getStackTraceAsString( - new RuntimeException("Project ID") - )) - .build(); - - TestEventFactory eventFactory = newInstance( - pack(projectId), - IntegrationBrokerTestEnv.class - ); - - return eventFactory.createEvent( - ItgProjectCreated.newBuilder() - .setProjectId(projectId) - .build() - ); - } - - public static Event projectStarted() { - ProjectId projectId = projectId(); - TestEventFactory eventFactory = - newInstance(pack(projectId), IntegrationBrokerTestEnv.class); - return eventFactory.createEvent( - ItgProjectStarted.newBuilder() - .setProjectId(projectId) - .build() - ); - } - - public static ProjectId projectId() { - return ProjectId.newBuilder() - .setId(newUuid()) - .build(); - } - - // ********************** - // proof of concept #2 - // ********************** - public static BlackBoxContext billingBc() { return BlackBoxContext.from( BoundedContext.singleTenant("BillingBc-" + testClassName) From 75e8a4bcd6166a920f0d33db313d3180fa702c13 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 16:55:54 +0300 Subject: [PATCH 13/26] Polish the code #2 --- .../io/spine/server/integration/IntegrationBrokerTest.java | 2 +- .../server/integration/given/broker/BillingAggregate.java | 2 +- .../integration/given/broker/IntegrationBrokerTestEnv.java | 1 + .../integration/given/broker/SubscribedBillingAggregate.java | 2 +- .../integration/given/broker/SubscribedPhotosAggregate.java | 4 ++-- .../given/broker/SubscribedStatisticsAggregate.java | 2 +- .../given/broker/SubscribedWarehouseAggregate.java | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index 341cd245abe..86fa3452b4d 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package io.spine.server.integration; import io.spine.server.ServerEnvironment; @@ -38,7 +39,6 @@ import io.spine.testing.server.model.ModelTests; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java index dab7b029339..3434310c9a5 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/BillingAggregate.java @@ -37,7 +37,7 @@ final class BillingAggregate extends Aggregate Date: Thu, 14 Oct 2021 17:19:05 +0300 Subject: [PATCH 14/26] Delete unused classes --- .../given/MemoizingProjectDetails1.java | 54 -------------- .../MemoizingProjectDetails1Repository.java | 36 ---------- .../given/MemoizingProjectDetails2.java | 54 -------------- .../MemoizingProjectDetails2Repository.java | 36 ---------- .../given/MemoizingProjection.java | 67 ----------------- .../integration/given/ProjectCommander.java | 70 ------------------ .../given/ProjectCountAggregate.java | 63 ---------------- .../integration/given/ProjectDetails.java | 71 ------------------- .../given/ProjectEventsSubscriber.java | 64 ----------------- .../given/ProjectStartedExtSubscriber.java | 51 ------------- .../integration/given/ProjectWizard.java | 71 ------------------- 11 files changed, 637 deletions(-) delete mode 100644 server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1Repository.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2Repository.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/MemoizingProjection.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/ProjectCommander.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/ProjectCountAggregate.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/ProjectDetails.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/ProjectEventsSubscriber.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/ProjectStartedExtSubscriber.java delete mode 100644 server/src/test/java/io/spine/server/integration/given/ProjectWizard.java diff --git a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1.java b/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1.java deleted file mode 100644 index 56c16b9f69d..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.core.External; -import io.spine.core.Subscribe; -import io.spine.server.test.shared.StringProjection; -import io.spine.test.integration.ProjectId; -import io.spine.test.integration.event.ItgProjectCreated; - -public class MemoizingProjectDetails1 - extends MemoizingProjection { - - /** - * Creates a new instance. - * - * @param id - * the ID for the new instance - * @throws IllegalArgumentException - * if the ID is not of one of the supported types - */ - protected MemoizingProjectDetails1(ProjectId id) { - super(id); - } - - @Subscribe - void on(@External ItgProjectCreated event) { - memoize(event); - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1Repository.java b/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1Repository.java deleted file mode 100644 index 9e0df95e308..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails1Repository.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.server.projection.ProjectionRepository; -import io.spine.server.test.shared.StringProjection; -import io.spine.test.integration.ProjectId; - -public class MemoizingProjectDetails1Repository - extends ProjectionRepository { - -} diff --git a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2.java b/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2.java deleted file mode 100644 index 2699a32dded..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.core.External; -import io.spine.core.Subscribe; -import io.spine.server.test.shared.Int64Projection; -import io.spine.test.integration.ProjectId; -import io.spine.test.integration.event.ItgProjectCreated; - -public class MemoizingProjectDetails2 - extends MemoizingProjection { - - /** - * Creates a new instance. - * - * @param id - * the ID for the new instance - * @throws IllegalArgumentException - * if the ID is not of one of the supported types - */ - protected MemoizingProjectDetails2(ProjectId id) { - super(id); - } - - @Subscribe - void on(@External ItgProjectCreated event) { - memoize(event); - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2Repository.java b/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2Repository.java deleted file mode 100644 index 78ab4607b29..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/MemoizingProjectDetails2Repository.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.server.projection.ProjectionRepository; -import io.spine.server.test.shared.Int64Projection; -import io.spine.test.integration.ProjectId; - -public class MemoizingProjectDetails2Repository - extends ProjectionRepository { - -} diff --git a/server/src/test/java/io/spine/server/integration/given/MemoizingProjection.java b/server/src/test/java/io/spine/server/integration/given/MemoizingProjection.java deleted file mode 100644 index f436303a715..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/MemoizingProjection.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import com.google.common.collect.ImmutableList; -import com.google.protobuf.Message; -import io.spine.base.EntityState; -import io.spine.protobuf.ValidatingBuilder; -import io.spine.server.projection.Projection; - -import java.util.Collection; - -import static com.google.common.collect.Lists.newLinkedList; - -public abstract class MemoizingProjection> - extends Projection { - - private static final Collection events = newLinkedList(); - - /** - * Creates a new instance. - * - * @param id - * the ID for the new instance - * @throws IllegalArgumentException - * if the ID is not of one of the supported types - */ - protected MemoizingProjection(I id) { - super(id); - } - - static void memoize(Message event) { - events.add(event); - } - - public static ImmutableList events() { - return ImmutableList.copyOf(events); - } - - public static void clear() { - events.clear(); - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/ProjectCommander.java b/server/src/test/java/io/spine/server/integration/given/ProjectCommander.java deleted file mode 100644 index 802210381f2..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/ProjectCommander.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.core.External; -import io.spine.server.command.AbstractCommander; -import io.spine.server.command.Command; -import io.spine.test.integration.command.ItgAddTask; -import io.spine.test.integration.command.ItgStartProject; -import io.spine.test.integration.event.ItgProjectCreated; -import io.spine.test.integration.event.ItgProjectStarted; - -import java.util.Optional; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") // OK to preserve the state. -public final class ProjectCommander extends AbstractCommander { - - private static ItgProjectCreated externalEvent = null; - private static ItgProjectStarted domesticEvent = null; - - - @Command - Optional on(@External ItgProjectCreated event) { - externalEvent = event; - return Optional.empty(); - } - - @Command - Optional on(ItgProjectStarted event) { - domesticEvent = event; - return Optional.empty(); - } - - public static ItgProjectCreated externalEvent() { - return externalEvent; - } - - public static ItgProjectStarted domesticEvent() { - return domesticEvent; - } - - public static void clear() { - externalEvent = null; - domesticEvent = null; - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/ProjectCountAggregate.java b/server/src/test/java/io/spine/server/integration/given/ProjectCountAggregate.java deleted file mode 100644 index 09de361f924..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/ProjectCountAggregate.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.base.EventMessage; -import io.spine.core.External; -import io.spine.server.aggregate.Aggregate; -import io.spine.server.event.React; -import io.spine.server.test.shared.Int32Aggregate; -import io.spine.test.integration.ProjectId; -import io.spine.test.integration.event.ItgProjectCreated; - -import java.util.Collections; -import java.util.List; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") // OK to preserve the state. -public class ProjectCountAggregate - extends Aggregate { - - private static ItgProjectCreated externalEvent = null; - - protected ProjectCountAggregate(ProjectId id) { - super(id); - } - - @React - List on(@External ItgProjectCreated event) { - externalEvent = event; - return Collections.emptyList(); - } - - public static ItgProjectCreated externalEvent() { - return externalEvent; - } - - public static void clear() { - externalEvent = null; - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/ProjectDetails.java b/server/src/test/java/io/spine/server/integration/given/ProjectDetails.java deleted file mode 100644 index bd8a9ef0096..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/ProjectDetails.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.core.External; -import io.spine.core.Subscribe; -import io.spine.server.projection.Projection; -import io.spine.server.test.shared.StringProjection; -import io.spine.test.integration.ProjectId; -import io.spine.test.integration.event.ItgProjectCreated; -import io.spine.test.integration.event.ItgProjectStarted; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") // OK to preserve the state. -public class ProjectDetails - extends Projection { - - private static ItgProjectCreated externalEvent = null; - - private static ItgProjectStarted domesticEvent = null; - - protected ProjectDetails(ProjectId id) { - super(id); - } - - @Subscribe - void on(@External ItgProjectCreated event) { - externalEvent = event; - } - - @Subscribe - void on(ItgProjectStarted event) { - domesticEvent = event; - } - - public static ItgProjectCreated externalEvent() { - return externalEvent; - } - - public static ItgProjectStarted domesticEvent() { - return domesticEvent; - } - - public static void clear() { - externalEvent = null; - domesticEvent = null; - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/ProjectEventsSubscriber.java b/server/src/test/java/io/spine/server/integration/given/ProjectEventsSubscriber.java deleted file mode 100644 index 20bf530afb9..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/ProjectEventsSubscriber.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.core.External; -import io.spine.core.Subscribe; -import io.spine.server.event.AbstractEventSubscriber; -import io.spine.test.integration.event.ItgProjectCreated; -import io.spine.test.integration.event.ItgProjectStarted; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") // OK to preserve the state. -public class ProjectEventsSubscriber extends AbstractEventSubscriber { - - private static ItgProjectCreated externalEvent = null; - - private static ItgProjectStarted domesticEvent = null; - - @Subscribe - void on(@External ItgProjectCreated msg) { - externalEvent = msg; - } - - @Subscribe - void on(ItgProjectStarted msg) { - domesticEvent = msg; - } - - public static ItgProjectCreated externalEvent() { - return externalEvent; - } - - public static ItgProjectStarted domesticEvent() { - return domesticEvent; - } - - public static void clear() { - externalEvent = null; - domesticEvent = null; - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/ProjectStartedExtSubscriber.java b/server/src/test/java/io/spine/server/integration/given/ProjectStartedExtSubscriber.java deleted file mode 100644 index 8cf45007b09..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/ProjectStartedExtSubscriber.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import io.spine.core.External; -import io.spine.core.Subscribe; -import io.spine.server.event.AbstractEventSubscriber; -import io.spine.test.integration.event.ItgProjectStarted; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") // OK to preserve the state. -public class ProjectStartedExtSubscriber extends AbstractEventSubscriber { - - private static ItgProjectStarted externalEvent = null; - - @Subscribe - void on(@External ItgProjectStarted msg) { - externalEvent = msg; - } - - public static ItgProjectStarted externalEvent() { - return externalEvent; - } - - public static void clear() { - externalEvent = null; - } -} diff --git a/server/src/test/java/io/spine/server/integration/given/ProjectWizard.java b/server/src/test/java/io/spine/server/integration/given/ProjectWizard.java deleted file mode 100644 index 3e9eeca694e..00000000000 --- a/server/src/test/java/io/spine/server/integration/given/ProjectWizard.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2021, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.server.integration.given; - -import com.google.protobuf.Message; -import io.spine.base.EventMessage; -import io.spine.core.External; -import io.spine.server.event.React; -import io.spine.server.procman.ProcessManager; -import io.spine.test.integration.Project; -import io.spine.test.integration.ProjectId; -import io.spine.test.integration.event.ItgProjectCreated; -import io.spine.test.integration.rejection.IntegrationRejections; - -import java.util.Collections; -import java.util.List; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") // OK to preserve the state. -public class ProjectWizard - extends ProcessManager { - - protected ProjectWizard(ProjectId id) { - super(id); - } - - private static Message externalEvent = null; - - @React - List on(@External ItgProjectCreated event) { - externalEvent = event; - return Collections.emptyList(); - } - - @React - List on(@External IntegrationRejections.ItgCannotStartArchivedProject rejection) { - externalEvent = rejection; - return Collections.emptyList(); - } - - public static Message externalEvent() { - return externalEvent; - } - - public static void clear() { - externalEvent = null; - } -} From aa745579394dd019fc5a6ced27f255106e4c7fb3 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 14 Oct 2021 19:17:07 +0300 Subject: [PATCH 15/26] Drop no longer used proto messages --- .../spine/server/integration/IntegrationBrokerTest.java | 2 +- .../src/test/proto/spine/test/integration/commands.proto | 9 --------- .../src/test/proto/spine/test/integration/events.proto | 9 --------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index 86fa3452b4d..f7825f627f9 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -51,7 +51,7 @@ import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedStatisticsBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedWarehouseBc; -@DisplayName("IntegrationBroker should") +@DisplayName("`IntegrationBroker` should") class IntegrationBrokerTest { @BeforeEach diff --git a/server/src/test/proto/spine/test/integration/commands.proto b/server/src/test/proto/spine/test/integration/commands.proto index 27c008654d8..ecb05e1177c 100644 --- a/server/src/test/proto/spine/test/integration/commands.proto +++ b/server/src/test/proto/spine/test/integration/commands.proto @@ -36,15 +36,6 @@ option java_multiple_files = true; import "spine/test/integration/project.proto"; -message ItgCreateProject { - ProjectId project_id = 1; -} - -message ItgAddTask { - ProjectId project_id = 1; - Task task = 2; -} - message ItgStartProject { ProjectId project_id = 1; } diff --git a/server/src/test/proto/spine/test/integration/events.proto b/server/src/test/proto/spine/test/integration/events.proto index b3eaab47d4b..a9222423165 100644 --- a/server/src/test/proto/spine/test/integration/events.proto +++ b/server/src/test/proto/spine/test/integration/events.proto @@ -39,12 +39,3 @@ import "spine/test/integration/project.proto"; message ItgProjectCreated { ProjectId project_id = 1; } - -message ItgTaskAdded { - ProjectId project_id = 1; - Task task = 2; -} - -message ItgProjectStarted { - ProjectId project_id = 1; -} From ba814b655af4e0336384651f5aff857c4c766772 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Sun, 17 Oct 2021 22:48:37 +0300 Subject: [PATCH 16/26] Proofread javadoc --- .../java/io/spine/server/integration/IntegrationBroker.java | 2 +- .../io/spine/server/integration/IntegrationBrokerTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java index 6b681383747..8b4aca1e231 100644 --- a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java +++ b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java @@ -61,7 +61,7 @@ * *

An {@code IntegrationBroker} is always based upon {@linkplain TransportFactory transport} * that delivers the messages from and to it. For several Bounded Contexts to communicate, - * their brokers have to share the transport. Typically that would be a single message queue. + * their brokers have to share the transport. Typically, that would be a single message queue. * *

The messages from external components received by an {@code IntegrationBroker} via * the transport are propagated into the Bounded Context via the domestic {@code EventBus}. diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index f7825f627f9..bd1d77f898a 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -127,8 +127,8 @@ void toMultipleOtherBcWithDifferentNeeds() { class BetweenTwoBc { @Test - @DisplayName("the subscribing BC is registered before the publishing one") - void whenSubscribingBcRegisteredBeforePublishing() { + @DisplayName("the subscribed BC is registered before the publishing one") + void whenSubscribedBcRegisteredBeforePublishing() { try (BlackBoxContext subscribedBillingBc = subscribedBillingBc(); BlackBoxContext publishingPhotosBc = photosBc() ) { From 1ccd047f710ac75e9d68dde8bc5037889fb42bbc Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Tue, 19 Oct 2021 14:14:21 +0300 Subject: [PATCH 17/26] Create MessagesSourceJoined message and make IntegrationBroker publish and react on it --- .../server/integration/ExternalMessages.java | 28 ++++-- .../server/integration/IntegrationBroker.java | 90 +++++++++++++------ .../spine/server/integration/broker.proto | 7 ++ .../integration/ExternalMessagesTest.java | 2 + 4 files changed, 95 insertions(+), 32 deletions(-) diff --git a/server/src/main/java/io/spine/server/integration/ExternalMessages.java b/server/src/main/java/io/spine/server/integration/ExternalMessages.java index f5cfd45a417..275b8f2170d 100644 --- a/server/src/main/java/io/spine/server/integration/ExternalMessages.java +++ b/server/src/main/java/io/spine/server/integration/ExternalMessages.java @@ -87,13 +87,27 @@ static ExternalMessage of(RequestForExternalMessages request, BoundedContextName checkNotNull(request); checkNotNull(origin); - String idString = Identifier.newUuid(); - ExternalMessage result = of(StringValue.newBuilder() - .setValue(idString) - .build(), - request, - origin); - return result; + return of(generateMessageId(), request, origin); + } + + /** + * Wraps the instance of {@link MessagesSourceJoined} into an {@code ExternalMessage}. + * + * @param notification the notification to wrap + * @param origin the name of a bounded context in which the notification was created + * @return the external message wrapping the given notification + */ + static ExternalMessage of(MessagesSourceJoined notification, BoundedContextName origin) { + checkNotNull(notification); + checkNotNull(origin); + + return of(generateMessageId(), notification, origin); + } + + private static StringValue generateMessageId() { + return StringValue.newBuilder() + .setValue(Identifier.newUuid()) + .build(); } private static ExternalMessage of(Message messageId, diff --git a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java index 8b4aca1e231..4656fc154a4 100644 --- a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java +++ b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java @@ -35,6 +35,7 @@ import io.spine.server.BoundedContext; import io.spine.server.ContextAware; import io.spine.server.ServerEnvironment; +import io.spine.server.event.EventBus; import io.spine.server.event.EventDispatcher; import io.spine.server.transport.ChannelId; import io.spine.server.transport.Publisher; @@ -48,6 +49,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import static com.google.common.collect.ImmutableSet.toImmutableSet; +import static io.spine.base.Identifier.newUuid; +import static io.spine.base.Identifier.pack; import static io.spine.grpc.StreamObservers.noOpObserver; import static io.spine.server.transport.MessageChannel.channelIdFor; @@ -114,42 +117,84 @@ @SuppressWarnings("OverlyCoupledClass") public final class IntegrationBroker implements ContextAware, AutoCloseable { - private static final ChannelId CONFIG_EXCHANGE_CHANNEL_ID = channelIdFor( + private static final TypeUrl EVENT_TYPE_URL = TypeUrl.of(Event.class); + private static final ChannelId MESSAGES_SOURCE_JOINED_CHANNEL_ID = channelIdFor( + TypeUrl.of(MessagesSourceJoined.class) + ); + private static final ChannelId NEEDS_EXCHANGE_CHANNEL_ID = channelIdFor( TypeUrl.of(RequestForExternalMessages.class) ); - private static final TypeUrl EVENT = TypeUrl.of(Event.class); private final SubscriberHub subscriberHub; private final PublisherHub publisherHub; + + private @MonotonicNonNull BoundedContextName contextName; private @MonotonicNonNull BusAdapter busAdapter; - private @MonotonicNonNull BoundedContextName context; - private @MonotonicNonNull ConfigurationChangeObserver configurationObserver; - private @MonotonicNonNull ConfigurationBroadcast broadcast; + + private @MonotonicNonNull ExternalNeedsObserver externalNeedsObserver; + private @MonotonicNonNull InternalNeedsBroadcast internalNeedsBroadcast; public IntegrationBroker() { TransportFactory transportFactory = ServerEnvironment .instance() .transportFactory(); + this.subscriberHub = new SubscriberHub(transportFactory); this.publisherHub = new PublisherHub(transportFactory); } + private static ChannelId toChannelId(EventClass cls) { + TypeUrl targetType = cls.typeUrl(); + return channelIdFor(targetType); + } + @Override public void registerWith(BoundedContext context) { checkNotRegistered(); + BoundedContextName name = context.name(); - this.busAdapter = new BusAdapter(this, context.eventBus()); - this.context = name; - this.configurationObserver = new ConfigurationChangeObserver(this, name, busAdapter); - this.subscriberHub.get(CONFIG_EXCHANGE_CHANNEL_ID) - .addObserver(configurationObserver); - Publisher configurationPublisher = publisherHub.get(CONFIG_EXCHANGE_CHANNEL_ID); - this.broadcast = new ConfigurationBroadcast(name, configurationPublisher); + EventBus eventBus = context.eventBus(); + + this.contextName = name; + this.busAdapter = new BusAdapter(this, eventBus); + + this.externalNeedsObserver = new ExternalNeedsObserver(name, busAdapter); + Publisher localNeedPublisher = publisherHub.get(NEEDS_EXCHANGE_CHANNEL_ID); + this.internalNeedsBroadcast = new InternalNeedsBroadcast(name, localNeedPublisher); + + this.subscriberHub.get(NEEDS_EXCHANGE_CHANNEL_ID) + .addObserver(externalNeedsObserver); + + publishMessagesSourceJoined(); + subscribeForMessagesSourceJoined(); } @Override public boolean isRegistered() { - return context != null; + return contextName != null; + } + + private void publishMessagesSourceJoined() { + MessagesSourceJoined messagesSourceJoined = MessagesSourceJoined.newBuilder().buildPartial(); + ExternalMessage externalMessage = ExternalMessages.of(messagesSourceJoined, contextName); + + publisherHub.get(MESSAGES_SOURCE_JOINED_CHANNEL_ID) + .publish(pack(newUuid()), externalMessage); + } + + private void subscribeForMessagesSourceJoined() { + StreamObserver sourceJoinedObserver = new AbstractChannelObserver( + contextName, + MessagesSourceJoined.class + ) { + @Override + protected void handle(ExternalMessage message) { + internalNeedsBroadcast.send(); + } + }; + + subscriberHub.get(MESSAGES_SOURCE_JOINED_CHANNEL_ID) + .addObserver(sourceJoinedObserver); } /** @@ -168,7 +213,7 @@ void publish(EventEnvelope event) { boolean eventFromUpstream = subscriberHub.hasChannel(channelId); if (!eventFromUpstream) { Event outerObject = event.outerObject(); - ExternalMessage msg = ExternalMessages.of(outerObject, context); + ExternalMessage msg = ExternalMessages.of(outerObject, contextName); Publisher channel = publisherHub.get(channelId); channel.publish(AnyPacker.pack(event.id()), msg); } @@ -223,14 +268,9 @@ public void unregister(EventDispatcher dispatcher) { subscriberHub.closeStaleChannels(); } - private static ChannelId toChannelId(EventClass cls) { - TypeUrl targetType = cls.typeUrl(); - return channelIdFor(targetType); - } - private ExternalMessageObserver observerFor(EventClass externalClass) { ExternalMessageObserver observer = - new ExternalMessageObserver(context, externalClass.value(), this); + new ExternalMessageObserver(contextName, externalClass.value(), this); return observer; } @@ -248,10 +288,10 @@ private void notifyTypesChanged() { .map(channelId -> ExternalMessageType .newBuilder() .setMessageTypeUrl(channelId.getTargetType()) - .setWrapperTypeUrl(EVENT.value()) + .setWrapperTypeUrl(EVENT_TYPE_URL.value()) .buildPartial()) .collect(toImmutableSet()); - broadcast.onTypesChanged(needs); + internalNeedsBroadcast.onTypesChanged(needs); } /** @@ -262,7 +302,7 @@ private void notifyTypesChanged() { * the needs of all the Contexts. */ void notifyOthers() { - broadcast.send(); + internalNeedsBroadcast.send(); } /** @@ -270,7 +310,7 @@ void notifyOthers() { */ @Override public void close() throws Exception { - configurationObserver.close(); + externalNeedsObserver.close(); notifyTypesChanged(); subscriberHub.close(); @@ -279,6 +319,6 @@ public void close() throws Exception { @Override public String toString() { - return "IntegrationBroker of <" + context.getValue() + '>'; + return "IntegrationBroker of <" + contextName.getValue() + '>'; } } diff --git a/server/src/main/proto/spine/server/integration/broker.proto b/server/src/main/proto/spine/server/integration/broker.proto index c3119e4a17d..5ae785e40bb 100644 --- a/server/src/main/proto/spine/server/integration/broker.proto +++ b/server/src/main/proto/spine/server/integration/broker.proto @@ -87,3 +87,10 @@ enum ExternalMessageValidationError { // The external message type is not supported by the server. UNSUPPORTED_EXTERNAL_MESSAGE = 1; } + +// A fact of a new potential messages publisher appearance in a multi-component environment. + +// Used to notify others in the environment so that they re-send their needs in a form of +// `RequestForExternalMessages` which will let the newly joined source contribute. +message MessagesSourceJoined { +} diff --git a/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java b/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java index a24f7ae95c7..759b5946369 100644 --- a/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java +++ b/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java @@ -55,6 +55,8 @@ void passNullToleranceCheck() { .setDefault(Command.class, Command.getDefaultInstance()) .setDefault(RequestForExternalMessages.class, RequestForExternalMessages.getDefaultInstance()) + .setDefault(MessagesSourceJoined.class, + MessagesSourceJoined.getDefaultInstance()) .testStaticMethods(ExternalMessages.class, PACKAGE); } } From 6c776581d4176e0b8b9888d8f038ce03e2c9a911 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Tue, 19 Oct 2021 14:16:52 +0300 Subject: [PATCH 18/26] Give more clear names to needs-servicing classes --- .../integration/AbstractChannelObserver.java | 2 +- ...server.java => ExternalNeedsObserver.java} | 24 +++++++++---------- ...dcast.java => InternalNeedsBroadcast.java} | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) rename server/src/main/java/io/spine/server/integration/{ConfigurationChangeObserver.java => ExternalNeedsObserver.java} (91%) rename server/src/main/java/io/spine/server/integration/{ConfigurationBroadcast.java => InternalNeedsBroadcast.java} (96%) diff --git a/server/src/main/java/io/spine/server/integration/AbstractChannelObserver.java b/server/src/main/java/io/spine/server/integration/AbstractChannelObserver.java index 85f34132812..a271ddbf0b3 100644 --- a/server/src/main/java/io/spine/server/integration/AbstractChannelObserver.java +++ b/server/src/main/java/io/spine/server/integration/AbstractChannelObserver.java @@ -41,7 +41,7 @@ /** * Base routines for the {@linkplain Subscriber#addObserver(StreamObserver)} - * subscriber observers}. + * subscriber observers. */ @SPI public abstract class AbstractChannelObserver implements StreamObserver, Logging { diff --git a/server/src/main/java/io/spine/server/integration/ConfigurationChangeObserver.java b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java similarity index 91% rename from server/src/main/java/io/spine/server/integration/ConfigurationChangeObserver.java rename to server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java index 707db56ae7d..51e9ffbcf19 100644 --- a/server/src/main/java/io/spine/server/integration/ConfigurationChangeObserver.java +++ b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java @@ -42,11 +42,10 @@ * An observer, which reacts to the configuration update messages sent by * external entities (such as {@code IntegrationBroker}s of other bounded contexts). */ -final class ConfigurationChangeObserver +final class ExternalNeedsObserver extends AbstractChannelObserver implements AutoCloseable { - private final IntegrationBroker broker; private final BoundedContextName boundedContextName; private final BusAdapter adapter; @@ -65,11 +64,11 @@ final class ConfigurationChangeObserver private final Multimap requestedTypes = HashMultimap.create(); - ConfigurationChangeObserver(IntegrationBroker broker, - BoundedContextName boundedContextName, - BusAdapter adapter) { + ExternalNeedsObserver( + BoundedContextName boundedContextName, + BusAdapter adapter + ) { super(boundedContextName, RequestForExternalMessages.class); - this.broker = broker; this.boundedContextName = boundedContextName; this.adapter = adapter; this.knownContexts.add(boundedContextName); @@ -88,15 +87,16 @@ final class ConfigurationChangeObserver */ @Override public void handle(ExternalMessage value) { - RequestForExternalMessages request = unpack(value.getOriginalMessage(), - RequestForExternalMessages.class); BoundedContextName origin = value.getBoundedContextName(); + RequestForExternalMessages request = unpack( + value.getOriginalMessage(), + RequestForExternalMessages.class + ); + addNewSubscriptions(request.getRequestedMessageTypeList(), origin); clearStaleSubscriptions(request.getRequestedMessageTypeList(), origin); - if (!knownContexts.contains(origin)) { - knownContexts.add(origin); - broker.notifyOthers(); - } + + knownContexts.add(origin); } private void addNewSubscriptions(Iterable types, diff --git a/server/src/main/java/io/spine/server/integration/ConfigurationBroadcast.java b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java similarity index 96% rename from server/src/main/java/io/spine/server/integration/ConfigurationBroadcast.java rename to server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java index c59849aaf70..66cc635e2d4 100644 --- a/server/src/main/java/io/spine/server/integration/ConfigurationBroadcast.java +++ b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java @@ -39,14 +39,14 @@ * *

Posts the updates on the requested messages. */ -final class ConfigurationBroadcast { +final class InternalNeedsBroadcast { private final BoundedContextName contextName; private final Publisher needsPublisher; private ImmutableSet requestedTypes = ImmutableSet.of(); - ConfigurationBroadcast(BoundedContextName contextName, Publisher publisher) { + InternalNeedsBroadcast(BoundedContextName contextName, Publisher publisher) { this.contextName = checkNotNull(contextName); this.needsPublisher = checkNotNull(publisher); } From 887faab511f0510efbebd23d0959adad3be1ab17 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Wed, 20 Oct 2021 17:42:38 +0300 Subject: [PATCH 19/26] Align javadoc with the changes were made --- .../spine/server/integration/BusAdapter.java | 2 +- .../server/integration/ExternalMessages.java | 4 +- .../integration/ExternalNeedsObserver.java | 31 ++-- .../server/integration/IntegrationBroker.java | 132 +++++++++--------- .../integration/InternalNeedsBroadcast.java | 25 ++-- .../spine/server/integration/broker.proto | 4 +- .../integration/ExternalMessagesTest.java | 4 +- 7 files changed, 102 insertions(+), 100 deletions(-) diff --git a/server/src/main/java/io/spine/server/integration/BusAdapter.java b/server/src/main/java/io/spine/server/integration/BusAdapter.java index 414d823b834..4ba45966add 100644 --- a/server/src/main/java/io/spine/server/integration/BusAdapter.java +++ b/server/src/main/java/io/spine/server/integration/BusAdapter.java @@ -73,7 +73,7 @@ void unregister(Class messageClass) { * the given class. * *

The created dispatcher is serving as a listener, notifying the {@code IntegrationBroker} - * of the messages, that are requested by the collaborators outside of this bounded context. + * of the messages, that are requested by the collaborators outside this bounded context. * * @param messageClass * the class of message to be dispatched by the created dispatcher diff --git a/server/src/main/java/io/spine/server/integration/ExternalMessages.java b/server/src/main/java/io/spine/server/integration/ExternalMessages.java index 275b8f2170d..cf7a2f2c157 100644 --- a/server/src/main/java/io/spine/server/integration/ExternalMessages.java +++ b/server/src/main/java/io/spine/server/integration/ExternalMessages.java @@ -91,13 +91,13 @@ static ExternalMessage of(RequestForExternalMessages request, BoundedContextName } /** - * Wraps the instance of {@link MessagesSourceJoined} into an {@code ExternalMessage}. + * Wraps the instance of {@link ExternalMessagesSourceAvailable} into an {@code ExternalMessage}. * * @param notification the notification to wrap * @param origin the name of a bounded context in which the notification was created * @return the external message wrapping the given notification */ - static ExternalMessage of(MessagesSourceJoined notification, BoundedContextName origin) { + static ExternalMessage of(ExternalMessagesSourceAvailable notification, BoundedContextName origin) { checkNotNull(notification); checkNotNull(origin); diff --git a/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java index 51e9ffbcf19..fa5f0c1ec85 100644 --- a/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java +++ b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package io.spine.server.integration; import com.google.common.collect.HashMultimap; @@ -39,21 +40,17 @@ import static java.util.Collections.synchronizedSet; /** - * An observer, which reacts to the configuration update messages sent by - * external entities (such as {@code IntegrationBroker}s of other bounded contexts). + * Reacts on {@code RequestForExternalMessages} sent by other parties (usually Bounded Contexts) + * in a multi-component environment. + * + * @see #handle(ExternalMessage) */ final class ExternalNeedsObserver extends AbstractChannelObserver implements AutoCloseable { private final BoundedContextName boundedContextName; - private final BusAdapter adapter; - - /** - * Names of Bounded Contexts already known to this observer. - * - *

If a context is unknown, the observer publishes a {@code RequestForExternalMessages}. - */ + private final BusAdapter busAdapter; private final Set knownContexts = synchronizedSet(new HashSet<>()); /** @@ -66,24 +63,20 @@ final class ExternalNeedsObserver ExternalNeedsObserver( BoundedContextName boundedContextName, - BusAdapter adapter + BusAdapter busAdapter ) { super(boundedContextName, RequestForExternalMessages.class); this.boundedContextName = boundedContextName; - this.adapter = adapter; + this.busAdapter = busAdapter; this.knownContexts.add(boundedContextName); } /** * Handles the {@code RequestForExternalMessages} by creating local publishers for the requested - * types. - * - *

If the request originates from a previously unknown Bounded Context, - * {@linkplain IntegrationBroker#notifyOthers() publishes} the types requested by the current - * Context, since they may be unknown to the new Context. + * types via {@code BusAdapter} and dismissing types that are no longer needed. * * @param value - * {@link RequestForExternalMessages} form another Bounded Context + * {@link RequestForExternalMessages} */ @Override public void handle(ExternalMessage value) { @@ -116,7 +109,7 @@ private void addNewSubscriptions(Iterable types, private void registerInAdapter(ExternalMessageType newType) { Class messageClass = newType.asMessageClass(); - adapter.register(messageClass); + busAdapter.register(messageClass); } private void clearStaleSubscriptions(Collection types, @@ -139,7 +132,7 @@ private void clearStaleSubscriptions(Collection types, private void unregisterInAdapter(ExternalMessageType itemForRemoval) { Class messageClass = itemForRemoval.asMessageClass(); - adapter.unregister(messageClass); + busAdapter.unregister(messageClass); } private Set findStale(Collection types, diff --git a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java index 4656fc154a4..87f662efe36 100644 --- a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java +++ b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package io.spine.server.integration; import com.google.common.collect.ImmutableSet; @@ -35,7 +36,6 @@ import io.spine.server.BoundedContext; import io.spine.server.ContextAware; import io.spine.server.ServerEnvironment; -import io.spine.server.event.EventBus; import io.spine.server.event.EventDispatcher; import io.spine.server.transport.ChannelId; import io.spine.server.transport.Publisher; @@ -55,34 +55,46 @@ import static io.spine.server.transport.MessageChannel.channelIdFor; /** - * Dispatches {@linkplain ExternalMessage external messages} from and to the Bounded Context - * in which this bus operates. + * Dispatches {@linkplain ExternalMessage external messages} from and to a Bounded Context with + * which this broker is associated. * - *

An {@code IntegrationBroker} is available as a part of single {@code BoundedContext}. - * In a multi-component environment messages may travel across components from one Bounded Context - * to another. + *

In a multi-component environment messages may travel across components from one + * Bounded Context to another. Accordingly, an {@code IntegrationBroker} is available as a part + * of a Bounded Context. * *

An {@code IntegrationBroker} is always based upon {@linkplain TransportFactory transport} - * that delivers the messages from and to it. For several Bounded Contexts to communicate, - * their brokers have to share the transport. Typically, that would be a single message queue. + * that delivers messages from and to it. For several Bounded Contexts to communicate, their brokers + * have to share the transport. Typically, that would be a single message queue. + * + *

{@code IntegrationBroker}s communicate with each other in order to keep the whole list of + * requested messages (needs) and their potential sources (Bounded Contexts) up-to-date. + * They use two special messages for this: + *

    + *
  • {@linkplain ExternalMessagesSourceAvailable} is sent when a broker is registered + * withing a Bounded Context; + *
  • {@linkplain RequestForExternalMessages} is sent + *
      + *
    • in response to {@linkplain ExternalMessagesSourceAvailable} sent by other brokers; + *
    • when internal needs for external messages are changed. + *
    + *
* - *

The messages from external components received by an {@code IntegrationBroker} via + *

Receiving. The messages from external components received by an {@code IntegrationBroker} via * the transport are propagated into the Bounded Context via the domestic {@code EventBus}. * - *

{@code IntegrationBroker} is also responsible for publishing the messages born within - * the current Bounded Context to external collaborators. To do that properly, the broker listens - * to a special document message called {@linkplain RequestForExternalMessages} that describes - * the needs of other parties. + *

Publishing. The messages requested by other parties are published from the domestic + * {@code EventBus} with the help of {@linkplain DomesticEventPublisher} special dispatcher. * *

Sample Usage. * - *

Bounded Context "Projects" has an external event handler method in a projection as follows: + *

Bounded Context "Projects" has a projection with an event handler that is subscribed to an + * external event as follows: *

  * {@code
- * public class ProjectListView extends Projection ...  {
+ * public class ProjectListView extends Projection<...>  {
  *
- *     {@literal @}Subscribe(external = true)
- *      public void on(UserDeleted event) {
+ *      {@literal @}Subscribe
+ *      public void on(@External UserDeleted event) {
  *          // Remove the projects that belong to this user.
  *          // ...
  *      }
@@ -90,18 +102,19 @@
  *  }
  * 
* - *

Upon a registration of the corresponding repository, the broker associated with the "Projects" - * context sends out a {@code RequestForExternalMessages} saying that the of {@code UserDeleted} - * event is needed. + *

Upon a registration of the corresponding repository for this projection in the context, + * the broker associated with that context is informed that one more external event is needed. + * It sends out an updated {@code RequestForExternalMessages} saying that {@code UserDeleted} + * events are needed too. * *

Let's say the second Context is "Users". Its broker will receive - * the {@code RequestForExternalMessages} request sent by "Projects". To handle it properly, it will - * create a bridge between "Users"'s Event Bus (which may eventually be transmitting - * a {@code UserDeleted} event) and the external message - * {@linkplain ServerEnvironment#transportFactory() transport}. + * the {@code RequestForExternalMessages} sent by "Projects". To handle it, it will create a bridge + * between "Users"'s Event Bus (which may eventually be transmitting a {@code UserDeleted} event) + * and the {@linkplain ServerEnvironment#transportFactory() transport}. * *

Once {@code UserDeleted} is emitted locally in "Users" context, it will be received - * by this bridge (as well as other local dispatchers) and published to the external transport. + * by this bridge (as well as other local dispatchers) and published to the external transport by + * its {@code IntegrationBroker}. * *

The integration broker on the "Projects" side will receive the {@code UserDeleted} * external message. The event will be dispatched to the external event handler of the projection. @@ -118,8 +131,8 @@ public final class IntegrationBroker implements ContextAware, AutoCloseable { private static final TypeUrl EVENT_TYPE_URL = TypeUrl.of(Event.class); - private static final ChannelId MESSAGES_SOURCE_JOINED_CHANNEL_ID = channelIdFor( - TypeUrl.of(MessagesSourceJoined.class) + private static final ChannelId MESSAGE_SOURCES_CHANNEL_ID = channelIdFor( + TypeUrl.of(ExternalMessagesSourceAvailable.class) ); private static final ChannelId NEEDS_EXCHANGE_CHANNEL_ID = channelIdFor( TypeUrl.of(RequestForExternalMessages.class) @@ -152,40 +165,39 @@ private static ChannelId toChannelId(EventClass cls) { public void registerWith(BoundedContext context) { checkNotRegistered(); - BoundedContextName name = context.name(); - EventBus eventBus = context.eventBus(); + this.contextName = context.name(); + this.busAdapter = new BusAdapter(this, context.eventBus()); - this.contextName = name; - this.busAdapter = new BusAdapter(this, eventBus); + setUpNeedsExchange(); + notifyOthersAboutRegistration(); + subscribeForFurtherRegistrations(); + } - this.externalNeedsObserver = new ExternalNeedsObserver(name, busAdapter); - Publisher localNeedPublisher = publisherHub.get(NEEDS_EXCHANGE_CHANNEL_ID); - this.internalNeedsBroadcast = new InternalNeedsBroadcast(name, localNeedPublisher); + private void setUpNeedsExchange() { + Publisher localNeedsPublisher = publisherHub.get(NEEDS_EXCHANGE_CHANNEL_ID); + + this.internalNeedsBroadcast = new InternalNeedsBroadcast(contextName, localNeedsPublisher); + this.externalNeedsObserver = new ExternalNeedsObserver(contextName, busAdapter); this.subscriberHub.get(NEEDS_EXCHANGE_CHANNEL_ID) .addObserver(externalNeedsObserver); - - publishMessagesSourceJoined(); - subscribeForMessagesSourceJoined(); } - @Override - public boolean isRegistered() { - return contextName != null; - } + private void notifyOthersAboutRegistration() { + ExternalMessagesSourceAvailable messagesSourceAvailable = ExternalMessagesSourceAvailable + .newBuilder() + .buildPartial(); - private void publishMessagesSourceJoined() { - MessagesSourceJoined messagesSourceJoined = MessagesSourceJoined.newBuilder().buildPartial(); - ExternalMessage externalMessage = ExternalMessages.of(messagesSourceJoined, contextName); + ExternalMessage externalMessage = ExternalMessages.of(messagesSourceAvailable, contextName); - publisherHub.get(MESSAGES_SOURCE_JOINED_CHANNEL_ID) + publisherHub.get(MESSAGE_SOURCES_CHANNEL_ID) .publish(pack(newUuid()), externalMessage); } - - private void subscribeForMessagesSourceJoined() { - StreamObserver sourceJoinedObserver = new AbstractChannelObserver( + + private void subscribeForFurtherRegistrations() { + StreamObserver newSourcesObserver = new AbstractChannelObserver( contextName, - MessagesSourceJoined.class + ExternalMessagesSourceAvailable.class ) { @Override protected void handle(ExternalMessage message) { @@ -193,8 +205,13 @@ protected void handle(ExternalMessage message) { } }; - subscriberHub.get(MESSAGES_SOURCE_JOINED_CHANNEL_ID) - .addObserver(sourceJoinedObserver); + subscriberHub.get(MESSAGE_SOURCES_CHANNEL_ID) + .addObserver(newSourcesObserver); + } + + @Override + public boolean isRegistered() { + return contextName != null; } /** @@ -291,18 +308,7 @@ private void notifyTypesChanged() { .setWrapperTypeUrl(EVENT_TYPE_URL.value()) .buildPartial()) .collect(toImmutableSet()); - internalNeedsBroadcast.onTypesChanged(needs); - } - - /** - * Notifies other Bounded Contexts of the application about the types requested by this Context. - * - *

The {@code IntegrationBroker} sends a {@link RequestForExternalMessages}. The request - * triggers other Contexts to send their requests. As the result, all the Contexts know about - * the needs of all the Contexts. - */ - void notifyOthers() { - internalNeedsBroadcast.send(); + internalNeedsBroadcast.onNeedsChange(needs); } /** diff --git a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java index 66cc635e2d4..8ca9294a206 100644 --- a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java +++ b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java @@ -44,7 +44,7 @@ final class InternalNeedsBroadcast { private final BoundedContextName contextName; private final Publisher needsPublisher; - private ImmutableSet requestedTypes = ImmutableSet.of(); + private ImmutableSet currentNeeds = ImmutableSet.of(); InternalNeedsBroadcast(BoundedContextName contextName, Publisher publisher) { this.contextName = checkNotNull(contextName); @@ -52,28 +52,31 @@ final class InternalNeedsBroadcast { } /** - * Notifies other Bounded contexts about a change in the requested messages. + * Notifies other Bounded Contexts about a change in the needed messages. * *

If the given {@code types} are the same as previous ones, the request is not sent. * - * @param types - * the types + * @param needs + * the requested external types */ - synchronized void onTypesChanged(ImmutableSet types) { - checkNotNull(types); - if (!requestedTypes.equals(types)) { - requestedTypes = types; - send(); + synchronized void onNeedsChange(ImmutableSet needs) { + checkNotNull(needs); + + if (currentNeeds.equals(needs)) { + return; } + + currentNeeds = needs; + send(); } /** - * Notifies other Bounded contexts about current requested messages. + * Notifies other Bounded contexts about current needs. */ synchronized void send() { RequestForExternalMessages request = RequestForExternalMessages .newBuilder() - .addAllRequestedMessageType(requestedTypes) + .addAllRequestedMessageType(currentNeeds) .buildPartial(); ExternalMessage externalMessage = ExternalMessages.of(request, contextName); needsPublisher.publish(pack(newUuid()), externalMessage); diff --git a/server/src/main/proto/spine/server/integration/broker.proto b/server/src/main/proto/spine/server/integration/broker.proto index 5ae785e40bb..f239c56af97 100644 --- a/server/src/main/proto/spine/server/integration/broker.proto +++ b/server/src/main/proto/spine/server/integration/broker.proto @@ -89,8 +89,8 @@ enum ExternalMessageValidationError { } // A fact of a new potential messages publisher appearance in a multi-component environment. - +// // Used to notify others in the environment so that they re-send their needs in a form of // `RequestForExternalMessages` which will let the newly joined source contribute. -message MessagesSourceJoined { +message ExternalMessagesSourceAvailable { } diff --git a/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java b/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java index 759b5946369..275af844f87 100644 --- a/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java +++ b/server/src/test/java/io/spine/server/integration/ExternalMessagesTest.java @@ -55,8 +55,8 @@ void passNullToleranceCheck() { .setDefault(Command.class, Command.getDefaultInstance()) .setDefault(RequestForExternalMessages.class, RequestForExternalMessages.getDefaultInstance()) - .setDefault(MessagesSourceJoined.class, - MessagesSourceJoined.getDefaultInstance()) + .setDefault(ExternalMessagesSourceAvailable.class, + ExternalMessagesSourceAvailable.getDefaultInstance()) .testStaticMethods(ExternalMessages.class, PACKAGE); } } From 8ec3e81320ab122de0b92ea9c7dc94e65dd31c50 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Wed, 20 Oct 2021 19:52:55 +0300 Subject: [PATCH 20/26] Polish the code and javadoc --- .../spine/server/integration/IntegrationBroker.java | 13 ++++++------- .../server/integration/InternalNeedsBroadcast.java | 6 +++--- .../proto/spine/server/integration/broker.proto | 2 +- .../testing/server/blackbox/BlackBoxContext.java | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java index 87f662efe36..0e19fc44460 100644 --- a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java +++ b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java @@ -83,7 +83,7 @@ * the transport are propagated into the Bounded Context via the domestic {@code EventBus}. * *

Publishing. The messages requested by other parties are published from the domestic - * {@code EventBus} with the help of {@linkplain DomesticEventPublisher} special dispatcher. + * {@code EventBus} with the help of {@linkplain DomesticEventPublisher special dispatcher}. * *

Sample Usage. * @@ -151,16 +151,10 @@ public IntegrationBroker() { TransportFactory transportFactory = ServerEnvironment .instance() .transportFactory(); - this.subscriberHub = new SubscriberHub(transportFactory); this.publisherHub = new PublisherHub(transportFactory); } - private static ChannelId toChannelId(EventClass cls) { - TypeUrl targetType = cls.typeUrl(); - return channelIdFor(targetType); - } - @Override public void registerWith(BoundedContext context) { checkNotRegistered(); @@ -285,6 +279,11 @@ public void unregister(EventDispatcher dispatcher) { subscriberHub.closeStaleChannels(); } + private static ChannelId toChannelId(EventClass cls) { + TypeUrl targetType = cls.typeUrl(); + return channelIdFor(targetType); + } + private ExternalMessageObserver observerFor(EventClass externalClass) { ExternalMessageObserver observer = new ExternalMessageObserver(contextName, externalClass.value(), this); diff --git a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java index 8ca9294a206..9771bfb1550 100644 --- a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java +++ b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java @@ -37,7 +37,7 @@ /** * A client of the {@code RequestForExternalMessages} {@link Publisher}. * - *

Posts the updates on the requested messages. + *

Posts the updates on the messages requested from outside. */ final class InternalNeedsBroadcast { @@ -52,12 +52,12 @@ final class InternalNeedsBroadcast { } /** - * Notifies other Bounded Contexts about a change in the needed messages. + * Notifies other Bounded Contexts about a change in the requested messages. * *

If the given {@code types} are the same as previous ones, the request is not sent. * * @param needs - * the requested external types + * types of external messages that are requested from outside */ synchronized void onNeedsChange(ImmutableSet needs) { checkNotNull(needs); diff --git a/server/src/main/proto/spine/server/integration/broker.proto b/server/src/main/proto/spine/server/integration/broker.proto index f239c56af97..6cea14684f3 100644 --- a/server/src/main/proto/spine/server/integration/broker.proto +++ b/server/src/main/proto/spine/server/integration/broker.proto @@ -88,7 +88,7 @@ enum ExternalMessageValidationError { UNSUPPORTED_EXTERNAL_MESSAGE = 1; } -// A fact of a new potential messages publisher appearance in a multi-component environment. +// A fact of a new potential message publisher appearance in a multi-component environment. // // Used to notify others in the environment so that they re-send their needs in a form of // `RequestForExternalMessages` which will let the newly joined source contribute. diff --git a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java index 350243d36b2..627ab83d931 100644 --- a/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java +++ b/testutil-server/src/main/java/io/spine/testing/server/blackbox/BlackBoxContext.java @@ -453,7 +453,7 @@ private BlackBoxSetup setup() { } /** - * Closes the bounded context so that it can shut down all of its repositories. + * Closes the bounded context, so it shuts down all of its repositories. * *

Instead of a checked {@link java.io.IOException IOException}, wraps any issues * that may occur while closing, into an {@link IllegalStateException}. From 853c6e0c60437b807500d2470ca1dea8926ab84c Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Wed, 20 Oct 2021 19:56:35 +0300 Subject: [PATCH 21/26] Change javadoc of InternalNeedsBroadcast --- .../io/spine/server/integration/InternalNeedsBroadcast.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java index 9771bfb1550..c2c7842158e 100644 --- a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java +++ b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java @@ -37,7 +37,7 @@ /** * A client of the {@code RequestForExternalMessages} {@link Publisher}. * - *

Posts the updates on the messages requested from outside. + *

Posts the updates on the requested messages. */ final class InternalNeedsBroadcast { @@ -57,7 +57,7 @@ final class InternalNeedsBroadcast { *

If the given {@code types} are the same as previous ones, the request is not sent. * * @param needs - * types of external messages that are requested from outside + * types of external messages that are requested */ synchronized void onNeedsChange(ImmutableSet needs) { checkNotNull(needs); From 5fe11ea153c60095bc928f54ff44fc4537a48f89 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Wed, 20 Oct 2021 20:31:41 +0300 Subject: [PATCH 22/26] Drop no longer used `ExternalNeedsObserver.knownContexts` field --- .../io/spine/server/integration/ExternalNeedsObserver.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java index fa5f0c1ec85..f2c5b917d23 100644 --- a/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java +++ b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java @@ -33,11 +33,9 @@ import io.spine.core.BoundedContextName; import java.util.Collection; -import java.util.HashSet; import java.util.Set; import static io.spine.protobuf.AnyPacker.unpack; -import static java.util.Collections.synchronizedSet; /** * Reacts on {@code RequestForExternalMessages} sent by other parties (usually Bounded Contexts) @@ -51,7 +49,6 @@ final class ExternalNeedsObserver private final BoundedContextName boundedContextName; private final BusAdapter busAdapter; - private final Set knownContexts = synchronizedSet(new HashSet<>()); /** * Current set of message type URLs, requested by other parties via sending the @@ -68,7 +65,6 @@ final class ExternalNeedsObserver super(boundedContextName, RequestForExternalMessages.class); this.boundedContextName = boundedContextName; this.busAdapter = busAdapter; - this.knownContexts.add(boundedContextName); } /** @@ -88,8 +84,6 @@ public void handle(ExternalMessage value) { addNewSubscriptions(request.getRequestedMessageTypeList(), origin); clearStaleSubscriptions(request.getRequestedMessageTypeList(), origin); - - knownContexts.add(origin); } private void addNewSubscriptions(Iterable types, From 629b16d9499fb65eb660a27d0c6a531a332826fd Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 21 Oct 2021 14:37:20 +0300 Subject: [PATCH 23/26] Enhance javadoc and naming --- .../java/io/spine/server/BoundedContext.java | 3 ++ .../integration/ExternalNeedsObserver.java | 37 +++++++++---------- .../server/integration/IntegrationBroker.java | 32 +++++++++------- .../integration/InternalNeedsBroadcast.java | 2 +- .../integration/IntegrationBrokerTest.java | 14 +++---- .../given/broker/PhotosAggregate.java | 8 ++-- .../broker/SubscribedStatisticsAggregate.java | 8 ++-- .../broker/SubscribedWarehouseAggregate.java | 10 ++--- .../given/broker/package-info.java | 4 +- .../test/integration/broker/events.proto | 6 +-- 10 files changed, 64 insertions(+), 60 deletions(-) diff --git a/server/src/main/java/io/spine/server/BoundedContext.java b/server/src/main/java/io/spine/server/BoundedContext.java index 9ef504b3cff..dbd5691a555 100644 --- a/server/src/main/java/io/spine/server/BoundedContext.java +++ b/server/src/main/java/io/spine/server/BoundedContext.java @@ -492,6 +492,7 @@ private InternalAccess() { /** * Registers the passed repository. * + * @return this instance of {@code InternalAccess} for call chaining * @see BoundedContext#register(Repository) */ @CanIgnoreReturnValue @@ -503,6 +504,7 @@ public InternalAccess register(Repository repository) { /** * Registers the passed command dispatcher. * + * @return this instance of {@code InternalAccess} for call chaining * @see BoundedContext#registerCommandDispatcher(CommandDispatcher) */ @CanIgnoreReturnValue @@ -514,6 +516,7 @@ public InternalAccess registerCommandDispatcher(CommandDispatcher dispatcher) { /** * Registers the passed event dispatcher. * + * @return this instance of {@code InternalAccess} for call chaining * @see BoundedContext#registerEventDispatcher(EventDispatcher) */ @CanIgnoreReturnValue diff --git a/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java index f2c5b917d23..f15dfb0d891 100644 --- a/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java +++ b/server/src/main/java/io/spine/server/integration/ExternalNeedsObserver.java @@ -33,6 +33,7 @@ import io.spine.core.BoundedContextName; import java.util.Collection; +import java.util.List; import java.util.Set; import static io.spine.protobuf.AnyPacker.unpack; @@ -48,7 +49,7 @@ final class ExternalNeedsObserver implements AutoCloseable { private final BoundedContextName boundedContextName; - private final BusAdapter busAdapter; + private final BusAdapter bus; /** * Current set of message type URLs, requested by other parties via sending the @@ -58,32 +59,28 @@ final class ExternalNeedsObserver private final Multimap requestedTypes = HashMultimap.create(); - ExternalNeedsObserver( - BoundedContextName boundedContextName, - BusAdapter busAdapter - ) { - super(boundedContextName, RequestForExternalMessages.class); - this.boundedContextName = boundedContextName; - this.busAdapter = busAdapter; + ExternalNeedsObserver(BoundedContextName context, BusAdapter bus) { + super(context, RequestForExternalMessages.class); + this.boundedContextName = context; + this.bus = bus; } /** - * Handles the {@code RequestForExternalMessages} by creating local publishers for the requested - * types via {@code BusAdapter} and dismissing types that are no longer needed. - * - * @param value - * {@link RequestForExternalMessages} + * Unpacks {@code RequestForExternalMessages} from the passed {@code ExternalMessage} and + * handles it by creating local publishers for the requested types and dismissing types + * that are no longer needed. */ @Override - public void handle(ExternalMessage value) { - BoundedContextName origin = value.getBoundedContextName(); + public void handle(ExternalMessage message) { + BoundedContextName origin = message.getBoundedContextName(); RequestForExternalMessages request = unpack( - value.getOriginalMessage(), + message.getOriginalMessage(), RequestForExternalMessages.class ); - addNewSubscriptions(request.getRequestedMessageTypeList(), origin); - clearStaleSubscriptions(request.getRequestedMessageTypeList(), origin); + List externalTypes = request.getRequestedMessageTypeList(); + addNewSubscriptions(externalTypes, origin); + clearStaleSubscriptions(externalTypes, origin); } private void addNewSubscriptions(Iterable types, @@ -103,7 +100,7 @@ private void addNewSubscriptions(Iterable types, private void registerInAdapter(ExternalMessageType newType) { Class messageClass = newType.asMessageClass(); - busAdapter.register(messageClass); + bus.register(messageClass); } private void clearStaleSubscriptions(Collection types, @@ -126,7 +123,7 @@ private void clearStaleSubscriptions(Collection types, private void unregisterInAdapter(ExternalMessageType itemForRemoval) { Class messageClass = itemForRemoval.asMessageClass(); - busAdapter.unregister(messageClass); + bus.unregister(messageClass); } private Set findStale(Collection types, diff --git a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java index 0e19fc44460..2f33474aa1b 100644 --- a/server/src/main/java/io/spine/server/integration/IntegrationBroker.java +++ b/server/src/main/java/io/spine/server/integration/IntegrationBroker.java @@ -70,22 +70,26 @@ * requested messages (needs) and their potential sources (Bounded Contexts) up-to-date. * They use two special messages for this: *

    - *
  • {@linkplain ExternalMessagesSourceAvailable} is sent when a broker is registered + *
  • {@link ExternalMessagesSourceAvailable} is sent when a broker is registered * withing a Bounded Context; - *
  • {@linkplain RequestForExternalMessages} is sent + *
  • {@link RequestForExternalMessages} is sent *
      - *
    • in response to {@linkplain ExternalMessagesSourceAvailable} sent by other brokers; + *
    • in response to {@link ExternalMessagesSourceAvailable} sent by other brokers; *
    • when internal needs for external messages are changed. *
    *
* - *

Receiving. The messages from external components received by an {@code IntegrationBroker} via + *

Receiving + * + *

The messages from external components received by an {@code IntegrationBroker} via * the transport are propagated into the Bounded Context via the domestic {@code EventBus}. * - *

Publishing. The messages requested by other parties are published from the domestic + *

Publishing + * + *

The messages requested by other parties are published from the domestic * {@code EventBus} with the help of {@linkplain DomesticEventPublisher special dispatcher}. * - *

Sample Usage. + *

Sample Usage * *

Bounded Context "Projects" has a projection with an event handler that is subscribed to an * external event as follows: @@ -93,7 +97,7 @@ * {@code * public class ProjectListView extends Projection<...> { * - * {@literal @}Subscribe + * {@literal @}Subscribe * public void on(@External UserDeleted event) { * // Remove the projects that belong to this user. * // ... @@ -142,7 +146,7 @@ public final class IntegrationBroker implements ContextAware, AutoCloseable { private final PublisherHub publisherHub; private @MonotonicNonNull BoundedContextName contextName; - private @MonotonicNonNull BusAdapter busAdapter; + private @MonotonicNonNull BusAdapter bus; private @MonotonicNonNull ExternalNeedsObserver externalNeedsObserver; private @MonotonicNonNull InternalNeedsBroadcast internalNeedsBroadcast; @@ -160,10 +164,10 @@ public void registerWith(BoundedContext context) { checkNotRegistered(); this.contextName = context.name(); - this.busAdapter = new BusAdapter(this, context.eventBus()); + this.bus = new BusAdapter(this, context.eventBus()); setUpNeedsExchange(); - notifyOthersAboutRegistration(); + notifyOfRegistration(); subscribeForFurtherRegistrations(); } @@ -171,16 +175,16 @@ private void setUpNeedsExchange() { Publisher localNeedsPublisher = publisherHub.get(NEEDS_EXCHANGE_CHANNEL_ID); this.internalNeedsBroadcast = new InternalNeedsBroadcast(contextName, localNeedsPublisher); - this.externalNeedsObserver = new ExternalNeedsObserver(contextName, busAdapter); + this.externalNeedsObserver = new ExternalNeedsObserver(contextName, bus); this.subscriberHub.get(NEEDS_EXCHANGE_CHANNEL_ID) .addObserver(externalNeedsObserver); } - private void notifyOthersAboutRegistration() { + private void notifyOfRegistration() { ExternalMessagesSourceAvailable messagesSourceAvailable = ExternalMessagesSourceAvailable .newBuilder() - .buildPartial(); + .vBuild(); ExternalMessage externalMessage = ExternalMessages.of(messagesSourceAvailable, contextName); @@ -241,7 +245,7 @@ void dispatchLocally(Event event) { * Dispatches the given event via the local {@code EventBus} and observes the acknowledgement. */ void dispatchLocally(Event event, StreamObserver ackObserver) { - busAdapter.dispatch(event, ackObserver); + bus.dispatch(event, ackObserver); } /** diff --git a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java index c2c7842158e..0bef3c0f930 100644 --- a/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java +++ b/server/src/main/java/io/spine/server/integration/InternalNeedsBroadcast.java @@ -77,7 +77,7 @@ synchronized void send() { RequestForExternalMessages request = RequestForExternalMessages .newBuilder() .addAllRequestedMessageType(currentNeeds) - .buildPartial(); + .vBuild(); ExternalMessage externalMessage = ExternalMessages.of(request, contextName); needsPublisher.publish(pack(newUuid()), externalMessage); } diff --git a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java index bd1d77f898a..3d5d614838f 100644 --- a/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java +++ b/server/src/test/java/io/spine/server/integration/IntegrationBrokerTest.java @@ -29,11 +29,11 @@ import io.spine.server.ServerEnvironment; import io.spine.server.integration.broker.ArchivePhotos; import io.spine.server.integration.broker.CreditsHeld; -import io.spine.server.integration.broker.IncreasedTotalPhotosUploaded; -import io.spine.server.integration.broker.PhotosArchived; -import io.spine.server.integration.broker.PhotosMarkedArchived; +import io.spine.server.integration.broker.PhotosMovedToWarehouse; +import io.spine.server.integration.broker.PhotosPreparedForArchiving; import io.spine.server.integration.broker.PhotosProcessed; import io.spine.server.integration.broker.PhotosUploaded; +import io.spine.server.integration.broker.TotalPhotosUploadedIncreased; import io.spine.server.integration.broker.UploadPhotos; import io.spine.testing.server.blackbox.BlackBoxContext; import io.spine.testing.server.model.ModelTests; @@ -45,8 +45,8 @@ import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.billingBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.photosBc; -import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedBillingBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.photosBcAndSubscribedBillingBc; +import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedBillingBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedPhotosBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedStatisticsBc; import static io.spine.server.integration.given.broker.IntegrationBrokerTestEnv.subscribedWarehouseBc; @@ -100,7 +100,7 @@ void toMultipleOtherBc() { publishingPhotosBc.assertEvent(PhotosUploaded.class); subscribedBillingBc.assertEvent(CreditsHeld.class); - subscribedStatisticsBc.assertEvent(IncreasedTotalPhotosUploaded.class); + subscribedStatisticsBc.assertEvent(TotalPhotosUploadedIncreased.class); } } @@ -116,8 +116,8 @@ void toMultipleOtherBcWithDifferentNeeds() { subscribedBillingBc.assertEvent(CreditsHeld.class); publishingPhotosBc.receivesCommand(ArchivePhotos.generate()); - publishingPhotosBc.assertEvent(PhotosMarkedArchived.class); - subscribedWarehouseBc.assertEvent(PhotosArchived.class); + publishingPhotosBc.assertEvent(PhotosPreparedForArchiving.class); + subscribedWarehouseBc.assertEvent(PhotosMovedToWarehouse.class); } } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java index 2845e84810b..65ef9bf0dbf 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/PhotosAggregate.java @@ -30,8 +30,8 @@ import io.spine.server.aggregate.Apply; import io.spine.server.command.Assign; import io.spine.server.integration.broker.ArchivePhotos; -import io.spine.server.integration.broker.PhotosMarkedArchived; import io.spine.server.integration.broker.PhotosAgg; +import io.spine.server.integration.broker.PhotosPreparedForArchiving; import io.spine.server.integration.broker.PhotosUploaded; import io.spine.server.integration.broker.UploadPhotos; @@ -48,12 +48,12 @@ private void on(PhotosUploaded event) { } @Assign - PhotosMarkedArchived handler(ArchivePhotos command) { - return PhotosMarkedArchived.generate(); + PhotosPreparedForArchiving handler(ArchivePhotos command) { + return PhotosPreparedForArchiving.generate(); } @Apply - private void on(PhotosMarkedArchived event) { + private void on(PhotosPreparedForArchiving event) { builder().setId(event.getUuid()); } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java index 449ed6114d0..0dab2aba605 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedStatisticsAggregate.java @@ -30,19 +30,19 @@ import io.spine.server.aggregate.Aggregate; import io.spine.server.aggregate.Apply; import io.spine.server.event.React; -import io.spine.server.integration.broker.IncreasedTotalPhotosUploaded; import io.spine.server.integration.broker.PhotosUploaded; import io.spine.server.integration.broker.StatisticsAgg; +import io.spine.server.integration.broker.TotalPhotosUploadedIncreased; final class SubscribedStatisticsAggregate extends Aggregate { @React - IncreasedTotalPhotosUploaded on(@External PhotosUploaded event) { - return IncreasedTotalPhotosUploaded.generate(); + TotalPhotosUploadedIncreased on(@External PhotosUploaded event) { + return TotalPhotosUploadedIncreased.generate(); } @Apply - private void on(IncreasedTotalPhotosUploaded event) { + private void on(TotalPhotosUploadedIncreased event) { builder().setId(event.getUuid()); } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java index f91d4092119..33639a74e29 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/SubscribedWarehouseAggregate.java @@ -30,19 +30,19 @@ import io.spine.server.aggregate.Aggregate; import io.spine.server.aggregate.Apply; import io.spine.server.event.React; -import io.spine.server.integration.broker.PhotosArchived; -import io.spine.server.integration.broker.PhotosMarkedArchived; +import io.spine.server.integration.broker.PhotosMovedToWarehouse; +import io.spine.server.integration.broker.PhotosPreparedForArchiving; import io.spine.server.integration.broker.WarehouseAgg; class SubscribedWarehouseAggregate extends Aggregate { @React - PhotosArchived on(@External PhotosMarkedArchived event) { - return PhotosArchived.generate(); + PhotosMovedToWarehouse on(@External PhotosPreparedForArchiving event) { + return PhotosMovedToWarehouse.generate(); } @Apply - private void on(PhotosArchived event) { + private void on(PhotosMovedToWarehouse event) { builder().setId(event.getUuid()); } } diff --git a/server/src/test/java/io/spine/server/integration/given/broker/package-info.java b/server/src/test/java/io/spine/server/integration/given/broker/package-info.java index 123c6c65d4f..0d07d187ab9 100644 --- a/server/src/test/java/io/spine/server/integration/given/broker/package-info.java +++ b/server/src/test/java/io/spine/server/integration/given/broker/package-info.java @@ -25,7 +25,7 @@ */ /** - * Test environment classes for tests of the {@code io.spine.server.integration.IntegrationBroker}. + * Test environment classes for {@code io.spine.server.integration.IntegrationBroker} tests. */ @CheckReturnValue @@ -34,4 +34,4 @@ import com.google.errorprone.annotations.CheckReturnValue; -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/src/test/proto/spine/test/integration/broker/events.proto b/server/src/test/proto/spine/test/integration/broker/events.proto index e9a09cd5ada..ec6414d754d 100644 --- a/server/src/test/proto/spine/test/integration/broker/events.proto +++ b/server/src/test/proto/spine/test/integration/broker/events.proto @@ -46,14 +46,14 @@ message CreditsHeld { string uuid = 1; } -message IncreasedTotalPhotosUploaded { +message TotalPhotosUploadedIncreased { string uuid = 1; } -message PhotosMarkedArchived { +message PhotosPreparedForArchiving { string uuid = 1; } -message PhotosArchived { +message PhotosMovedToWarehouse { string uuid = 1; } From 89b7e3f795ee15a9f266e648cef4792bf38fac96 Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 21 Oct 2021 15:02:17 +0300 Subject: [PATCH 24/26] Bump the library version --- .idea/codeStyles/Project.xml | 2 +- license-report.md | 32 ++++++++++++++++---------------- pom.xml | 2 +- version.gradle.kts | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index e5ff744791c..f8d0e008bbd 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -108,4 +108,4 @@ - + \ No newline at end of file diff --git a/license-report.md b/license-report.md index 63bac2293d3..20bc5fc030b 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine:spine-client:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -399,12 +399,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:52 EEST 2021** 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 Oct 21 14:59:27 EEST 2021** 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:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine:spine-core:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -763,12 +763,12 @@ This report was generated on **Tue Sep 28 16:46:52 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:52 EEST 2021** 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 Oct 21 14:59:27 EEST 2021** 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-model-assembler:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine.tools:spine-model-assembler:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1162,12 +1162,12 @@ This report was generated on **Tue Sep 28 16:46:52 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:52 EEST 2021** 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 Oct 21 14:59:28 EEST 2021** 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-model-verifier:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine.tools:spine-model-verifier:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1627,12 +1627,12 @@ This report was generated on **Tue Sep 28 16:46:52 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:53 EEST 2021** 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 Oct 21 14:59:28 EEST 2021** 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:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine:spine-server:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2039,12 +2039,12 @@ This report was generated on **Tue Sep 28 16:46:53 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:53 EEST 2021** 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 Oct 21 14:59:29 EEST 2021** 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-testutil-client:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine:spine-testutil-client:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2493,12 +2493,12 @@ This report was generated on **Tue Sep 28 16:46:53 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:54 EEST 2021** 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 Oct 21 14:59:30 EEST 2021** 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-testutil-core:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine:spine-testutil-core:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2947,12 +2947,12 @@ This report was generated on **Tue Sep 28 16:46:54 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:55 EEST 2021** 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 Oct 21 14:59:31 EEST 2021** 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-testutil-server:1.7.7-SNAPSHOT.0` +# Dependencies of `io.spine:spine-testutil-server:1.7.7-SNAPSHOT.1` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3445,4 +3445,4 @@ This report was generated on **Tue Sep 28 16:46:55 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Sep 28 16:46:57 EEST 2021** 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). \ No newline at end of file +This report was generated on **Thu Oct 21 14:59:33 EEST 2021** 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). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 323c2ac96ec..b39d8827517 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.7.7-SNAPSHOT.0 +1.7.7-SNAPSHOT.1 2015 diff --git a/version.gradle.kts b/version.gradle.kts index ec174a2e0f7..2bc6c810786 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -34,7 +34,7 @@ /** * Version of this library. */ -val coreJava = "1.7.7-SNAPSHOT.0" +val coreJava = "1.7.7-SNAPSHOT.1" /** * Versions of the Spine libraries that `core-java` depends on. From 9b9d33697a2c5aae332c755842962d3a6c5f29ce Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 21 Oct 2021 15:18:44 +0300 Subject: [PATCH 25/26] Bump the library version #2 --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index 2bc6c810786..cea37a10946 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -34,7 +34,7 @@ /** * Version of this library. */ -val coreJava = "1.7.7-SNAPSHOT.1" +val coreJava = "1.7.7-SNAPSHOT.2" /** * Versions of the Spine libraries that `core-java` depends on. From 8bf4de1b08cceb9068b611ad951a953847aeeaee Mon Sep 17 00:00:00 2001 From: "yevhenii.nadtochii" Date: Thu, 21 Oct 2021 16:56:05 +0300 Subject: [PATCH 26/26] Bump the library version #3 --- license-report.md | 32 ++++++++++++++++---------------- pom.xml | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/license-report.md b/license-report.md index 20bc5fc030b..2184b070498 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-client:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine:spine-client:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -399,12 +399,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:27 EEST 2021** 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 Oct 21 16:54:26 EEST 2021** 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:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine:spine-core:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -763,12 +763,12 @@ This report was generated on **Thu Oct 21 14:59:27 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:27 EEST 2021** 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 Oct 21 16:54:26 EEST 2021** 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-model-assembler:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine.tools:spine-model-assembler:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1162,12 +1162,12 @@ This report was generated on **Thu Oct 21 14:59:27 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:28 EEST 2021** 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 Oct 21 16:54:27 EEST 2021** 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-model-verifier:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine.tools:spine-model-verifier:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1627,12 +1627,12 @@ This report was generated on **Thu Oct 21 14:59:28 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:28 EEST 2021** 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 Oct 21 16:54:27 EEST 2021** 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:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine:spine-server:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2039,12 +2039,12 @@ This report was generated on **Thu Oct 21 14:59:28 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:29 EEST 2021** 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 Oct 21 16:54:27 EEST 2021** 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-testutil-client:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine:spine-testutil-client:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2493,12 +2493,12 @@ This report was generated on **Thu Oct 21 14:59:29 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:30 EEST 2021** 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 Oct 21 16:54:29 EEST 2021** 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-testutil-core:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine:spine-testutil-core:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -2947,12 +2947,12 @@ This report was generated on **Thu Oct 21 14:59:30 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:31 EEST 2021** 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 Oct 21 16:54:30 EEST 2021** 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-testutil-server:1.7.7-SNAPSHOT.1` +# Dependencies of `io.spine:spine-testutil-server:1.7.7-SNAPSHOT.2` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -3445,4 +3445,4 @@ This report was generated on **Thu Oct 21 14:59:31 EEST 2021** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Oct 21 14:59:33 EEST 2021** 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). \ No newline at end of file +This report was generated on **Thu Oct 21 16:54:32 EEST 2021** 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). \ No newline at end of file diff --git a/pom.xml b/pom.xml index b39d8827517..0f731f39cd8 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-core-java -1.7.7-SNAPSHOT.1 +1.7.7-SNAPSHOT.2 2015