### Question:
Keys { @SneakyThrows @SuppressWarnings("PMD.ShortMethodName") public static <E extends Element> Object id(E element) { if (element == null) { return null; } Object elementId = element.id(); if (elementId != null) { return elementId; } Map<String, Object> mappedId = new HashMap<>(); if (isVertex(element)) { mappedId.put(T.label.getAccessor(), element.label()); } Consumer<Field> addKey = field -> { Object propertyValue = propertyValue(field, element); if (isMissing(propertyValue)) { throw Element.Exceptions.requiredKeysMissing(element.getClass(), propertyKey(field)); } mappedId.put(propertyKey(field), propertyValue); }; primaryKeyFields(element).forEach(addKey); orderingKeyFields(element).forEach(addKey); return mappedId.isEmpty() ? null : mappedId; } private  Keys(); static boolean isKey(Field field); static boolean isPrimaryKey(Field field); static boolean isOrderingKey(Field field); static List<Field> keyFields(Element element); static List<Field> keyFields(Class<? extends Element> elementType); static List<Field> primaryKeyFields(Element element); static List<Field> primaryKeyFields(Class<? extends Element> elementType); static boolean hasPrimaryKeys(Element element); static boolean hasPrimaryKeys(Class<? extends Element> elementType); static List<Field> orderingKeyFields(Element element); static List<Field> orderingKeyFields(Class<? extends Element> elementType); static List<String> primaryKeyNames(Element element); static List<String> primaryKeyNames(Class<? extends Element> elementType); @SneakyThrows @SuppressWarnings("PMD.ShortMethodName") static Object id(E element);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testNullPrimaryKey() { marko.name(null); id(marko); }
@Test(expected = IllegalArgumentException.class) public void testNullOrderingKey() { Primitives.allowDefaultKeys = false; marko.age(0); id(marko); }
@Test @SuppressWarnings("serial") public void testIdIsInternalOrGenerated() { assertEquals(new HashMap<String, Object>() { { put(T.label.getAccessor(), marko.label()); put("name", "marko"); put("age", 29); } }, id(marko)); }