Search in sources :

Example 1 with AlarmServiceImpl

use of com.navercorp.pinpoint.web.service.AlarmServiceImpl in project pinpoint by naver.

the class AlarmReaderTest method readTest3.

@Test
public void readTest3() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    stepExecution.setExecutionContext(executionContext);
    AlarmServiceImpl alarmService = new AlarmServiceImpl(mock(AlarmDao.class), mock(WebhookSendInfoDao.class)) {

        @Override
        public List<Rule> selectRuleByApplicationId(String applicationId) {
            return new LinkedList<>();
        }
    };
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    assertNull(reader.read());
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) StepExecution(org.springframework.batch.core.StepExecution) AlarmDao(com.navercorp.pinpoint.web.dao.AlarmDao) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with AlarmServiceImpl

use of com.navercorp.pinpoint.web.service.AlarmServiceImpl in project pinpoint by naver.

the class AlarmReaderTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    applicationIndexDao = new ApplicationIndexDao() {

        @Override
        public List<Application> selectAllApplicationNames() {
            List<Application> apps = new LinkedList<>();
            for (int i = 0; i < 7; i++) {
                apps.add(new Application(APP_NAME + i, ServiceType.STAND_ALONE));
            }
            return apps;
        }

        @Override
        public List<Application> selectApplicationName(String applicationName) {
            List<Application> apps = new LinkedList<>();
            apps.add(new Application(APP_NAME, ServiceType.STAND_ALONE));
            return apps;
        }

        @Override
        public List<String> selectAgentIds(String applicationName) {
            return null;
        }

        @Override
        public void deleteApplicationName(String applicationName) {
        }

        @Override
        public void deleteAgentIds(Map<String, List<String>> applicationAgentIdMap) {
        }

        @Override
        public void deleteAgentId(String applicationName, String agentId) {
        }
    };
    alarmService = new AlarmServiceImpl(mock(AlarmDao.class), mock(WebhookSendInfoDao.class)) {

        private final Map<String, Rule> ruleMap;

        {
            ruleMap = new HashMap<>();
            for (int i = 0; i <= 6; i++) {
                ruleMap.put(APP_NAME + i, new Rule(APP_NAME + i, SERVICE_TYPE, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, false, ""));
            }
        }

        @Override
        public List<Rule> selectRuleByApplicationId(String applicationId) {
            List<Rule> rules = new LinkedList<>();
            rules.add(ruleMap.get(applicationId));
            return rules;
        }
    };
    dataCollectorFactory = mock(DataCollectorFactory.class);
    when(dataCollectorFactory.createDataCollector(any(), any(), anyLong())).thenAnswer(new Answer<DataCollector>() {

        @Override
        public DataCollector answer(InvocationOnMock invocation) throws Throwable {
            return new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, null, null, 0, 0);
        }
    });
}
Also used : ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) HashMap(java.util.HashMap) ResponseTimeDataCollector(com.navercorp.pinpoint.batch.alarm.collector.ResponseTimeDataCollector) DataCollector(com.navercorp.pinpoint.batch.alarm.collector.DataCollector) ResponseTimeDataCollector(com.navercorp.pinpoint.batch.alarm.collector.ResponseTimeDataCollector) InvocationOnMock(org.mockito.invocation.InvocationOnMock) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) LinkedList(java.util.LinkedList) List(java.util.List) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) Application(com.navercorp.pinpoint.web.vo.Application) BeforeClass(org.junit.BeforeClass)

Example 3 with AlarmServiceImpl

use of com.navercorp.pinpoint.web.service.AlarmServiceImpl in project pinpoint by naver.

the class ReaderTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    applicationIndexDao = new ApplicationIndexDao() {

        @Override
        public List<Application> selectAllApplicationNames() {
            List<Application> apps = new LinkedList<Application>();
            for (int i = 0; i < 7; i++) {
                apps.add(new Application(APP_NAME + i, ServiceType.STAND_ALONE));
            }
            return apps;
        }

        @Override
        public List<String> selectAgentIds(String applicationName) {
            return null;
        }

        @Override
        public void deleteApplicationName(String applicationName) {
        }

        @Override
        public void deleteAgentIds(Map<String, List<String>> applicationAgentIdMap) {
        }

        @Override
        public void deleteAgentId(String applicationName, String agentId) {
        }
    };
    alarmService = new AlarmServiceImpl() {

        private Map<String, Rule> ruleMap;

        {
            ruleMap = new HashMap<String, Rule>();
            for (int i = 0; i <= 6; i++) {
                ruleMap.put(APP_NAME + i, new Rule(APP_NAME + i, SERVICE_TYPE, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, ""));
            }
        }

        @Override
        public List<Rule> selectRuleByApplicationId(String applicationId) {
            List<Rule> rules = new LinkedList<Rule>();
            rules.add(ruleMap.get(applicationId));
            return rules;
        }
    };
    dataCollectorFactory = new DataCollectorFactory() {

        @Override
        public DataCollector createDataCollector(CheckerCategory checker, Application application, long timeSlotEndTime) {
            return new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, null, null, 0, 0);
        }
    };
}
Also used : ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) HashMap(java.util.HashMap) DataCollector(com.navercorp.pinpoint.web.alarm.collector.DataCollector) ResponseTimeDataCollector(com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector) ResponseTimeDataCollector(com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) List(java.util.List) LinkedList(java.util.LinkedList) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) Application(com.navercorp.pinpoint.web.vo.Application) BeforeClass(org.junit.BeforeClass)

Example 4 with AlarmServiceImpl

use of com.navercorp.pinpoint.web.service.AlarmServiceImpl in project pinpoint by naver.

the class ReaderTest method readTest3.

@Test
public void readTest3() {
    StepExecution stepExecution = new StepExecution("alarmStep", null);
    ExecutionContext executionContext = new ExecutionContext();
    executionContext.put(AlarmPartitioner.PARTITION_NUMBER, 2);
    stepExecution.setExecutionContext(executionContext);
    AlarmServiceImpl alarmService = new AlarmServiceImpl() {

        @Override
        public java.util.List<Rule> selectRuleByApplicationId(String applicationId) {
            return new LinkedList<Rule>();
        }
    };
    AlarmReader reader = new AlarmReader(dataCollectorFactory, applicationIndexDao, alarmService);
    reader.beforeStep(stepExecution);
    assertNull(reader.read());
}
Also used : ExecutionContext(org.springframework.batch.item.ExecutionContext) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) StepExecution(org.springframework.batch.core.StepExecution) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

Rule (com.navercorp.pinpoint.web.alarm.vo.Rule)4 AlarmServiceImpl (com.navercorp.pinpoint.web.service.AlarmServiceImpl)4 LinkedList (java.util.LinkedList)4 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)2 Application (com.navercorp.pinpoint.web.vo.Application)2 HashMap (java.util.HashMap)2 List (java.util.List)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 StepExecution (org.springframework.batch.core.StepExecution)2 ExecutionContext (org.springframework.batch.item.ExecutionContext)2 DataCollector (com.navercorp.pinpoint.batch.alarm.collector.DataCollector)1 ResponseTimeDataCollector (com.navercorp.pinpoint.batch.alarm.collector.ResponseTimeDataCollector)1 DataCollector (com.navercorp.pinpoint.web.alarm.collector.DataCollector)1 ResponseTimeDataCollector (com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector)1 AlarmDao (com.navercorp.pinpoint.web.dao.AlarmDao)1 WebhookSendInfoDao (com.navercorp.pinpoint.web.dao.WebhookSendInfoDao)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1