Commit 69a4a442 authored by Ben Anderson's avatar Ben Anderson

Created test for getPromotionByPromoId

parent ae8d9aba
package com.nisum.ascend.promotions.controller; package com.nisum.ascend.promotions.controller;
import com.nisum.ascend.promotions.dto.PromotionDto; import com.nisum.ascend.promotions.dto.PromotionDto;
import com.nisum.ascend.promotions.model.Promotion;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -28,9 +27,15 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -28,9 +27,15 @@ import static org.junit.jupiter.api.Assertions.*;
class PromotionsControllerTest { class PromotionsControllerTest {
@Autowired @Autowired
private WebTestClient webTestClient; private WebTestClient webTestClient;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
} }
WebTestClient.ResponseSpec getPromotionWebClient(String promoId) {
return webTestClient.get().uri("/api/promos/" + promoId).exchange();
}
@Test @Test
void getAllPromotions() { void getAllPromotions() {
webTestClient.get().uri("http://localhost:8081/api/promos").exchange() webTestClient.get().uri("http://localhost:8081/api/promos").exchange()
...@@ -48,4 +53,13 @@ class PromotionsControllerTest { ...@@ -48,4 +53,13 @@ class PromotionsControllerTest {
}); });
}); });
} }
@Test
void getPromotionById() {
getPromotionWebClient("0003")
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON_VALUE)
.expectBody()
.jsonPath("promotionId", "0003");
}
} }
\ No newline at end of file
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