<commit_before>package com.spotify.reaper.acceptance;

import com.google.common.base.Optional;
import com.google.common.collect.Maps;

import com.spotify.reaper.AppContext;
import com.sun.jersey.api.client.ClientResponse;

import java.util.Map;

import javax.ws.rs.core.Response;

import cucumber.api.java.Before;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

import static org.junit.Assert.assertEquals;

/**
 * Basic acceptance test (Cucumber) steps.
 */
public class BasicSteps {

  @Before
  public static void setup() throws Exception {
    AppContext context = new AppContext();
    ReaperTestJettyRunner.setup(context);
  }

  public void callAndExpect(String httpMethod, String callPath,
                            Optional<Map<String, String>> params, Response.Status expectedStatus) {
    ClientResponse response = ReaperTestJettyRunner.callReaper(httpMethod, callPath, params);
    assertEquals(expectedStatus.getStatusCode(), response.getStatus());
  }

  @Given("^a reaper service is running$")
  public void a_reaper_service_is_running() throws Throwable {
    callAndExpect("GET", "/ping", Optional.<Map<String, String>>absent(), Response.Status.OK);
  }<commit_msg>Mock a JmxProxy that can report cluster name in acceptance test<commit_after>package com.spotify.reaper.acceptance;

import com.google.common.base.Optional;
import com.google.common.collect.Maps;

import com.spotify.reaper.AppContext;
import com.spotify.reaper.ReaperException;
import com.spotify.reaper.cassandra.JmxConnectionFactory;
import com.spotify.reaper.cassandra.JmxProxy;
import com.spotify.reaper.cassandra.RepairStatusHandler;
import com.sun.jersey.api.client.ClientResponse;

import java.util.Map;

import javax.ws.rs.core.Response;

import cucumber.api.java.Before;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
 * Basic acceptance test (Cucumber) steps.
 */
public class BasicSteps {

  @Before
  public static void setup() throws Exception {
    AppContext context = new AppContext();
    context.jmxConnectionFactory = new JmxConnectionFactory() {
      @Override
      public JmxProxy connect(Optional<RepairStatusHandler> handler, String host)
          throws ReaperException {
        JmxProxy jmx = mock(JmxProxy.class);
        when(jmx.getClusterName()).thenReturn("testcluster");
        return jmx;
      }
    };
    ReaperTestJettyRunner.setup(context);
  }

  public void callAndExpect(String httpMethod, String callPath,
                            Optional<Map<String, String>> params, Response.Status expectedStatus) {
    ClientResponse response = ReaperTestJettyRunner.callReaper(httpMethod, callPath, params);
    assertEquals(expectedStatus.getStatusCode(), response.getStatus());
  }

  @Given("^a reaper service is running$")
  public void a_reaper_service_is_running() throws Throwable {
    callAndExpect("GET", "/ping", Optional.<Map<String, String>>absent(), Response.Status.OK);
  }
{'fraction_non_alphanumeric': 0.11028269648959305, 'fraction_numerical': 0.0, 'mean_word_length': 4.494880546075085, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3630954', 'n_tokens_mistral': 987, 'n_tokens_neox': 963, 'n_words': 202}