Skip to content

Instantly share code, notes, and snippets.

@lhauspie
Created August 22, 2017 23:01
Show Gist options
  • Save lhauspie/8da1cb8c5f8c3b72ba4009c1653f6da3 to your computer and use it in GitHub Desktop.
Save lhauspie/8da1cb8c5f8c3b72ba4009c1653f6da3 to your computer and use it in GitHub Desktop.
Test d’intégration du Custom Repository produit
@SpringBootTest
@RunWith(SpringRunner.class)
public class ProductRepositoryIntegrationTest {
@Autowired
private ProductRepository productRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Test
public void searchProductTest() {
// partie init de données
Assertions.assertThat(productRepo.findAll()).hasSize(0);
Product product = productRepo.save(new Product(null, "CODE", "LABEL", "DESCRIPTION", 1234D));
// appel de la couche Repository à tester
Collection<Product> products = productRepo.search(new SearchQuery("CODE", null, null, null, null));
// partie verification de l'execution
Assertions.assertThat(products).hasSize(1);
Assertions.assertThat(products).containsExactly(product);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment