Ingredient { protected <T> T getProperty(String key) { return (T) properties.get(key); } Ingredient(String ingredientType, String domain);  Ingredient(String ingredientType); protected  Ingredient(Ingredient other); String getDomain(); String getIngredientType();  }
@Test public void testGetProperty_returnsNullOnNonExistentKey() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; assertNull(ingredient.getProperty("foo")); }
@Test public void testGetProperty_withType_intDefaultsTo0() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; int value = ingredient.getProperty(int.class, "foo"); assertEquals(0, value); }
@Test public void testGetProperty_withType_floatDefaultsTo0() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; float value = ingredient.getProperty(float.class, "foo"); assertEquals(0.0f, value, 0.0); }
@Test public void testGetProperty_withType_booleanDefaultsToFalse() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; boolean value = ingredient.getProperty(boolean.class, "foo"); assertEquals(false, value); }
@Test public void testGetProperty_withType_stringDefaultsToNull() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; String value = ingredient.getProperty(String.class, "foo"); assertEquals(null, value); }
@Test public void testGetProperty_withType_enumDefaultsToFirstDeclaredValue() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; TestEnum value = ingredient.getProperty(TestEnum.class, "foo"); assertEquals(TestEnum.A, value); }
@Test public void testGetProperty_withType_arrayDefaultsToEmptyArray() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; String[] value = ingredient.getProperty(String[].class, "foo"); assertArrayEquals(new String[0], value); }
@Test public void testGetProperty_withType_objectDefaultsToNull() { Ingredient ingredient = new Ingredient("TestIngredient", "A") {}; SomeClass value = ingredient.getProperty(SomeClass.class, "foo"); assertEquals(null, value); }