ItemFactory implements IItemFactory { @Override public ItemRef createNewItemRef(final String name, final String alias, final String description, final String required, final String reference) throws APIRestGeneratorException { ItemRef itemRef = null ; final Pattern pattern = Pattern.compile(ConstantsInput.PATT_DEFINITION_REF) ; final Matcher matcher = pattern.matcher(reference) ; if (matcher.matches()) { final String itemRefString = matcher.group(1) ; if (!this.mainItemsMap.containsKey(itemRefString)) { final String errorString = "The following reference was not found in the items map: " + itemRefString ; ItemFactory.LOGGER.error(errorString) ; throw new APIRestGeneratorException(errorString) ; } itemRef = new ItemRef(name, alias, description, required, itemRefString) ; } else { final String errorString = "The following reference was not defined properly to be search in the items map: " + reference ; ItemFactory.LOGGER.error(errorString) ; throw new APIRestGeneratorException(errorString) ; } return itemRef ; } ItemFactory(final Map<String, Item> mainItemsMap); @Override boolean isSimpleItem(final String type); @Override Item createNewSimpleItem(final String name,
									final String alias,
						   	  		final String description,
						   	  		final String required,
						   	  		final String type,
						   	  		final String format); @Override boolean isArrayItem(final String type); @Override ItemArray createNewArray(final String name, final String alias, final String description, final String required); @Override ItemRef createNewItemRef(final String name,
    								final String alias,
    								final String description,
    								final String required,
    								final String reference); @Override boolean isComplexItem(final String type); @Override ItemComplex createNewItemComplex(final String name, final String alias, final String description, final String required); @Override boolean isFileItem(final String type); @Override ItemFile createNewItemFile(final String name, final String alias, final String description, final String required);  }
@Test(expected = APIRestGeneratorException.class) public void invalidItemRef() throws APIRestGeneratorException { final ItemFactory itemFactory = ItemFactoryTest.generateDummyItemFactory() ; itemFactory.createNewItemRef(ConstantsTest.ITEM_NAME, ConstantsTest.ALIAS, ConstantsTest.DESCRIPTION, ConstantsTest.REQUIRED, ConstantsTest.REFERENCE_DEFINITIONS) ; }