Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Borys Tkachenko authored and Borys Tkachenko committed Dec 31, 2024
1 parent 64fc236 commit ce5f761
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2828,30 +2828,36 @@ private void getAndAssert(ExperimentItem expectedExperimentItem, String workspac
.ignoringFields(ITEM_IGNORED_FIELDS)
.isEqualTo(expectedExperimentItem);

assertIgnoredFields(actualExperimentItem, expectedExperimentItem);
assertIgnoredFields(actualExperimentItem, expectedExperimentItem, false);
}
}

private void assertIgnoredFields(
List<ExperimentItem> actualExperimentItems, List<ExperimentItem> expectedExperimentItems) {
assertThat(actualExperimentItems).hasSameSizeAs(expectedExperimentItems);
for (int i = 0; i < actualExperimentItems.size(); i++) {
assertIgnoredFields(actualExperimentItems.get(i), expectedExperimentItems.get(i));
assertIgnoredFields(actualExperimentItems.get(i), expectedExperimentItems.get(i), true);
}
}

private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem) {
assertThat(actualExperimentItem.input()).isEqualTo(expectedExperimentItem.input());
assertThat(actualExperimentItem.output()).isEqualTo(expectedExperimentItem.output());
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);
assertThat(actualExperimentItem.lastUpdatedBy()).isEqualTo(USER);
assertThat(actualExperimentItem.feedbackScores())
.usingRecursiveComparison()
.withComparatorForType(BigDecimal::compareTo, BigDecimal.class)
.ignoringCollectionOrder()
.isEqualTo(expectedExperimentItem.feedbackScores());
if (isFullContent) {
assertThat(actualExperimentItem.feedbackScores())
.usingRecursiveComparison()
.withComparatorForType(BigDecimal::compareTo, BigDecimal.class)
.ignoringCollectionOrder()
.isEqualTo(expectedExperimentItem.feedbackScores());
assertThat(actualExperimentItem.input()).isEqualTo(expectedExperimentItem.input());
assertThat(actualExperimentItem.output()).isEqualTo(expectedExperimentItem.output());
} else {
assertThat(actualExperimentItem.input()).isNull();
assertThat(actualExperimentItem.output()).isNull();
assertThat(actualExperimentItem.feedbackScores()).isNull();
}
}

private void getAndAssertNotFound(UUID id, String apiKey, String workspaceName) {
Expand Down

0 comments on commit ce5f761

Please sign in to comment.