Skip to content

Commit

Permalink
fix(test): fix test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker committed Sep 22, 2023
1 parent aff1e7a commit 3df5b2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ subprojects {
}
// https://docs.gradle.org/current/userguide/performance.html
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1

if (project.configurations.getByName("testImplementation").getDependencies()
.any{ it.getName() == "testng" }) {
useTestNG()
}
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.linkedin.datahub.graphql.resolvers.auth;

import com.datahub.authentication.Authentication;
import com.google.common.collect.ImmutableList;
import com.linkedin.datahub.graphql.QueryContext;
import com.linkedin.datahub.graphql.TestUtils;
Expand All @@ -8,6 +9,10 @@
import com.linkedin.datahub.graphql.generated.ListAccessTokenResult;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.metadata.Constants;
import com.linkedin.metadata.query.SearchFlags;
import com.linkedin.metadata.query.filter.SortCriterion;
import com.linkedin.metadata.search.SearchEntityArray;
import com.linkedin.metadata.search.SearchResult;
import graphql.schema.DataFetchingEnvironment;
import java.util.Collections;
import org.mockito.Mockito;
Expand Down Expand Up @@ -36,14 +41,17 @@ public void testGetSuccess() throws Exception {
Mockito.when(mockEnv.getArgument(Mockito.eq("input"))).thenReturn(input);

final EntityClient mockClient = Mockito.mock(EntityClient.class);
Mockito.when(Mockito.eq(mockClient.filter(
Mockito.eq(Constants.ACCESS_TOKEN_ENTITY_NAME),
Mockito.eq(buildFilter(filters, Collections.emptyList())),
Mockito.notNull(),
Mockito.eq(input.getStart()),
Mockito.eq(input.getCount()),
Mockito.eq(getAuthentication(mockEnv)))))
.thenReturn(null);
final Authentication testAuth = getAuthentication(mockEnv);
Mockito.when(mockClient.search(
Mockito.eq(Constants.ACCESS_TOKEN_ENTITY_NAME),
Mockito.eq(""),
Mockito.eq(buildFilter(filters, Collections.emptyList())),
Mockito.any(SortCriterion.class),
Mockito.eq(input.getStart()),
Mockito.eq(input.getCount()),
Mockito.eq(testAuth),
Mockito.any(SearchFlags.class)))
.thenReturn(new SearchResult().setFrom(0).setNumEntities(0).setPageSize(0).setEntities(new SearchEntityArray()));

final ListAccessTokensResolver resolver = new ListAccessTokensResolver(mockClient);
final ListAccessTokenResult listAccessTokenResult = resolver.get(mockEnv).get();
Expand Down

0 comments on commit 3df5b2a

Please sign in to comment.