44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
package com.drinkool.services;
|
|
|
|
import static io.restassured.RestAssured.given;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import com.drinkool.dtos.SendReview;
|
|
import com.drinkool.entities.ReviewEntity;
|
|
import com.drinkool.models.ReviewModel;
|
|
import io.quarkus.test.junit.QuarkusTest;
|
|
import io.restassured.http.ContentType;
|
|
import java.util.Random;
|
|
import java.util.UUID;
|
|
import org.junit.jupiter.api.*;
|
|
|
|
@QuarkusTest
|
|
public class ReviewServiceTest {
|
|
|
|
@Test
|
|
void receiveReview() {
|
|
Random random = new Random();
|
|
|
|
UUID reviewerId = UUID.randomUUID();
|
|
UUID orderId = UUID.randomUUID();
|
|
String comment = UUID.randomUUID().toString();
|
|
int rating = random.nextInt();
|
|
|
|
SendReview input = new SendReview();
|
|
input.reviewerId = reviewerId;
|
|
input.orderId = orderId;
|
|
ReviewModel reviewModel = new ReviewModel(rating, comment);
|
|
input.review = reviewModel;
|
|
|
|
given()
|
|
.contentType(ContentType.JSON)
|
|
.body(input)
|
|
.when()
|
|
.post("/api/review/create")
|
|
.then()
|
|
.statusCode(201);
|
|
|
|
assertEquals(1, ReviewEntity.find("reviewerId", reviewerId).count());
|
|
}
|
|
}
|