This is an automated email from the ASF dual-hosted git repository.

sarath pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new e21f569  ATLAS-2901: Change classification name rule - Support 
multiple languages (unicode)
e21f569 is described below

commit e21f569f21736237dab8cb2bc8e34a232ee5fa9d
Author: Yu-Hsin Shih <[email protected]>
AuthorDate: Tue May 7 13:26:30 2019 -0700

    ATLAS-2901: Change classification name rule - Support multiple languages 
(unicode)
    
    Signed-off-by: Sarath Subramanian <[email protected]>
---
 .../main/java/org/apache/atlas/AtlasErrorCode.java |  2 +-
 .../graph/v2/AtlasClassificationDefStoreV2.java    |  2 +-
 .../v2/AtlasClassificationDefStoreV2Test.java      | 68 ++++++++++++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java 
b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index c04f561..0790998 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -52,7 +52,7 @@ public enum AtlasErrorCode {
     PATCH_NOT_APPLICABLE_FOR_TYPE(400, "ATLAS-400-00-016", "{0} - invalid 
patch for type {1}"),
     PATCH_FOR_UNKNOWN_TYPE(400, "ATLAS-400-00-017", "{0} - patch references 
unknown type {1}"),
     PATCH_INVALID_DATA(400, "ATLAS-400-00-018", "{0} - patch data is invalid 
for type {1}"),
-    TYPE_NAME_INVALID_FORMAT(400, "ATLAS-400-00-019", "{0}: invalid name for 
{1}.  Names must consist of a letter followed by a sequence of letter, number, 
or '_' characters"),
+    TYPE_NAME_INVALID_FORMAT(400, "ATLAS-400-00-019", "{0}: invalid name for 
{1}.  Names must consist of a letter followed by a sequence of letter, number, 
space, or '_' characters"),
     ATTRIBUTE_NAME_INVALID(400, "ATLAS-400-00-020", "{0}: invalid name. 
Attribute name must not contain query keywords"),
     INVALID_PARAMETERS(400, "ATLAS-400-00-01A", "invalid parameters: {0}"),
     CLASSIFICATION_ALREADY_ASSOCIATED(400, "ATLAS-400-00-01B", "instance {0} 
already is associated with classification {1}"),
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
index dd020d1..9ffede4 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
@@ -48,7 +48,7 @@ import static 
org.apache.atlas.repository.Constants.TYPENAME_PROPERTY_KEY;
 class AtlasClassificationDefStoreV2 extends 
AtlasAbstractDefStoreV2<AtlasClassificationDef> {
     private static final Logger LOG = 
LoggerFactory.getLogger(AtlasClassificationDefStoreV2.class);
 
-    private static final String  TRAIT_NAME_REGEX   = "[a-zA-Z][a-zA-Z0-9_ 
.]*";
+    private static final String  TRAIT_NAME_REGEX   = 
"[a-zA-Z[^\\p{ASCII}]][a-zA-Z0-9[^\\p{ASCII}]_ .]*";
 
     private static final Pattern TRAIT_NAME_PATTERN = 
Pattern.compile(TRAIT_NAME_REGEX);
 
diff --git 
a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java
 
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java
new file mode 100644
index 0000000..3242a33
--- /dev/null
+++ 
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2Test.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.repository.store.graph.v2;
+
+import static org.testng.Assert.assertEquals;
+
+import com.google.inject.Inject;
+import org.apache.atlas.TestModules;
+import org.apache.atlas.type.AtlasTypeRegistry;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for AtlasClassificationDefStoreV2
+ */
+@Guice(modules = TestModules.TestOnlyModule.class)
+public class AtlasClassificationDefStoreV2Test {
+  private AtlasClassificationDefStoreV2 classificationDefStore;
+
+  @Inject
+  AtlasTypeRegistry atlasTypeRegistry;
+
+  @Inject
+  AtlasTypeDefGraphStoreV2 typeDefStore;
+
+  @BeforeClass
+  public void setUp() {
+    classificationDefStore = new AtlasClassificationDefStoreV2(typeDefStore, 
atlasTypeRegistry);
+  }
+
+  @DataProvider
+  public Object[][] traitRegexString() {
+    // Test unicode regex for classification
+    return new Object[][] {
+      {"test1", true},
+      {"\u597D", true},
+      {"\u597D\u597D", true},
+      {"\u597D \u597D", true},
+      {"\u597D_\u597D", true},
+      {"\u597D.\u597D", true},
+      {"class1.attr1", true},
+      {"1test", false},
+      {"_test1", false},
+    };
+  }
+
+  @Test(dataProvider = "traitRegexString")
+  public void testIsValidName(String data, boolean expected) {
+    assertEquals(classificationDefStore.isValidName(data), expected);
+  }
+}
\ No newline at end of file

Reply via email to