Commit 39c52b2b by Shwetha GS

ATLAS-79 Unique constraint is not honoured (shwethags)

parent 96059e0a
......@@ -8,6 +8,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (suma.shivaprasad via shwethags)
ALL CHANGES:
ATLAS-79 Unique constraint is not honoured (shwethags)
ATLAS-25 Fix Atlas on Java 8 (sandeep.samudrala via shwethags)
ATLAS-86 Jenkins build failing as of build #41 (shwethags)
ATLAS-80 Support for variables in application properties (shwethags)
......
......@@ -26,19 +26,16 @@ public final class Constants {
public static final String INTERNAL_PROPERTY_KEY_PREFIX = "__";
public static final String GUID_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "guid";
public static final String GUID_INDEX = "guid_index";
/**
* Entity type name property key.
*/
public static final String ENTITY_TYPE_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "typeName";
public static final String ENTITY_TYPE_INDEX = "type_index";
/**
* Entity type's super types property key.
*/
public static final String SUPER_TYPES_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "superTypeNames";
public static final String SUPER_TYPES_INDEX = "super_types_index";
/**
* Full-text for the entity for enabling full-text search.
......@@ -57,7 +54,6 @@ public final class Constants {
* Trait names property key and index name.
*/
public static final String TRAIT_NAMES_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "traitNames";
public static final String TRAIT_NAMES_INDEX = "trait_names_index";
public static final String VERSION_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "version";
public static final String TIMESTAMP_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "timestamp";
......
......@@ -116,6 +116,49 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
@Test
public void testUniqueAttribute() throws Exception {
//create type
String typeName = "type" + randomString();
HierarchicalTypeDefinition<ClassType> typeDefinition = TypesUtil
.createClassTypeDef(typeName, ImmutableList.<String>of(),
TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE));
TypesDef typesDef = TypeUtils
.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
ImmutableList.of(typeDefinition));
createType(typesDef);
//create entity
String name = "name" + randomString();
Referenceable referenceable = new Referenceable(typeName);
referenceable.set("name", name);
createInstance(referenceable);
//create entity with same name again - should fail
try {
createInstance(referenceable);
Assert.fail("Expected exception");
} catch(Exception e) {
//expected exception
}
//create another type with same attribute - should allow
typeName = "type" + randomString();
typeDefinition = TypesUtil
.createClassTypeDef(typeName, ImmutableList.<String>of(),
TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE));
typesDef = TypeUtils
.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
ImmutableList.of(typeDefinition));
createType(typesDef);
referenceable = new Referenceable(typeName);
referenceable.set("name", name);
createInstance(referenceable);
}
@Test
public void testSubmitEntityWithBadDateFormat() throws Exception {
try {
......
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