Commit a7869bee by Suma Shivaprasad

ATLAS-931 Delete entities fails when hard delete is configured (dkantor via sumasai)

parent 7666ae99
......@@ -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)
......
......@@ -216,9 +216,6 @@ public class EntityResource {
if (sample == null) {
sample = getSample(entityResult.getUpdateEntities());
}
if (sample == null) {
sample = getSample(entityResult.getDeletedEntities());
}
return sample;
}
......
/**
* 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));
}
}
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