Last active
June 30, 2022 13:25
-
-
Save atesibrahim/b37d9bb57b96faa207967ed973666f98 to your computer and use it in GitHub Desktop.
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
@ExtendWith(SpringExtension.class) | |
public class ProductRepositoryTest { | |
@Autowired | |
private ProductRepository productRepository; | |
@Autowired | |
private TestEntityManager testEntityManager; | |
@Test | |
public void it_should_update_name() { | |
//Given | |
Clock.freeze(); | |
LocalDateTime now = LocalDateTime.now(); | |
Product product = Product.builder() | |
.name("product") | |
.id(1) | |
.build(); | |
testEntityManager.persistAndFlush(product); | |
//When | |
productRepository.updateName(1, "product_new"); | |
testEntityManager.clear(); | |
//Then | |
assertThat(productRepository.findById(product.getId()).map(Product::getId)).contains(1); | |
Clock.unfreeze(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment