### Question:
IdFieldEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; } IdFieldEmittableKey();  IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other);  }### Answer:
@Test public void testToBSON() { IdFieldEmittableKey key = new IdFieldEmittableKey("test.id.key.field"); key.setId(new Text("1234")); BSONObject bson = key.toBSON(); assertNotNull(bson); assertTrue(bson.containsField("test.id.key.field")); Object obj = bson.get("test.id.key.field"); assertNotNull(obj); assertTrue(obj instanceof String); String val = (String) obj; assertEquals(val, "1234"); }