test_class.declarator: MIN_PORT = 12000
test_class.modifier: private static final
test_class.original_string: private static final int MIN_PORT = 12000;
test_class.type: int
test_class.var_name: MIN_PORT
test_class.declarator: MAX_PORT = 65535
test_class.modifier: private static final
test_class.original_string: private static final int MAX_PORT = 65535;
test_class.type: int
test_class.var_name: MAX_PORT
test_class.declarator: BASIC_JSON_FILE = "/esDiskSpaceChecker/spaceFree.json"
test_class.modifier: private static final
test_class.original_string: private static final String BASIC_JSON_FILE = "/esDiskSpaceChecker/spaceFree.json";
test_class.type: String
test_class.var_name: BASIC_JSON_FILE
test_class.declarator: cacheMs = 1500L
test_class.modifier: private static final
test_class.original_string: private static final long cacheMs = 1500L;
test_class.type: long
test_class.var_name: cacheMs
test_class.declarator: clusterStatsJson
test_class.modifier: private static
test_class.original_string: private static String clusterStatsJson;
test_class.type: String
test_class.var_name: clusterStatsJson
test_class.declarator: port = MIN_PORT + (int) (Math.random() * (MAX_PORT - MIN_PORT + 1))
test_class.modifier: private final
test_class.original_string: private final int port = MIN_PORT + (int) (Math.random() * (MAX_PORT - MIN_PORT + 1));
test_class.type: int
test_class.var_name: port
test_class.declarator: builder = new JerseyClientBuilder(new MetricRegistry())
test_class.modifier: private final
test_class.original_string: private final JerseyClientBuilder builder = new JerseyClientBuilder(new MetricRegistry());
test_class.type: JerseyClientBuilder
test_class.var_name: builder
test_class.declarator: lifecycleEnvironment = spy(new LifecycleEnvironment())
test_class.modifier: private final
test_class.original_string: private final LifecycleEnvironment lifecycleEnvironment = spy(new LifecycleEnvironment());
test_class.type: LifecycleEnvironment
test_class.var_name: lifecycleEnvironment
test_class.declarator: environment = mock(Environment.class)
test_class.modifier: private final
test_class.original_string: private final Environment environment = mock(Environment.class);
test_class.type: Environment
test_class.var_name: environment
test_class.declarator: mockServer
test_class.modifier: private
test_class.original_string: private MockServerClient mockServer;
test_class.type: MockServerClient
test_class.var_name: mockServer
test_class.declarator: esClient
test_class.modifier: private
test_class.original_string: private ElasticsearchClient esClient;
test_class.type: ElasticsearchClient
test_class.var_name: esClient
test_class.file: harahachibu/src/test/java/uk/co/flax/harahachibu/services/impl/ElasticsearchClientTest.java
test_class.identifier: ElasticsearchClientTest
test_case.body: @Test
  	public void serverCalledOnceInCacheTime() throws Exception {
  		mockServer.when(request().withPath(ElasticsearchClient.CLUSTER_STATS_ENDPOINT))
  				.respond(response()
  						.withBody(new JsonBody(clusterStatsJson))
  						.withHeaders(new Header("Content-Type", "application/json"))
  						.withStatusCode(HttpServletResponse.SC_OK));
  
  		ElasticsearchClusterStats clusterStats = esClient.getClusterStats();
  		assertThat(clusterStats).isNotNull();
  		assertThat(clusterStats.getStatus()).isEqualTo("red");
  		assertThat(clusterStats.getNodes().getFileSystem().getTotalBytes()).isEqualTo(206289465344L);
  		assertThat(clusterStats.getNodes().getFileSystem().getFreeBytes()).isEqualTo(132861665280L);
  		assertThat(clusterStats.getNodes().getFileSystem().getAvailableBytes()).isEqualTo(122359132160L);
  
  		// Call again, should hit cache
  		clusterStats = esClient.getClusterStats();
  		assertThat(clusterStats).isNotNull();
  		assertThat(clusterStats.getStatus()).isEqualTo("red");
  		assertThat(clusterStats.getNodes().getFileSystem().getTotalBytes()).isEqualTo(206289465344L);
  		assertThat(clusterStats.getNodes().getFileSystem().getFreeBytes()).isEqualTo(132861665280L);
  		assertThat(clusterStats.getNodes().getFileSystem().getAvailableBytes()).isEqualTo(122359132160L);
  
  		// Verify mockServer calls
  		mockServer.verify(request().withPath(ElasticsearchClient.CLUSTER_STATS_ENDPOINT), VerificationTimes.once());
  	}
test_case.class_method_signature: ElasticsearchClientTest.serverCalledOnceInCacheTime()
test_case.full_signature: @Test public void serverCalledOnceInCacheTime()
test_case.identifier: serverCalledOnceInCacheTime
test_case.invocations: respond when withPath request withStatusCode withHeaders withBody response getClusterStats isNotNull assertThat isEqualTo assertThat getStatus isEqualTo assertThat getTotalBytes getFileSystem getNodes isEqualTo assertThat getFreeBytes getFileSystem getNodes isEqualTo assertThat getAvailableBytes getFileSystem getNodes getClusterStats isNotNull assertThat isEqualTo assertThat getStatus isEqualTo assertThat getTotalBytes getFileSystem getNodes isEqualTo assertThat getFreeBytes getFileSystem getNodes isEqualTo assertThat getAvailableBytes getFileSystem getNodes verify withPath request once
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void serverCalledOnceInCacheTime()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(ElasticsearchClient.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClient.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: CLUSTER_STATS_ENDPOINT = "/_cluster/stats"
focal_class.modifier: static final
focal_class.original_string: static final String CLUSTER_STATS_ENDPOINT = "/_cluster/stats";
focal_class.type: String
focal_class.var_name: CLUSTER_STATS_ENDPOINT
focal_class.declarator: client
focal_class.modifier: private final
focal_class.original_string: private final Client client;
focal_class.type: Client
focal_class.var_name: client
focal_class.declarator: baseUrl
focal_class.modifier: private final
focal_class.original_string: private final String baseUrl;
focal_class.type: String
focal_class.var_name: baseUrl
focal_class.declarator: cacheMs
focal_class.modifier: private final
focal_class.original_string: private final long cacheMs;
focal_class.type: long
focal_class.var_name: cacheMs
focal_class.declarator: latestStats
focal_class.modifier: private
focal_class.original_string: private ElasticsearchClusterStats latestStats;
focal_class.type: ElasticsearchClusterStats
focal_class.var_name: latestStats
focal_class.declarator: lastUpdate
focal_class.modifier: private
focal_class.original_string: private long lastUpdate;
focal_class.type: long
focal_class.var_name: lastUpdate
focal_class.declarator: statsLock = new Object()
focal_class.modifier: private final
focal_class.original_string: private final Object statsLock = new Object();
focal_class.type: Object
focal_class.var_name: statsLock
focal_class.file: harahachibu/src/main/java/uk/co/flax/harahachibu/services/impl/ElasticsearchClient.java
focal_class.identifier: ElasticsearchClient
focal_class.class_method_signature: ElasticsearchClient.ElasticsearchClient(Client client, String baseUrl, long cacheMs)
focal_class.full_signature: public  ElasticsearchClient(Client client, String baseUrl, long cacheMs)
focal_class.identifier: ElasticsearchClient
focal_class.modifiers: public
focal_class.parameters: (Client client, String baseUrl, long cacheMs)
focal_class.signature:  ElasticsearchClient(Client client, String baseUrl, long cacheMs)
focal_class.class_method_signature: ElasticsearchClient.getClusterStats()
focal_class.full_signature: public ElasticsearchClusterStats getClusterStats()
focal_class.identifier: getClusterStats
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: ElasticsearchClusterStats
focal_class.signature: ElasticsearchClusterStats getClusterStats()
focal_class.class_method_signature: ElasticsearchClient.cacheUpToDate()
focal_class.full_signature: private boolean cacheUpToDate()
focal_class.identifier: cacheUpToDate
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean cacheUpToDate()
focal_class.class_method_signature: ElasticsearchClient.getRemoteClusterStats()
focal_class.full_signature: private ElasticsearchClusterStats getRemoteClusterStats()
focal_class.identifier: getRemoteClusterStats
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ElasticsearchClusterStats
focal_class.signature: ElasticsearchClusterStats getRemoteClusterStats()
focal_method.body: public ElasticsearchClusterStats getClusterStats() throws DiskSpaceCheckerException {
  		final ElasticsearchClusterStats stats;
  
  		if (cacheUpToDate()) {
  			stats = latestStats;
  		} else {
  			stats = getRemoteClusterStats();
  			synchronized (statsLock) {
  				this.latestStats = stats;
  				this.lastUpdate = System.currentTimeMillis();
  			}
  		}
  
  		return stats;
  	}
focal_method.class_method_signature: ElasticsearchClient.getClusterStats()
focal_method.full_signature: public ElasticsearchClusterStats getClusterStats()
focal_method.identifier: getClusterStats
focal_method.invocations: cacheUpToDate getRemoteClusterStats currentTimeMillis
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: ElasticsearchClusterStats
focal_method.signature: ElasticsearchClusterStats getClusterStats()