Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

テストプログラムのRandomオブジェクトの扱い方をstaticに変更する #1693

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class CatalogApplicationServiceTest {

private CatalogApplicationService service;

private static final Random random = new Random();

@BeforeEach
void setUp() {
service = new CatalogApplicationService(messages, catalogRepository, brandRepository, catalogCategoryRepository);
Expand Down Expand Up @@ -106,7 +108,6 @@ void setUp() {
}

private CatalogItem createCatalogItem(long id) {
Random random = new Random();
long defaultCatalogCategoryId = random.nextInt(1000);
long defaultCatalogBrandId = random.nextInt(1000);
String defaultDescription = "Description.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class ShoppingApplicationServiceTest {

private ShoppingApplicationService service;

private static final Random random = new Random();

@BeforeEach
void setUp() {
service = new ShoppingApplicationService(messages, basketRepository, catalogRepository, orderRepository,
Expand Down Expand Up @@ -382,7 +384,6 @@ private List<OrderItem> createDefaultOrderItems() {
}

private CatalogItem createCatalogItem(long id) {
Random random = new Random();
long defaultCatalogCategoryId = random.nextInt(1000);
long defaultCatalogBrandId = random.nextInt(1000);
String defaultDescription = "Description.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class CatalogDomainServiceTest {
@InjectMocks
private CatalogDomainService service;

private static final Random random = new Random();

@Test
void testGetExistCatalogItems_正常系_リポジトリのfindByCategoryIdInを1度だけ呼出す() {
// Arrange
Expand Down Expand Up @@ -122,7 +124,6 @@ public class CatalogDomainServiceTest {
}

private CatalogItem createCatalogItem(long id) {
Random random = new Random();
long defaultCatalogCategoryId = random.nextInt(1000);
long defaultCatalogBrandId = random.nextInt(1000);
String defaultDescription = "Description.";
Expand Down
Loading