@Test(expected = IllegalIndexException.class) public void testValidate_indexName3() { char[] invalidBeginChars = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')'}; Random randomGenerator = new Random(); String indexName = String.valueOf(invalidBeginChars[randomGenerator.nextInt(invalidBeginChars.length)]); IndexInfo idx = new IndexInfo(indexName); idx.validate(); }
public void validate() { checkIndexName(); CheckConditions.checkCondition(keyList.size() < CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX, new IllegalIndexException("The number of fields in a compound index can not be exceed " + CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX)); for (String key : keyList) { if (!PATTERN.matcher(key).matches()) { throw new IllegalIndexException("key name must be valid attribute name characters of [A-Za-z0-9_]*!"); } } if (options.contains(IndexOptionEnum.hashed)) { if (options.contains(IndexOptionEnum.unique)) { throw new IllegalIndexException("Currently hashed indexes cannot guarantee uniqueness!"); } if (keyList.size() > 1) { throw new IllegalIndexException("Currently only single field hashed index supported!"); } } }
IndexInfo { public void validate() { checkIndexName(); CheckConditions.checkCondition(keyList.size() < CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX, new IllegalIndexException("The number of fields in a compound index can not be exceed " + CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX)); for (String key : keyList) { if (!PATTERN.matcher(key).matches()) { throw new IllegalIndexException("key name must be valid attribute name characters of [A-Za-z0-9_]*!"); } } if (options.contains(IndexOptionEnum.hashed)) { if (options.contains(IndexOptionEnum.unique)) { throw new IllegalIndexException("Currently hashed indexes cannot guarantee uniqueness!"); } if (keyList.size() > 1) { throw new IllegalIndexException("Currently only single field hashed index supported!"); } } } }
IndexInfo { public void validate() { checkIndexName(); CheckConditions.checkCondition(keyList.size() < CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX, new IllegalIndexException("The number of fields in a compound index can not be exceed " + CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX)); for (String key : keyList) { if (!PATTERN.matcher(key).matches()) { throw new IllegalIndexException("key name must be valid attribute name characters of [A-Za-z0-9_]*!"); } } if (options.contains(IndexOptionEnum.hashed)) { if (options.contains(IndexOptionEnum.unique)) { throw new IllegalIndexException("Currently hashed indexes cannot guarantee uniqueness!"); } if (keyList.size() > 1) { throw new IllegalIndexException("Currently only single field hashed index supported!"); } } } IndexInfo();  IndexInfo(String idxName);  IndexInfo(String idxName, boolean internal);  IndexInfo(IndexInfo other, MetaRelationship field); }
IndexInfo { public void validate() { checkIndexName(); CheckConditions.checkCondition(keyList.size() < CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX, new IllegalIndexException("The number of fields in a compound index can not be exceed " + CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX)); for (String key : keyList) { if (!PATTERN.matcher(key).matches()) { throw new IllegalIndexException("key name must be valid attribute name characters of [A-Za-z0-9_]*!"); } } if (options.contains(IndexOptionEnum.hashed)) { if (options.contains(IndexOptionEnum.unique)) { throw new IllegalIndexException("Currently hashed indexes cannot guarantee uniqueness!"); } if (keyList.size() > 1) { throw new IllegalIndexException("Currently only single field hashed index supported!"); } } } IndexInfo();  IndexInfo(String idxName);  IndexInfo(String idxName, boolean internal);  IndexInfo(IndexInfo other, MetaRelationship field); void addKeyField(String fieldName); String getIndexName(); void setIndexName(String idxName); List<String> getKeyList(); List<IndexInfo.IndexOptionEnum> getIndexOptions(); void addOption(IndexOptionEnum option); void removeOption(IndexOptionEnum option); void validate(); @JsonIgnore boolean isOverridable(IndexInfo info); @JsonIgnore boolean isInternal(); static List<IndexInfo> getInternalIndexes(); }
IndexInfo { public void validate() { checkIndexName(); CheckConditions.checkCondition(keyList.size() < CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX, new IllegalIndexException("The number of fields in a compound index can not be exceed " + CMSConsts.MAX_FIELDS_OF_COMPOUND_INDEX)); for (String key : keyList) { if (!PATTERN.matcher(key).matches()) { throw new IllegalIndexException("key name must be valid attribute name characters of [A-Za-z0-9_]*!"); } } if (options.contains(IndexOptionEnum.hashed)) { if (options.contains(IndexOptionEnum.unique)) { throw new IllegalIndexException("Currently hashed indexes cannot guarantee uniqueness!"); } if (keyList.size() > 1) { throw new IllegalIndexException("Currently only single field hashed index supported!"); } } } IndexInfo();  IndexInfo(String idxName);  IndexInfo(String idxName, boolean internal);  IndexInfo(IndexInfo other, MetaRelationship field); void addKeyField(String fieldName); String getIndexName(); void setIndexName(String idxName); List<String> getKeyList(); List<IndexInfo.IndexOptionEnum> getIndexOptions(); void addOption(IndexOptionEnum option); void removeOption(IndexOptionEnum option); void validate(); @JsonIgnore boolean isOverridable(IndexInfo info); @JsonIgnore boolean isInternal(); static List<IndexInfo> getInternalIndexes(); static final String OID_INDEX; static final String PK_INDEX; static final String INDEX_PREFIX; static final String INDEX_POSTFIX; static final String LAST_MODIFIED_INDEX; }