Coverage Report - com.ctrip.apollo.adminservice.AdminServiceHealthIndicator
 
Classes in this File Line Coverage Branch Coverage Complexity
AdminServiceHealthIndicator
12%
1/8
0%
0/2
2
 
 1  
 package com.ctrip.apollo.adminservice;
 2  
 
 3  
 import org.springframework.beans.factory.annotation.Autowired;
 4  
 import org.springframework.boot.actuate.health.Health;
 5  
 import org.springframework.boot.actuate.health.HealthIndicator;
 6  
 import org.springframework.data.domain.PageRequest;
 7  
 import org.springframework.stereotype.Component;
 8  
 
 9  
 import com.ctrip.apollo.biz.service.AppService;
 10  
 
 11  
 @Component
 12  1
 public class AdminServiceHealthIndicator implements HealthIndicator {
 13  
 
 14  
   @Autowired
 15  
   private AppService appService;
 16  
 
 17  
   @Override
 18  
   public Health health() {
 19  0
     int errorCode = check();
 20  0
     if (errorCode != 0) {
 21  0
       return Health.down().withDetail("Error Code", errorCode).build();
 22  
     }
 23  0
     return Health.up().build();
 24  
   }
 25  
 
 26  
   private int check() {
 27  0
     PageRequest pageable = new PageRequest(0, 1);
 28  0
     appService.findAll(pageable);
 29  0
     return 0;
 30  
   }
 31  
 
 32  
 }