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);
}
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));
}
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);
}
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));
}
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();
}
Aggregations