Skip to content

Commit

Permalink
LPD-22908: Update usages of IndexNameBuilder API in search tuning tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peerkar authored and brianchandotcom committed Apr 24, 2024
1 parent 7ba9524 commit 44cd416
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.junit.Rule;
import org.junit.Test;

import org.mockito.Mockito;

/**
* @author André de Oliveira
*/
Expand All @@ -28,7 +30,7 @@ public class RankingIndexNameBuilderImplTest {
@Test
public void testMultiTenancy() {
_assertIndexName(
2021, companyId -> "liferay-" + companyId,
2021, _createIndexNameBuilder(),
"liferay-2021-search-tuning-rankings");
}

Expand All @@ -47,4 +49,19 @@ private void _assertIndexName(
Assert.assertEquals(expected, rankingIndexName.getIndexName());
}

private IndexNameBuilder _createIndexNameBuilder() {
IndexNameBuilder indexNameBuilder = Mockito.mock(
IndexNameBuilder.class);

Mockito.when(
indexNameBuilder.getIndexName(Mockito.anyLong())
).then(
invocation ->
"liferay-" +
String.valueOf(invocation.getArgument(0, Long.class))
);

return indexNameBuilder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.junit.Rule;
import org.junit.Test;

import org.mockito.Mockito;

/**
* @author André de Oliveira
*/
Expand All @@ -28,7 +30,7 @@ public class SynonymSetIndexNameBuilderImplTest {
@Test
public void testMultiTenancy() {
_assertIndexName(
2021, companyId -> "liferay-" + companyId,
2021, _createIndexNameBuilder(),
"liferay-2021-search-tuning-synonyms");
}

Expand All @@ -48,4 +50,19 @@ private void _assertIndexName(
Assert.assertEquals(expected, synonymSetIndexName.getIndexName());
}

private IndexNameBuilder _createIndexNameBuilder() {
IndexNameBuilder indexNameBuilder = Mockito.mock(
IndexNameBuilder.class);

Mockito.when(
indexNameBuilder.getIndexName(Mockito.anyLong())
).then(
invocation ->
"liferay-" +
String.valueOf(invocation.getArgument(0, Long.class))
);

return indexNameBuilder;
}

}

0 comments on commit 44cd416

Please sign in to comment.