use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityNotificationTest method testGetEntity.
@Test
public void testGetEntity() throws Exception {
Referenceable entity = getEntity("id");
EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
assertEquals(entity, entityNotification.getEntity());
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityNotificationTest method getEntity.
public static Referenceable getEntity(String id, Struct... traits) {
String typeName = "typeName";
List<String> traitNames = new LinkedList<>();
Map<String, Struct> traitMap = new HashMap<>();
for (Struct trait : traits) {
String traitName = trait.getTypeName();
traitNames.add(traitName);
traitMap.put(traitName, trait);
}
return new Referenceable(id, typeName, new HashMap<String, Object>(), traitNames, traitMap);
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityNotificationTest method testGetOperationType.
@Test
public void testGetOperationType() throws Exception {
Referenceable entity = getEntity("id");
EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
assertEquals(EntityNotificationV1.OperationType.ENTITY_CREATE, entityNotification.getOperationType());
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityNotificationTest method testEquals.
@Test
public void testEquals() throws Exception {
Referenceable entity = getEntity("id");
EntityNotificationV1 entityNotification2 = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
assertTrue(entityNotification.equals(entityNotification2));
assertTrue(entityNotification2.equals(entityNotification));
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityNotificationTest method testGetAllTraitsSuperTraits.
@Test
public void testGetAllTraitsSuperTraits() throws Exception {
AtlasTypeRegistry typeRegistry = mock(AtlasTypeRegistry.class);
String traitName = "MyTrait";
Struct myTrait = new Struct(traitName);
String superTraitName = "MySuperTrait";
AtlasClassificationType traitType = mock(AtlasClassificationType.class);
Set<String> superTypeNames = Collections.singleton(superTraitName);
AtlasClassificationType superTraitType = mock(AtlasClassificationType.class);
Set<String> superSuperTypeNames = Collections.emptySet();
Referenceable entity = getEntity("id", myTrait);
when(typeRegistry.getClassificationTypeByName(traitName)).thenReturn(traitType);
when(typeRegistry.getClassificationTypeByName(superTraitName)).thenReturn(superTraitType);
when(traitType.getAllSuperTypes()).thenReturn(superTypeNames);
when(superTraitType.getAllSuperTypes()).thenReturn(superSuperTypeNames);
EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.TRAIT_ADD, typeRegistry);
List<Struct> allTraits = entityNotification.getAllTraits();
assertEquals(2, allTraits.size());
for (Struct trait : allTraits) {
String typeName = trait.getTypeName();
assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName));
}
}
Aggregations