Skip to content

Commit

Permalink
fix: turn on werror for restli-resources. (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Plaisted authored Dec 1, 2020
1 parent b4f46ad commit df6433d
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def wErrorProjects = [
// project(':dao-impl:ebean-dao'),
// project(':dao-impl:elasticsearch-dao'),
// project(':dao-impl:neo4j-dao'),
// project(':restli-resources'),
project(':restli-resources'),
project(':testing'),
project(':validators')
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public Task<Void> ingest(@ActionParam(PARAM_SNAPSHOT) @Nonnull SNAPSHOT snapshot
protected Task<Void> ingestInternal(@Nonnull SNAPSHOT snapshot,
@Nonnull Set<Class<? extends RecordTemplate>> aspectsToIgnore) {
return RestliUtils.toTask(() -> {
@SuppressWarnings("unchecked")
final URN urn = (URN) ModelUtils.getUrnFromSnapshot(snapshot);
final AuditStamp auditStamp = getAuditor().requestAuditStamp(getContext().getRawRequestContext());
ModelUtils.getAspectsFromSnapshot(snapshot).stream().forEach(aspect -> {
Expand Down Expand Up @@ -222,6 +223,7 @@ public Task<SNAPSHOT> getSnapshot(@ActionParam(PARAM_URN) @Nonnull String urnStr
* @deprecated Use {@link #backfill(String[], String[])} instead
*/
@Action(name = ACTION_BACKFILL_LEGACY)
@Deprecated
@Nonnull
public Task<BackfillResult> backfill(@ActionParam(PARAM_URN) @Nonnull String urnString,
@ActionParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
Expand Down Expand Up @@ -319,6 +321,7 @@ private IndexFilter getDefaultIndexFilter() {
* @deprecated Use {@link #filter(IndexFilter, String[], String, PagingContext)} instead
*/
@Action(name = ACTION_LIST_URNS_FROM_INDEX)
@Deprecated
@Nonnull
public Task<String[]> listUrnsFromIndex(@ActionParam(PARAM_FILTER) @Optional @Nullable IndexFilter indexFilter,
@ActionParam(PARAM_URN) @Optional @Nullable String lastUrn, @ActionParam(PARAM_LIMIT) int limit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public Task<AutoCompleteResult> autocomplete(@ActionParam(PARAM_QUERY) @Nonnull
return RestliUtils.toTask(() -> getSearchDAO().autoComplete(query, field, filter, limit));
}

@SuppressWarnings("unchecked")
@Nonnull
private CollectionResult<VALUE, SearchResultMetadata> getSearchQueryCollectionResult(@Nonnull SearchResult<DOCUMENT> searchResult,
@Nullable String[] aspectNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public Task<CreateKVResponse<Long, ASPECT>> createAndGet(@Nonnull Class<ASPECT>
*/
@RestMethod.Create
@ReturnEntity
@SuppressWarnings("unchecked")
@Nonnull
public Task<CreateKVResponse<Long, ASPECT>> createIfAbsent(@Nonnull ASPECT defaultValue) {
return createAndGet((Class<ASPECT>) defaultValue.getClass(), ignored -> ignored.orElse(defaultValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
* @deprecated Use {@link BaseBrowsableClient} instead
*/
@Deprecated
public interface BrowsableClient<URN extends Urn> {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @param <VALUE> the client's value type.
* @deprecated Use {@link BaseSearchableClient} instead
*/
@Deprecated
public interface SearchableClient<VALUE extends RecordTemplate> {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public TestResource() {
@Nonnull
@Override
protected BaseLocalDAO<EntityAspectUnion, Urn> getLocalDAO() {
throw new RuntimeException("Not implemented");
throw new UnsupportedOperationException("Not implemented");
}

@Nonnull
@Override
protected BaseSearchDAO getSearchDAO() {
throw new RuntimeException("Not implemented");
protected BaseSearchDAO<EntityDocument> getSearchDAO() {
throw new UnsupportedOperationException("Not implemented");
}

@Nonnull
Expand All @@ -74,25 +74,25 @@ protected Urn createUrnFromString(@Nonnull String urnString) {
@Nonnull
@Override
protected Urn toUrn(@Nonnull ComplexResourceKey<EntityKey, EmptyRecord> key) {
throw new RuntimeException("Not implemented");
throw new UnsupportedOperationException("Not implemented");
}

@Nonnull
@Override
protected ComplexResourceKey<EntityKey, EmptyRecord> toKey(@Nonnull Urn urn) {
throw new RuntimeException("Not implemented");
throw new UnsupportedOperationException("Not implemented");
}

@Nonnull
@Override
protected EntityValue toValue(@Nonnull EntitySnapshot snapshot) {
throw new RuntimeException("Not implemented");
throw new UnsupportedOperationException("Not implemented");
}

@Nonnull
@Override
protected EntitySnapshot toSnapshot(@Nonnull EntityValue value, @Nonnull Urn urn) {
throw new RuntimeException("Not implemented");
throw new UnsupportedOperationException("Not implemented");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public ResourceContext getContext() {
}

@BeforeMethod
@SuppressWarnings("unchecked")
public void setup() {
_mockLocalDAO = mock(BaseLocalDAO.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected BaseLocalDAO<EntityAspectUnion, Urn> getLocalDAO() {

@Nonnull
@Override
protected BaseSearchDAO getSearchDAO() {
protected BaseSearchDAO<EntityDocument> getSearchDAO() {
return _mockSearchDAO;
}

Expand Down Expand Up @@ -130,6 +130,7 @@ public ResourceContext getContext() {
}

@BeforeMethod
@SuppressWarnings("unchecked")
public void setup() {
_mockLocalDAO = mock(BaseLocalDAO.class);
_mockSearchDAO = mock(BaseSearchDAO.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.testng.annotations.Test;

import static com.linkedin.common.AuditStamps.*;
import static com.linkedin.metadata.dao.BaseReadDAO.LATEST_VERSION;
import static com.linkedin.metadata.dao.BaseReadDAO.*;
import static com.linkedin.testing.TestUtils.*;
import static org.mockito.Mockito.*;
import static org.testng.Assert.*;
Expand Down Expand Up @@ -199,7 +199,7 @@ public void testGetAll() {
ExtraInfo extraInfo2 = makeExtraInfo(makeUrn(2), LATEST_VERSION, makeAuditStamp("bar2"));
ListResultMetadata listResultMetadata =
new ListResultMetadata().setExtraInfos(new ExtraInfoArray(ImmutableList.of(extraInfo1, extraInfo2)));
ListResult listResult = ListResult.<AspectBar>builder().values(bars).metadata(listResultMetadata).build();
ListResult<AspectBar> listResult = ListResult.<AspectBar>builder().values(bars).metadata(listResultMetadata).build();

PagingContext pagingContext = new PagingContext(0, 2);
when(_mockLocalDao.list(AspectBar.class, pagingContext.getStart(), pagingContext.getCount())).thenReturn(listResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public ResourceContext getContext() {
}

@BeforeMethod
@SuppressWarnings("unchecked")
public void setup() {
_mockLocalDAO = mock(BaseLocalDAO.class);
}
Expand All @@ -88,7 +89,8 @@ public void testGetAllWithMetadata() {
new AuditStamp().setActor(Urns.createFromTypeSpecificString("testUser", "bar2")).setTime(0L));
ListResultMetadata listResultMetadata =
new ListResultMetadata().setExtraInfos(new ExtraInfoArray(ImmutableList.of(extraInfo1, extraInfo2)));
ListResult listResult = ListResult.<AspectFoo>builder().values(foos).metadata(listResultMetadata).build();
ListResult<AspectFoo> listResult =
ListResult.<AspectFoo>builder().values(foos).metadata(listResultMetadata).build();
when(_mockLocalDAO.list(AspectFoo.class, ENTITY_URN, 1, 2)).thenReturn(listResult);

CollectionResult<AspectFoo, ListResultMetadata> collectionResult =
Expand Down Expand Up @@ -137,6 +139,7 @@ public void testCreateResponseViaLambda() {
}

@Test
@SuppressWarnings("unchecked")
public void testCreateIfAbsentWithoutExistingValue() {
AspectFoo defaultValue = new AspectFoo().setValue("foo");
when(_mockLocalDAO.add(eq(ENTITY_URN), eq(AspectFoo.class), any(), any())).thenAnswer(
Expand All @@ -156,6 +159,7 @@ public void testCreateIfAbsentWithoutExistingValue() {
}

@Test
@SuppressWarnings("unchecked")
public void testCreateIfAbsentWithExistingValue() {
AspectFoo oldVal = new AspectFoo().setValue("foo");
AspectFoo defaultValue = new AspectFoo().setValue("defaultFoo");
Expand Down

0 comments on commit df6433d

Please sign in to comment.