Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Jun 6, 2024
1 parent 73ab43b commit 294ecf5
Showing 1 changed file with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ public void setUp() throws Exception {
}

public void testCreateManySynonyms() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
CountDownLatch putLatch = new CountDownLatch(1);
String synonymSetId = randomIdentifier();
int rulesNumber = randomIntBetween(
SynonymsManagementAPIService.MAX_SYNONYMS_SETS / 2,
SynonymsManagementAPIService.MAX_SYNONYMS_SETS
);
synonymsManagementAPIService.putSynonymsSet(
randomIdentifier(),
randomSynonymsSet(
randomIntBetween(SynonymsManagementAPIService.MAX_SYNONYMS_SETS / 2, SynonymsManagementAPIService.MAX_SYNONYMS_SETS),
SynonymsManagementAPIService.MAX_SYNONYMS_SETS
),
synonymSetId,
randomSynonymsSet(rulesNumber, rulesNumber),
new ActionListener<SynonymsManagementAPIService.SynonymsReloadResult>() {
@Override
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
latch.countDown();
putLatch.countDown();
}

@Override
Expand All @@ -58,7 +60,30 @@ public void onFailure(Exception e) {
}
);

latch.await(5, TimeUnit.SECONDS);
putLatch.await(5, TimeUnit.SECONDS);

CountDownLatch getLatch = new CountDownLatch(1);
// Also retrieve them
synonymsManagementAPIService.getSynonymSetRules(
synonymSetId,
0,
SynonymsManagementAPIService.MAX_SYNONYMS_SETS,
new ActionListener<PagedResult<SynonymRule>>() {
@Override
public void onResponse(PagedResult<SynonymRule> synonymRulePagedResult) {
assertEquals(rulesNumber, synonymRulePagedResult.totalResults());
assertEquals(rulesNumber, synonymRulePagedResult.pageResults().length);
getLatch.countDown();
}

@Override
public void onFailure(Exception e) {
fail(e);
}
}
);

getLatch.await(5, TimeUnit.SECONDS);
}

public void testCreateTooManySynonymsAtOnce() throws InterruptedException {
Expand Down

0 comments on commit 294ecf5

Please sign in to comment.