ATLAS-1979: Update storm model relationship category and fix for UT and Coverity scan issues
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
diff --git a/addons/models/0080-storm_model.json b/addons/models/0080-storm_model.json
index b008c7a..ab3d603 100644
--- a/addons/models/0080-storm_model.json
+++ b/addons/models/0080-storm_model.json
@@ -147,7 +147,7 @@
{
"name": "storm_topology_nodes",
"typeVersion": "1.0",
- "relationshipCategory": "ASSOCIATION",
+ "relationshipCategory": "AGGREGATION",
"endDef1": {
"type": "storm_topology",
"name": "nodes",
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
index 1282be5..b8fd70e 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
@@ -1075,7 +1075,7 @@
String newEntityId = getIdFromVertex(newEntityVertex);
AtlasEdge ret = currentEdge;
- if (!currentEntityId.equals(newEntityId) && newEntityVertex != null) {
+ if (!currentEntityId.equals(newEntityId)) {
// create a new relationship edge to the new attribute vertex from the instance
String relationshipName = AtlasGraphUtilsV1.getTypeName(currentEdge);
@@ -1230,6 +1230,11 @@
// get the classification vertex from entity
String relationshipLabel = GraphHelper.getTraitLabel(entityTypeName, classification.getTypeName());
AtlasEdge classificationEdge = graphHelper.getEdgeForLabel(instanceVertex, relationshipLabel);
+
+ if (classificationEdge == null) {
+ throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "classificationEdge is null for label: " + relationshipLabel);
+ }
+
AtlasVertex classificationVertex = classificationEdge.getInVertex();
if (LOG.isDebugEnabled()) {
@@ -1363,7 +1368,7 @@
private boolean objectIdsContain(Collection<AtlasObjectId> objectIds, AtlasObjectId objectId) {
boolean ret = false;
- if (objectIds != null && objectIds.isEmpty()) {
+ if (CollectionUtils.isEmpty(objectIds)) {
ret = false;
} else {
diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateSoftDeleteTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateSoftDeleteTest.java
index c5eda37..ce43bdc 100644
--- a/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateSoftDeleteTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateSoftDeleteTest.java
@@ -48,6 +48,7 @@
AtlasVertex vertexForGUID = GraphHelper.getInstance().getVertexForGUID(referencingInstance.getId()._getId());
String edgeLabel = GraphHelper.getEdgeLabel(typeB, typeB.fieldMapping.fields.get("a"));
AtlasEdge edgeForLabel = GraphHelper.getInstance().getEdgeForLabel(vertexForGUID, edgeLabel);
+ Assert.assertNotNull(edgeForLabel);
String edgeState = edgeForLabel.getProperty(Constants.STATE_PROPERTY_KEY, String.class);
Assert.assertEquals(edgeState, Id.EntityState.DELETED.name());
}
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
index 31efe86..3ebda0d 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
@@ -169,7 +169,7 @@
assertObjectIdEquals(johnMentorId, maxId);
List<AtlasObjectId> johnMenteesId = toAtlasObjectIds(john.getRelationshipAttribute("mentees"));
- assertNull(johnMenteesId);
+ assertEmpty(johnMenteesId);
// Jane Manager validation
AtlasObjectId janeDepartmentId = toAtlasObjectId(jane.getRelationshipAttribute("department"));
@@ -183,7 +183,7 @@
assertNull(janeMentorId);
List<AtlasObjectId> janeMenteesId = toAtlasObjectIds(jane.getRelationshipAttribute("mentees"));
- assertNull(janeMenteesId);
+ assertEmpty(janeMenteesId);
List<AtlasObjectId> janeSubordinateIds = toAtlasObjectIds(jane.getRelationshipAttribute("subordinates"));
assertNotNull(janeSubordinateIds);
@@ -208,7 +208,7 @@
assertObjectIdsContains(juliusMenteesId, maxId);
List<AtlasObjectId> juliusSubordinateIds = toAtlasObjectIds(julius.getRelationshipAttribute("subordinates"));
- assertNull(juliusSubordinateIds);
+ assertEmpty(juliusSubordinateIds);
}
@Test
@@ -444,6 +444,10 @@
assertTrue(objId1.equals(objId2));
}
+ private static void assertEmpty(List collection) {
+ assertTrue(collection != null && collection.isEmpty());
+ }
+
private static List<AtlasObjectId> toAtlasObjectIds(Object objectIds) {
if (objectIds instanceof List) {
return (List<AtlasObjectId>) objectIds;