@Test
  public void testAddPartitionWithWriteId() throws Exception {
    List<String> newPartVals = new ArrayList<String>(2);
    newPartVals.add("WriteId_continent");
    newPartVals.add("WriteId_country");

    StrictDelimitedInputWriter writerT = StrictDelimitedInputWriter.newBuilder()
        .withFieldDelimiter(',')
        .build();
    HiveStreamingConnection transactionConnection = HiveStreamingConnection.newBuilder()
        .withDatabase(dbName)
        .withTable(tblName)
        .withStaticPartitionValues(newPartVals)
        .withRecordWriter(writerT)
        .withHiveConf(conf)
        .connect();
    transactionConnection.beginTransaction();

    Table tObject = transactionConnection.getTable();
    Long writeId = transactionConnection.getCurrentWriteId();

    Assert.assertNotNull(tObject);
    Assert.assertNotNull(writeId);

    StrictDelimitedInputWriter writer = StrictDelimitedInputWriter.newBuilder()
        .withFieldDelimiter(',')
        .build();
    HiveStreamingConnection connection = HiveStreamingConnection.newBuilder()
        .withDatabase(dbName)
        .withTable(tblName)
        .withStaticPartitionValues(newPartVals)
        .withRecordWriter(writer)
        .withHiveConf(conf)
        .withWriteId(writeId)
        .withStatementId(1)
        .withTableObject(tObject)
        .connect();

    Assert.assertNotNull(connection);

    connection.beginTransaction();
    connection.write("3,Hello streaming - once again".getBytes());
    connection.commitTransaction();

    Set<String> partitions = new HashSet<>(connection.getPartitions());

    connection.close();

    // Ensure partition is not present
    try {
      msClient.getPartition(dbName, tblName, newPartVals);
      Assert.fail("Partition shouldn't exist so a NoSuchObjectException should have been raised");
    } catch (NoSuchObjectException e) {}

    transactionConnection.commitTransaction(partitions);

    // Ensure partition is present
    Partition p = msClient.getPartition(dbName, tblName, newPartVals);
    Assert.assertNotNull("Did not find added partition", p);
  }
@param validationQuery query to read from table to compare data against {@code records}
@param records         expected data.  each row is CVS list of values
streaming/src/test/org/apache/hive/streaming/TestStreaming.java