This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add correct Company aggregate test #28
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
companies/src/test/java/org/axonframework/samples/trader/company/command/CompanyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.axonframework.samples.trader.company.command; | ||
|
||
import org.axonframework.samples.trader.api.company.*; | ||
import org.axonframework.samples.trader.api.orders.OrderBookId; | ||
import org.axonframework.samples.trader.api.users.UserId; | ||
import org.axonframework.test.aggregate.AggregateTestFixture; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class CompanyTest { | ||
|
||
private AggregateTestFixture<Company> fixture; | ||
|
||
private CompanyId companyId = new CompanyId(); | ||
private OrderBookId orderBookId = new OrderBookId(); | ||
|
||
private CompanyCreatedEvent companyCreatedEvent; | ||
|
||
@Before | ||
public void setUp() { | ||
fixture = new AggregateTestFixture<>(Company.class); | ||
|
||
companyCreatedEvent = new CompanyCreatedEvent(companyId, "TestItem", 1000L, 10000L); | ||
} | ||
|
||
@Test | ||
public void testCreateCompany() { | ||
fixture.givenNoPriorActivity() | ||
.when(new CreateCompanyCommand(companyId, new UserId(), "TestItem", 1000L, 10000L)) | ||
.expectEvents(companyCreatedEvent); | ||
} | ||
|
||
@Test | ||
public void testAddOrderBookToCompany() { | ||
fixture.given(companyCreatedEvent) | ||
.when(new AddOrderBookToCompanyCommand(companyId, orderBookId)) | ||
.expectEvents(new OrderBookAddedToCompanyEvent(companyId, orderBookId)); | ||
} | ||
} |