Skip to content

Instantly share code, notes, and snippets.

@atesibrahim
Last active June 30, 2022 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atesibrahim/b37d9bb57b96faa207967ed973666f98 to your computer and use it in GitHub Desktop.
Save atesibrahim/b37d9bb57b96faa207967ed973666f98 to your computer and use it in GitHub Desktop.
@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