-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from leung018:order-service
Order service part 3
- Loading branch information
Showing
12 changed files
with
169 additions
and
68 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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/leungcheng/spring_simple_backend/RetryConfig.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,8 @@ | ||
package com.leungcheng.spring_simple_backend; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.retry.annotation.EnableRetry; | ||
|
||
@EnableRetry | ||
@Configuration | ||
public class RetryConfig {} |
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
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
34 changes: 34 additions & 0 deletions
34
src/test/java/com/leungcheng/spring_simple_backend/domain/PrecisionTest.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,34 @@ | ||
package com.leungcheng.spring_simple_backend.domain; | ||
|
||
import static com.leungcheng.spring_simple_backend.testutil.CustomAssertions.assertBigDecimalEquals; | ||
import static com.leungcheng.spring_simple_backend.testutil.DefaultBuilders.productBuilder; | ||
import static com.leungcheng.spring_simple_backend.testutil.DefaultBuilders.userBuilder; | ||
|
||
import java.math.BigDecimal; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class PrecisionTest { | ||
private @Autowired ProductRepository productRepository; | ||
private @Autowired UserRepository userRepository; | ||
|
||
@Test | ||
void shouldProductKeepPrecisionAfterSavingToRepository() { | ||
Product product = productBuilder().price(new BigDecimal("123456.78912")).build(); | ||
productRepository.save(product); | ||
Product savedProduct = productRepository.findById(product.getId()).orElseThrow(); | ||
|
||
assertBigDecimalEquals(product.getPrice(), savedProduct.getPrice()); | ||
} | ||
|
||
@Test | ||
void shouldUserKeepPrecisionAfterSavingToRepository() { | ||
User user = userBuilder().balance(new BigDecimal("123456.78912")).build(); | ||
userRepository.save(user); | ||
User savedUser = userRepository.findById(user.getId()).orElseThrow(); | ||
|
||
assertBigDecimalEquals(user.getBalance(), savedUser.getBalance()); | ||
} | ||
} |
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
8 changes: 1 addition & 7 deletions
8
src/test/java/com/leungcheng/spring_simple_backend/domain/UserTest.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
Oops, something went wrong.