@Test
  public void contextMenuRebuildMetadata() throws InterruptedException, NoSuchRepositoryException {

    RepositoriesTab repositories = startContextMenuTest();

    // rebuild metadata
    MockHelper.expect(REBUILD_URI, new MockResponse(Status.SUCCESS_OK, null));
    repositories.contextMenuRebuildMetadata(hostedRepo.getId());
    new Window(selenium).waitFor();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();

    MockHelper.expect(REBUILD_URI, new MockResponse(Status.CLIENT_ERROR_BAD_REQUEST, null));
    repositories.contextMenuRebuildMetadata(hostedRepo.getId());
    new MessageBox(selenium).clickOk();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();
  }
  @Test(enabled = false)
  // TODO can't test plugins
  public void contextMenuIndex() throws InterruptedException, NoSuchRepositoryException {

    RepositoriesTab repositories = startContextMenuTest();

    // reindex
    MockHelper.expect(REINDEX_URI, new MockResponse(Status.SUCCESS_OK, null));
    repositories.contextMenuReindex(hostedRepo.getId());
    new Window(selenium).waitFor();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();

    MockHelper.expect(REINDEX_URI, new MockResponse(Status.CLIENT_ERROR_BAD_REQUEST, null));
    repositories.contextMenuReindex(hostedRepo.getId());
    new MessageBox(selenium).clickOk();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();

    // incremental reindex
    MockHelper.expect(INCREMENTAL_REINDEX_URI, new MockResponse(Status.SUCCESS_OK, null));
    repositories.contextMenuIncrementalReindex(hostedRepo.getId());
    new Window(selenium).waitFor();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();

    MockHelper.expect(
        INCREMENTAL_REINDEX_URI, new MockResponse(Status.CLIENT_ERROR_BAD_REQUEST, null));
    repositories.contextMenuIncrementalReindex(hostedRepo.getId());
    new MessageBox(selenium).clickOk();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();
  }
  @Test
  public void contextMenuOutofService() throws InterruptedException, NoSuchRepositoryException {

    RepositoriesTab repositories = startContextMenuTest();

    // put out of service
    MockHelper.expect(
        "/repositories/{repositoryId}/status",
        new MockResponse(Status.SERVER_ERROR_INTERNAL, null));
    repositories.contextMenuPutOutOfService(hostedRepo.getId());
    new MessageBox(selenium).clickOk();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();

    MockHelper.listen("/repositories/{repositoryId}/status", new MockListener());
    repositories.contextMenuPutOutOfService(hostedRepo.getId());
    new Window(selenium).waitFor();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();
    // check on server
    assertThat(hostedRepo.getLocalStatus(), equalTo(LocalStatus.OUT_OF_SERVICE));
    // check on UI
    assertThat(
        repositories.getStatus(hostedRepo.getId()), StringStartsWith.startsWith("Out of Service"));

    // back to service
    MockHelper.expect(
        "/repositories/{repositoryId}/status",
        new MockResponse(Status.CLIENT_ERROR_BAD_REQUEST, null));
    repositories.contextMenuPutInService(hostedRepo.getId());
    new MessageBox(selenium).clickOk();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();

    MockHelper.listen("/repositories/{repositoryId}/status", new MockListener());
    repositories.contextMenuPutInService(hostedRepo.getId());
    new Window(selenium).waitFor();

    MockHelper.checkExecutions();
    MockHelper.clearMocks();
    // check on server
    assertThat(hostedRepo.getLocalStatus(), equalTo(LocalStatus.IN_SERVICE));
    // check on UI
    assertThat(
        repositories.getStatus(hostedRepo.getId()), StringStartsWith.startsWith("In Service"));
  }