You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by su...@apache.org on 2016/06/22 00:48:33 UTC
incubator-atlas git commit: ATLAS-931 Delete entities fails when hard
delete is configured (dkantor via sumasai)
Repository: incubator-atlas
Updated Branches:
refs/heads/master 7666ae996 -> a7869beeb
ATLAS-931 Delete entities fails when hard delete is configured (dkantor via sumasai)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/a7869bee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/a7869bee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/a7869bee
Branch: refs/heads/master
Commit: a7869beebf5cd32caebf86a24fd2661f6229c45a
Parents: 7666ae9
Author: Suma Shivaprasad <su...@gmail.com>
Authored: Tue Jun 21 17:48:34 2016 -0700
Committer: Suma Shivaprasad <su...@gmail.com>
Committed: Tue Jun 21 17:48:34 2016 -0700
----------------------------------------------------------------------
release-log.txt | 1 +
.../atlas/web/resources/EntityResource.java | 3 -
.../atlas/web/resources/EntityResourceTest.java | 74 ++++++++++++++++++++
3 files changed, 75 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a7869bee/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index e19209b..661bf21 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -40,6 +40,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
+ATLAS-931 Delete entities fails when hard delete is configured (dkantor via sumasai)
ATLAS-932 UI: 'create tag' button does not work (mneethiraj via sumasai)
ATLAS-928 UI is not showing the name column for hive tables in the schema tab (yhemanth via sumasai)
ATLAS-922 remove test atlas-application.properties embedded in atlas-typesystem.jar ( mneethiraj via sumasai)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a7869bee/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
index 76e8276..21ed04f 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
@@ -216,9 +216,6 @@ public class EntityResource {
if (sample == null) {
sample = getSample(entityResult.getUpdateEntities());
}
- if (sample == null) {
- sample = getSample(entityResult.getDeletedEntities());
- }
return sample;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a7869bee/webapp/src/test/java/org/apache/atlas/web/resources/EntityResourceTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityResourceTest.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityResourceTest.java
new file mode 100644
index 0000000..3fe8e11
--- /dev/null
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityResourceTest.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.web.resources;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.atlas.AtlasClient.EntityResult;
+import org.apache.atlas.services.MetadataService;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Unit test of {@link EntityResource}
+ */
+public class EntityResourceTest {
+
+ private static final String DELETED_GUID = "deleted_guid";
+
+ @Mock
+ MetadataService mockService;
+
+ @BeforeMethod
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testDeleteEntitiesDoesNotLookupDeletedEntity() throws Exception {
+ List<String> guids = Collections.singletonList(DELETED_GUID);
+
+ // Create EntityResult with a deleted guid and no other guids.
+ EntityResult entityResult = new EntityResult(Collections.<String>emptyList(),
+ Collections.<String>emptyList(), guids);
+ when(mockService.deleteEntities(guids)).thenReturn(entityResult);
+
+ // Create EntityResource with mock MetadataService.
+ EntityResource entityResource = new EntityResource(mockService);
+
+ Response response = entityResource.deleteEntities(guids, null, null, null);
+
+ // Verify that if the EntityResult returned by MetadataService includes only deleted guids,
+ // deleteEntities() does not perform any entity lookup.
+ verify(mockService, never()).getEntityDefinition(Matchers.anyString());
+
+ EntityResult resultFromEntityResource = EntityResult.fromString(response.getEntity().toString());
+ Assert.assertTrue(resultFromEntityResource.getDeletedEntities().contains(DELETED_GUID));
+ }
+}