@Test public void testFindByName() { final String name = "item1"; final ItemDefinition item1 = makeItem("item1"); final ItemDefinition item2 = makeItem("item2"); final Definitions definitions = mock(Definitions.class); final List<ItemDefinition> itemDefinitions = asList(item1, item2); when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions); when(definitions.getItemDefinition()).thenReturn(itemDefinitions); final Optional<ItemDefinition> actual = utils.findByName(name); final Optional<ItemDefinition> expected = Optional.of(item1); assertEquals(expected, actual); }
public Optional<ItemDefinition> findByName(final String name) { return all() .stream() .filter(itemDefinition -> itemDefinition.getName().getValue().equals(name)) .findFirst(); }
ItemDefinitionUtils { public Optional<ItemDefinition> findByName(final String name) { return all() .stream() .filter(itemDefinition -> itemDefinition.getName().getValue().equals(name)) .findFirst(); } }
ItemDefinitionUtils { public Optional<ItemDefinition> findByName(final String name) { return all() .stream() .filter(itemDefinition -> itemDefinition.getName().getValue().equals(name)) .findFirst(); } @Inject  ItemDefinitionUtils(final DMNGraphUtils dmnGraphUtils); }
ItemDefinitionUtils { public Optional<ItemDefinition> findByName(final String name) { return all() .stream() .filter(itemDefinition -> itemDefinition.getName().getValue().equals(name)) .findFirst(); } @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); }
ItemDefinitionUtils { public Optional<ItemDefinition> findByName(final String name) { return all() .stream() .filter(itemDefinition -> itemDefinition.getName().getValue().equals(name)) .findFirst(); } @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);  }