From b695293de3d806383c271ea1f4e85584a901de1c Mon Sep 17 00:00:00 2001 From: Ido Berkovich Date: Wed, 8 Jan 2025 13:46:43 +0200 Subject: [PATCH] apply spotless (#994) --- .../api/ExperimentItemSearchCriteria.java | 6 ++--- .../opik/api/ExperimentItemStreamRequest.java | 3 +-- .../comet/opik/domain/ExperimentItemDAO.java | 3 ++- .../opik/domain/ExperimentItemService.java | 1 - .../opik/infrastructure/EncryptionUtils.java | 1 + .../api/resources/utils/AssertionUtils.java | 9 ++++--- .../v1/priv/DatasetsResourceTest.java | 8 +++--- .../v1/priv/ExperimentsResourceTest.java | 26 ++++++++++++------- .../priv/FeedbackDefinitionResourceTest.java | 2 +- .../v1/priv/ProjectMetricsResourceTest.java | 2 +- .../v1/priv/ProjectsResourceTest.java | 2 +- .../resources/v1/priv/PromptResourceTest.java | 2 +- .../resources/v1/priv/SpansResourceTest.java | 2 +- .../resources/v1/priv/TracesResourceTest.java | 2 +- 14 files changed, 40 insertions(+), 29 deletions(-) diff --git a/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemSearchCriteria.java b/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemSearchCriteria.java index 3da8b17445..eee0b1fc6f 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemSearchCriteria.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemSearchCriteria.java @@ -5,9 +5,9 @@ import java.util.UUID; @Builder(toBuilder = true) -public record ExperimentItemSearchCriteria ( +public record ExperimentItemSearchCriteria( String experimentName, Integer limit, UUID lastRetrievedId, - boolean truncate -) {} + boolean truncate) { +} diff --git a/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemStreamRequest.java b/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemStreamRequest.java index d7a945b423..6150d5f142 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemStreamRequest.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/api/ExperimentItemStreamRequest.java @@ -19,8 +19,7 @@ public record ExperimentItemStreamRequest( @NotBlank String experimentName, @Min(1) @Max(2000) Integer limit, UUID lastRetrievedId, - @Schema(description = "Truncate image included in either input, output or metadata", defaultValue = "true") - @DefaultValue("true") boolean truncate) { + @Schema(description = "Truncate image included in either input, output or metadata", defaultValue = "true") @DefaultValue("true") boolean truncate) { @Override public Integer limit() { diff --git a/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemDAO.java b/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemDAO.java index 70ef7fb3f2..78cb1505d4 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemDAO.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemDAO.java @@ -274,7 +274,8 @@ private Publisher get(UUID id, Connection connection) { return makeFluxContextAware(bindWorkspaceIdToFlux(statement)); } - public Flux getItems(@NonNull Set experimentIds, @NonNull ExperimentItemSearchCriteria criteria) { + public Flux getItems(@NonNull Set experimentIds, + @NonNull ExperimentItemSearchCriteria criteria) { if (experimentIds.isEmpty()) { log.info("Getting experiment items by empty experimentIds, limit '{}', lastRetrievedId '{}'", criteria.limit(), criteria.lastRetrievedId()); diff --git a/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemService.java b/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemService.java index 44f437425a..7424672510 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemService.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/domain/ExperimentItemService.java @@ -3,7 +3,6 @@ import com.comet.opik.api.Experiment; import com.comet.opik.api.ExperimentItem; import com.comet.opik.api.ExperimentItemSearchCriteria; -import com.comet.opik.api.ExperimentItemStreamRequest; import com.comet.opik.infrastructure.auth.RequestContext; import com.google.common.base.Preconditions; import jakarta.inject.Inject; diff --git a/apps/opik-backend/src/main/java/com/comet/opik/infrastructure/EncryptionUtils.java b/apps/opik-backend/src/main/java/com/comet/opik/infrastructure/EncryptionUtils.java index 9cf0be0934..1beb757994 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/infrastructure/EncryptionUtils.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/infrastructure/EncryptionUtils.java @@ -9,6 +9,7 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.SecretKeySpec; + import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.Key; diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/AssertionUtils.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/AssertionUtils.java index 8e206f328e..888e47ea1d 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/AssertionUtils.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/AssertionUtils.java @@ -1,7 +1,7 @@ package com.comet.opik.api.resources.utils; -import com.comet.opik.api.FeedbackScoreNames; import com.comet.opik.api.ExperimentItem; +import com.comet.opik.api.FeedbackScoreNames; import lombok.experimental.UtilityClass; import java.util.List; @@ -20,7 +20,8 @@ public static void assertFeedbackScoreNames(FeedbackScoreNames actual, List experimentItem.toBuilder().experimentId(experiment1.id()).traceId(traceWithScores1.getLeft().id()).build()) + .map(experimentItem -> experimentItem.toBuilder().experimentId(experiment1.id()) + .traceId(traceWithScores1.getLeft().id()).build()) .collect(toUnmodifiableSet()); var createRequest1 = ExperimentItemsBatch.builder().experimentItems(experimentItems1).build(); createAndAssert(createRequest1, apiKey, workspaceName); var experimentItems2 = PodamFactoryUtils.manufacturePojoList(podamFactory, ExperimentItem.class).stream() - .map(experimentItem -> experimentItem.toBuilder().experimentId(experiment2.id()).traceId(traceWithScores2.getLeft().id()).build()) + .map(experimentItem -> experimentItem.toBuilder().experimentId(experiment2.id()) + .traceId(traceWithScores2.getLeft().id()).build()) .collect(toUnmodifiableSet()); var createRequest2 = ExperimentItemsBatch.builder().experimentItems(experimentItems2).build(); createAndAssert(createRequest2, apiKey, workspaceName); @@ -2434,14 +2437,16 @@ void streamByExperimentName() { .map(experimentItem -> experimentItem.toBuilder() .input(traceWithScores2.getLeft().input()) .output(traceWithScores2.getLeft().output()) - .feedbackScores(traceWithScores2.getRight().stream().map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList()) + .feedbackScores(traceWithScores2.getRight().stream() + .map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList()) .build()) .toList(); var expectedExperimentItems2 = expectedExperimentItems.subList(limit, size).stream() .map(experimentItem -> experimentItem.toBuilder() .input(traceWithScores1.getLeft().input()) .output(traceWithScores1.getLeft().output()) - .feedbackScores(traceWithScores1.getRight().stream().map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList()) + .feedbackScores(traceWithScores1.getRight().stream() + .map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList()) .build()) .toList(); @@ -2807,15 +2812,18 @@ private void assertIgnoredFields( } } - private void assertIgnoredFieldsFullContent(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem) { + private void assertIgnoredFieldsFullContent(ExperimentItem actualExperimentItem, + ExperimentItem expectedExperimentItem) { assertIgnoredFields(actualExperimentItem, expectedExperimentItem, true); } - private void assertIgnoredFieldsWithoutFeedbacks(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem) { + private void assertIgnoredFieldsWithoutFeedbacks(ExperimentItem actualExperimentItem, + ExperimentItem expectedExperimentItem) { assertIgnoredFields(actualExperimentItem, expectedExperimentItem, false); } - private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem, boolean isFullContent) { + private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem, + boolean isFullContent) { assertThat(actualExperimentItem.createdAt()).isAfter(expectedExperimentItem.createdAt()); assertThat(actualExperimentItem.lastUpdatedAt()).isAfter(expectedExperimentItem.lastUpdatedAt()); assertThat(actualExperimentItem.createdBy()).isEqualTo(USER); diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/FeedbackDefinitionResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/FeedbackDefinitionResourceTest.java index 93f475c136..03d1947428 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/FeedbackDefinitionResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/FeedbackDefinitionResourceTest.java @@ -53,10 +53,10 @@ import static com.comet.opik.api.FeedbackDefinition.CategoricalFeedbackDefinition.CategoricalFeedbackDetail; import static com.comet.opik.api.FeedbackDefinition.FeedbackDefinitionPage; import static com.comet.opik.api.FeedbackDefinition.NumericalFeedbackDefinition; +import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.domain.FeedbackDefinitionModel.FeedbackType; import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE; import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER; -import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectMetricsResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectMetricsResourceTest.java index a5ae3bf8cf..9ccb370369 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectMetricsResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectMetricsResourceTest.java @@ -81,9 +81,9 @@ import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME; import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE; +import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE; import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER; -import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java index 18eda81469..6317b2b556 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java @@ -88,10 +88,10 @@ import static com.comet.opik.api.resources.utils.AssertionUtils.assertFeedbackScoreNames; import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME; import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE; +import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.domain.ProjectService.DEFAULT_PROJECT; import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE; import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER; -import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/PromptResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/PromptResourceTest.java index 696a1468fc..ed72672cdb 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/PromptResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/PromptResourceTest.java @@ -62,9 +62,9 @@ import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME; import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE; +import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE; import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER; -import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java index 56e923bdb1..6363fd3aaa 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java @@ -102,11 +102,11 @@ import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME; import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE; import static com.comet.opik.api.resources.utils.StatsUtils.getProjectSpanStatItems; +import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.domain.ProjectService.DEFAULT_PROJECT; import static com.comet.opik.domain.SpanService.PROJECT_AND_WORKSPACE_NAME_MISMATCH; import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE; import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER; -import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.utils.ValidationUtils.MAX_FEEDBACK_SCORE_VALUE; import static com.comet.opik.utils.ValidationUtils.MIN_FEEDBACK_SCORE_VALUE; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java index 2743d96470..7f26f22b6a 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java @@ -100,11 +100,11 @@ import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME; import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE; import static com.comet.opik.api.resources.utils.StatsUtils.getProjectTraceStatItems; +import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.comet.opik.domain.ProjectService.DEFAULT_PROJECT; import static com.comet.opik.domain.TraceService.PROJECT_NAME_AND_WORKSPACE_NAME_MISMATCH; import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE; import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER; -import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;