Clean up code warnings (#8532)

This commit is contained in:
Suresh Srinivas 2022-11-04 11:24:46 -07:00 committed by GitHub
parent a7347e1873
commit 292672a970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 69 additions and 77 deletions

View File

@ -186,4 +186,10 @@ public final class CommonUtil {
public static String getResourceAsStream(ClassLoader loader, String file) throws IOException {
return IOUtils.toString(Objects.requireNonNull(loader.getResourceAsStream(file)), UTF_8);
}
/** Return list of entiries that are modifiable for performing sort and other operations */
@SafeVarargs
public static <T> List<T> listOf(T... entries) {
return new ArrayList<>(List.of(entries));
}
}

View File

@ -17,7 +17,7 @@
<sonar.tests>${project.basedir}/src/test/java</sonar.tests>
<sonar.tests>${project.basedir}/src/test/java</sonar.tests>
<org.testcontainers.version>1.17.4</org.testcontainers.version>
<awssdk.version>2.17.286</awssdk.version>
<awssdk.version>2.18.1</awssdk.version>
<expiring.map.version>0.5.10</expiring.map.version>
</properties>

View File

@ -32,7 +32,6 @@ import io.federecio.dropwizard.swagger.SwaggerBundle;
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerBundle;
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerHttpFilter;
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerJdbiTimingCollector;
import io.socket.engineio.server.EngineIoServerOptions;
import io.socket.engineio.server.JettyWebSocketHandler;
import java.io.IOException;
@ -177,8 +176,6 @@ public class OpenMetadataApplication extends Application<OpenMetadataApplication
private Jdbi createAndSetupJDBI(Environment environment, DataSourceFactory dbFactory) {
Jdbi jdbi = new JdbiFactory().build(environment, dbFactory, "database");
jdbi.setTimingCollector(new MicrometerJdbiTimingCollector());
SqlLogger sqlLogger =
new SqlLogger() {
@Override

View File

@ -14,7 +14,6 @@ public class ResourceRegistry {
public static void initialize(List<ResourceDescriptor> resourceDescriptors) {
RESOURCE_DESCRIPTORS.clear();
;
RESOURCE_DESCRIPTORS.addAll(resourceDescriptors);
RESOURCE_DESCRIPTORS.sort(Comparator.comparing(ResourceDescriptor::getName));
}

View File

@ -176,7 +176,7 @@ public class AirflowRESTClient extends PipelineServiceClient {
public Response getServiceStatus() {
HttpResponse<String> response;
try {
response = getRequestNoAuthForJsonContent("%s/%s/health", serviceURL, API_ENDPOINT);
response = getRequestNoAuthForJsonContent(serviceURL, API_ENDPOINT);
if (response.statusCode() == 200) {
JSONObject responseJSON = new JSONObject(response.body());
String ingestionVersion = responseJSON.getString("version");
@ -296,9 +296,9 @@ public class AirflowRESTClient extends PipelineServiceClient {
.header(AUTH_HEADER, getBasicAuthenticationHeader(username, password));
}
private HttpResponse<String> getRequestNoAuthForJsonContent(String stringUrlFormat, Object... stringReplacement)
private HttpResponse<String> getRequestNoAuthForJsonContent(Object... stringReplacement)
throws IOException, InterruptedException {
String url = String.format(stringUrlFormat, stringReplacement);
String url = String.format("%s/%s/health", stringReplacement);
HttpRequest request = HttpRequest.newBuilder(URI.create(url)).header(CONTENT_HEADER, CONTENT_TYPE).GET().build();
return client.send(request, HttpResponse.BodyHandlers.ofString());
}

View File

@ -43,6 +43,7 @@ public class EventFilter implements ContainerResponseFilter {
Set<String> eventHandlerClassNames =
new HashSet<>(config.getEventHandlerConfiguration().getEventHandlerClassNames());
for (String eventHandlerClassName : eventHandlerClassNames) {
@SuppressWarnings("unchecked")
EventHandler eventHandler =
((Class<EventHandler>) Class.forName(eventHandlerClassName)).getConstructor().newInstance();
eventHandler.init(config, jdbi);

View File

@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory;
public class CatalogGenericExceptionMapper implements ExceptionMapper<Throwable> {
@Override
public Response toResponse(Throwable ex) {
ex.printStackTrace();
LOG.debug(ex.getMessage());
if (ex instanceof ProcessingException || ex instanceof IllegalArgumentException) {
final Response response = BadRequestException.of().getResponse();

View File

@ -3158,7 +3158,7 @@ public interface CollectionDAO {
public static Settings getSettings(SettingsType configType, String json) {
Settings settings = new Settings();
settings.setConfigType(configType);
Object value = null;
Object value;
try {
if (configType == SettingsType.ACTIVITY_FEED_FILTER_SETTING) {
value = JsonUtils.readValue(json, new TypeReference<ArrayList<EventFilter>>() {});
@ -3206,7 +3206,7 @@ public interface CollectionDAO {
}
public static TokenInterface getToken(TokenType type, String json) throws IOException {
TokenInterface resp = null;
TokenInterface resp;
try {
switch (type) {
case EMAIL_VERIFICATION:

View File

@ -42,7 +42,7 @@ public class WebAnalyticEventRepository extends EntityRepository<WebAnalyticEven
}
@Override
public void prepare(WebAnalyticEvent entity) throws IOException {
public void prepare(WebAnalyticEvent entity) {
entity.setFullyQualifiedName(entity.getName());
}
@ -57,7 +57,7 @@ public class WebAnalyticEventRepository extends EntityRepository<WebAnalyticEven
}
@Override
public void storeRelationships(WebAnalyticEvent entity) throws IOException {
public void storeRelationships(WebAnalyticEvent entity) {
storeOwner(entity, entity.getOwner());
}

View File

@ -18,7 +18,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import java.io.IOException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@ -45,7 +44,7 @@ public class ConfigResource {
this.jwtTokenGenerator = JWTTokenGenerator.getInstance();
}
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
public void initialize(OpenMetadataApplicationConfig config) {
this.openMetadataApplicationConfig = config;
}

View File

@ -92,7 +92,7 @@ public class BuildSearchIndexResource {
2, 2, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(5), new ThreadPoolExecutor.CallerRunsPolicy());
}
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
public void initialize(OpenMetadataApplicationConfig config) {
if (config.getElasticSearchConfiguration() != null) {
this.client = ElasticSearchClientUtils.createElasticSearchClient(config.getElasticSearchConfiguration());
this.elasticSearchIndexDefinition = new ElasticSearchIndexDefinition(client, dao);
@ -308,7 +308,7 @@ public class BuildSearchIndexResource {
}
private synchronized void updateEntityStream(
UriInfo uriInfo, UUID startedBy, String entityType, CreateEventPublisherJob createRequest) throws IOException {
UriInfo uriInfo, UUID startedBy, String entityType, CreateEventPublisherJob createRequest) {
ElasticSearchIndexDefinition.ElasticSearchIndexType indexType =
elasticSearchIndexDefinition.getIndexMappingByEntityType(entityType);

View File

@ -339,8 +339,8 @@ public class FeedResource {
// check if logged in user satisfies any of the following
// - Creator of the task
// - logged in user or the teams they belong to were assigned the task
// - logged in user or the teams they belong to owns the entity that the task is about
// - logged-in user or the teams they belong to were assigned the task
// - logged-in user or the teams they belong to, owns the entity that the task is about
List<String> finalTeamNames = teamNames;
if (createdBy.equals(userName)
|| assignees.stream().anyMatch(assignee -> assignee.getName().equals(userName))

View File

@ -225,7 +225,7 @@ public class LineageResource {
return lineage;
}
class LineageResourceContext implements ResourceContextInterface {
static class LineageResourceContext implements ResourceContextInterface {
@Override
public String getResource() {

View File

@ -155,7 +155,7 @@ public class MetricsResource extends EntityResource<Metrics, MetricsRepository>
public Response create(@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid Metrics metrics)
throws IOException {
addToMetrics(securityContext, metrics);
return create(uriInfo, securityContext, metrics);
return super.create(uriInfo, securityContext, metrics);
}
@PUT
@ -174,7 +174,7 @@ public class MetricsResource extends EntityResource<Metrics, MetricsRepository>
public Response createOrUpdate(
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid Metrics metrics) throws IOException {
addToMetrics(securityContext, metrics);
return createOrUpdate(uriInfo, securityContext, metrics);
return super.createOrUpdate(uriInfo, securityContext, metrics);
}
private void addToMetrics(SecurityContext securityContext, Metrics metrics) {

View File

@ -147,7 +147,7 @@ public class ReportResource extends EntityResource<Report, ReportRepository> {
public Response create(@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid Report report)
throws IOException {
addToReport(securityContext, report);
return create(uriInfo, securityContext, report);
return super.create(uriInfo, securityContext, report);
}
@PUT
@ -166,7 +166,7 @@ public class ReportResource extends EntityResource<Report, ReportRepository> {
public Response createOrUpdate(
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid Report report) throws IOException {
addToReport(securityContext, report);
return createOrUpdate(uriInfo, securityContext, report);
return super.createOrUpdate(uriInfo, securityContext, report);
}
private void addToReport(SecurityContext securityContext, Report report) {

View File

@ -93,7 +93,7 @@ public class SearchResource {
public SearchResource() {}
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
public void initialize(OpenMetadataApplicationConfig config) {
if (config.getElasticSearchConfiguration() != null) {
this.client = ElasticSearchClientUtils.createElasticSearchClient(config.getElasticSearchConfiguration());
}

View File

@ -130,7 +130,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
private final TokenRepository tokenRepository;
private boolean isEmailServiceEnabled;
private AuthenticationConfiguration authenticationConfiguration;
private AuthenticatorHandler authHandler;
private final AuthenticatorHandler authHandler;
@Override
public User addHref(UriInfo uriInfo, User user) {
@ -151,7 +151,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
}
@Override
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
public void initialize(OpenMetadataApplicationConfig config) {
this.authenticationConfiguration = config.getAuthenticationConfiguration();
SmtpSettings smtpSettings = config.getSmtpSettings();
this.isEmailServiceEnabled = smtpSettings != null && smtpSettings.getEnableSmtpServer();
@ -864,8 +864,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = "400", description = "Bad request")
})
public Response resetUserPassword(@Context UriInfo uriInfo, @Valid PasswordResetRequest request)
throws IOException, TemplateException {
public Response resetUserPassword(@Context UriInfo uriInfo, @Valid PasswordResetRequest request) throws IOException {
authHandler.resetUserPasswordWithToken(uriInfo, request);
return Response.status(200).entity("Password Changed Successfully").build();
}

View File

@ -235,11 +235,8 @@ public class DefaultAuthorizer implements Authorizer {
return true;
}
SecretsManager secretsManager = SecretsManagerFactory.getSecretsManager();
if (subjectContext.isBot() && secretsManager.isLocal()) {
// Local secretsManager true means secrets are not encrypted. So allow decrypted secrets for bots.
return true;
}
return false;
// Local secretsManager true means secrets are not encrypted. So allow decrypted secrets for bots.
return subjectContext.isBot() && secretsManager.isLocal();
}
private void addUsers(Set<String> users, String domain, Boolean isAdmin) {

View File

@ -431,6 +431,7 @@ public class BasicAuthenticator implements AuthenticatorHandler {
}
public void validatePassword(User storedUser, String reqPassword) throws TemplateException, IOException {
@SuppressWarnings("unchecked")
LinkedHashMap<String, String> storedData =
(LinkedHashMap<String, String>) storedUser.getAuthenticationMechanism().getConfig();
String storedHashPassword = storedData.get("password");

View File

@ -69,17 +69,17 @@ public class EmailUtil {
}
private Mailer createMailer(SmtpSettings smtpServerSettings) {
TransportStrategy strategy = SMTP;
TransportStrategy strategy;
switch (smtpServerSettings.getTransportationStrategy()) {
case SMTP:
strategy = SMTP;
break;
case SMPTS:
strategy = SMTPS;
break;
case SMTP_TLS:
strategy = SMTP_TLS;
break;
default:
strategy = SMTP;
break;
}
return MailerBuilder.withSMTPServer(
smtpServerSettings.getServerEndpoint(),
@ -240,18 +240,13 @@ public class EmailUtil {
mailer.testConnection();
}
public void sendMailWithSmtp(Email email, SmtpSettings settings) {
createMailer(settings).sendMail(email);
}
public static class EmailUtilBuilder {
private EmailUtilBuilder() {}
public static EmailUtil build(SmtpSettings smtpServerSettings) {
public static void build(SmtpSettings smtpServerSettings) {
if (INSTANCE == null) {
INSTANCE = new EmailUtil(smtpServerSettings);
}
return INSTANCE;
}
}

View File

@ -144,6 +144,7 @@ public class FilterUtil {
public static Settings updateEntityFilter(Settings oldValue, String entityType, List<Filters> filters) {
// all existing filters
@SuppressWarnings("unchecked")
List<EventFilter> existingEntityFilter = (List<EventFilter>) oldValue.getConfigValue();
EventFilter entititySpecificFilter = null;
int position = 0;

View File

@ -105,7 +105,9 @@ public final class JsonUtils {
}
public static Map<String, Object> getMap(Object o) {
return OBJECT_MAPPER.convertValue(o, Map.class);
@SuppressWarnings("unchecked")
Map<String, Object> map = OBJECT_MAPPER.convertValue(o, Map.class);
return map;
}
public static <T> T readValue(String json, Class<T> clz) throws IOException {

View File

@ -72,7 +72,6 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -96,6 +95,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.CreateEntity;
import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.api.data.TermReference;
@ -1315,7 +1315,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
String json = JsonUtils.pojoToJson(entityType);
ChangeDescription change = getChangeDescription(entityType.getVersion());
fieldAdded(change, "customProperties", Arrays.asList(fieldB));
fieldAdded(change, "customProperties", CommonUtil.listOf(fieldB));
entityType.getCustomProperties().add(fieldB);
entityType = typeResourceTest.patchEntityAndCheck(entityType, json, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);

View File

@ -49,7 +49,7 @@ public class WebAnalyticEventResourceTest extends EntityResourceTest<WebAnalytic
}
@Test
void post_web_analytic_event_4x(TestInfo test) throws IOException {
void post_web_analytic_event_4x(TestInfo test) {
assertResponseContains(
() -> createEntity(createRequest(test).withEventType(null), ADMIN_AUTH_HEADERS),
BAD_REQUEST,
@ -62,7 +62,7 @@ public class WebAnalyticEventResourceTest extends EntityResourceTest<WebAnalytic
}
@Test
void put_web_analytic_event_data_200(TestInfo test) throws IOException, ParseException {
void put_web_analytic_event_data_200() throws IOException, ParseException {
WebAnalyticEventData webAnalyticEventData =
new WebAnalyticEventData()
.withTimestamp(TestUtils.dateToTimestamp("2022-10-11"))
@ -95,30 +95,25 @@ public class WebAnalyticEventResourceTest extends EntityResourceTest<WebAnalytic
@Override
public void validateCreatedEntity(
WebAnalyticEvent createdEntity, CreateWebAnalyticEvent request, Map<String, String> authHeaders)
throws HttpResponseException {
WebAnalyticEvent createdEntity, CreateWebAnalyticEvent request, Map<String, String> authHeaders) {
assertEquals(request.getName(), createdEntity.getName());
assertEquals(request.getDescription(), createdEntity.getDescription());
}
@Override
public void compareEntities(WebAnalyticEvent expected, WebAnalyticEvent updated, Map<String, String> authHeaders)
throws HttpResponseException {
public void compareEntities(WebAnalyticEvent expected, WebAnalyticEvent updated, Map<String, String> authHeaders) {
assertEquals(expected.getName(), updated.getName());
assertEquals(expected.getFullyQualifiedName(), updated.getFullyQualifiedName());
assertEquals(expected.getDescription(), updated.getDescription());
}
@Override
public WebAnalyticEvent validateGetWithDifferentFields(WebAnalyticEvent entity, boolean byName)
throws HttpResponseException {
public WebAnalyticEvent validateGetWithDifferentFields(WebAnalyticEvent entity, boolean byName) {
return null;
}
@Override
public void assertFieldChange(String fieldName, Object expected, Object actual) throws IOException {
return;
}
public void assertFieldChange(String fieldName, Object expected, Object actual) {}
public static void putWebAnalyticEventData(WebAnalyticEventData data, Map<String, String> authHeaders)
throws HttpResponseException {

View File

@ -15,8 +15,8 @@ package org.openmetadata.service.resources.services.ingestionpipelines;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.OK;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openmetadata.service.Entity.FIELD_OWNER;
@ -138,15 +138,13 @@ public class IngestionPipelineResourceTest extends EntityResourceTest<IngestionP
@Override
public void validateCreatedEntity(
IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map<String, String> authHeaders)
throws HttpResponseException {
IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map<String, String> authHeaders) {
assertEquals(createRequest.getAirflowConfig().getConcurrency(), ingestion.getAirflowConfig().getConcurrency());
validateSourceConfig(createRequest.getSourceConfig(), ingestion.getSourceConfig(), ingestion);
}
@Override
public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map<String, String> authHeaders)
throws HttpResponseException {
public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map<String, String> authHeaders) {
assertEquals(expected.getDisplayName(), updated.getDisplayName());
assertReference(expected.getService(), updated.getService());
assertEquals(expected.getSourceConfig(), updated.getSourceConfig());

View File

@ -129,6 +129,7 @@ public class IngestionPipelineResourceUnitTest {
mockConstruction(AirflowRESTClient.class, this::preparePipelineServiceClient)) {
ingestionPipelineResource.initialize(openMetadataApplicationConfig);
PipelineServiceClient client = mocked.constructed().get(0);
@SuppressWarnings("unchecked")
HttpResponse<String> httpResponse = mock(HttpResponse.class);
when(client.testConnection(any())).thenReturn(httpResponse);
ingestionPipelineResource.testIngestion(null, null, testServiceConnection);

View File

@ -65,6 +65,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.api.policies.CreatePolicy;
import org.openmetadata.schema.api.teams.CreateRole;
import org.openmetadata.schema.api.teams.CreateTeam;
@ -598,7 +599,7 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
EntityReference deletedUser = team.getUsers().get(removeUserIndex);
team.getUsers().remove(removeUserIndex);
ChangeDescription change = getChangeDescription(team.getVersion());
fieldDeleted(change, "users", Arrays.asList(deletedUser));
fieldDeleted(change, "users", CommonUtil.listOf(deletedUser));
team = patchEntityAndCheck(team, json, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change);
// Remove a default role from the team using patch request
@ -607,7 +608,7 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
EntityReference deletedRole = team.getDefaultRoles().get(removeDefaultRoleIndex);
team.getDefaultRoles().remove(removeDefaultRoleIndex);
change = getChangeDescription(team.getVersion());
fieldDeleted(change, "defaultRoles", Arrays.asList(deletedRole));
fieldDeleted(change, "defaultRoles", CommonUtil.listOf(deletedRole));
patchEntityAndCheck(team, json, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change);
}

View File

@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.service.exception.CatalogExceptionMessage.PASSWORD_INVALID_FORMAT;
@ -579,7 +580,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
String origJson = JsonUtils.pojoToJson(user);
String timezone = "America/Los_Angeles";
user.withRoles(Arrays.asList(role1))
user.withRoles(listOf(role1))
.withTeams(teams)
.withTimezone(timezone)
.withDisplayName("displayName")
@ -587,8 +588,8 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
.withIsBot(false)
.withIsAdmin(false);
ChangeDescription change = getChangeDescription(user.getVersion());
fieldAdded(change, "roles", Arrays.asList(role1));
fieldDeleted(change, "teams", Arrays.asList(ORG_TEAM.getEntityReference()));
fieldAdded(change, "roles", listOf(role1));
fieldDeleted(change, "teams", listOf(ORG_TEAM.getEntityReference()));
fieldAdded(change, "teams", teams);
fieldAdded(change, "timezone", timezone);
fieldAdded(change, "displayName", "displayName");
@ -607,7 +608,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
roleResourceTest.createEntity(roleResourceTest.createRequest(test, 2), ADMIN_AUTH_HEADERS).getEntityReference();
origJson = JsonUtils.pojoToJson(user);
user.withRoles(Arrays.asList(role2))
user.withRoles(listOf(role2))
.withTeams(teams1)
.withTimezone(timezone1)
.withDisplayName("displayName1")
@ -616,10 +617,10 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
.withIsAdmin(false);
change = getChangeDescription(user.getVersion());
fieldDeleted(change, "roles", Arrays.asList(role1));
fieldAdded(change, "roles", Arrays.asList(role2));
fieldDeleted(change, "teams", of(team2));
fieldAdded(change, "teams", of(team3));
fieldDeleted(change, "roles", listOf(role1));
fieldAdded(change, "roles", listOf(role2));
fieldDeleted(change, "teams", listOf(team2));
fieldAdded(change, "teams", listOf(team3));
fieldUpdated(change, "timezone", timezone, timezone1);
fieldUpdated(change, "displayName", "displayName", "displayName1");
fieldUpdated(change, "profile", profile, profile1);
@ -640,9 +641,9 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
// Note non-empty display field is not deleted. When teams are deleted, Organization is added back as default team.
change = getChangeDescription(user.getVersion());
fieldDeleted(change, "roles", Arrays.asList(role2));
fieldDeleted(change, "roles", listOf(role2));
fieldDeleted(change, "teams", teams1);
fieldAdded(change, "teams", Arrays.asList(ORG_TEAM.getEntityReference()));
fieldAdded(change, "teams", listOf(ORG_TEAM.getEntityReference()));
fieldDeleted(change, "timezone", timezone1);
fieldDeleted(change, "displayName", "displayName1");
fieldDeleted(change, "profile", profile1);

View File

@ -30,7 +30,7 @@ class LambdaExceptionUtilTest {
void testThrowingConsumer() {
assertThrows(
ClassNotFoundException.class,
() -> Stream.of("java.lang.String", "java.bad.Class").forEach(rethrowConsumer(c -> Class.forName(c))));
() -> Stream.of("java.lang.String", "java.bad.Class").forEach(rethrowConsumer(Class::forName)));
}
@Test

View File

@ -439,7 +439,7 @@ public final class TestUtils {
for (UUID id : listOrEmpty(expected)) {
actual = listOrEmpty(actual);
assertEquals(expected.size(), actual.size());
assertNotNull(actual.stream().filter(entity -> entity.getId().equals(id)).findAny().get());
assertNotNull(actual.stream().filter(entity -> entity.getId().equals(id)).findAny().orElse(null));
}
validateEntityReferences(actual);
}