Search in sources :

Example 6 with Webhook

use of com.navercorp.pinpoint.web.vo.Webhook in project pinpoint by naver.

the class WebhookServiceImplTest method selectWebhookByServiceNameTest.

@Test
public void selectWebhookByServiceNameTest() {
    WebhookSendInfoDao webhookSendInfoDao = new MemoryWebhookSendInfoDao(mock(WebhookDao.class));
    WebhookDao webhookDao = new MemoryWebhookDao(mock(AlarmDao.class));
    WebhookService webhookService = new WebhookServiceImpl(webhookDao, webhookSendInfoDao);
    for (Webhook webhook : webhookList) {
        webhookService.insertWebhook(webhook);
    }
    List<Webhook> selectedWebhooks = webhookService.selectWebhookByServiceName("testGroup1");
    assertEquals(2, selectedWebhooks.size());
    webhookService.deleteWebhookByServiceName("testGroup1");
    selectedWebhooks = webhookService.selectWebhookByServiceName("testGroup1");
    assertEquals(0, selectedWebhooks.size());
}
Also used : WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) WebhookDao(com.navercorp.pinpoint.web.dao.WebhookDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) Webhook(com.navercorp.pinpoint.web.vo.Webhook) AlarmDao(com.navercorp.pinpoint.web.dao.AlarmDao) Test(org.junit.Test)

Example 7 with Webhook

use of com.navercorp.pinpoint.web.vo.Webhook in project pinpoint by naver.

the class WebhookServiceImplTest method updateWebhookSendInfoTest.

@Test
public void updateWebhookSendInfoTest() {
    WebhookSendInfoDao webhookSendInfoDao = new MemoryWebhookSendInfoDao(mock(WebhookDao.class));
    WebhookDao webhookDao = new MemoryWebhookDao(mock(AlarmDao.class));
    WebhookService webhookService = new WebhookServiceImpl(webhookDao, webhookSendInfoDao);
    Webhook webhook = new Webhook("0", "alias", "url", "applicationId", "groupId");
    webhookService.insertWebhook(webhook);
    Webhook updateWebhook = new Webhook("0", "alias1", "url1", "applicationId1", "groupId1");
    webhookService.updateWebhook(updateWebhook);
    Webhook selectedWebhook = webhookDao.selectWebhook("0");
    assertNotEquals(webhook, selectedWebhook);
    assertEquals(updateWebhook.getWebhookId(), selectedWebhook.getWebhookId());
    assertEquals(updateWebhook.getAlias(), selectedWebhook.getAlias());
    assertEquals(updateWebhook.getUrl(), selectedWebhook.getUrl());
    assertEquals(updateWebhook.getApplicationId(), selectedWebhook.getApplicationId());
    assertEquals(updateWebhook.getServiceName(), selectedWebhook.getServiceName());
}
Also used : WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) WebhookDao(com.navercorp.pinpoint.web.dao.WebhookDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) Webhook(com.navercorp.pinpoint.web.vo.Webhook) AlarmDao(com.navercorp.pinpoint.web.dao.AlarmDao) Test(org.junit.Test)

Example 8 with Webhook

use of com.navercorp.pinpoint.web.vo.Webhook in project pinpoint by naver.

the class WebhookServiceImplTest method deleteAndSelectWebhookByApplicationIdTest.

@Test
public void deleteAndSelectWebhookByApplicationIdTest() {
    WebhookSendInfoDao webhookSendInfoDao = new MemoryWebhookSendInfoDao(mock(WebhookDao.class));
    WebhookDao webhookDao = new MemoryWebhookDao(mock(AlarmDao.class));
    WebhookService webhookService = new WebhookServiceImpl(webhookDao, webhookSendInfoDao);
    for (Webhook webhook : webhookList) {
        webhookService.insertWebhook(webhook);
    }
    List<Webhook> selectedWebhooks = webhookService.selectWebhookByApplicationId("testApp");
    assertEquals(2, selectedWebhooks.size());
    webhookService.deleteWebhookByApplicationId("testApp");
    selectedWebhooks = webhookService.selectWebhookByApplicationId("testApp");
    assertEquals(0, selectedWebhooks.size());
}
Also used : WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) WebhookDao(com.navercorp.pinpoint.web.dao.WebhookDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) Webhook(com.navercorp.pinpoint.web.vo.Webhook) AlarmDao(com.navercorp.pinpoint.web.dao.AlarmDao) Test(org.junit.Test)

Example 9 with Webhook

use of com.navercorp.pinpoint.web.vo.Webhook in project pinpoint by naver.

the class MemoryWebhookSendInfoDao method selectWebhookSendInfoByServiceName.

@Override
public List<WebhookSendInfo> selectWebhookSendInfoByServiceName(String serviceName) {
    List<WebhookSendInfo> selectedWebhookSendInfos = new LinkedList<>();
    List<Webhook> webhooks = webhookDao.selectWebhookByServiceName(serviceName);
    for (Webhook webhook : webhooks) {
        for (WebhookSendInfo webhookSendInfo : webhookSendInfos.values()) {
            if (webhook.getWebhookId().equals(webhookSendInfo.getWebhookId())) {
                selectedWebhookSendInfos.add(webhookSendInfo);
            }
        }
    }
    return selectedWebhookSendInfos;
}
Also used : Webhook(com.navercorp.pinpoint.web.vo.Webhook) WebhookSendInfo(com.navercorp.pinpoint.web.vo.WebhookSendInfo) LinkedList(java.util.LinkedList)

Aggregations

Webhook (com.navercorp.pinpoint.web.vo.Webhook)9 AlarmDao (com.navercorp.pinpoint.web.dao.AlarmDao)4 WebhookDao (com.navercorp.pinpoint.web.dao.WebhookDao)4 WebhookSendInfoDao (com.navercorp.pinpoint.web.dao.WebhookSendInfoDao)4 MemoryWebhookDao (com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao)4 MemoryWebhookSendInfoDao (com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao)4 Test (org.junit.Test)4 WebhookSendInfo (com.navercorp.pinpoint.web.vo.WebhookSendInfo)3 LinkedList (java.util.LinkedList)2 Before (org.junit.Before)2 UserGroup (com.navercorp.pinpoint.batch.alarm.vo.sender.payload.UserGroup)1 UserMember (com.navercorp.pinpoint.batch.alarm.vo.sender.payload.UserMember)1 WebhookPayload (com.navercorp.pinpoint.batch.alarm.vo.sender.payload.WebhookPayload)1 Rule (com.navercorp.pinpoint.web.alarm.vo.Rule)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1 RestClientException (org.springframework.web.client.RestClientException)1