@Test
  public void testRunToolSuccess() throws Exception {
    Properties properties = new Properties();
    String testKey = "testKey";
    String testValue = "testValue";
    properties.setProperty(testKey, testValue);
    when(namedCluster.isMapr()).thenReturn(true);

    String[] testArgs = {"testARgs"};
    assertEquals(0, sqoopService.runTool(new ArrayList<>(Arrays.asList(testArgs)), properties));

    verify(configuration).set(testKey, testValue);
    verify(hadoopShim)
        .configureConnectionInformation(
            eq(""), eq(""), eq(""), eq(""), eq(configuration), any(List.class));
    verify(sqoopShim).runTool(eq(testArgs), eq(configuration));
    assertEquals(Boolean.toString(true), System.getProperty(SqoopServiceImpl.SQOOP_THROW_ON_ERROR));
  }
  @Test
  public void shouldUseOnlyLastCoffeeStatusForUpdates() throws Exception {
    CoffeeStatus coffeeStatus1 = new CoffeeStatus();
    CoffeeStatus coffeeStatus2 = new CoffeeStatus();
    coffeeStatus2.cupsRemaining = 999;
    coffeeStatus2.carafePresent = true;
    coffeeStatus2.lastBrewed = 888;

    coffeeStatusProcessor.coffeeStatus(coffeeStatus1);
    coffeeStatusProcessor.coffeeStatus(coffeeStatus2);

    HeartbeatEvent heartbeatEvent = new HeartbeatEvent();
    coffeeStatusProcessor.heartbeatEvent(heartbeatEvent);

    ArgumentCaptor<HttpPost> httpPostArgumentCaptor = ArgumentCaptor.forClass(HttpPost.class);

    verify(mockHttpClient, times(1)).execute(httpPostArgumentCaptor.capture());

    HttpPost httpPost = httpPostArgumentCaptor.getValue();
    String content = IOUtils.toString(httpPost.getEntity().getContent());

    String carafePresentString =
        coffeeStatusProcessor.getCarafePresentName()
            + "="
            + Boolean.toString(coffeeStatus2.carafePresent);
    String cupsRemainingString =
        coffeeStatusProcessor.getCupsRemainingName()
            + "="
            + String.valueOf(coffeeStatus2.cupsRemaining);
    String lastBrewedString =
        coffeeStatusProcessor.getLastBrewedName() + "=" + String.valueOf(coffeeStatus2.lastBrewed);

    Assert.assertThat(content, containsString(carafePresentString));
    Assert.assertThat(content, containsString(cupsRemainingString));
    Assert.assertThat(content, containsString(lastBrewedString));
  }
  @Test
  public void killTopologyWhileAuthenticated() {
    final String requestTopologyId = "topology-test";
    final int requestWaitTimeSecs = 10;
    final boolean async = true;

    doNothing()
        .when(topologyServiceMock)
        .killTopology(requestTopologyId, requestWaitTimeSecs, async, TEST_SUBJECT_ID);

    mockAuthenticatedSubject();

    ClientResponse clientResponse =
        resource()
            .path("/api/topologies/" + requestTopologyId + "/kill")
            .queryParam("waitTimeSecs", Integer.toString(requestWaitTimeSecs))
            .queryParam("async", Boolean.toString(async))
            .get(ClientResponse.class);

    assertEquals("Response HTTP status code should be 200 (OK)", clientResponse.getStatus(), 200);

    verify(topologyServiceMock)
        .killTopology(requestTopologyId, requestWaitTimeSecs, async, TEST_SUBJECT_ID);
  }