### Question:
EntityUtils { public static long getLong(Entity Entity, String key) { return getLong(Entity.toString(), key, Entity.getProperty(key)); } private  EntityUtils(); static Map<Long, T> entitiesToMap(Collection<T> entities); static Long[] ids(Iterable<? extends Entity> entities); static String valueToString(Object value); static Map<String, Object> propertiesToMap(Entity Entity); static Map<String, Object> propertiesToMap(Entity Entity, ObjectInclusionPolicy<String> propertyInclusionPolicy); static int deleteNodeAndRelationships(Node toDelete); static String nodeToString(Node node); static String relationshipToString(Relationship relationship); static String propertiesToString(Entity Entity); static int getInt(Entity Entity, String key); static int getInt(Entity Entity, String key, int defaultValue); static long getLong(Entity Entity, String key); static long getLong(Entity Entity, String key, long defaultValue); static float getFloat(Entity Entity, String key); static float getFloat(Entity Entity, String key, float defaultValue);  }### Answer:
@Test public void shouldSafelyGetLong() { populateDatabaseWithNumberProperties(); long expected = 123L; try (Transaction tx = database.beginTx()) { assertEquals(expected, getLong(database.getNodeById(0), "test")); assertEquals(expected, getLong(database.getNodeById(1), "test")); assertEquals(expected, getLong(database.getNodeById(2), "test")); try { getLong(database.getNodeById(3), "test"); fail(); } catch (ClassCastException e) { } try { getLong(database.getNodeById(4), "test"); fail(); } catch (NotFoundException e) { } tx.success(); } }
@Test public void shouldSafelyGetLongWithDefaults() { populateDatabaseWithNumberProperties(); long expected = 123L; try (Transaction tx = database.beginTx()) { assertEquals(expected, getLong(database.getNodeById(0), "test", 123L)); assertEquals(expected, getLong(database.getNodeById(1), "test", 123L)); assertEquals(expected, getLong(database.getNodeById(2), "test", 123L)); assertEquals(expected, getLong(database.getNodeById(4), "test", 123L)); try { getLong(database.getNodeById(3), "test", 123L); fail(); } catch (ClassCastException e) { } tx.success(); } }