Return-Path: X-Original-To: apmail-atlas-commits-archive@minotaur.apache.org Delivered-To: apmail-atlas-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4CFCF18BF5 for ; Fri, 18 Dec 2015 10:44:11 +0000 (UTC) Received: (qmail 53215 invoked by uid 500); 18 Dec 2015 10:44:11 -0000 Delivered-To: apmail-atlas-commits-archive@atlas.apache.org Received: (qmail 53182 invoked by uid 500); 18 Dec 2015 10:44:11 -0000 Mailing-List: contact commits-help@atlas.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.incubator.apache.org Delivered-To: mailing list commits@atlas.incubator.apache.org Received: (qmail 53173 invoked by uid 99); 18 Dec 2015 10:44:11 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2015 10:44:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id BF2EF1804B0 for ; Fri, 18 Dec 2015 10:44:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.226 X-Spam-Level: * X-Spam-Status: No, score=1.226 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.554] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id O_5wzHD7C20W for ; Fri, 18 Dec 2015 10:44:08 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id D383A31A99 for ; Fri, 18 Dec 2015 10:44:03 +0000 (UTC) Received: (qmail 51434 invoked by uid 99); 18 Dec 2015 10:44:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2015 10:44:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6C0C0E0104; Fri, 18 Dec 2015 10:44:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sumasai@apache.org To: commits@atlas.incubator.apache.org Date: Fri, 18 Dec 2015 10:44:23 -0000 Message-Id: In-Reply-To: <97cfde4902f74bc5a42d57f6e7845572@git.apache.org> References: <97cfde4902f74bc5a42d57f6e7845572@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/26] incubator-atlas git commit: Removing accidental file commit - GraphBackedMetadataRepositoryDeleteEntitiesTest Removing accidental file commit - GraphBackedMetadataRepositoryDeleteEntitiesTest Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/fa502b21 Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/fa502b21 Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/fa502b21 Branch: refs/heads/branch-0.6-incubating Commit: fa502b21700fb3c05c0ee8df1ed0f7525b7d3030 Parents: ae1d636 Author: Suma Shivaprasad Authored: Thu Dec 17 22:41:23 2015 +0530 Committer: Suma Shivaprasad Committed: Thu Dec 17 22:41:38 2015 +0530 ---------------------------------------------------------------------- ...kedMetadataRepositoryDeleteEntitiesTest.java | 189 ------------------- 1 file changed, 189 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fa502b21/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteEntitiesTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteEntitiesTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteEntitiesTest.java deleted file mode 100644 index e63f6d3..0000000 --- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteEntitiesTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * 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.repository.graph; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import org.apache.atlas.RepositoryMetadataModule; -import org.apache.atlas.TestUtils; -import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.util.TitanCleanup; -import com.tinkerpop.blueprints.Vertex; - -/** - * Test for GraphBackedMetadataRepository.deleteEntities - * - * Guice loads the dependencies and injects the necessary objects - * - */ -@Guice(modules = RepositoryMetadataModule.class) -public class GraphBackedMetadataRepositoryDeleteEntitiesTest { - - @Inject - private GraphProvider graphProvider; - - @Inject - private GraphBackedMetadataRepository repositoryService; - - @Inject - private GraphBackedDiscoveryService discoveryService; - - private TypeSystem typeSystem; - - @BeforeClass - public void setUp() throws Exception { - typeSystem = TypeSystem.getInstance(); - typeSystem.reset(); - - new GraphBackedSearchIndexer(graphProvider); - - TestUtils.defineDeptEmployeeTypes(typeSystem); - TestUtils.createHiveTypes(typeSystem); - } - - - @AfterClass - public void tearDown() throws Exception { - TypeSystem.getInstance().reset(); - try { - graphProvider.get().shutdown(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - TitanCleanup.clear(graphProvider.get()); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - @Test - public void testDeleteEntities() throws Exception { - String hrDeptGuid = createHrDeptGraph(); - - ITypedReferenceableInstance hrDept = repositoryService.getEntityDefinition(hrDeptGuid); - Object refValue = hrDept.get("employees"); - Assert.assertTrue(refValue instanceof List); - List employees = (List)refValue; - Assert.assertEquals(employees.size(), 4); - List employeeGuids = new ArrayList(4); - for (Object listValue : employees) { - Assert.assertTrue(listValue instanceof ITypedReferenceableInstance); - ITypedReferenceableInstance employee = (ITypedReferenceableInstance) listValue; - employeeGuids.add(employee.getId()._getId()); - } - - // There should be 4 vertices for Address structs (one for each Person.address attribute value). - int vertexCount = countVertices(Constants.ENTITY_TYPE_PROPERTY_KEY, "Address"); - Assert.assertEquals(vertexCount, 4); - vertexCount = countVertices(Constants.ENTITY_TYPE_PROPERTY_KEY, "SecurityClearance"); - Assert.assertEquals(vertexCount, 1); - - List deletedEntities = repositoryService.deleteEntities(hrDeptGuid); - Assert.assertTrue(deletedEntities.contains(hrDeptGuid)); - - // Verify Department entity and its contained Person entities were deleted. - verifyEntityDoesNotExist(hrDeptGuid); - for (String employeeGuid : employeeGuids) { - verifyEntityDoesNotExist(employeeGuid); - } - // Verify all Person.address struct vertices were removed. - vertexCount = countVertices(Constants.ENTITY_TYPE_PROPERTY_KEY, "Address"); - Assert.assertEquals(vertexCount, 0); - - // Verify all SecurityClearance trait vertices were removed. - vertexCount = countVertices(Constants.ENTITY_TYPE_PROPERTY_KEY, "SecurityClearance"); - Assert.assertEquals(vertexCount, 0); - } - - @Test(dependsOnMethods = "testDeleteEntities") - public void testDeleteContainedEntity() throws Exception { - String hrDeptGuid = createHrDeptGraph(); - ITypedReferenceableInstance hrDept = repositoryService.getEntityDefinition(hrDeptGuid); - Object refValue = hrDept.get("employees"); - Assert.assertTrue(refValue instanceof List); - List employees = (List)refValue; - Assert.assertEquals(employees.size(), 4); - Object listValue = employees.get(2); - Assert.assertTrue(listValue instanceof ITypedReferenceableInstance); - ITypedReferenceableInstance employee = (ITypedReferenceableInstance) listValue; - String employeeGuid = employee.getId()._getId(); - - List deletedEntities = repositoryService.deleteEntities(employeeGuid); - Assert.assertTrue(deletedEntities.contains(employeeGuid)); - verifyEntityDoesNotExist(employeeGuid); - - } - - private String createHrDeptGraph() throws Exception { - Referenceable deptEg1 = TestUtils.createDeptEg1(typeSystem); - ClassType deptType = typeSystem.getDataType(ClassType.class, "Department"); - ITypedReferenceableInstance hrDept2 = deptType.convert(deptEg1, Multiplicity.REQUIRED); - - List guids = repositoryService.createEntities(hrDept2); - Assert.assertNotNull(guids); - Assert.assertEquals(guids.size(), 5); - List entityList = repositoryService.getEntityList("Department"); - Assert.assertNotNull(entityList); - Assert.assertEquals(entityList.size(), 1); - String hrDeptGuid = entityList.get(0); - return hrDeptGuid; - } - - private int countVertices(String propertyName, Object value) { - Iterable vertices = graphProvider.get().getVertices(propertyName, value); - int vertexCount = 0; - for (Vertex vertex : vertices) { - vertexCount++; - } - return vertexCount; - } - - private void verifyEntityDoesNotExist(String hrDeptGuid) throws RepositoryException { - - try { - repositoryService.getEntityDefinition(hrDeptGuid); - Assert.fail("EntityNotFoundException was expected but none thrown"); - } - catch(EntityNotFoundException e) { - // good - } - } - -}