Commit 99aa8537 authored by Sumaiyya Burney's avatar Sumaiyya Burney

Fixes create and get tests

parent 90afae02
......@@ -17,6 +17,7 @@ import reactor.core.publisher.Mono;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.*;
......@@ -66,7 +67,9 @@ class PromotionsControllerTest {
@Test
void createPromotion(){
Promotion promotion = new Promotion("50OFF","SH1234", (float) 0.5,5);
Random rd = new Random();
String newPromoId = Integer.toString(rd.nextInt());
Promotion promotion = new Promotion(newPromoId,"AFP-1", 0.5f,5);
webTestClient.post().uri("/api/promos")
.contentType(MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE))
.body(Mono.just(promotion),Promotion.class)
......@@ -90,7 +93,6 @@ class PromotionsControllerTest {
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON_VALUE)
.expectBodyList(Promotion.class)
.hasSize(1)
.consumeWith(promo ->{
List<Promotion> promos = promo.getResponseBody();
assert promos != null;
......@@ -106,7 +108,6 @@ class PromotionsControllerTest {
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON_VALUE)
.expectBodyList(Promotion.class)
.hasSize(2)
.consumeWith(promo ->{
List<Promotion> promos = promo.getResponseBody();
assert promos != null;
......
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