@Test
  public void should_use_default_cql_version() {
    CqlExecCassandraMojo cqlExecCassandraMojo = builder.cqlStatement(CQL_STATEMENT).build();
    ArgumentCaptor<ThriftApiOperation> operation = mockThriftExecution();

    try {
      cqlExecCassandraMojo.execute();

      assertEquals("3.4.0", operation.getValue().getCqlVersion());
    } catch (MojoExecutionException | MojoFailureException e) {
      fail(e.getMessage());
    }
  }
  @Test
  public void should_fail_if_io_error_occurs_when_reading_cql_script() {
    CqlExecCassandraMojo cqlExecCassandraMojo = builder.cqlScript(file("emptyfile.cql")).build();
    mockToThrows(new IOException());

    try {
      cqlExecCassandraMojo.execute();
      fail();
    } catch (MojoExecutionException e) {
      assertEquals("Could not parse or load cql file", e.getMessage());
    } catch (MojoFailureException e) {
      fail(e.getMessage());
    }
  }
  @Test
  public void should_use_custom_keyspace() {
    CqlExecCassandraMojo cqlExecCassandraMojo =
        builder.keyspace("identifier").cqlStatement(CQL_STATEMENT).build();
    ArgumentCaptor<ThriftApiOperation> operation = mockThriftExecution();

    try {
      cqlExecCassandraMojo.execute();

      assertEquals("identifier", operation.getValue().getKeyspace());
    } catch (MojoExecutionException | MojoFailureException e) {
      fail(e.getMessage());
    }
  }
  @Test
  public void should_fail_if_file_not_found_occurs_when_reading_cql_script() {
    CqlExecCassandraMojo cqlExecCassandraMojo = builder.cqlScript(file("emptyfile.cql")).build();
    mockToThrows(new FileNotFoundException());

    try {
      cqlExecCassandraMojo.execute();
      fail();
    } catch (MojoExecutionException e) {
      assertThat(
          e.getMessage(),
          allOf(
              startsWith("Cql file '"),
              endsWith("emptyfile.cql' was deleted before I could read it")));
    } catch (MojoFailureException e) {
      fail(e.getMessage());
    }
  }
  @Test
  public void should_fail_when_request_fails() {
    CqlExecCassandraMojo cqlExecCassandraMojo = builder.cqlStatement(CQL_STATEMENT).build();
    mockThriftExecutionWith(
        new ThrowsException(
            new ThriftApiExecutionException(new InvalidRequestException("bad statement"))));

    try {
      cqlExecCassandraMojo.execute();
      fail();
    } catch (MojoExecutionException e) {
      assertEquals(
          "There was a problem calling Apache Cassandra's Thrift API. Details: The request was not properly formatted bad statement",
          e.getMessage());
    } catch (MojoFailureException e) {
      fail(e.getMessage());
    }
  }