### Question:
JestBulkOperations implements BatchOperations<Bulk> { @Override public Object createBatchItem(String indexName, Object source) { return new Index.Builder(source) .index(indexName) .type(mappingType) .build(); } JestBulkOperations();  JestBulkOperations(String mappingType); @Override Object createBatchItem(String indexName, Object source); @Override Object createBatchItem(String indexName, ItemSource source); @Override BatchBuilder<Bulk> createBatchBuilder(); static final String DEFAULT_MAPPING_TYPE; }### Answer:
@Test public void nonStringItemSourceIsNotSupported() { BatchOperations<Bulk> bulkOperations = JestHttpObjectFactoryTest.createTestObjectFactoryBuilder().build().createBatchOperations(); ItemSource itemSource = Object::new; expectedException.expect(ConfigurationException.class); expectedException.expectMessage("Non String payloads are not supported"); bulkOperations.createBatchItem("testIndex", itemSource); }
@Test public void defaultJestBulkOperationsSetsDefaultMappingType() { BatchOperations<Bulk> bulkOperations = new JestBulkOperations(); String testPayload = "{ \"testfield\": \"testvalue\" }"; StringItemSource itemSource = spy(new StringItemSource(testPayload)); Index item = (Index) bulkOperations.createBatchItem("testIndex", itemSource); String type = item.getType(); assertEquals("index", type); }
@Test public void mappingTypeCanBeSet() { String expectedMappingType = UUID.randomUUID().toString(); BatchOperations<Bulk> bulkOperations = new JestBulkOperations(expectedMappingType); String testPayload = "{ \"testfield\": \"testvalue\" }"; StringItemSource itemSource = spy(new StringItemSource(testPayload)); Index item = (Index) bulkOperations.createBatchItem("testIndex", itemSource); String type = item.getType(); assertEquals(expectedMappingType, type); }