Search in sources :

Example 6 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class SubscriptionRecordShould method match_record_to_given_parameters.

@Test
public void match_record_to_given_parameters() {
    final SubscriptionRecord matchingRecord = new SubscriptionRecord(Given.subscription(), Given.target(), Given.TYPE);
    final Project entityState = Project.getDefaultInstance();
    final Any wrappedState = AnyPacker.pack(entityState);
    final ProjectId redundantId = ProjectId.getDefaultInstance();
    final boolean matchResult = matchingRecord.matches(Given.TYPE, redundantId, wrappedState);
    assertTrue(matchResult);
}
Also used : Project(io.spine.test.aggregate.Project) ProjectId(io.spine.test.aggregate.ProjectId) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 7 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class AggregateRootShould method setUp.

@Before
public void setUp() {
    boundedContext = BoundedContext.newBuilder().build();
    ProjectId projectId = ProjectId.newBuilder().setId(newUuid()).build();
    aggregateRoot = new ProjectRoot(boundedContext, projectId);
    boundedContext.register(new ProjectDefinitionRepository(boundedContext));
    boundedContext.register(new ProjectLifeCycleRepository(boundedContext));
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId) Before(org.junit.Before)

Example 8 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class AggregateRootShould method have_different_cache_for_different_instances.

@Test
public void have_different_cache_for_different_instances() {
    final ProjectId projectId = ProjectId.getDefaultInstance();
    final AggregateRoot firstRoot = new ProjectRoot(boundedContext, projectId);
    final AggregateRoot secondRoot = new ProjectRoot(boundedContext, projectId);
    final AggregateRoot firstRootSpy = spy(firstRoot);
    final AggregateRoot secondRootSpy = spy(secondRoot);
    final Class<ProjectDefinition> partClass = ProjectDefinition.class;
    firstRootSpy.getPartState(partClass);
    secondRootSpy.getPartState(partClass);
    verify(firstRootSpy, times(1)).lookup(partClass);
    verify(secondRootSpy, times(1)).lookup(partClass);
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId) ProjectDefinition(io.spine.test.aggregate.ProjectDefinition) Test(org.junit.Test)

Example 9 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class AggregatePartRepositoryLookupShould method setUp.

@Before
public void setUp() {
    boundedContext = BoundedContext.newBuilder().build();
    final ProjectId id = ProjectId.newBuilder().setId(newUuid()).build();
    final ProjectRoot root = new ProjectRoot(boundedContext, id);
    boundedContext.register(new ProjectPartRepository(boundedContext));
    boundedContext.register(new TaskAggregateRepository(boundedContext));
}
Also used : ProjectId(io.spine.test.aggregate.ProjectId) Before(org.junit.Before)

Example 10 with ProjectId

use of io.spine.test.aggregate.ProjectId in project core-java by SpineEventEngine.

the class SubscriptionServiceShould method cancel_subscription_on_topic.

@Test
public void cancel_subscription_on_topic() {
    final BoundedContext boundedContext = setupBoundedContextWithProjectAggregateRepo();
    final SubscriptionService subscriptionService = SubscriptionService.newBuilder().add(boundedContext).build();
    final Target target = getProjectQueryTarget();
    final Topic topic = requestFactory.topic().forTarget(target);
    // Subscribe
    final MemoizeStreamObserver<Subscription> subscribeObserver = new MemoizeStreamObserver<>();
    subscriptionService.subscribe(topic, subscribeObserver);
    // Activate subscription
    final MemoizeStreamObserver<SubscriptionUpdate> activateSubscription = spy(new MemoizeStreamObserver<SubscriptionUpdate>());
    subscriptionService.activate(subscribeObserver.streamFlowValue, activateSubscription);
    // Cancel subscription
    subscriptionService.cancel(subscribeObserver.streamFlowValue, new MemoizeStreamObserver<Response>());
    // Post update to Stand
    final ProjectId projectId = ProjectId.newBuilder().setId("some-other-id").build();
    final Message projectState = Project.newBuilder().setId(projectId).build();
    final int version = 1;
    final VersionableEntity entity = mockEntity(projectId, projectState, version);
    boundedContext.getStand().post(entity, requestFactory.createCommandContext());
    // The update must not be handled by the observer
    verify(activateSubscription, never()).onNext(any(SubscriptionUpdate.class));
    verify(activateSubscription, never()).onCompleted();
}
Also used : Message(com.google.protobuf.Message) ProjectId(io.spine.test.aggregate.ProjectId) SubscriptionUpdate(io.spine.client.SubscriptionUpdate) AbstractVersionableEntity(io.spine.server.entity.AbstractVersionableEntity) VersionableEntity(io.spine.server.entity.VersionableEntity) Response(io.spine.base.Response) Target(io.spine.client.Target) Topic(io.spine.client.Topic) Subscription(io.spine.client.Subscription) Test(org.junit.Test)

Aggregations

ProjectId (io.spine.test.aggregate.ProjectId)16 Test (org.junit.Test)12 Any (com.google.protobuf.Any)3 Project (io.spine.test.aggregate.Project)3 Message (com.google.protobuf.Message)2 Subscription (io.spine.client.Subscription)2 SubscriptionUpdate (io.spine.client.SubscriptionUpdate)2 Target (io.spine.client.Target)2 Topic (io.spine.client.Topic)2 AbstractVersionableEntity (io.spine.server.entity.AbstractVersionableEntity)2 VersionableEntity (io.spine.server.entity.VersionableEntity)2 Before (org.junit.Before)2 Response (io.spine.base.Response)1 CommandEnvelope (io.spine.envelope.CommandEnvelope)1 ProjectDefinition (io.spine.test.aggregate.ProjectDefinition)1 ImportEvents (io.spine.test.aggregate.command.ImportEvents)1