From 864d00260bd49cf2e281a58b16bcd34a49ca15ba Mon Sep 17 00:00:00 2001 From: John Plaisted Date: Tue, 3 Nov 2020 10:01:39 -0800 Subject: [PATCH] fix: enable werror for dao-api. --- build.gradle | 6 ++- .../linkedin/metadata/dao/BaseLocalDAO.java | 50 ++++++++++++------- .../linkedin/metadata/dao/BaseReadDAO.java | 2 + .../equality/AlwaysFalseEqualityTester.java | 14 +++--- .../dao/equality/DefaultEqualityTester.java | 12 +++-- .../metadata/dao/equality/EqualityTester.java | 4 +- .../metadata/dao/utils/ModelUtils.java | 21 +++++--- .../metadata/dao/utils/RecordUtils.java | 16 +++--- .../metadata/dao/BaseLocalDAOTest.java | 36 +++++++------ .../equality/DefaultEqualityTesterTest.java | 2 +- .../metadata/dao/utils/ModelUtilsTest.java | 2 +- .../metadata/dao/EbeanLocalDAOTest.java | 4 +- 12 files changed, 105 insertions(+), 64 deletions(-) diff --git a/build.gradle b/build.gradle index 27dd0cce7..82cbcc453 100644 --- a/build.gradle +++ b/build.gradle @@ -66,8 +66,10 @@ apply plugin: 'org.shipkit.shipkit-auto-version' // than in one big change. def wErrorProjects = [ project(':core-models'), - // project(':dao-api'), - // project(':dao-api-impl'), + project(':dao-api'), + // project(':dao-impl:ebean-dao'), + // project(':dao-impl:elasticsearch-dao'), + // project(':dao-impl:neo4j-dao'), // project(':restli-resources'), project(':testing'), project(':validators') diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/BaseLocalDAO.java b/dao-api/src/main/java/com/linkedin/metadata/dao/BaseLocalDAO.java index 71fc23237..41b6de9c2 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/BaseLocalDAO.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/BaseLocalDAO.java @@ -74,15 +74,15 @@ static class AddResult { private static final int DEFAULT_MAX_TRANSACTION_RETRY = 3; - protected final BaseMetadataEventProducer _producer; + protected final BaseMetadataEventProducer _producer; protected final LocalDAOStorageConfig _storageConfig; // Maps an aspect class to the corresponding retention policy private final Map, Retention> _aspectRetentionMap = new HashMap<>(); // Maps as aspect class to a list of post-update hooks - private final Map, List>> _aspectPostUpdateHooksMap = - new HashMap<>(); + private final Map, List>> + _aspectPostUpdateHooksMap = new HashMap<>(); // Maps an aspect class to the corresponding equality tester private final Map, EqualityTester> @@ -108,7 +108,8 @@ static class AddResult { * com.linkedin.metadata.aspect * @param producer {@link BaseMetadataEventProducer} for the metadata event producer */ - public BaseLocalDAO(@Nonnull Class aspectUnionClass, @Nonnull BaseMetadataEventProducer producer) { + public BaseLocalDAO(@Nonnull Class aspectUnionClass, + @Nonnull BaseMetadataEventProducer producer) { super(aspectUnionClass); _producer = producer; _storageConfig = LocalDAOStorageConfig.builder().build(); @@ -120,7 +121,8 @@ public BaseLocalDAO(@Nonnull Class aspectUnionClass, @Nonnull Base * @param producer {@link BaseMetadataEventProducer} for the metadata event producer * @param storageConfig {@link LocalDAOStorageConfig} containing storage config of full list of supported aspects */ - public BaseLocalDAO(@Nonnull BaseMetadataEventProducer producer, @Nonnull LocalDAOStorageConfig storageConfig) { + public BaseLocalDAO(@Nonnull BaseMetadataEventProducer producer, + @Nonnull LocalDAOStorageConfig storageConfig) { super(storageConfig.getAspectStorageConfigMap().keySet()); _producer = producer; _storageConfig = storageConfig; @@ -158,20 +160,20 @@ public Retention getRetention(@Nonnull Class void addPostUpdateHook(@Nonnull Class aspectClass, + public void addPostUpdateHook(@Nonnull Class aspectClass, @Nonnull BiConsumer postUpdateHook) { checkValidAspect(aspectClass); // TODO: Also validate Urn once we convert all aspect models to PDL with proper annotation - final List> hooks = + final List> hooks = _aspectPostUpdateHooksMap.getOrDefault(aspectClass, new LinkedList<>()); if (hooks.contains(postUpdateHook)) { throw new IllegalArgumentException("Adding an already-registered hook"); } - hooks.add((BiConsumer) postUpdateHook); + hooks.add(postUpdateHook); _aspectPostUpdateHooksMap.put(aspectClass, hooks); } @@ -188,10 +190,11 @@ public void setEqualityTester(@Nonnull Class EqualityTester getEqualityTester(@Nonnull Class aspectClass) { checkValidAspect(aspectClass); return (EqualityTester) _aspectEqualityTesterMap.computeIfAbsent(aspectClass, - key -> new DefaultEqualityTester()); + key -> new DefaultEqualityTester<>()); } /** @@ -220,6 +223,7 @@ public void setEmitAspectSpecificAuditEvent(boolean emitAspectSpecificAuditEvent * * @deprecated Use {@link #enableLocalSecondaryIndex(boolean)} instead */ + @Deprecated public void setWriteToLocalSecondaryIndex(boolean writeToLocalSecondaryIndex) { _enableLocalSecondaryIndex = writeToLocalSecondaryIndex; } @@ -306,7 +310,11 @@ public ASPECT add(@Nonnull URN urn, @Nonnull Cla // 7. Invoke post-update hooks if there's any if (_aspectPostUpdateHooksMap.containsKey(aspectClass)) { - _aspectPostUpdateHooksMap.get(aspectClass).forEach(hook -> hook.accept(urn, newValue)); + for (BiConsumer hook : _aspectPostUpdateHooksMap.get(aspectClass)) { + @SuppressWarnings("unchecked") + final BiConsumer typedHook = ((BiConsumer) hook); + typedHook.accept(urn, newValue); + } } return newValue; @@ -325,6 +333,7 @@ public ASPECT add(@Nonnull URN urn, @Nonnull Cla * Similar to {@link #add(Urn, Class, Function, AuditStamp)} but takes the new value directly. */ @Nonnull + @SuppressWarnings("unchecked") public ASPECT add(@Nonnull URN urn, @Nonnull ASPECT newValue, @Nonnull AuditStamp auditStamp) { return add(urn, (Class) newValue.getClass(), ignored -> newValue, auditStamp); @@ -369,8 +378,8 @@ protected abstract long saveLatest(@Nonnull URN * @param newValue {@link RecordTemplate} of the new value of aspect * @param version version of the aspect */ - protected abstract void updateLocalIndex(@Nonnull URN urn, - @Nullable ASPECT newValue, long version); + protected abstract void updateLocalIndex(@Nonnull URN urn, @Nullable ASPECT newValue, + long version); /** * Returns list of urns from local secondary index that satisfy the given filter conditions. @@ -390,8 +399,8 @@ protected abstract void updateLocalIndex(@Nonnul */ @Nonnull public List listUrns(@Nonnull Class urnClazz, @Nullable URN lastUrn, int pageSize) { - final IndexFilter indexFilter = new IndexFilter() - .setCriteria(new IndexCriterionArray(new IndexCriterion().setAspect(urnClazz.getCanonicalName()))); + final IndexFilter indexFilter = new IndexFilter().setCriteria( + new IndexCriterionArray(new IndexCriterion().setAspect(urnClazz.getCanonicalName()))); return listUrns(indexFilter, lastUrn, pageSize); } @@ -510,8 +519,10 @@ protected abstract void applyTimeBasedRetention( * @return backfilled aspect * @deprecated Use {@link #backfill(Set, Set)} instead */ + @Deprecated @Nonnull - public Optional backfill(@Nonnull Class aspectClass, @Nonnull URN urn) { + public Optional backfill(@Nonnull Class aspectClass, + @Nonnull URN urn) { return backfill(BackfillMode.BACKFILL_ALL, aspectClass, urn); } @@ -551,7 +562,8 @@ public Map, Optional, Optional>> backfill( @Nonnull BackfillMode mode, @Nonnull Set> aspectClasses, @Nonnull Set urns) { checkValidAspects(aspectClasses); - final Map, Optional>> urnToAspects = get(aspectClasses, urns); + final Map, Optional>> urnToAspects = + get(aspectClasses, urns); urnToAspects.forEach((urn, aspects) -> { aspects.forEach((aspectClass, aspect) -> aspect.ifPresent(value -> backfill(mode, value, urn))); }); @@ -575,7 +587,7 @@ public Map, Optional urnClazz, @Nullable URN lastUrn, int pageSize) { final List urnList = listUrns(urnClazz, lastUrn, pageSize); - return backfill(mode, aspectClasses, new HashSet(urnList)); + return backfill(mode, aspectClasses, new HashSet<>(urnList)); } /** @@ -586,7 +598,8 @@ public Map, Optional must be a supported aspect type in {@code ASPECT_UNION}. */ - private void backfill(@Nonnull BackfillMode mode, @Nonnull ASPECT aspect, @Nonnull URN urn) { + private void backfill(@Nonnull BackfillMode mode, @Nonnull ASPECT aspect, + @Nonnull URN urn) { if (_enableLocalSecondaryIndex && (mode == BackfillMode.SCSI_ONLY || mode == BackfillMode.BACKFILL_ALL)) { updateLocalIndex(urn, aspect, FIRST_VERSION); } @@ -678,6 +691,7 @@ public abstract ListResult list(@Nonnull * Similar to {@link #getWithExtraInfo(Set)} but only using only one {@link AspectKey}. */ @Nonnull + @SuppressWarnings("unchecked") public Optional> getWithExtraInfo( @Nonnull AspectKey key) { if (getWithExtraInfo(Collections.singleton(key)).containsKey(key)) { diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/BaseReadDAO.java b/dao-api/src/main/java/com/linkedin/metadata/dao/BaseReadDAO.java index 3019e6646..7bdeedf74 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/BaseReadDAO.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/BaseReadDAO.java @@ -48,6 +48,7 @@ public BaseReadDAO(@Nonnull Set> aspects) { * Similar to {@link #get(Set)} but only using only one {@link AspectKey}. */ @Nonnull + @SuppressWarnings("unchecked") public Optional get(@Nonnull AspectKey key) { return (Optional) get(Collections.singleton(key)).get(key); } @@ -116,6 +117,7 @@ public Map, Optional> * Similar to {@link #get(Set, Set)} but only for one aspect. */ @Nonnull + @SuppressWarnings("unchecked") public Map> get( @Nonnull Class aspectClass, @Nonnull Set urns) { diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/equality/AlwaysFalseEqualityTester.java b/dao-api/src/main/java/com/linkedin/metadata/dao/equality/AlwaysFalseEqualityTester.java index 225ee4c17..c42575b0c 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/equality/AlwaysFalseEqualityTester.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/equality/AlwaysFalseEqualityTester.java @@ -1,23 +1,25 @@ package com.linkedin.metadata.dao.equality; -import com.linkedin.data.template.DataTemplate; +import com.linkedin.data.template.RecordTemplate; import javax.annotation.Nonnull; /** * A {@link EqualityTester} that always returns false. */ -public class AlwaysFalseEqualityTester implements EqualityTester { +public class AlwaysFalseEqualityTester implements EqualityTester { + private static final AlwaysFalseEqualityTester INSTANCE = new AlwaysFalseEqualityTester<>(); /** - * Creates a new instance of {@link AlwaysFalseEqualityTester}. + * Returns the singleton instance of {@link AlwaysFalseEqualityTester}. */ - public static AlwaysFalseEqualityTester newInstance() { - return new AlwaysFalseEqualityTester<>(); + @SuppressWarnings("unchecked") + public static AlwaysFalseEqualityTester instance() { + return (AlwaysFalseEqualityTester) INSTANCE; } @Override - public boolean equals(@Nonnull T o1, @Nonnull T o2) { + public boolean equals(@Nonnull RecordTemplate o1, @Nonnull RecordTemplate o2) { return false; } } diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/equality/DefaultEqualityTester.java b/dao-api/src/main/java/com/linkedin/metadata/dao/equality/DefaultEqualityTester.java index 83c0ec86a..4425ad8f4 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/equality/DefaultEqualityTester.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/equality/DefaultEqualityTester.java @@ -2,19 +2,23 @@ import com.linkedin.data.template.DataTemplate; import com.linkedin.data.template.DataTemplateUtil; +import com.linkedin.data.template.RecordTemplate; import javax.annotation.Nonnull; + /** * A {@link EqualityTester} that uses {@link DataTemplateUtil#areEqual(DataTemplate, DataTemplate)} to check for * semantic equality. */ -public class DefaultEqualityTester implements EqualityTester { +public class DefaultEqualityTester implements EqualityTester { + private static final DefaultEqualityTester INSTANCE = new DefaultEqualityTester<>(); /** - * Creates a new instance of {@link DefaultEqualityTester}. + * Returns the singleton instance of {@link DefaultEqualityTester}. */ - public static DefaultEqualityTester newInstance() { - return new DefaultEqualityTester<>(); + @SuppressWarnings("unchecked") + public static DefaultEqualityTester instance() { + return (DefaultEqualityTester) INSTANCE; } @Override diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/equality/EqualityTester.java b/dao-api/src/main/java/com/linkedin/metadata/dao/equality/EqualityTester.java index f09e5f20b..a5cce82b7 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/equality/EqualityTester.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/equality/EqualityTester.java @@ -1,13 +1,13 @@ package com.linkedin.metadata.dao.equality; -import com.linkedin.data.template.DataTemplate; +import com.linkedin.data.template.RecordTemplate; import javax.annotation.Nonnull; /** * An interface for testing equality between two objects of the same type. */ -public interface EqualityTester { +public interface EqualityTester { boolean equals(@Nonnull T o1, @Nonnull T o2); } diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/utils/ModelUtils.java b/dao-api/src/main/java/com/linkedin/metadata/dao/utils/ModelUtils.java index 89fce4333..95de7f70d 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/utils/ModelUtils.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/utils/ModelUtils.java @@ -47,7 +47,7 @@ private ModelUtils() { * @param must be a valid aspect type * @return the corresponding aspect name, which is actually the FQCN of type */ - public static String getAspectName(@Nonnull Class aspectClass) { + public static String getAspectName(@Nonnull Class> aspectClass) { return aspectClass.getCanonicalName(); } @@ -241,7 +241,7 @@ public static List getAspectsF * @return the extracted aspect */ @Nonnull - public static Optional getAspectFromSnapshot( + public static > Optional getAspectFromSnapshot( @Nonnull SNAPSHOT snapshot, @Nonnull Class aspectClass) { return getAspectsFromSnapshot(snapshot).stream() @@ -260,9 +260,9 @@ public static List getAspectsFromSnapshotUnion(@Nonnull UnionTem @Nonnull private static List getAspects(@Nonnull RecordTemplate snapshot) { - final Class clazz = getAspectsArrayClass(snapshot.getClass()); + final Class> clazz = getAspectsArrayClass(snapshot.getClass()); - WrappingArrayTemplate aspectArray = RecordUtils.getRecordTemplateWrappedField(snapshot, "aspects", clazz); + WrappingArrayTemplate aspectArray = RecordUtils.getRecordTemplateWrappedField(snapshot, "aspects", clazz); final List aspects = new ArrayList<>(); aspectArray.forEach(item -> aspects.add(RecordUtils.getSelectedRecordTemplateFromUnion((UnionTemplate) item))); @@ -286,12 +286,14 @@ public static aspectArrayClass = getAspectsArrayClass(snapshotClass); + final Class> aspectArrayClass = getAspectsArrayClass(snapshotClass); try { final SNAPSHOT snapshot = snapshotClass.newInstance(); RecordUtils.setRecordTemplatePrimitiveField(snapshot, "urn", urn.toString()); - WrappingArrayTemplate aspectArray = aspectArrayClass.newInstance(); + @SuppressWarnings("unchecked") + WrappingArrayTemplate aspectArray = + (WrappingArrayTemplate) aspectArrayClass.newInstance(); aspectArray.addAll(aspects); RecordUtils.setRecordTemplateComplexField(snapshot, "aspects", aspectArray); return snapshot; @@ -301,11 +303,14 @@ public static Class getAspectsArrayClass( + @SuppressWarnings("unchecked") + private static Class> getAspectsArrayClass( @Nonnull Class snapshotClass) { try { - return snapshotClass.getMethod("getAspects").getReturnType().asSubclass(WrappingArrayTemplate.class); + return (Class>) snapshotClass.getMethod("getAspects") + .getReturnType() + .asSubclass(WrappingArrayTemplate.class); } catch (NoSuchMethodException | ClassCastException e) { throw new RuntimeException((e)); } diff --git a/dao-api/src/main/java/com/linkedin/metadata/dao/utils/RecordUtils.java b/dao-api/src/main/java/com/linkedin/metadata/dao/utils/RecordUtils.java index 6b4fdfef3..76ed73742 100644 --- a/dao-api/src/main/java/com/linkedin/metadata/dao/utils/RecordUtils.java +++ b/dao-api/src/main/java/com/linkedin/metadata/dao/utils/RecordUtils.java @@ -231,7 +231,7 @@ public static void setRecordTemplatePrimitiveField * @param fieldName the name of the field to update * @param value the value to set */ - public static void setRecordTemplateComplexField( + public static > void setRecordTemplateComplexField( @Nonnull T recordTemplate, @Nonnull String fieldName, @Nonnull V value) { final RecordDataSchema.Field field = getRecordDataSchemaField(recordTemplate, fieldName); @@ -250,6 +250,7 @@ public static void setRecordT * @return the value for the field */ @Nonnull + @SuppressWarnings("unchecked") public static V getRecordTemplateField(@Nonnull T recordTemplate, @Nonnull String fieldName, @Nonnull Class valueClass) { @@ -269,7 +270,8 @@ public static V getRecordTemplateField(@Nonnull T * @return the value for the field */ @Nonnull - public static V getRecordTemplateWrappedField( + @SuppressWarnings("unchecked") + public static > V getRecordTemplateWrappedField( @Nonnull T recordTemplate, @Nonnull String fieldName, @Nonnull Class valueClass) { final RecordDataSchema.Field field = getRecordDataSchemaField(recordTemplate, fieldName); @@ -286,6 +288,7 @@ public static V getRecordTemp * @return the currently selected value in {@code unionTemplate} */ @Nonnull + @SuppressWarnings("unchecked") public static RecordTemplate getSelectedRecordTemplateFromUnion( @Nonnull UnionTemplate unionTemplate) { @@ -312,6 +315,7 @@ public static RecordTemplate getSelectedRecordTemplat * @return the currently selected value in {@code unionTemplate} */ @Nonnull + @SuppressWarnings("unchecked") public static RecordTemplate setSelectedRecordTemplateInUnion( @Nonnull UnionTemplate unionTemplate, @Nonnull RecordTemplate selectedMember) { @@ -323,7 +327,7 @@ public static RecordTemplate setSelectedRecordTemplat } @Nonnull - private static Method getProtectedMethod(@Nonnull Class clazz, @Nonnull String methodName, + private static Method getProtectedMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... parameterTypes) { try { return clazz.getDeclaredMethod(methodName, parameterTypes); @@ -333,10 +337,10 @@ private static Method getProtectedMethod(@Nonnull Class clazz, @Nonnull String m } @Nonnull - private static T invokeProtectedMethod(Object object, Method method, Object... args) { + private static Object invokeProtectedMethod(Object object, Method method, Object... args) { try { method.setAccessible(true); - return (T) method.invoke(object, args); + return method.invoke(object, args); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } finally { @@ -427,7 +431,7 @@ public static Optional getFieldValue(@Nonnull RecordTemplate recordTempl * @return Referenced object of the RecordTemplate corresponding to the PathSpec */ @Nonnull - @SuppressWarnings("rawtypes") + @SuppressWarnings({"rawtypes", "unchecked"}) public static Optional getFieldValue(@Nonnull RecordTemplate recordTemplate, @Nonnull PathSpec ps) { Object reference = recordTemplate; final int pathSize = ps.getPathComponents().size(); diff --git a/dao-api/src/test/java/com/linkedin/metadata/dao/BaseLocalDAOTest.java b/dao-api/src/test/java/com/linkedin/metadata/dao/BaseLocalDAOTest.java index 0de44133f..a2d7a7484 100644 --- a/dao-api/src/test/java/com/linkedin/metadata/dao/BaseLocalDAOTest.java +++ b/dao-api/src/test/java/com/linkedin/metadata/dao/BaseLocalDAOTest.java @@ -18,7 +18,6 @@ import java.util.Optional; import java.util.Set; import java.util.function.BiConsumer; -import java.util.function.BiFunction; import java.util.function.Supplier; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -33,14 +32,20 @@ public class BaseLocalDAOTest { + interface FakeLatestAspectSupplier { + @Nonnull + BaseLocalDAO.AspectEntry getLatest(@Nonnull FooUrn urn, + @Nonnull Class aspectClass); + } + static class DummyLocalDAO extends BaseLocalDAO { - private final BiFunction, AspectEntry> _getLatestFunction; + private final FakeLatestAspectSupplier _getLatestSupplier; - public DummyLocalDAO(BiFunction, AspectEntry> getLatestFunction, - BaseMetadataEventProducer eventProducer) { + public DummyLocalDAO(FakeLatestAspectSupplier getLatestSupplier, + BaseMetadataEventProducer eventProducer) { super(EntityAspectUnion.class, eventProducer); - _getLatestFunction = getLatestFunction; + _getLatestSupplier = getLatestSupplier; } @Override @@ -50,8 +55,8 @@ protected long saveLatest(FooUrn urn, Class void updateLocalIndex(@Nonnull FooUrn urn, - @Nullable ASPECT newValue, long version) { + protected void updateLocalIndex(@Nonnull FooUrn urn, @Nullable ASPECT newValue, + long version) { } @@ -61,8 +66,9 @@ protected T runInTransactionWithRetry(Supplier block, int maxTransactionR } @Override + @SuppressWarnings("unchecked") protected AspectEntry getLatest(FooUrn urn, Class aspectClass) { - return _getLatestFunction.apply(urn, aspectClass); + return (AspectEntry) _getLatestSupplier.getLatest(urn, aspectClass); } @Override @@ -143,24 +149,25 @@ public long newNumericId(String namespace, int maxTransactionRetry) { private DummyLocalDAO _dummyLocalDAO; private AuditStamp _dummyAuditStamp; - private BaseMetadataEventProducer _mockEventProducer; - private BiFunction, BaseLocalDAO.AspectEntry> _mockGetLatestFunction; + private BaseMetadataEventProducer _mockEventProducer; + private FakeLatestAspectSupplier _mockLatestSupplier; @BeforeMethod + @SuppressWarnings("unchecked") public void setup() { - _mockGetLatestFunction = mock(BiFunction.class); + _mockLatestSupplier = mock(FakeLatestAspectSupplier.class); _mockEventProducer = mock(BaseMetadataEventProducer.class); - _dummyLocalDAO = new DummyLocalDAO(_mockGetLatestFunction, _mockEventProducer); + _dummyLocalDAO = new DummyLocalDAO(_mockLatestSupplier, _mockEventProducer); _dummyAuditStamp = makeAuditStamp("foo", 1234); } private BaseLocalDAO.AspectEntry makeAspectEntry(T aspect, AuditStamp auditStamp) { - return new BaseLocalDAO.AspectEntry(aspect, new ExtraInfo().setAudit(auditStamp)); + return new BaseLocalDAO.AspectEntry<>(aspect, new ExtraInfo().setAudit(auditStamp)); } private void expectGetLatest(FooUrn urn, Class aspectClass, List> returnValues) { - OngoingStubbing> ongoing = when(_mockGetLatestFunction.apply(urn, aspectClass)); + OngoingStubbing> ongoing = when(_mockLatestSupplier.getLatest(urn, aspectClass)); for (BaseLocalDAO.AspectEntry value : returnValues) { ongoing = ongoing.thenReturn(value); } @@ -236,6 +243,7 @@ public void testAddSamePostUpdateHookTwice() { public void testPostUpdateHookInvoked() throws URISyntaxException { FooUrn urn = new FooUrn(1); AspectFoo foo = new AspectFoo().setValue("foo"); + @SuppressWarnings("unchecked") BiConsumer hook = mock(BiConsumer.class); _dummyLocalDAO.addPostUpdateHook(AspectFoo.class, hook); diff --git a/dao-api/src/test/java/com/linkedin/metadata/dao/equality/DefaultEqualityTesterTest.java b/dao-api/src/test/java/com/linkedin/metadata/dao/equality/DefaultEqualityTesterTest.java index 2eeac5214..c2dea99e4 100644 --- a/dao-api/src/test/java/com/linkedin/metadata/dao/equality/DefaultEqualityTesterTest.java +++ b/dao-api/src/test/java/com/linkedin/metadata/dao/equality/DefaultEqualityTesterTest.java @@ -25,6 +25,6 @@ public void testSemanticEquality() throws IOException, CloneNotSupportedExceptio assertEquals(cloned.data().get("longField").getClass(), Long.class); // The two should still be semantically equal - assertTrue(new DefaultEqualityTester().equals(fromJson, cloned)); + assertTrue(new DefaultEqualityTester<>().equals(fromJson, cloned)); } } diff --git a/dao-api/src/test/java/com/linkedin/metadata/dao/utils/ModelUtilsTest.java b/dao-api/src/test/java/com/linkedin/metadata/dao/utils/ModelUtilsTest.java index 124b07702..72071b9c5 100644 --- a/dao-api/src/test/java/com/linkedin/metadata/dao/utils/ModelUtilsTest.java +++ b/dao-api/src/test/java/com/linkedin/metadata/dao/utils/ModelUtilsTest.java @@ -51,7 +51,7 @@ public void testGetAspectName() { @Test public void testGetAspectClass() { - Class aspectClass = ModelUtils.getAspectClass("com.linkedin.testing.AspectFoo"); + Class aspectClass = ModelUtils.getAspectClass("com.linkedin.testing.AspectFoo"); assertEquals(aspectClass, AspectFoo.class); } diff --git a/dao-impl/ebean-dao/src/test/java/com/linkedin/metadata/dao/EbeanLocalDAOTest.java b/dao-impl/ebean-dao/src/test/java/com/linkedin/metadata/dao/EbeanLocalDAOTest.java index 28eb423fe..5704c57c6 100644 --- a/dao-impl/ebean-dao/src/test/java/com/linkedin/metadata/dao/EbeanLocalDAOTest.java +++ b/dao-impl/ebean-dao/src/test/java/com/linkedin/metadata/dao/EbeanLocalDAOTest.java @@ -149,7 +149,7 @@ public void testAddTwo() { public void testDefaultEqualityTester() { EbeanLocalDAO dao = new EbeanLocalDAO<>(EntityAspectUnion.class, _mockProducer, _server, FooUrn.class); - dao.setEqualityTester(AspectFoo.class, DefaultEqualityTester.newInstance()); + dao.setEqualityTester(AspectFoo.class, DefaultEqualityTester.instance()); FooUrn urn = makeFooUrn(1); String aspectName = ModelUtils.getAspectName(AspectFoo.class); AspectFoo foo = new AspectFoo().setValue("foo"); @@ -181,7 +181,7 @@ public void testDefaultEqualityTester() { public void testAlwaysFalseEqualityTester() { EbeanLocalDAO dao = new EbeanLocalDAO<>(EntityAspectUnion.class, _mockProducer, _server, FooUrn.class); - dao.setEqualityTester(AspectFoo.class, AlwaysFalseEqualityTester.newInstance()); + dao.setEqualityTester(AspectFoo.class, AlwaysFalseEqualityTester.instance()); FooUrn urn = makeFooUrn(1); String aspectName = ModelUtils.getAspectName(AspectFoo.class); AspectFoo foo1 = new AspectFoo().setValue("foo");