package com.bqreaders.silkroad.common.health;

import org.springframework.data.redis.core.RedisTemplate;

import com.google.gson.JsonObject;
import com.yammer.metrics.core.HealthCheck;

/**
 * @author Rubén Carrasco
 *
 */
public class AuthorizationRedisHealthCheck extends HealthCheck {

	private final static String NAME = "Redis";
	private final RedisTemplate<String, JsonObject> redisTemplate;

	public AuthorizationRedisHealthCheck(RedisTemplate<String, JsonObject> redisTemplate) {
		super(NAME);
		this.redisTemplate = redisTemplate;
	}

	@Override
	protected Result check() throws Exception {
		if (redisTemplate.getConnectionFactory().getConnection().ping().equals("PONG")) {
			return Result.healthy();
		}
		return Result.unhealthy("Redis is down");
	}
}

@@ -286,53 +286,8 @@
  %7B%0A%0A
-%09private final static String NAME = %22Redis%22;%0A
 %09pri
@@ -448,12 +448,15 @@
 per(
-NAME
+%22redis%22
 );%0A%09

Change Redis healthCheck name.