Commit de4cf430 authored by John Lam's avatar John Lam

add application-test.properties and /api/products to tests

parent 40dcdddd
...@@ -18,7 +18,7 @@ public class ProductController { ...@@ -18,7 +18,7 @@ public class ProductController {
@Autowired @Autowired
ProductService productService; ProductService productService;
@GetMapping("{sku}") @GetMapping("/{sku}")
public ResponseEntity<Mono<ProductDto>> getProductBySku(@PathVariable String sku) { public ResponseEntity<Mono<ProductDto>> getProductBySku(@PathVariable String sku) {
Mono<ProductDto> monoProd = productService.getProductBySku(sku); Mono<ProductDto> monoProd = productService.getProductBySku(sku);
HttpStatus status = monoProd != null ? HttpStatus.OK : HttpStatus.NOT_FOUND; HttpStatus status = monoProd != null ? HttpStatus.OK : HttpStatus.NOT_FOUND;
......
spring.config.import=classpath:secret.properties
spring.data.mongodb.uri=mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb\
.net/${spring.data.mongodb.database}?retryWrites=true&w=majority
spring.data.mongodb.database=test
...@@ -42,7 +42,7 @@ class ProductControllerTest { ...@@ -42,7 +42,7 @@ class ProductControllerTest {
void testProductInvalidSkuNotFound() { void testProductInvalidSkuNotFound() {
client client
.get() .get()
.uri("/products/".concat("{sku}"), "invalid") .uri("/api/products/".concat("{sku}"), "invalid")
.exchange() .exchange()
.expectStatus() .expectStatus()
.isNotFound(); .isNotFound();
...@@ -50,10 +50,10 @@ class ProductControllerTest { ...@@ -50,10 +50,10 @@ class ProductControllerTest {
@Test @Test
void testProductBySkuFound() { void testProductBySkuFound() {
String sku = "100000"; String sku = "000001";
client.get() client.get()
.uri("/products/".concat("/{sku}"), sku) .uri("/api/products/".concat("/{sku}"), sku)
.exchange() .exchange()
.expectStatus() .expectStatus()
.isOk() .isOk()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment