Skip to content

Commit

Permalink
LPD-24555 portal-search-elasticsearch-impl: Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavolimav authored and brianchandotcom committed May 20, 2024
1 parent 00806bf commit 3bf3c56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.liferay.portal.search.elasticsearch7.internal.connection.ElasticsearchFixture;
import com.liferay.portal.search.elasticsearch7.internal.document.DefaultElasticsearchDocumentFactory;
import com.liferay.portal.search.elasticsearch7.internal.document.ElasticsearchDocumentFactory;
import com.liferay.portal.search.elasticsearch7.internal.index.constants.LiferayTypeMappingsConstants;
import com.liferay.portal.search.elasticsearch7.internal.search.engine.adapter.document.DocumentRequestExecutorFixture;
import com.liferay.portal.search.engine.adapter.SearchEngineAdapter;
import com.liferay.portal.search.engine.adapter.document.BulkDocumentItemResponse;
Expand Down Expand Up @@ -116,7 +117,8 @@ public void testExecuteBulkDocumentRequest() {
IndexDocumentRequest indexDocumentRequest1 = new IndexDocumentRequest(
_INDEX_NAME, document1);

indexDocumentRequest1.setType(_MAPPING_NAME);
indexDocumentRequest1.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

BulkDocumentRequest bulkDocumentRequest1 = new BulkDocumentRequest();

Expand All @@ -130,7 +132,8 @@ public void testExecuteBulkDocumentRequest() {
IndexDocumentRequest indexDocumentRequest2 = new IndexDocumentRequest(
_INDEX_NAME, document2);

indexDocumentRequest2.setType(_MAPPING_NAME);
indexDocumentRequest2.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

bulkDocumentRequest1.addBulkableDocumentRequest(indexDocumentRequest2);

Expand Down Expand Up @@ -159,7 +162,8 @@ public void testExecuteBulkDocumentRequest() {
DeleteDocumentRequest deleteDocumentRequest = new DeleteDocumentRequest(
_INDEX_NAME, "1");

deleteDocumentRequest.setType(_MAPPING_NAME);
deleteDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

BulkDocumentRequest bulkDocumentRequest2 = new BulkDocumentRequest();

Expand All @@ -173,7 +177,8 @@ public void testExecuteBulkDocumentRequest() {
UpdateDocumentRequest updateDocumentRequest = new UpdateDocumentRequest(
_INDEX_NAME, "2", document2Update);

updateDocumentRequest.setType(_MAPPING_NAME);
updateDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

bulkDocumentRequest2.addBulkableDocumentRequest(updateDocumentRequest);

Expand Down Expand Up @@ -221,7 +226,8 @@ public void testExecuteBulkDocumentRequestNoUid() {
IndexDocumentRequest indexDocumentRequest1 = new IndexDocumentRequest(
_INDEX_NAME, document1);

indexDocumentRequest1.setType(_MAPPING_NAME);
indexDocumentRequest1.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

BulkDocumentRequest bulkDocumentRequest1 = new BulkDocumentRequest();

Expand All @@ -234,7 +240,8 @@ public void testExecuteBulkDocumentRequestNoUid() {
IndexDocumentRequest indexDocumentRequest2 = new IndexDocumentRequest(
_INDEX_NAME, document2);

indexDocumentRequest2.setType(_MAPPING_NAME);
indexDocumentRequest2.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

bulkDocumentRequest1.addBulkableDocumentRequest(indexDocumentRequest2);

Expand Down Expand Up @@ -265,7 +272,8 @@ public void testExecuteBulkDocumentRequestNoUid() {
DeleteDocumentRequest deleteDocumentRequest = new DeleteDocumentRequest(
_INDEX_NAME, bulkDocumentItemResponse1.getId());

deleteDocumentRequest.setType(_MAPPING_NAME);
deleteDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

BulkDocumentRequest bulkDocumentRequest2 = new BulkDocumentRequest();

Expand All @@ -280,7 +288,8 @@ public void testExecuteBulkDocumentRequestNoUid() {
UpdateDocumentRequest updateDocumentRequest = new UpdateDocumentRequest(
_INDEX_NAME, bulkDocumentItemResponse2.getId(), document2Update);

updateDocumentRequest.setType(_MAPPING_NAME);
updateDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

bulkDocumentRequest2.addBulkableDocumentRequest(updateDocumentRequest);

Expand Down Expand Up @@ -360,7 +369,8 @@ public void testExecuteDeleteDocumentRequest() {
DeleteDocumentRequest deleteDocumentRequest = new DeleteDocumentRequest(
_INDEX_NAME, id);

deleteDocumentRequest.setType(_MAPPING_NAME);
deleteDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

DeleteDocumentResponse deleteDocumentResponse =
_searchEngineAdapter.execute(deleteDocumentRequest);
Expand Down Expand Up @@ -668,7 +678,7 @@ private void _indexDocument(String documentSource, String id) {
indexRequest.id(id);
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
indexRequest.source(documentSource, XContentType.JSON);
indexRequest.type(_MAPPING_NAME);
indexRequest.type(LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

try {
_restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
Expand All @@ -684,7 +694,8 @@ private IndexDocumentResponse _indexDocumentWithAdapter(
IndexDocumentRequest indexDocumentRequest = new IndexDocumentRequest(
_INDEX_NAME, uid, document);

indexDocumentRequest.setType(_MAPPING_NAME);
indexDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

return _searchEngineAdapter.execute(indexDocumentRequest);
}
Expand All @@ -695,7 +706,8 @@ private UpdateDocumentResponse _updateDocumentWithAdapter(
UpdateDocumentRequest updateDocumentRequest = new UpdateDocumentRequest(
_INDEX_NAME, uid, document);

updateDocumentRequest.setType(_MAPPING_NAME);
updateDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

return _searchEngineAdapter.execute(updateDocumentRequest);
}
Expand All @@ -707,7 +719,8 @@ private UpdateDocumentResponse _updateDocumentWithAdapter(
_INDEX_NAME, uid, script);

updateDocumentRequest.setScriptedUpsert(scriptedUpsert);
updateDocumentRequest.setType(_MAPPING_NAME);
updateDocumentRequest.setType(
LiferayTypeMappingsConstants.LIFERAY_DOCUMENT_TYPE);

return _searchEngineAdapter.execute(updateDocumentRequest);
}
Expand All @@ -716,8 +729,6 @@ private UpdateDocumentResponse _updateDocumentWithAdapter(

private static final String _INDEX_NAME = "test_request_index";

private static final String _MAPPING_NAME = "testDocumentMapping";

private static final String _MAPPING_SOURCE =
"{\"properties\":{\"matchDocument\":{\"type\":\"boolean\"}}}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,10 @@ public void testExecuteCreateIndexRequest() {
StringBundler.concat(
"{\n", " \"settings\": {\n",
" \"number_of_shards\": 1\n", " },\n",
" \"mappings\": {\n", " \"type1\": {\n",
" \"properties\": {\n",
" \"mappings\": {\n", " \"properties\": {\n",
" \"field1\": {\n",
" \"type\": \"text\"\n",
" }\n", " }\n", " }\n",
" }\n", "}"));
" }\n", " }\n", " }\n", "}"));

CreateIndexResponse createIndexResponse = _searchEngineAdapter.execute(
createIndexRequest);
Expand Down

0 comments on commit 3bf3c56

Please sign in to comment.