Commit c0b4975b by Shwetha GS

ATLAS-300 Need additional integration test coverage for entity notifications…

ATLAS-300 Need additional integration test coverage for entity notifications (tbeerbower via shwethags)
parent 35d42ad1
...@@ -42,108 +42,108 @@ import static org.testng.Assert.assertTrue; ...@@ -42,108 +42,108 @@ import static org.testng.Assert.assertTrue;
*/ */
public class EntityNotificationImplTest { public class EntityNotificationImplTest {
@Test @Test
public void testGetEntity() throws Exception { public void testGetEntity() throws Exception {
Referenceable entity = getEntity("id"); Referenceable entity = getEntity("id");
EntityNotificationImpl entityNotification = EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
Collections.<IStruct>emptyList()); Collections.<IStruct>emptyList());
assertEquals(entity, entityNotification.getEntity()); assertEquals(entity, entityNotification.getEntity());
} }
@Test @Test
public void testGetOperationType() throws Exception { public void testGetOperationType() throws Exception {
Referenceable entity = getEntity("id"); Referenceable entity = getEntity("id");
EntityNotificationImpl entityNotification = EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
Collections.<IStruct>emptyList()); Collections.<IStruct>emptyList());
assertEquals(EntityNotification.OperationType.ENTITY_CREATE, entityNotification.getOperationType()); assertEquals(EntityNotification.OperationType.ENTITY_CREATE, entityNotification.getOperationType());
} }
@Test @Test
public void testGetAllTraits() throws Exception { public void testGetAllTraits() throws Exception {
Referenceable entity = getEntity("id"); Referenceable entity = getEntity("id");
String traitName = "MyTrait"; String traitName = "MyTrait";
List<IStruct> traitInfo = new LinkedList<>(); List<IStruct> traitInfo = new LinkedList<>();
IStruct trait = new Struct(traitName, Collections.<String, Object>emptyMap()); IStruct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
traitInfo.add(trait); traitInfo.add(trait);
EntityNotificationImpl entityNotification = EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, traitInfo); new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, traitInfo);
assertEquals(traitInfo, entityNotification.getAllTraits()); assertEquals(traitInfo, entityNotification.getAllTraits());
} }
@Test @Test
public void testGetAllTraits_superTraits() throws Exception { public void testGetAllTraits_superTraits() throws Exception {
TypeSystem typeSystem = mock(TypeSystem.class); TypeSystem typeSystem = mock(TypeSystem.class);
String traitName = "MyTrait"; String traitName = "MyTrait";
IStruct myTrait = new Struct(traitName); IStruct myTrait = new Struct(traitName);
String superTraitName = "MySuperTrait"; String superTraitName = "MySuperTrait";
TraitType traitDef = mock(TraitType.class); TraitType traitDef = mock(TraitType.class);
Set<String> superTypeNames = Collections.singleton(superTraitName); Set<String> superTypeNames = Collections.singleton(superTraitName);
TraitType superTraitDef = mock(TraitType.class); TraitType superTraitDef = mock(TraitType.class);
Set<String> superSuperTypeNames = Collections.emptySet(); Set<String> superSuperTypeNames = Collections.emptySet();
Referenceable entity = getEntity("id", myTrait); Referenceable entity = getEntity("id", myTrait);
when(typeSystem.getDataType(TraitType.class, traitName)).thenReturn(traitDef); when(typeSystem.getDataType(TraitType.class, traitName)).thenReturn(traitDef);
when(typeSystem.getDataType(TraitType.class, superTraitName)).thenReturn(superTraitDef); when(typeSystem.getDataType(TraitType.class, superTraitName)).thenReturn(superTraitDef);
when(traitDef.getAllSuperTypeNames()).thenReturn(superTypeNames); when(traitDef.getAllSuperTypeNames()).thenReturn(superTypeNames);
when(superTraitDef.getAllSuperTypeNames()).thenReturn(superSuperTypeNames); when(superTraitDef.getAllSuperTypeNames()).thenReturn(superSuperTypeNames);
EntityNotificationImpl entityNotification = EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, typeSystem); new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, typeSystem);
List<IStruct> allTraits = entityNotification.getAllTraits(); List<IStruct> allTraits = entityNotification.getAllTraits();
assertEquals(2, allTraits.size()); assertEquals(2, allTraits.size());
for (IStruct trait : allTraits) { for (IStruct trait : allTraits) {
String typeName = trait.getTypeName(); String typeName = trait.getTypeName();
assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName)); assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName));
}
} }
}
@Test @Test
public void testEquals() throws Exception { public void testEquals() throws Exception {
Referenceable entity = getEntity("id"); Referenceable entity = getEntity("id");
EntityNotificationImpl entityNotification2 = EntityNotificationImpl entityNotification2 =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
Collections.<IStruct>emptyList()); Collections.<IStruct>emptyList());
EntityNotificationImpl entityNotification = EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
Collections.<IStruct>emptyList()); Collections.<IStruct>emptyList());
assertTrue(entityNotification.equals(entityNotification2)); assertTrue(entityNotification.equals(entityNotification2));
assertTrue(entityNotification2.equals(entityNotification)); assertTrue(entityNotification2.equals(entityNotification));
} }
private Referenceable getEntity(String id, IStruct ... traits) { private Referenceable getEntity(String id, IStruct... traits) {
String typeName = "typeName"; String typeName = "typeName";
Map<String, Object> values = new HashMap<>(); Map<String, Object> values = new HashMap<>();
List<String> traitNames = new LinkedList<>(); List<String> traitNames = new LinkedList<>();
Map<String, IStruct> traitMap = new HashMap<>(); Map<String, IStruct> traitMap = new HashMap<>();
for (IStruct trait : traits) { for (IStruct trait : traits) {
String traitName = trait.getTypeName(); String traitName = trait.getTypeName();
traitNames.add(traitName); traitNames.add(traitName);
traitMap.put(traitName, trait); traitMap.put(traitName, trait);
}
return new Referenceable(id, typeName, values, traitNames, traitMap);
} }
return new Referenceable(id, typeName, values, traitNames, traitMap);
}
} }
\ No newline at end of file
...@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags) ...@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags) ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags)
ALL CHANGES: ALL CHANGES:
ATLAS-300 Need additional integration test coverage for entity notifications (tbeerbower via shwethags)
ATLAS-304 surefire fails to run tests if maven project directory path has embedded space(dkantor via sumasai) ATLAS-304 surefire fails to run tests if maven project directory path has embedded space(dkantor via sumasai)
ATLAS-301 Atlas Distribution module test is failing (yhemanth via shwethags) ATLAS-301 Atlas Distribution module test is failing (yhemanth via shwethags)
ATLAS-114 Upgrade hbase client to 1.1.2 (sumasai) ATLAS-114 Upgrade hbase client to 1.1.2 (sumasai)
......
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