Skip to content

Commit

Permalink
[Webhook] Write Test for Webhook module (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtranq-nashtechglobal committed Sep 3, 2024
1 parent 612cf56 commit d93f820
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.yas.webhook.controller;

import static io.restassured.RestAssured.given;
import static org.mockito.Mockito.when;

import com.yas.webhook.config.IntegrationTestConfiguration;
import com.yas.webhook.config.constants.ApiConstant;
import com.yas.webhook.model.Event;
import com.yas.webhook.model.enums.EventName;
import com.yas.webhook.model.viewmodel.webhook.WebhookDetailVm;
import com.yas.webhook.repository.EventRepository;
import com.yas.webhook.service.WebhookService;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
Expand All @@ -23,12 +28,22 @@ public class WebhookControllerIT extends AbstractControllerIT {

@Autowired
private WebhookService service;
@Autowired
private EventRepository eventRepository;

private static final String WEBHOOK_URL = "/webhook" + ApiConstant.WEBHOOK_URL;

@BeforeEach
public void insertTestData() {
Event event = new Event();
event.setName(EventName.ON_PRODUCT_UPDATED);
event.setDescription("");

eventRepository.save(event);
}

@Test
public void test_createWebhook_shouldSuccess() {
WebhookDetailVm webhookDetailVm = new WebhookDetailVm();
given(getRequestSpecification())
.auth().oauth2(getAccessToken("admin", "admin"))
.contentType(ContentType.JSON)
Expand Down

0 comments on commit d93f820

Please sign in to comment.