### Question:
UtilAerospike { public static <T> Pair<Object, AerospikeRecord> getAerospikeRecordFromObject(T t) throws IllegalAccessException, InstantiationException, InvocationTargetException { Field[] fields = AnnotationUtils.filterDeepFields(t.getClass()); Pair<Field[], Field[]> keysAndFields = AnnotationUtils.filterKeyFields(t.getClass()); Field[] keys = keysAndFields.left; Object key; Map<String, Object> bins = new HashMap<>(); if(keys.length == 0) { throw new InvocationTargetException(new Exception("One key field must be defined.")); } else if(keys.length > 1) { throw new InvocationTargetException(new Exception("Aerospike only supports one key field")); } else { Field keyField = keys[0]; Method method = Utils.findGetter(keyField.getName(), t.getClass()); key = method.invoke(t); } for (Field field : fields) { Method method = Utils.findGetter(field.getName(), t.getClass()); Object object = method.invoke(t); if (object != null) { bins.put(AnnotationUtils.deepFieldName(field), object); } } Record record = new Record(bins, 0, 0); AerospikeRecord aerospikeRecord = new AerospikeRecord(record); Pair<Object, AerospikeRecord> result = Pair.create(key, aerospikeRecord); return result; } private  UtilAerospike(); static T getObjectFromAerospikeRecord(Class<T> classEntity, AerospikeRecord aerospikeRecord,
                                                     AerospikeDeepJobConfig aerospikeConfig); static Pair<Object, AerospikeRecord> getAerospikeRecordFromObject(T t); static Cells getCellFromAerospikeRecord(AerospikeKey key, AerospikeRecord aerospikeRecord,
                                                   AerospikeDeepJobConfig aerospikeConfig); static Pair<Object, AerospikeRecord> getAerospikeRecordFromCell(Cells cells);  }### Answer:
@Test public void testGetRecordFromObject() throws UnknownHostException, NoSuchFieldException, IllegalAccessException, InvocationTargetException, InstantiationException { MessageTestEntity messageEntity = new MessageTestEntity(); messageEntity.setId("3"); messageEntity.setMessage("Test message"); Pair<Object, AerospikeRecord> record = UtilAerospike.getAerospikeRecordFromObject(messageEntity); Map<String, Object> bins = record.right.bins; Object key = record.left; assertEquals(messageEntity.getId().toString(), key.toString()); assertEquals(bins.get("id"), messageEntity.getId()); assertEquals(bins.get("message"), messageEntity.getMessage()); }