### Question:
Product implements Serializable { public Long getFieldValueAsLong(String fieldName) { Object value = getFieldValue(fieldName); try { Long longValue = (Long) value; return longValue; } catch(ClassCastException e) { try { Integer intValue = (Integer) value; return new Long(intValue); } catch(ClassCastException f) { return null; } } } Product(Map<String, Object> fields); ImmutableSet<String> getFieldNames(); Object getFieldValue(String fieldName); String getFieldValueAsString(String fieldName); Double getFieldValueAsDouble(String fieldName); Long getFieldValueAsLong(String fieldName); String toString();  }### Answer:
@Test public void testLong() { Map<String, Object> fields = Maps.newHashMap(); fields.put(Constants.PRODUCT_CATEGORY, "poop bags"); fields.put(Constants.PRODUCT_QUANTITY, 120); fields.put("price", 12.80); Product product = new Product(fields); assertNull(product.getFieldValueAsLong(Constants.PRODUCT_CATEGORY)); assertNull(product.getFieldValueAsLong("price")); assertEquals((long) product.getFieldValueAsLong(Constants.PRODUCT_QUANTITY), 120L); }