### Question:
IndexRequestBuilderCreator { public IndexRequestBuilder createIndexRequestBuilder(TableMetadata targetTable, Client elasticClient, Row row) throws ExecutionException { Map<String, Object> dataInsert = createInsertMap(row); String pk = createPrimaryKey(targetTable, dataInsert); IndexRequestBuilder indexRequestBuilder = createIndexRequestBuilder(elasticClient, targetTable, dataInsert, pk); return indexRequestBuilder; }  IndexRequestBuilder createIndexRequestBuilder(TableMetadata targetTable, Client elasticClient, Row row);  }### Answer:
@Test public void createIndexRequestBuilderTest() throws UnsupportedException, ExecutionException { partitionKey.add(new ColumnName(INDEX_NAME, TYPE_NAME, COLUMN_NAME)); TableMetadata targetTable = new TableMetadata(tableName, options, columns, indexes, clusterRef, partitionKey, clusterKey); Row row = createRow(COLUMN_NAME, CELL_VALUE); row.addCell(COLUMN_NAME, new Cell(CELL_VALUE)); Map<String, Object> dataInsert = new HashMap<>(); dataInsert.put(COLUMN_NAME, CELL_VALUE); Map<String, Object> other = new HashMap<>(); other.put(COLUMN_NAME, CELL_VALUE); IndexRequestBuilder indexRequiestBuilder = mock(IndexRequestBuilder.class); when(indexRequiestBuilder.setSource(eq(other))).thenReturn(indexRequiestBuilder); when(client.prepareIndex(INDEX_NAME, TYPE_NAME, CELL_VALUE)).thenReturn(indexRequiestBuilder); IndexRequestBuilder indexRequestBuilder = indexRequestBuilderCreator.createIndexRequestBuilder(targetTable, client, row); assertNotNull("The index request builder is not null", indexRequestBuilder); }
@Test public void createIndexRequestBuilderWithPkTest() throws UnsupportedException, ExecutionException { TableMetadata targetTable = new TableMetadata(tableName, options, columns, indexes, clusterRef, partitionKey, clusterKey); Row row = createRow(COLUMN_NAME, CELL_VALUE); row.addCell(COLUMN_NAME, new Cell(CELL_VALUE)); partitionKey.add(new ColumnName(INDEX_NAME, TYPE_NAME, COLUMN_NAME)); Map<String, Object> dataInsert = new HashMap<>(); dataInsert.put(COLUMN_NAME, CELL_VALUE); Map<String, Object> other = new HashMap<>(); other.put(COLUMN_NAME, CELL_VALUE); IndexRequestBuilder indexRequestBuilder = mock(IndexRequestBuilder.class); when(indexRequestBuilder.setSource(eq(other))).thenReturn(indexRequestBuilder); when(client.prepareIndex(INDEX_NAME, TYPE_NAME, CELL_VALUE)).thenReturn(indexRequestBuilder); assertEquals(indexRequestBuilder, indexRequestBuilderCreator.createIndexRequestBuilder(targetTable, client, row)); }