From bf5ed18f63eac52bcf15613aa4d1a128656239b5 Mon Sep 17 00:00:00 2001 From: Abhinav Pandey Date: Mon, 18 Jul 2022 14:35:30 +0000 Subject: [PATCH] BAEL-3201 - Deleting Integration Test file --- .../ProductServiceIntegrationTest.java | 75 ------------------- 1 file changed, 75 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java b/spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java deleted file mode 100644 index 519db1b335..0000000000 --- a/spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.baeldung.redistestcontainers.service; - -import com.baeldung.redistestcontainers.hash.Product; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -@SpringBootTest -public class ProductServiceIntegrationTest { - - static { - GenericContainer redis = new GenericContainer<>(DockerImageName.parse("redis:5.0.3-alpine")) - .withExposedPorts(6379); - redis.start(); - System.setProperty("spring.redis.host", redis.getHost()); - System.setProperty("spring.redis.port", redis.getMappedPort(6379).toString()); - } - - @Autowired - private ProductService productService; - - @Test - void givenProductCreated_whenGettingProductById_thenProductExistsAndHasSameProperties() { - Product product = new Product("1", "Test Product", 10.0); - productService.createProduct(product); - Product productFromDb = productService.getProduct("1"); - assertEquals("1", productFromDb.getId()); - assertEquals("Test Product", productFromDb.getName()); - assertEquals(10.0, productFromDb.getPrice()); - } - - @Test - void givenProductCreatedAndUpdated_whenGettingTheProduct_thenUpdatedProductReturned() { - Product product = new Product("1", "Test Product", 10.0); - productService.createProduct(product); - Product productFromDb = productService.getProduct("1"); - assertEquals("1", productFromDb.getId()); - assertEquals("Test Product", productFromDb.getName()); - assertEquals(10.0, productFromDb.getPrice()); - productFromDb.setName("Updated Product"); - productFromDb.setPrice(20.0); - productService.updateProduct(productFromDb); - Product updatedProductFromDb = productService.getProduct("1"); - assertEquals("Updated Product", updatedProductFromDb.getName()); - assertEquals(20.0, updatedProductFromDb.getPrice()); - } - - @Test - void givenProductCreatedAndDeleted_whenGettingTheProduct_thenNoProductReturned() { - Product product = new Product("1", "Test Product", 10.0); - productService.createProduct(product); - Product productFromDb = productService.getProduct("1"); - assertEquals("1", productFromDb.getId()); - assertEquals("Test Product", productFromDb.getName()); - assertEquals(10.0, productFromDb.getPrice()); - productService.deleteProduct("1"); - Product deletedProductFromDb = productService.getProduct("1"); - assertNull(deletedProductFromDb); - } - - @Test - void givenProductCreated_whenGettingProductById_thenSameProductReturned() { - Product product = new Product("1", "Test Product", 10.0); - productService.createProduct(product); - Product productFromDb = productService.getProduct("1"); - assertEquals("1", productFromDb.getId()); - assertEquals("Test Product", productFromDb.getName()); - assertEquals(10.0, productFromDb.getPrice()); - } -} \ No newline at end of file