### Question:
ItemDefinitionUtils { public String getConstraintText(final ItemDefinition itemDefinition) { return Optional .ofNullable(itemDefinition.getAllowedValues()) .map(UnaryTests::getText) .orElse(new Text()) .getValue(); } @Inject  ItemDefinitionUtils(final DMNGraphUtils dmnGraphUtils); Optional<ItemDefinition> findByName(final String name); List<ItemDefinition> all(); void addItemDefinitions(final List<ItemDefinition> newItemDefinitions); String getConstraintText(final ItemDefinition itemDefinition); QName normaliseTypeRef(final QName typeRef);  }### Answer:
@Test public void testGetConstraintTextWhenItemDefinitionDoesNotHaveAllowedValues() { final ItemDefinition itemDefinition = mock(ItemDefinition.class); final String expectedText = ""; final String actualText = utils.getConstraintText(itemDefinition); assertEquals(expectedText, actualText); }
@Test public void testGetConstraintTextWhenItemDefinitionHasAllowedValues() { final ItemDefinition itemDefinition = mock(ItemDefinition.class); final UnaryTests allowedValues = mock(UnaryTests.class); final String expectedText = "(1..10)"; when(allowedValues.getText()).thenReturn(new Text(expectedText)); when(itemDefinition.getAllowedValues()).thenReturn(allowedValues); final String actualText = utils.getConstraintText(itemDefinition); assertEquals(expectedText, actualText); }