Commit 1dee77af by Ashutosh Mestry Committed by Madhan Neethiraj

ATLAS-2146: Remove Powermock Usage

parent 2bcbd259
...@@ -33,12 +33,6 @@ ...@@ -33,12 +33,6 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-reflect</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-intg</artifactId> <artifactId>atlas-intg</artifactId>
</dependency> </dependency>
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
package org.apache.atlas.discovery; package org.apache.atlas.discovery;
import com.google.common.annotations.VisibleForTesting;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasConfiguration; import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -770,7 +771,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -770,7 +771,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
return ""; return "";
} }
private static String getTypeFilter(AtlasTypeRegistry typeRegistry, String typeName, int maxTypesLengthInIdxQuery) { @VisibleForTesting
static String getTypeFilter(AtlasTypeRegistry typeRegistry, String typeName, int maxTypesLengthInIdxQuery) {
AtlasEntityType type = typeRegistry.getEntityTypeByName(typeName); AtlasEntityType type = typeRegistry.getEntityTypeByName(typeName);
String typeAndSubTypesQryStr = type != null ? type.getTypeAndAllSubTypesQryStr() : null; String typeAndSubTypesQryStr = type != null ? type.getTypeAndAllSubTypesQryStr() : null;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
package org.apache.atlas.repository.impexp; package org.apache.atlas.repository.impexp;
import com.google.common.annotations.VisibleForTesting;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
...@@ -167,7 +168,8 @@ public class ExportService { ...@@ -167,7 +168,8 @@ public class ExportService {
return statuses; return statuses;
} }
private AtlasExportResult.OperationStatus getOverallOperationStatus(AtlasExportResult.OperationStatus... statuses) { @VisibleForTesting
AtlasExportResult.OperationStatus getOverallOperationStatus(AtlasExportResult.OperationStatus... statuses) {
AtlasExportResult.OperationStatus overall = (statuses.length == 0) ? AtlasExportResult.OperationStatus overall = (statuses.length == 0) ?
AtlasExportResult.OperationStatus.FAIL : statuses[0]; AtlasExportResult.OperationStatus.FAIL : statuses[0];
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
package org.apache.atlas.repository.impexp; package org.apache.atlas.repository.impexp;
import com.google.common.annotations.VisibleForTesting;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasImportResult; import org.apache.atlas.model.impexp.AtlasImportResult;
...@@ -92,7 +93,8 @@ public class TypeAttributeDifference { ...@@ -92,7 +93,8 @@ public class TypeAttributeDifference {
} }
} }
private boolean addElements(AtlasEnumDef existing, AtlasEnumDef incoming) throws AtlasBaseException { @VisibleForTesting
boolean addElements(AtlasEnumDef existing, AtlasEnumDef incoming) throws AtlasBaseException {
return addElements(existing, getElementsAbsentInExisting(existing, incoming)); return addElements(existing, getElementsAbsentInExisting(existing, incoming));
} }
...@@ -100,7 +102,8 @@ public class TypeAttributeDifference { ...@@ -100,7 +102,8 @@ public class TypeAttributeDifference {
return addAttributes(existing, getElementsAbsentInExisting(existing, incoming)); return addAttributes(existing, getElementsAbsentInExisting(existing, incoming));
} }
private List<AtlasStructDef.AtlasAttributeDef> getElementsAbsentInExisting(AtlasStructDef existing, AtlasStructDef incoming) throws AtlasBaseException { @VisibleForTesting
List<AtlasStructDef.AtlasAttributeDef> getElementsAbsentInExisting(AtlasStructDef existing, AtlasStructDef incoming) throws AtlasBaseException {
List<AtlasStructDef.AtlasAttributeDef> difference = new ArrayList<>(); List<AtlasStructDef.AtlasAttributeDef> difference = new ArrayList<>();
for (AtlasStructDef.AtlasAttributeDef attr : incoming.getAttributeDefs()) { for (AtlasStructDef.AtlasAttributeDef attr : incoming.getAttributeDefs()) {
updateCollectionWithDifferingAttributes(difference, existing, attr); updateCollectionWithDifferingAttributes(difference, existing, attr);
...@@ -123,7 +126,8 @@ public class TypeAttributeDifference { ...@@ -123,7 +126,8 @@ public class TypeAttributeDifference {
} }
} }
private List<AtlasEnumDef.AtlasEnumElementDef> getElementsAbsentInExisting(AtlasEnumDef existing, AtlasEnumDef incoming) throws AtlasBaseException { @VisibleForTesting
List<AtlasEnumDef.AtlasEnumElementDef> getElementsAbsentInExisting(AtlasEnumDef existing, AtlasEnumDef incoming) throws AtlasBaseException {
List<AtlasEnumDef.AtlasEnumElementDef> difference = new ArrayList<>(); List<AtlasEnumDef.AtlasEnumElementDef> difference = new ArrayList<>();
for (AtlasEnumDef.AtlasEnumElementDef ed : incoming.getElementDefs()) { for (AtlasEnumDef.AtlasEnumElementDef ed : incoming.getElementDefs()) {
updateCollectionWithDifferingAttributes(existing, difference, ed); updateCollectionWithDifferingAttributes(existing, difference, ed);
......
...@@ -15,24 +15,20 @@ ...@@ -15,24 +15,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.services; package org.apache.atlas.discovery;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.discovery.EntityDiscoveryService;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.powermock.reflect.Whitebox;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.inject.Inject; import javax.inject.Inject;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.*;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@Guice(modules = TestModules.TestOnlyModule.class) @Guice(modules = TestModules.TestOnlyModule.class)
public class EntityDiscoveryServiceTest { public class EntityDiscoveryServiceTest {
...@@ -121,7 +117,7 @@ public class EntityDiscoveryServiceTest { ...@@ -121,7 +117,7 @@ public class EntityDiscoveryServiceTest {
} }
private String invokeGetSubTypesForType(String inputString, int maxSubTypes) throws Exception { private String invokeGetSubTypesForType(String inputString, int maxSubTypes) throws Exception {
String s = Whitebox.invokeMethod(EntityDiscoveryService.class, "getTypeFilter", typeRegistry, inputString, maxSubTypes); String s = EntityDiscoveryService.getTypeFilter(typeRegistry, inputString, maxSubTypes);
assertNotNull(s); assertNotNull(s);
return s; return s;
......
...@@ -37,7 +37,6 @@ import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper; ...@@ -37,7 +37,6 @@ import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper;
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.powermock.reflect.Whitebox;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testng.Assert; import org.testng.Assert;
...@@ -264,38 +263,29 @@ public class ExportServiceTest { ...@@ -264,38 +263,29 @@ public class ExportServiceTest {
public void verifyOverallStatus() throws Exception { public void verifyOverallStatus() throws Exception {
// ExportService service = new ExportService(typeRegistry); // ExportService service = new ExportService(typeRegistry);
assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(exportService, assertEquals(AtlasExportResult.OperationStatus.FAIL, exportService.getOverallOperationStatus());
"getOverallOperationStatus"));
assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(exportService, assertEquals(AtlasExportResult.OperationStatus.SUCCESS, exportService.getOverallOperationStatus(AtlasExportResult.OperationStatus.SUCCESS));
"getOverallOperationStatus",
AtlasExportResult.OperationStatus.SUCCESS));
assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(exportService, assertEquals(AtlasExportResult.OperationStatus.SUCCESS, exportService.getOverallOperationStatus(
"getOverallOperationStatus",
AtlasExportResult.OperationStatus.SUCCESS, AtlasExportResult.OperationStatus.SUCCESS,
AtlasExportResult.OperationStatus.SUCCESS, AtlasExportResult.OperationStatus.SUCCESS,
AtlasExportResult.OperationStatus.SUCCESS)); AtlasExportResult.OperationStatus.SUCCESS));
assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(exportService, assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, exportService.getOverallOperationStatus(
"getOverallOperationStatus",
AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL,
AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, AtlasExportResult.OperationStatus.PARTIAL_SUCCESS,
AtlasExportResult.OperationStatus.SUCCESS)); AtlasExportResult.OperationStatus.SUCCESS));
assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(exportService, assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, exportService.getOverallOperationStatus(
"getOverallOperationStatus",
AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL,
AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL,
AtlasExportResult.OperationStatus.PARTIAL_SUCCESS)); AtlasExportResult.OperationStatus.PARTIAL_SUCCESS));
assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(exportService, assertEquals(AtlasExportResult.OperationStatus.FAIL, exportService.getOverallOperationStatus(
"getOverallOperationStatus",
AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL,
AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL,
AtlasExportResult.OperationStatus.FAIL)); AtlasExportResult.OperationStatus.FAIL));
} }
@Test @Test
......
...@@ -21,7 +21,6 @@ import org.apache.atlas.model.typedef.AtlasBaseTypeDef; ...@@ -21,7 +21,6 @@ import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef; import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef;
import org.powermock.reflect.Whitebox;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
...@@ -76,11 +75,11 @@ public class TypeAttributeDifferenceTest { ...@@ -76,11 +75,11 @@ public class TypeAttributeDifferenceTest {
} }
private List<AtlasStructDef.AtlasAttributeDef> invokeGetAttributesAbsentInExisting(AtlasStructDef existing, AtlasStructDef incoming) throws Exception { private List<AtlasStructDef.AtlasAttributeDef> invokeGetAttributesAbsentInExisting(AtlasStructDef existing, AtlasStructDef incoming) throws Exception {
return Whitebox.invokeMethod(typeAttributeDifference, "getElementsAbsentInExisting", existing, incoming); return typeAttributeDifference.getElementsAbsentInExisting(existing, incoming);
} }
private List<AtlasEnumDef.AtlasEnumElementDef> invokeGetAttributesAbsentInExisting(AtlasEnumDef existing, AtlasEnumDef incoming) throws Exception { private List<AtlasEnumDef.AtlasEnumElementDef> invokeGetAttributesAbsentInExisting(AtlasEnumDef existing, AtlasEnumDef incoming) throws Exception {
return Whitebox.invokeMethod(typeAttributeDifference, "getElementsAbsentInExisting", existing, incoming); return typeAttributeDifference.getElementsAbsentInExisting(existing, incoming);
} }
private AtlasEnumDef getAtlasEnumWithAttributes(String... elements) { private AtlasEnumDef getAtlasEnumWithAttributes(String... elements) {
...@@ -146,6 +145,6 @@ public class TypeAttributeDifferenceTest { ...@@ -146,6 +145,6 @@ public class TypeAttributeDifferenceTest {
} }
private boolean invokeUpdate(AtlasEnumDef existing, AtlasEnumDef incoming) throws Exception { private boolean invokeUpdate(AtlasEnumDef existing, AtlasEnumDef incoming) throws Exception {
return Whitebox.invokeMethod(typeAttributeDifference, "addElements", existing, incoming); return typeAttributeDifference.addElements(existing, incoming);
} }
} }
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