diff --git a/common/src/main/java/org/openmetadata/common/utils/CommonUtil.java b/common/src/main/java/org/openmetadata/common/utils/CommonUtil.java index 9f9a7cd40c8..7a9c1e3f30a 100644 --- a/common/src/main/java/org/openmetadata/common/utils/CommonUtil.java +++ b/common/src/main/java/org/openmetadata/common/utils/CommonUtil.java @@ -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 List listOf(T... entries) { + return new ArrayList<>(List.of(entries)); + } } diff --git a/openmetadata-service/pom.xml b/openmetadata-service/pom.xml index 1cbec4416f2..cb596eb4b39 100644 --- a/openmetadata-service/pom.xml +++ b/openmetadata-service/pom.xml @@ -17,7 +17,7 @@ ${project.basedir}/src/test/java ${project.basedir}/src/test/java 1.17.4 - 2.17.286 + 2.18.1 0.5.10 diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java b/openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java index 4fa3c74dbfc..f87fb5fcc2f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java @@ -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 resourceDescriptors) { RESOURCE_DESCRIPTORS.clear(); - ; RESOURCE_DESCRIPTORS.addAll(resourceDescriptors); RESOURCE_DESCRIPTORS.sort(Comparator.comparing(ResourceDescriptor::getName)); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/airflow/AirflowRESTClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/airflow/AirflowRESTClient.java index 9a8e3a21c41..389cc5b61e7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/airflow/AirflowRESTClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/airflow/AirflowRESTClient.java @@ -176,7 +176,7 @@ public class AirflowRESTClient extends PipelineServiceClient { public Response getServiceStatus() { HttpResponse 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 getRequestNoAuthForJsonContent(String stringUrlFormat, Object... stringReplacement) + private HttpResponse 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()); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/events/EventFilter.java b/openmetadata-service/src/main/java/org/openmetadata/service/events/EventFilter.java index ce5c09d88a3..d17ec3d8ab7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/events/EventFilter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/events/EventFilter.java @@ -43,6 +43,7 @@ public class EventFilter implements ContainerResponseFilter { Set eventHandlerClassNames = new HashSet<>(config.getEventHandlerConfiguration().getEventHandlerClassNames()); for (String eventHandlerClassName : eventHandlerClassNames) { + @SuppressWarnings("unchecked") EventHandler eventHandler = ((Class) Class.forName(eventHandlerClassName)).getConstructor().newInstance(); eventHandler.init(config, jdbi); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogGenericExceptionMapper.java b/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogGenericExceptionMapper.java index 5166438f9a5..7e3c0d9ee87 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogGenericExceptionMapper.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogGenericExceptionMapper.java @@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory; public class CatalogGenericExceptionMapper implements ExceptionMapper { @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(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java index 4908c6d6cc8..937ba7a3a8e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java @@ -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>() {}); @@ -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: diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WebAnalyticEventRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WebAnalyticEventRepository.java index bf8daa1debf..c139ef2c7f7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WebAnalyticEventRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WebAnalyticEventRepository.java @@ -42,7 +42,7 @@ public class WebAnalyticEventRepository extends EntityRepository(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); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/feeds/FeedResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/feeds/FeedResource.java index 10eea1b117c..9b4bdba3ba4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/feeds/FeedResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/feeds/FeedResource.java @@ -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 finalTeamNames = teamNames; if (createdBy.equals(userName) || assignees.stream().anyMatch(assignee -> assignee.getName().equals(userName)) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java index 94180e41de9..af84042ec5c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java @@ -225,7 +225,7 @@ public class LineageResource { return lineage; } - class LineageResourceContext implements ResourceContextInterface { + static class LineageResourceContext implements ResourceContextInterface { @Override public String getResource() { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricsResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricsResource.java index cc9299ac529..5f886fa422a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricsResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricsResource.java @@ -155,7 +155,7 @@ public class MetricsResource extends EntityResource 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 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) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/reports/ReportResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/reports/ReportResource.java index c077265595b..252f076047a 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/reports/ReportResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/reports/ReportResource.java @@ -147,7 +147,7 @@ public class ReportResource extends EntityResource { 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 { 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) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java index e29b468fe03..a894f9a177d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/search/SearchResource.java @@ -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()); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java index e0797f424c2..a58cf6f78e3 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java @@ -130,7 +130,7 @@ public class UserResource extends EntityResource { 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 { } @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 { 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(); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/DefaultAuthorizer.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/DefaultAuthorizer.java index 17bb0b1425e..c2c0bfc7aca 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/DefaultAuthorizer.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/DefaultAuthorizer.java @@ -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 users, String domain, Boolean isAdmin) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/BasicAuthenticator.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/BasicAuthenticator.java index 287313dd7d4..94be28ebeb5 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/BasicAuthenticator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/BasicAuthenticator.java @@ -431,6 +431,7 @@ public class BasicAuthenticator implements AuthenticatorHandler { } public void validatePassword(User storedUser, String reqPassword) throws TemplateException, IOException { + @SuppressWarnings("unchecked") LinkedHashMap storedData = (LinkedHashMap) storedUser.getAuthenticationMechanism().getConfig(); String storedHashPassword = storedData.get("password"); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/EmailUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/EmailUtil.java index b6fd1e3555e..2a72ce088ce 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/EmailUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/EmailUtil.java @@ -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; } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/FilterUtil.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/FilterUtil.java index 40d18f08fff..d91a129b303 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/FilterUtil.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/FilterUtil.java @@ -144,6 +144,7 @@ public class FilterUtil { public static Settings updateEntityFilter(Settings oldValue, String entityType, List filters) { // all existing filters + @SuppressWarnings("unchecked") List existingEntityFilter = (List) oldValue.getConfigValue(); EventFilter entititySpecificFilter = null; int position = 0; diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonUtils.java b/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonUtils.java index 10dbe90f448..6d6c2affc89 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonUtils.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/util/JsonUtils.java @@ -105,7 +105,9 @@ public final class JsonUtils { } public static Map getMap(Object o) { - return OBJECT_MAPPER.convertValue(o, Map.class); + @SuppressWarnings("unchecked") + Map map = OBJECT_MAPPER.convertValue(o, Map.class); + return map; } public static T readValue(String json, Class clz) throws IOException { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java index 2d06568d778..2a13f36252d 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/EntityResourceTest.java @@ -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 createEntity(createRequest(test).withEventType(null), ADMIN_AUTH_HEADERS), BAD_REQUEST, @@ -62,7 +62,7 @@ public class WebAnalyticEventResourceTest extends EntityResourceTest authHeaders) - throws HttpResponseException { + WebAnalyticEvent createdEntity, CreateWebAnalyticEvent request, Map authHeaders) { assertEquals(request.getName(), createdEntity.getName()); assertEquals(request.getDescription(), createdEntity.getDescription()); } @Override - public void compareEntities(WebAnalyticEvent expected, WebAnalyticEvent updated, Map authHeaders) - throws HttpResponseException { + public void compareEntities(WebAnalyticEvent expected, WebAnalyticEvent updated, Map 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 authHeaders) throws HttpResponseException { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceTest.java index ce190a2ea84..4d76a1f2619 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceTest.java @@ -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 authHeaders) - throws HttpResponseException { + IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map authHeaders) { assertEquals(createRequest.getAirflowConfig().getConcurrency(), ingestion.getAirflowConfig().getConcurrency()); validateSourceConfig(createRequest.getSourceConfig(), ingestion.getSourceConfig(), ingestion); } @Override - public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map authHeaders) - throws HttpResponseException { + public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map authHeaders) { assertEquals(expected.getDisplayName(), updated.getDisplayName()); assertReference(expected.getService(), updated.getService()); assertEquals(expected.getSourceConfig(), updated.getSourceConfig()); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceUnitTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceUnitTest.java index a0d5a5b2d71..65e9a8acc95 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceUnitTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResourceUnitTest.java @@ -129,6 +129,7 @@ public class IngestionPipelineResourceUnitTest { mockConstruction(AirflowRESTClient.class, this::preparePipelineServiceClient)) { ingestionPipelineResource.initialize(openMetadataApplicationConfig); PipelineServiceClient client = mocked.constructed().get(0); + @SuppressWarnings("unchecked") HttpResponse httpResponse = mock(HttpResponse.class); when(client.testConnection(any())).thenReturn(httpResponse); ingestionPipelineResource.testIngestion(null, null, testServiceConnection); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/TeamResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/TeamResourceTest.java index c3fc4c1055a..1fed9560b9c 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/TeamResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/TeamResourceTest.java @@ -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 { 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 { 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); } diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/UserResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/UserResourceTest.java index 56ec1c16ff1..51e25ea7598 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/UserResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/teams/UserResourceTest.java @@ -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 { 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 { .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 { 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 { .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 { // 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); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/util/LambdaExceptionUtilTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/util/LambdaExceptionUtilTest.java index cb649f109d8..2c37dffa7b7 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/util/LambdaExceptionUtilTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/util/LambdaExceptionUtilTest.java @@ -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 diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/util/TestUtils.java b/openmetadata-service/src/test/java/org/openmetadata/service/util/TestUtils.java index 1f08782095e..f5ea10d1d2a 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/util/TestUtils.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/util/TestUtils.java @@ -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); }