-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release' of https://github.com/UMC-5th-Muffler/Money-Pl…
…anner-BE into release
- Loading branch information
Showing
5 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
44 changes: 44 additions & 0 deletions
44
src/test/java/com/umc5th/muffler/domain/expense/repository/GetSumByDateTest.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,44 @@ | ||
package com.umc5th.muffler.domain.expense.repository; | ||
|
||
import com.umc5th.muffler.domain.member.repository.MemberRepository; | ||
import com.umc5th.muffler.entity.Category; | ||
import com.umc5th.muffler.entity.Expense; | ||
import com.umc5th.muffler.entity.Member; | ||
import com.umc5th.muffler.fixture.CategoryFixture; | ||
import com.umc5th.muffler.fixture.ExpenseFixture; | ||
import com.umc5th.muffler.fixture.MemberFixture; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
class GetSumByDateTest { | ||
@Autowired private ExpenseRepository expenseRepository; | ||
@Autowired private MemberRepository memberRepository; | ||
@Test | ||
void getSumByDate() { | ||
Member member = MemberFixture.create("test"); | ||
Category category = CategoryFixture.create(member); | ||
member.addCategory(category); | ||
member = memberRepository.save(member); | ||
|
||
Expense ex1 = ExpenseFixture.create(1L, LocalDate.of(2024, 1, 1), member, category); | ||
Expense ex2 = ExpenseFixture.create(2L, LocalDate.of(2024, 1, 1), member, category); | ||
Expense ex3 = ExpenseFixture.create(3L, LocalDate.of(2024, 1, 1), member, category); | ||
expenseRepository.save(ex1); | ||
expenseRepository.save(ex2); | ||
expenseRepository.save(ex3); | ||
|
||
Map<LocalDate, Long> totalCostDate = expenseRepository.findTotalCostDate(member.getId(), LocalDate.of(2024, 1, 1), | ||
LocalDate.of(2024, 1, 1)); | ||
assertEquals(1, totalCostDate.size()); | ||
assertEquals(300L, totalCostDate.get(LocalDate.of(2024, 1, 1))); | ||
} | ||
|
||
} |
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