### Question:
EntityUtil { public static <T extends BaseEntity> String getPKFieldValue(T entity) { String value = null; Field field = getPKField(entity); if (field != null) { field.setAccessible(true); Object pkValue; try { pkValue = field.get(entity); if (pkValue != null) { value = pkValue.toString(); } } catch (IllegalArgumentException | IllegalAccessException ex) { throw new OpenStorefrontRuntimeException("Unable to get value on " + entity.getClass().getName(), "Check entity passed in."); } } else { throw new OpenStorefrontRuntimeException("Unable to find PK for enity: " + entity.getClass().getName(), "Check entity passed in."); } return value; }  static void setDefaultsOnFields(Object entity); static boolean isObjectsDifferent(Object original, Object compare, boolean consumeFieldsOnly); @SuppressWarnings("unchecked") static int compareConsumeFields(Object original, Object compare); static Field getPKField(T entity); static boolean isPKFieldGenerated(T entity); static String getPKFieldValue(T entity); static Object getPKFieldObjectValue(T entity); static void updatePKFieldValue(T entity, String value); static Map<String, Object> findIdField(Class entityClass, Object id); static String getRealClassName(String className);  }### Answer:
@Test public void testGetPKFieldValue() { System.out.println("getPKFieldValue"); Component entity = new Component(); entity.setComponentId("Test"); String expResult = "Test"; String result = EntityUtil.getPKFieldValue(entity); assertEquals(expResult, result); AttributeType aType = new AttributeType(); aType.setAttributeType("Attribute PK"); expResult = "Attribute PK"; result = EntityUtil.getPKFieldValue(aType); assertEquals(expResult, result); AttributeCode aCode = new AttributeCode(); AttributeCodePk aCodePk = new AttributeCodePk(); aCodePk.setAttributeCode("Attribute Code PK"); aCodePk.setAttributeType("Attribute Type PK"); aCode.setAttributeCodePk(aCodePk); result = EntityUtil.getPKFieldValue(aCode); expResult = aCodePk.toKey(); assertEquals(result, expResult); }