Commit 883251c0 by Shwetha GS

ATLAS-33 Atlas restart fails (shwethags)

parent 155554e6
......@@ -6,13 +6,13 @@ Apache Atlas Release Notes
INCOMPATIBLE CHANGES:
ALL CHANGES:
ATLAS-33 Atlas restart fails (shwethags)
ATLAS-10 Update trunk version to 0.6-incubating-SNAPSHOT (shwethags)
--Release 0.5-incubating
ALL CHANGES:
ATLAS-26 Minor issues with release prep (Venkatesh Seetharam)
ATLAS-17 Parameterize schema API query per typeName (shwethags)
ATLAS-13 Add project website (Venkatesh Seetharam)
......
......@@ -340,12 +340,16 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A
@Override
public int compareTo(ST o) {
String oName = o.getName();
if (superTypes.contains(oName)) {
return 1;
} else if (o.superTypes.contains(getName())) {
return -1;
} else {
return getName().compareTo(oName);
try {
if (o.isSubType(getName())) {
return 1;
} else if (isSubType(oName)) {
return -1;
} else {
return getName().compareTo(oName);
}
} catch(AtlasException e) {
throw new RuntimeException(e);
}
}
......
......@@ -19,6 +19,7 @@
package org.apache.atlas.typesystem.types;
import com.google.common.collect.ImmutableList;
import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.commons.lang3.RandomStringUtils;
import org.testng.Assert;
......@@ -118,4 +119,23 @@ public class TypeSystemTest extends BaseTest {
ts.defineTypes(ImmutableList.of(structType), ImmutableList.of(traitType), ImmutableList.of(classType));
}
@Test
public void testHierarchy() throws AtlasException {
HierarchicalTypeDefinition<ClassType> a = TypesUtil.createClassTypeDef("a", ImmutableList.<String>of());
HierarchicalTypeDefinition<ClassType> b = TypesUtil.createClassTypeDef("B", ImmutableList.of("a"));
HierarchicalTypeDefinition<ClassType> c = TypesUtil.createClassTypeDef("C", ImmutableList.of("B"));
TypeSystem ts = getTypeSystem();
ts.defineTypes(ImmutableList.<StructTypeDefinition>of(),
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
ImmutableList.of(a, b, c));
ClassType ac = ts.getDataType(ClassType.class, "a");
ClassType bc = ts.getDataType(ClassType.class, "B");
ClassType cc = ts.getDataType(ClassType.class, "C");
Assert.assertTrue(ac.compareTo(bc) < 0);
Assert.assertTrue(bc.compareTo(cc) < 0);
Assert.assertTrue(ac.compareTo(cc) < 0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment