Created
April 27, 2019 08:05
-
-
Save tbelmega/80961329c1055def09da9cffbaa16e1f 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
@ActiveProfiles("test") | |
@RunWith(SpringJUnit4ClassRunner::class) | |
@DataJpaTest | |
class ProductRepositoryTest { | |
@Autowired | |
private lateinit var productRepository: ProductRepository | |
@Test | |
fun `saves product in database and loads by id`() { | |
// given | |
val productToSave = Product("1", "Ryzen 7 2700X", "AMD") | |
// when | |
productRepository.save(productToSave) | |
// then | |
val loadedProduct = productRepository.getOne("1") | |
assertThat(loadedProduct).isEqualTo(productToSave) | |
} | |
@Test | |
fun `loads all products from database`() { | |
// given | |
val product1 = productRepository.save(Product("1", "Ryzen 7 2700X", "AMD")) | |
val product2 = productRepository.save(Product("2", "Core i9 9900K", "Intel")) | |
// when | |
val products = productRepository.findAll() | |
// then | |
assertThat(products).containsExactlyInAnyOrder(product1, product2) | |
} | |
@Test | |
fun `findMostOrderedProducts - first test TODO name it correctly`() { | |
// given | |
// when | |
// then | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment