Repository: incubator-atlas Updated Branches: refs/heads/master f6e27b59c -> 1620284e4
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java index fba6d19..aaa8fa0 100755 --- a/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java @@ -88,7 +88,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { super.setUp(); final TypeSystem typeSystem = TypeSystem.getInstance(); - Collection<String> oldTypeNames = new HashSet<String>(); + Collection<String> oldTypeNames = new HashSet<>(); oldTypeNames.addAll(typeSystem.getTypeNames()); TestUtils.defineDeptEmployeeTypes(typeSystem); @@ -111,7 +111,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { newTypeNames.addAll(typeSystem.getTypeNames()); newTypeNames.removeAll(oldTypeNames); - Collection<IDataType> newTypes = new ArrayList<IDataType>(); + Collection<IDataType> newTypes = new ArrayList<>(); for(String name : newTypeNames) { try { newTypes.add(typeSystem.getDataType(IDataType.class, name)); @@ -294,7 +294,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { resultList = (List<Map<String, Object>>) r; Assert.assertTrue(resultList.size() > 0); System.out.println("search result = " + r); - List<Object> names = new ArrayList<Object>(resultList.size()); + List<Object> names = new ArrayList<>(resultList.size()); for (Map<String, Object> vertexProps : resultList) { names.addAll(vertexProps.values()); } @@ -884,7 +884,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { assertNotNull(rows); assertEquals(rows.length(), expectedNumRows.intValue()); // some queries may not have any results - List<String> returnedList = new ArrayList<String> (); + List<String> returnedList = new ArrayList<>(); for (int i = 0; i < rows.length(); i++) { JSONObject row = rows.getJSONObject(i); try @@ -953,7 +953,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { JSONArray rows = results.getJSONArray("rows"); assertNotNull(rows); - assertEquals( rows.length(), expectedNumRows.intValue(), "query [" + dslQuery + "] returned [" + rows.length() + "] rows. Expected " + expectedNumRows.intValue() + " rows."); // some queries may not have any results + assertEquals( rows.length(), expectedNumRows.intValue(), "query [" + dslQuery + "] returned [" + rows.length() + "] rows. Expected " + expectedNumRows + " rows."); // some queries may not have any results System.out.println("query [" + dslQuery + "] returned [" + rows.length() + "] rows"); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java b/repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java index 7ae5e20..7ea15cb 100644 --- a/repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java +++ b/repository/src/test/java/org/apache/atlas/repository/audit/AuditRepositoryTestBase.java @@ -18,7 +18,6 @@ package org.apache.atlas.repository.audit; -import junit.framework.Assert; import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.typesystem.Referenceable; import org.apache.commons.lang.RandomStringUtils; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperMockTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperMockTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperMockTest.java index dbd4bf1..8f8aadc 100644 --- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperMockTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperMockTest.java @@ -74,8 +74,8 @@ public class GraphHelperMockTest { when(v2.getEdges(AtlasEdgeDirection.IN)).thenReturn(noEdgesIterable); when(v1.getEdges(AtlasEdgeDirection.OUT)).thenReturn(noEdgesIterable); - when(v1.getId()).thenReturn(new String("1234")); - when(v2.getId()).thenReturn(new String("5678")); + when(v1.getId()).thenReturn("1234"); + when(v2.getId()).thenReturn("5678"); when(graph.addEdge(v1, v2, edgeLabel)).thenThrow(new RuntimeException("Unique property constraint violated")); graphHelperInstance.getOrCreateEdge(v1, v2, edgeLabel); } @@ -110,9 +110,9 @@ public class GraphHelperMockTest { when(v2.getEdges(AtlasEdgeDirection.IN)).thenReturn(noEdgesIterable); when(v1.getEdges(AtlasEdgeDirection.OUT)).thenReturn(noEdgesIterable); - when(v1.getId()).thenReturn(new String("v1")); - when(v2.getId()).thenReturn(new String("v2")); - when(edge.getId()).thenReturn(new String("edge")); + when(v1.getId()).thenReturn("v1"); + when(v2.getId()).thenReturn("v2"); + when(edge.getId()).thenReturn("edge"); when(graph.addEdge(v1, v2, edgeLabel)) .thenThrow(new RuntimeException("Unique property constraint violated")).thenReturn(edge); AtlasEdge redge = graphHelperInstance.getOrCreateEdge(v1, v2, edgeLabel); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java index 000f2f4..6b83aa3 100755 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java @@ -96,7 +96,7 @@ public class GraphBackedTypeStoreTest { @Test(dependsOnMethods = "testStore") public void testRestoreType() throws Exception { - TypesDef typesDef = ((GraphBackedTypeStore)typeStore).restoreType("Manager"); + TypesDef typesDef = typeStore.restoreType("Manager"); verifyRestoredClassType(typesDef, "Manager"); } @@ -214,8 +214,8 @@ public class GraphBackedTypeStoreTest { Iterator<AtlasEdge> outGoingEdgesByLabel = GraphHelper.getInstance().getOutGoingEdgesByLabel(typeVertex, edgeLabel); int edgeCount = 0; - for (Iterator<AtlasEdge> iterator = outGoingEdgesByLabel; iterator.hasNext();) { - iterator.next(); + for (; outGoingEdgesByLabel.hasNext();) { + outGoingEdgesByLabel.next(); edgeCount++; } return edgeCount; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java index d659c0f..ca5f988 100644 --- a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java @@ -644,8 +644,8 @@ public class DefaultMetadataServiceTest { List<Referenceable> actualArray = (List<Referenceable>) entityDefinition.get(arrAttrName); if (expectedArray == null && actualArray != null) { //all are marked as deleted in case of soft delete - for (int index = 0; index < actualArray.size(); index++) { - assertEquals(actualArray.get(index).getId().state, Id.EntityState.DELETED); + for (Referenceable referenceable : actualArray) { + assertEquals(referenceable.getId().state, Id.EntityState.DELETED); } } else if(expectedArray == null) { //hard delete case http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java index 75ec9a2..8b3cee3 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java @@ -57,7 +57,7 @@ public class ReferenceableInstance extends StructInstance implements ITypedRefer bigIntegers, dates, strings, arrays, maps, structs, referenceableInstances, ids); this.id = id; this.traits = traits; - ImmutableList.Builder<String> b = new ImmutableList.Builder<String>(); + ImmutableList.Builder<String> b = new ImmutableList.Builder<>(); for (String t : traits.keySet()) { b.add(t); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java index 6fb2087..1616e7d 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java @@ -129,19 +129,19 @@ public class StructInstance implements ITypedStruct { } nullFlags[nullPos] = false; if (i.dataType() == DataTypes.BOOLEAN_TYPE) { - bools[pos] = ((Boolean) cVal).booleanValue(); + bools[pos] = (Boolean) cVal; } else if (i.dataType() == DataTypes.BYTE_TYPE) { - bytes[pos] = ((Byte) cVal).byteValue(); + bytes[pos] = (Byte) cVal; } else if (i.dataType() == DataTypes.SHORT_TYPE) { - shorts[pos] = ((Short) cVal).shortValue(); + shorts[pos] = (Short) cVal; } else if (i.dataType() == DataTypes.INT_TYPE) { - ints[pos] = ((Integer) cVal).intValue(); + ints[pos] = (Integer) cVal; } else if (i.dataType() == DataTypes.LONG_TYPE) { - longs[pos] = ((Long) cVal).longValue(); + longs[pos] = (Long) cVal; } else if (i.dataType() == DataTypes.FLOAT_TYPE) { - floats[pos] = ((Float) cVal).floatValue(); + floats[pos] = (Float) cVal; } else if (i.dataType() == DataTypes.DOUBLE_TYPE) { - doubles[pos] = ((Double) cVal).doubleValue(); + doubles[pos] = (Double) cVal; } else if (i.dataType() == DataTypes.BIGINTEGER_TYPE) { bigIntegers[pos] = (BigInteger) cVal; } else if (i.dataType() == DataTypes.BIGDECIMAL_TYPE) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java index 35a45b9..c24a55f 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java @@ -106,7 +106,7 @@ public class AttributeInfo { Objects.equals(name, that.name) && Objects.equals(multiplicity, that.multiplicity) && Objects.equals(reverseAttributeName, that.reverseAttributeName) && - Objects.equals(dataType, that.dataType); + dataType == null ? that.dataType == null : Objects.equals(dataType.getName(), that.dataType.getName()); } public String toJson() throws JSONException { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java index 6398829..350d01b 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java @@ -191,7 +191,7 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc public ITypedReferenceableInstance createInstanceWithTraits(Id id, AtlasSystemAttributes systemAttributes, Referenceable r, String... traitNames) throws AtlasException { - ImmutableMap.Builder<String, ITypedStruct> b = new ImmutableBiMap.Builder<String, ITypedStruct>(); + ImmutableMap.Builder<String, ITypedStruct> b = new ImmutableBiMap.Builder<>(); if (traitNames != null) { for (String t : traitNames) { TraitType tType = typeSystem.getDataType(TraitType.class, t); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java index 425e163..21d5f1a 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java @@ -79,7 +79,7 @@ public class DataTypes { return mapTypeName(keyType.getName(), valueType.getName()); } - public static enum TypeCategory { + public enum TypeCategory { PRIMITIVE, ENUM, ARRAY, @@ -179,7 +179,7 @@ public class DataTypes { @Override public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException { if ( val != null ) { - digester.update(((Byte) val).byteValue()); + digester.update((Byte) val); } } } @@ -267,7 +267,7 @@ public class DataTypes { } public Long nullValue() { - return 0l; + return 0L; } } @@ -524,9 +524,7 @@ public class DataTypes { return val; } ImmutableCollection.Builder b = m.isUnique ? ImmutableSet.builder() : ImmutableList.builder(); - Iterator it = val.iterator(); - while (it.hasNext()) { - Object elem = it.next(); + for (Object elem : val) { if (elem instanceof IReferenceableInstance) { Id oldId = ((IReferenceableInstance) elem).getId(); Id newId = transientToNewIds.get(oldId); @@ -613,9 +611,7 @@ public class DataTypes { return val; } ImmutableMap.Builder b = ImmutableMap.builder(); - Iterator<Map.Entry> it = val.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry elem = it.next(); + for (Map.Entry elem : (Iterable<Map.Entry>) val.entrySet()) { Object oldKey = elem.getKey(); Object oldValue = elem.getValue(); Object newKey = oldKey; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java index 392d2bf..ac7f442 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java @@ -30,16 +30,7 @@ import org.apache.atlas.typesystem.persistence.DownCastStructInstance; import org.apache.atlas.typesystem.types.TypeUtils.Pair; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; /** * Represents a Type that can have SuperTypes. An Instance of the HierarchicalType can be @@ -153,21 +144,21 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A } private void setupSuperTypesGraph(ImmutableSet<String> superTypes) throws AtlasException { - Map<String, List<Path>> superTypePaths = new HashMap<String, List<Path>>(); - Map<String, Path> pathNameToPathMap = new HashMap<String, Path>(); - Queue<Path> queue = new LinkedList<Path>(); + Map<String, List<Path>> superTypePaths = new HashMap<>(); + Map<String, Path> pathNameToPathMap = new HashMap<>(); + Queue<Path> queue = new LinkedList<>(); queue.add(new Node(getName())); while (!queue.isEmpty()) { Path currentPath = queue.poll(); - ST superType = currentPath.typeName == getName() ? (ST) this : - (ST) typeSystem.getDataType(superTypeClass, currentPath.typeName); + ST superType = Objects.equals(currentPath.typeName, getName()) ? (ST) this : + typeSystem.getDataType(superTypeClass, currentPath.typeName); pathNameToPathMap.put(currentPath.pathName, currentPath); if (superType != this) { List<Path> typePaths = superTypePaths.get(superType.getName()); if (typePaths == null) { - typePaths = new ArrayList<Path>(); + typePaths = new ArrayList<>(); superTypePaths.put(superType.getName(), typePaths); } typePaths.add(currentPath); @@ -217,13 +208,13 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A while (pathItr.hasNext()) { Path currentPath = pathItr.next(); - ST superType = currentPath.typeName == getName() ? (ST) this : - (ST) typeSystem.getDataType(superTypeClass, currentPath.typeName); + ST superType = Objects.equals(currentPath.typeName, getName()) ? (ST) this : + typeSystem.getDataType(superTypeClass, currentPath.typeName); ImmutableList<AttributeInfo> superTypeFields = superType == this ? ImmutableList.copyOf(fields) : superType.immediateAttrs; - Set<String> immediateFields = new HashSet<String>(); + Set<String> immediateFields = new HashSet<>(); for (AttributeInfo i : superTypeFields) { if (superType == this) { @@ -315,7 +306,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A } if (s != null) { - if (s.getTypeName() != getName()) { + if (!Objects.equals(s.getTypeName(), getName())) { throw new AtlasException( String.format("Downcast called on wrong type %s, instance type is %s", getName(), s.getTypeName())); @@ -328,7 +319,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A superTypeName, getName())); } - ST superType = (ST) typeSystem.getDataType(superTypeClass, superTypeName); + ST superType = typeSystem.getDataType(superTypeClass, superTypeName); Map<String, String> downCastMap = superType.constructDowncastFieldMap(this, pathToSuper.get(0)); return new DownCastStructInstance(superTypeName, new DownCastFieldMapping(ImmutableMap.copyOf(downCastMap)), s); @@ -359,7 +350,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A /* * the downcastMap; */ - Map<String, String> dCMap = new HashMap<String, String>(); + Map<String, String> dCMap = new HashMap<>(); Iterator<Path> itr = pathIterator(); while (itr.hasNext()) { Path p = itr.next(); @@ -516,7 +507,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A Queue<Path> pathQueue; PathItr() { - pathQueue = new LinkedList<Path>(); + pathQueue = new LinkedList<>(); pathQueue.add(pathNameToPathMap.get(getName())); } @@ -532,13 +523,12 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A if(p != null) { ST t = null; try { - t = (ST) typeSystem.getDataType(superTypeClass, p.typeName); + t = typeSystem.getDataType(superTypeClass, p.typeName); } catch (AtlasException me) { throw new RuntimeException(me); } if (t.superTypes != null) { - ImmutableSet<String> sTs = t.superTypes; - for (String sT : sTs) { + for (String sT : (ImmutableSet<String>) t.superTypes) { String nm = sT + "." + p.pathName; pathQueue.add(pathNameToPathMap.get(nm)); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java index a8f2eeb..9a1847c 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java @@ -41,8 +41,8 @@ public class ObjectGraphTraversal implements Iterator<ObjectGraphTraversal.Insta public ObjectGraphTraversal(TypeSystem typeSystem, IReferenceableInstance start) throws AtlasException { this.typeSystem = typeSystem; - queue = new LinkedList<InstanceTuple>(); - processedIds = new HashSet<Id>(); + queue = new LinkedList<>(); + processedIds = new HashSet<>(); processReferenceableInstance(start); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java index 81884e8..036d18d 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java @@ -66,8 +66,8 @@ public class ObjectGraphWalker { List<? extends IReferenceableInstance> roots) throws AtlasException { this.typeSystem = typeSystem; this.nodeProcessor = nodeProcessor; - queue = new LinkedList<IReferenceableInstance>(); - processedIds = new HashSet<Id>(); + queue = new LinkedList<>(); + processedIds = new HashSet<>(); for (IReferenceableInstance r : roots) { visitReferenceableInstance(r); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java index 5d25730..57f2517 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java @@ -94,9 +94,9 @@ public class StructType extends AbstractDataType<IStruct> implements IConstructa protected FieldMapping constructFieldMapping(AttributeInfo... fields) throws AtlasException { - Map<String, AttributeInfo> fieldsMap = new LinkedHashMap<String, AttributeInfo>(); - Map<String, Integer> fieldPos = new HashMap<String, Integer>(); - Map<String, Integer> fieldNullPos = new HashMap<String, Integer>(); + Map<String, AttributeInfo> fieldsMap = new LinkedHashMap<>(); + Map<String, Integer> fieldPos = new HashMap<>(); + Map<String, Integer> fieldNullPos = new HashMap<>(); int numBools = 0; int numBytes = 0; int numShorts = 0; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java index b97669a..b142e71 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java @@ -33,6 +33,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.Map; +import java.util.Objects; import java.util.Set; public class TypedStructHandler { @@ -49,7 +50,7 @@ public class TypedStructHandler { if (val != null) { if (val instanceof ITypedStruct) { ITypedStruct ts = (ITypedStruct) val; - if (ts.getTypeName() != structType.getName()) { + if (!Objects.equals(ts.getTypeName(), structType.getName())) { throw new ValueConversionException(structType, val); } return ts; @@ -70,7 +71,7 @@ public class TypedStructHandler { } } return ts; - } else if (val instanceof StructInstance && ((StructInstance) val).getTypeName() == structType.getName()) { + } else if (val instanceof StructInstance && Objects.equals(((StructInstance) val).getTypeName(), structType.getName())) { return (StructInstance) val; } else { throw new ValueConversionException(structType, val); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java index 87d83a6..c8f65be 100644 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java @@ -66,7 +66,7 @@ public interface TypeCache { * @return returns non-null type if cached, otherwise null * @throws AtlasException */ - public IDataType get(String typeName) throws AtlasException; + IDataType get(String typeName) throws AtlasException; /** * @param typeCategory Non-null category of type. The category can be one of @@ -75,7 +75,7 @@ public interface TypeCache { * @return returns non-null type (of the specified category) if cached, otherwise null * @throws AtlasException */ - public IDataType get(DataTypes.TypeCategory typeCategory, String typeName) throws AtlasException; + IDataType get(DataTypes.TypeCategory typeCategory, String typeName) throws AtlasException; /** * http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala ---------------------------------------------------------------------- diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala index df1851c..9e22f67 100644 --- a/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala +++ b/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala @@ -69,7 +69,7 @@ object DynamicValue { if ( s != null ) { new DynamicCollection(ib, attr, s) } else { - new DynamicValue(ib, attr, s, jL.map{ e => transformOut(null, null, e)}.toSeq) + new DynamicValue(ib, attr, s, jL.map { e => transformOut(null, null, e) }) } } case jM : java.util.Map[_,_] => { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/TypesBuilder.scala ---------------------------------------------------------------------- diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/TypesBuilder.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/TypesBuilder.scala index f18151a..5ea345f 100644 --- a/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/TypesBuilder.scala +++ b/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/TypesBuilder.scala @@ -148,10 +148,10 @@ class TypesBuilder { def types(f : => Unit ) : TypesDef = { f - TypesDef(context.value.enums.toSeq, - context.value.structs.toSeq, - context.value.traits.toSeq, - context.value.classes.toSeq) + TypesDef(context.value.enums, + context.value.structs, + context.value.traits, + context.value.classes) } def _class(name : String, superTypes : List[String] = List())(f : => Unit): Unit = { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala ---------------------------------------------------------------------- diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala index 6f63d0f..3354d7c 100755 --- a/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala +++ b/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala @@ -278,7 +278,7 @@ object InstanceSerialization { convertId.map(asJava(_)(format)).getOrElse { jsonMap.map { t => (t._1 -> asJava(t._2)(format)) - }.toMap.asJava + }.asJava } } } @@ -305,7 +305,7 @@ object InstanceSerialization { asJava(r.traitNames).asInstanceOf[java.util.List[String]], asJava(r.traits).asInstanceOf[java.util.Map[String, IStruct]], s_attr) } - case l : List[_] => l.map(e => asJava(e)).toList.asJava + case l : List[_] => l.map(e => asJava(e)).asJava case m : Map[_, _] if Try{m.asInstanceOf[Map[String,_]]}.isDefined => { if (m.keys.size == 2 && m.keys.contains("value") && m.keys.contains("ordinal")) { new EnumValue(m.get("value").toString, m.get("ordinal").asInstanceOf[BigInt].intValue()) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java index eb1a15a..5ee019c 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java @@ -74,7 +74,7 @@ public class SerializationJavaTest extends BaseTest { new AttributeDefinition("department", "Department", Multiplicity.REQUIRED, false, "employees"), new AttributeDefinition("manager", "Manager", Multiplicity.OPTIONAL, false, "subordinates")); HierarchicalTypeDefinition<ClassType> managerTypeDef = - createClassTypeDef("Manager", ImmutableSet.<String>of("Person"), + createClassTypeDef("Manager", ImmutableSet.of("Person"), new AttributeDefinition("subordinates", String.format("array<%s>", "Person"), Multiplicity.COLLECTION, false, "manager")); @@ -98,9 +98,9 @@ public class SerializationJavaTest extends BaseTest { john.set("manager", jane); - hrDept.set("employees", ImmutableList.<Referenceable>of(john, jane)); + hrDept.set("employees", ImmutableList.of(john, jane)); - jane.set("subordinates", ImmutableList.<Referenceable>of(john)); + jane.set("subordinates", ImmutableList.of(john)); jane.getTrait("SecurityClearance").set("level", 1); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java index e52962b..3a1675e 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java @@ -19,7 +19,6 @@ package org.apache.atlas.typesystem.types; import com.google.common.collect.ImmutableList; -import com.sun.source.tree.AssertTree; import org.apache.atlas.AtlasException; import org.apache.atlas.typesystem.ITypedStruct; import org.apache.atlas.typesystem.Struct; @@ -29,7 +28,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; public class StructTest extends TypeUpdateBaseTest { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java index 31bfb2c..7c39213 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java @@ -70,16 +70,16 @@ public class TraitTest extends HierarchicalTypeTest<TraitType> { HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); - HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableSet.<String>of("A"), + HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableSet.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); HierarchicalTypeDefinition C = - createTraitTypeDef("C", ImmutableSet.<String>of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); - HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableSet.<String>of("B", "C"), + createTraitTypeDef("C", ImmutableSet.of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableSet.of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); defineTraits(A, B, C, D); - TraitType DType = (TraitType) getTypeSystem().getDataType(TraitType.class, "D"); + TraitType DType = getTypeSystem().getDataType(TraitType.class, "D"); // for(String aName : DType.fieldMapping().fields.keySet()) { // System.out.println(String.format("nameToQualifiedName.put(\"%s\", \"%s\");", aName, DType @@ -134,7 +134,7 @@ public class TraitTest extends HierarchicalTypeTest<TraitType> { /* * cast to B and set the 'b' attribute on A. */ - TraitType BType = (TraitType) getTypeSystem().getDataType(TraitType.class, "B"); + TraitType BType = getTypeSystem().getDataType(TraitType.class, "B"); IStruct s2 = DType.castAs(ts, "B"); s2.set("A.B.b", false); @@ -155,7 +155,7 @@ public class TraitTest extends HierarchicalTypeTest<TraitType> { /* * cast again to A and set the 'b' attribute on A. */ - TraitType AType = (TraitType) getTypeSystem().getDataType(TraitType.class, "A"); + TraitType AType = getTypeSystem().getDataType(TraitType.class, "A"); IStruct s3 = BType.castAs(s2, "A"); s3.set("b", true); Assert.assertEquals(ts.toString(), "{\n" + @@ -178,16 +178,16 @@ public class TraitTest extends HierarchicalTypeTest<TraitType> { HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); - HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableSet.<String>of("A"), + HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableSet.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableSet.<String>of("A"), + HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableSet.of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); - HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableSet.<String>of("B", "C"), + HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableSet.of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); defineTraits(B, D, A, C); - TraitType DType = (TraitType) getTypeSystem().getDataType(TraitType.class, "D"); + TraitType DType = getTypeSystem().getDataType(TraitType.class, "D"); Struct s1 = new Struct("D"); s1.set("d", 1); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java index 96946ea..175ba7e 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java @@ -188,18 +188,18 @@ public class TypeSystemTest extends BaseTest { HierarchicalTypeDefinition<TraitType> trait_A = createTraitTypeDef("trait_A", null, createRequiredAttrDef("t_A", DataTypes.STRING_TYPE)); - HierarchicalTypeDefinition<TraitType> trait_B = createTraitTypeDef("trait_B", ImmutableSet.<String>of("trait_A"), + HierarchicalTypeDefinition<TraitType> trait_B = createTraitTypeDef("trait_B", ImmutableSet.of("trait_A"), createRequiredAttrDef("t_B", DataTypes.STRING_TYPE)); - HierarchicalTypeDefinition<TraitType> trait_C = createTraitTypeDef("trait_C", ImmutableSet.<String>of("trait_A"), + HierarchicalTypeDefinition<TraitType> trait_C = createTraitTypeDef("trait_C", ImmutableSet.of("trait_A"), createRequiredAttrDef("t_C", DataTypes.STRING_TYPE)); - HierarchicalTypeDefinition<TraitType> trait_D = createTraitTypeDef("trait_D", ImmutableSet.<String>of("trait_B", "trait_C"), + HierarchicalTypeDefinition<TraitType> trait_D = createTraitTypeDef("trait_D", ImmutableSet.of("trait_B", "trait_C"), createRequiredAttrDef("t_D", DataTypes.STRING_TYPE)); HierarchicalTypeDefinition<ClassType> class_A = createClassTypeDef("class_A", null, createRequiredAttrDef("c_A", DataTypes.STRING_TYPE)); - HierarchicalTypeDefinition<ClassType> class_B = createClassTypeDef("class_B", ImmutableSet.<String>of("class_A"), + HierarchicalTypeDefinition<ClassType> class_B = createClassTypeDef("class_B", ImmutableSet.of("class_A"), createRequiredAttrDef("c_B", DataTypes.STRING_TYPE)); - HierarchicalTypeDefinition<ClassType> class_C = createClassTypeDef("class_C", ImmutableSet.<String>of("class_B"), + HierarchicalTypeDefinition<ClassType> class_C = createClassTypeDef("class_C", ImmutableSet.of("class_B"), createRequiredAttrDef("c_C", DataTypes.STRING_TYPE)); ts.defineTypes(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.of(struct_A, struct_B), http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/test/java/org/apache/atlas/typesystem/types/ValidationTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/ValidationTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/ValidationTest.java index 0748f8f..1a86cf3 100644 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/ValidationTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/ValidationTest.java @@ -17,7 +17,6 @@ package org.apache.atlas.typesystem.types; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.apache.atlas.typesystem.types.utils.TypesUtil; @@ -75,14 +74,12 @@ public class ValidationTest { @Test(dataProvider = "classTypeData", expectedExceptions = {IllegalArgumentException.class}) public void testClassType(String name) { AttributeDefinition value = TypesUtil.createRequiredAttrDef("name", "type"); - ; TypesUtil.createClassTypeDef(name, ImmutableSet.of("super"), value); } @Test(dataProvider = "classTypeData", expectedExceptions = {IllegalArgumentException.class}) public void testTraitType(String name) { AttributeDefinition value = TypesUtil.createRequiredAttrDef("name", "type"); - ; TypesUtil.createTraitTypeDef(name, ImmutableSet.of("super"), value); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java index f885a6b..5c397dd 100644 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCacheTest.java @@ -176,7 +176,7 @@ public class DefaultTypeCacheTest { @Test public void testCacheGetAllTypeNames() throws Exception { - List<String> allTypeNames = new ArrayList<String>(cache.getAllTypeNames()); + List<String> allTypeNames = new ArrayList<>(cache.getAllTypeNames()); Collections.sort(allTypeNames); final int EXPECTED_TYPE_COUNT = 4; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java b/webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java index e746855..8f6613a 100644 --- a/webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java +++ b/webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java @@ -103,7 +103,7 @@ public class UserDao { throw new AtlasAuthenticationException("User role credentials is not set properly for " + username ); } - List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>(); + List<GrantedAuthority> grantedAuths = new ArrayList<>(); if (StringUtils.hasText(role)) { grantedAuths.add(new SimpleGrantedAuthority(role)); } else { @@ -129,8 +129,8 @@ public class UserDao { byte[] hash = digest.digest(base.getBytes("UTF-8")); StringBuffer hexString = new StringBuffer(); - for (int i = 0; i < hash.length; i++) { - String hex = Integer.toHexString(0xff & hash[i]); + for (byte aHash : hash) { + String hex = Integer.toHexString(0xff & aHash); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java index 1ff8000..ecc67a7 100644 --- a/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java +++ b/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java @@ -37,7 +37,6 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; /** * A servlet {@link Filter} that redirects web requests from a passive Atlas server instance to an active one. @@ -113,9 +112,8 @@ public class ActiveServerFilter implements Filter { private void handleRedirect(HttpServletRequest servletRequest, HttpServletResponse httpServletResponse, String activeServerAddress) throws IOException { - HttpServletRequest httpServletRequest = servletRequest; - String requestURI = httpServletRequest.getRequestURI(); - String queryString = httpServletRequest.getQueryString(); + String requestURI = servletRequest.getRequestURI(); + String queryString = servletRequest.getQueryString(); if ((queryString != null) && (!queryString.isEmpty())) { requestURI += "?" + queryString; } @@ -127,7 +125,7 @@ public class ActiveServerFilter implements Filter { LOG.info("Not active. Redirecting to {}", redirectLocation); // A POST/PUT/DELETE require special handling by sending HTTP 307 instead of the regular 301/302. // Reference: http://stackoverflow.com/questions/2068418/whats-the-difference-between-a-302-and-a-307-redirect - if (isUnsafeHttpMethod(httpServletRequest)) { + if (isUnsafeHttpMethod(servletRequest)) { httpServletResponse.setHeader(HttpHeaders.LOCATION, redirectLocation); httpServletResponse.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT); } else { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java index 3307015..b752810 100644 --- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java +++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java @@ -22,11 +22,9 @@ import org.apache.atlas.ApplicationProperties; import org.apache.atlas.RequestContext; import org.apache.atlas.security.SecurityProperties; import org.apache.atlas.utils.AuthenticationUtil; -import org.apache.atlas.web.listeners.LoginProcessor; import org.apache.atlas.web.util.Servlets; import org.apache.commons.collections.iterators.IteratorEnumeration; import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationConverter; import org.apache.commons.lang.StringUtils; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; @@ -110,7 +108,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter { LOG.info("AtlasAuthenticationFilter initialization started"); final FilterConfig globalConf = filterConfig; - final Map<String, String> params = new HashMap<String, String>(); + final Map<String, String> params = new HashMap<>(); FilterConfig filterConfig1 = new FilterConfig() { @Override @@ -473,9 +471,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter { if (isCookieSet) { Collection<String> authUserName = response1.getHeaders("Set-Cookie"); if (authUserName != null) { - Iterator<String> i = authUserName.iterator(); - while (i.hasNext()) { - String cookie = i.next(); + for (String cookie : authUserName) { if (!StringUtils.isEmpty(cookie)) { if (cookie.toLowerCase().startsWith(AuthenticatedURL.AUTH_COOKIE.toLowerCase()) && cookie.contains("u=")) { String[] split = cookie.split(";"); @@ -571,7 +567,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter { void parseBrowserUserAgents(String userAgents) { String[] agentsArray = userAgents.split(","); - browserUserAgents = new HashSet<Pattern>(); + browserUserAgents = new HashSet<>(); for (String patternString : agentsArray) { browserUserAgents.add(Pattern.compile(patternString)); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java index 5bd2bd7..26e6b1e 100644 --- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java +++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java @@ -99,7 +99,7 @@ public class AtlasAuthorizationFilter extends GenericFilterBean { } String userName = null; - Set<String> groups = new HashSet<String>(); + Set<String> groups = new HashSet<>(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); @@ -166,7 +166,6 @@ public class AtlasAuthorizationFilter extends GenericFilterBean { + atlasResourceTypes + " : " + atlasRequest.getResource() + "\nReturning 403 since the access is blocked update!!!!"); } - return; } } else { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java index 3cc83c5..2fe2dba 100644 --- a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java +++ b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilter.java @@ -19,6 +19,7 @@ package org.apache.atlas.web.filters; import java.io.IOException; +import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; @@ -98,15 +99,13 @@ public class AtlasCSRFPreventionFilter implements Filter { void parseMethodsToIgnore(String mti) { String[] methods = mti.split(","); - methodsToIgnore = new HashSet<String>(); - for (int i = 0; i < methods.length; i++) { - methodsToIgnore.add(methods[i]); - } + methodsToIgnore = new HashSet<>(); + Collections.addAll(methodsToIgnore, methods); } void parseBrowserUserAgents(String userAgents) { String[] agentsArray = userAgents.split(","); - browserUserAgents = new HashSet<Pattern>(); + browserUserAgents = new HashSet<>(); for (String patternString : agentsArray) { browserUserAgents.add(Pattern.compile(patternString)); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java index ec5d891..c20e978 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java @@ -151,10 +151,10 @@ public class AdminResource { Boolean enableTaxonomy = null; try { PropertiesConfiguration configProperties = new PropertiesConfiguration("atlas-application.properties"); - enableTaxonomy = new Boolean(configProperties.getString(isTaxonomyEnabled, "false")); + enableTaxonomy = configProperties.getBoolean(isTaxonomyEnabled, false); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String userName = null; - Set<String> groups = new HashSet<String>(); + Set<String> groups = new HashSet<>(); if (auth != null) { userName = auth.getName(); Collection<? extends GrantedAuthority> authorities = auth.getAuthorities(); @@ -172,8 +172,7 @@ public class AdminResource { responseData.put("userName", userName); responseData.put("groups", groups); - Response response = Response.ok(responseData).build(); - return response; + return Response.ok(responseData).build(); } catch (JSONException | ConfigurationException e) { throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/rest/module/RestModule.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/module/RestModule.java b/webapp/src/main/java/org/apache/atlas/web/rest/module/RestModule.java deleted file mode 100644 index 62e1e57..0000000 --- a/webapp/src/main/java/org/apache/atlas/web/rest/module/RestModule.java +++ /dev/null @@ -1,29 +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.web.rest.module; - -import com.google.inject.AbstractModule; - -import org.apache.atlas.type.AtlasTypeRegistry; - -public class RestModule extends AbstractModule { - @Override - protected void configure() { - bind(AtlasTypeRegistry.class).to(AtlasTypeRegistry.class).asEagerSingleton(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java index b99a30a..74bfb97 100644 --- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java +++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java @@ -55,9 +55,8 @@ public abstract class AtlasAbstractAuthenticationProvider implements UsernamePasswordAuthenticationToken result = null; if (authentication != null && authentication.isAuthenticated()) { final List<GrantedAuthority> grantedAuths = getAuthorities(authentication - .getName().toString()); - final UserDetails userDetails = new User(authentication.getName() - .toString(), authentication.getCredentials().toString(), + .getName()); + final UserDetails userDetails = new User(authentication.getName(), authentication.getCredentials().toString(), grantedAuths); result = new UsernamePasswordAuthenticationToken(userDetails, authentication.getCredentials(), grantedAuths); @@ -72,7 +71,7 @@ public abstract class AtlasAbstractAuthenticationProvider implements * */ protected List<GrantedAuthority> getAuthorities(String username) { - final List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>(); + final List<GrantedAuthority> grantedAuths = new ArrayList<>(); grantedAuths.add(new SimpleGrantedAuthority("DATA_SCIENTIST")); return grantedAuths; } @@ -84,10 +83,9 @@ public abstract class AtlasAbstractAuthenticationProvider implements if (authentication != null && authentication.isAuthenticated()) { List<GrantedAuthority> grantedAuthsUGI = getAuthoritiesFromUGI(authentication - .getName().toString()); + .getName()); - final UserDetails userDetails = new User(authentication.getName() - .toString(), authentication.getCredentials().toString(), + final UserDetails userDetails = new User(authentication.getName(), authentication.getCredentials().toString(), grantedAuthsUGI); result = new UsernamePasswordAuthenticationToken(userDetails, authentication.getCredentials(), grantedAuthsUGI); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java b/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java index c57de84..50351f0 100644 --- a/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java +++ b/webapp/src/main/java/org/apache/atlas/web/service/CuratorFactory.java @@ -125,7 +125,7 @@ public class CuratorFactory { getIdForLogging(acl.getId().getScheme(), acl.getId().getId()), acl.getId().getScheme(), acl.getPerms()); LOG.info("Current logged in user: {}", getCurrentUser()); - final List<ACL> acls = Arrays.asList(new ACL[]{acl}); + final List<ACL> acls = Arrays.asList(acl); aclProvider = new ACLProvider() { @Override public List<ACL> getDefaultAcl() { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/service/UserService.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/service/UserService.java b/webapp/src/main/java/org/apache/atlas/web/service/UserService.java index 33101e2..6e5c210 100644 --- a/webapp/src/main/java/org/apache/atlas/web/service/UserService.java +++ b/webapp/src/main/java/org/apache/atlas/web/service/UserService.java @@ -22,7 +22,6 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.apache.atlas.web.dao.UserDao; -import org.apache.atlas.web.service.UserService; import org.apache.atlas.web.model.User; @Service http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/main/java/org/apache/atlas/web/setup/SetupSteps.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/setup/SetupSteps.java b/webapp/src/main/java/org/apache/atlas/web/setup/SetupSteps.java index b060def..65c88fe 100644 --- a/webapp/src/main/java/org/apache/atlas/web/setup/SetupSteps.java +++ b/webapp/src/main/java/org/apache/atlas/web/setup/SetupSteps.java @@ -147,7 +147,7 @@ public class SetupSteps { String serverId = getServerId(configuration); ACL acl = AtlasZookeeperSecurityProperties.parseAcl(zookeeperProperties.getAcl(), ZooDefs.Ids.OPEN_ACL_UNSAFE.get(0)); - List<ACL> acls = Arrays.asList(new ACL[]{acl}); + List<ACL> acls = Arrays.asList(acl); CuratorFramework client = curatorFactory.clientInstance(); try { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java b/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java index c2f89bd..01e4d48 100644 --- a/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java +++ b/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java @@ -18,7 +18,6 @@ package org.apache.atlas.examples; -import org.apache.atlas.Atlas; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasServiceException; import org.apache.atlas.typesystem.Referenceable; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java index 961154b..e37839a 100644 --- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java +++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java @@ -121,9 +121,7 @@ public class NotificationHookConsumerKafkaTest { try { hookConsumer.handleMessage(consumer.next()); - } catch (AtlasServiceException e) { - Assert.fail("Consumer failed with exception ", e); - } catch (AtlasException e) { + } catch (AtlasServiceException | AtlasException e) { Assert.fail("Consumer failed with exception ", e); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java b/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java index b3ec8de..a8d1110 100644 --- a/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java @@ -36,8 +36,6 @@ import java.io.IOException; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; public class ActiveServerFilterTest { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java index f85892a..02a6fe4 100644 --- a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java @@ -133,13 +133,13 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof PasswordCallback) { - PasswordCallback passwordCallback = (PasswordCallback) callbacks[i]; + for (Callback callback : callbacks) { + if (callback instanceof PasswordCallback) { + PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(TESTPASS.toCharArray()); } - if (callbacks[i] instanceof NameCallback) { - NameCallback nameCallback = (NameCallback) callbacks[i]; + if (callback instanceof NameCallback) { + NameCallback nameCallback = (NameCallback) callback; nameCallback.setName(TESTUSER); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java b/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java index 42692cd..bb80738 100644 --- a/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java @@ -17,7 +17,6 @@ package org.apache.atlas.web.listeners; import org.apache.atlas.web.security.BaseSecurityTest; -import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/listeners/TestGuiceServletConfig.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/listeners/TestGuiceServletConfig.java b/webapp/src/test/java/org/apache/atlas/web/listeners/TestGuiceServletConfig.java index 88cfc63..da221fc 100644 --- a/webapp/src/test/java/org/apache/atlas/web/listeners/TestGuiceServletConfig.java +++ b/webapp/src/test/java/org/apache/atlas/web/listeners/TestGuiceServletConfig.java @@ -27,7 +27,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.Module; -import com.thinkaurelius.titan.core.util.TitanCleanup; public class TestGuiceServletConfig extends GuiceServletConfig { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java index b5af111..22bcc02 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java @@ -772,7 +772,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT { private static class AtlasEntity { String typeName; - final Map<String, Object> values = new HashMap<String, Object>(); + final Map<String, Object> values = new HashMap<>(); } @Test http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java b/webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java index 3f20453..e1734e4 100644 --- a/webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java @@ -18,7 +18,6 @@ package org.apache.atlas.web.resources; -import org.apache.atlas.AtlasConstants; import org.apache.atlas.AtlasException; import org.apache.atlas.catalog.*; import org.apache.atlas.services.MetadataService; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/security/BaseSecurityTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/security/BaseSecurityTest.java b/webapp/src/test/java/org/apache/atlas/web/security/BaseSecurityTest.java index ff2cfc3..ad87025 100644 --- a/webapp/src/test/java/org/apache/atlas/web/security/BaseSecurityTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/security/BaseSecurityTest.java @@ -41,7 +41,6 @@ import static org.apache.atlas.security.SecurityProperties.CERT_STORES_CREDENTIA import static org.apache.atlas.security.SecurityProperties.KEYSTORE_FILE_KEY; import static org.apache.atlas.security.SecurityProperties.TLS_ENABLED; import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_FILE_KEY; -import static org.apache.atlas.security.SecurityProperties.SSL_CLIENT_PROPERTIES; import static org.apache.atlas.security.SecurityProperties.CLIENT_AUTH_KEY; import static org.apache.atlas.security.SecurityProperties.SSL_CLIENT_PROPERTIES; import org.apache.commons.io.FileUtils; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java b/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java index 6823c83..49d56b2 100755 --- a/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java @@ -72,7 +72,7 @@ public class SSLAndKerberosTest extends BaseSSLAndKerberosTest { // client will actually only leverage subset of these properties final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl); - persistSSLClientConfiguration((org.apache.commons.configuration.Configuration) configuration); + persistSSLClientConfiguration(configuration); TestUtils.writeConfiguration(configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES); @@ -163,13 +163,13 @@ public class SSLAndKerberosTest extends BaseSSLAndKerberosTest { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof PasswordCallback) { - PasswordCallback passwordCallback = (PasswordCallback) callbacks[i]; + for (Callback callback : callbacks) { + if (callback instanceof PasswordCallback) { + PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(TESTPASS.toCharArray()); } - if (callbacks[i] instanceof NameCallback) { - NameCallback nameCallback = (NameCallback) callbacks[i]; + if (callback instanceof NameCallback) { + NameCallback nameCallback = (NameCallback) callback; nameCallback.setName(TESTUSER); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceStateTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceStateTest.java b/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceStateTest.java index 599e9cb..7ad2f76 100644 --- a/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceStateTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceStateTest.java @@ -25,14 +25,11 @@ import org.apache.curator.framework.api.CreateBuilder; import org.apache.curator.framework.api.ExistsBuilder; import org.apache.curator.framework.api.GetDataBuilder; import org.apache.curator.framework.api.SetDataBuilder; -import org.apache.curator.framework.recipes.locks.InterProcessMutex; -import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.data.ACL; import org.apache.zookeeper.data.Id; import org.apache.zookeeper.data.Stat; -import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.testng.annotations.BeforeTest; @@ -41,12 +38,10 @@ import scala.actors.threadpool.Arrays; import java.nio.charset.Charset; -import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; import static org.testng.Assert.assertNull; public class ActiveInstanceStateTest { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTestBase.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTestBase.java b/webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTestBase.java index 455f121..1ca8147 100755 --- a/webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTestBase.java +++ b/webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTestBase.java @@ -69,10 +69,7 @@ public class SecureEmbeddedServerTestBase { javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() { public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { - if (hostname.equals("localhost")) { - return true; - } - return false; + return hostname.equals("localhost"); } }); System.setProperty("javax.net.ssl.trustStore", DEFAULT_KEYSTORE_FILE_LOCATION);
