diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/search/NodeContentTest.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/search/NodeContentTest.java new file mode 100644 index 0000000000..d57dbe36da --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/search/NodeContentTest.java @@ -0,0 +1,95 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2025 - 2025 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.search; + +import static org.testng.Assert.*; + +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.RetryOperation; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; + +public class NodeContentTest extends RestTest +{ + + @TestRail(section = {TestGroup.REST_API, + TestGroup.SEARCH}, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/sites") + @Test(groups = {TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE}) + public void testNodeContent() throws Exception + { + + UserModel adminUser = dataContent.getAdminUser(); + final String fileName = "nodecontent.pdf"; + final String term = "babekyrtso"; + + FileModel fileModel = FileModel.getFileModelBasedOnTestDataFile(fileName); + restClient.authenticateUser(adminUser) + .configureRequestSpec() + .addMultiPart("filedata", fileModel.toFile()); + RestNodeModel node = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(ContentModel.my()).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryModel = new RestRequestQueryModel(); + queryModel.setLanguage("afts"); + queryModel.setQuery(term); + query.setQuery(queryModel); + + RetryOperation op = () -> { + List entries = restClient.authenticateUser(adminUser) + .withSearchAPI() + .search(query).getEntries(); + + assertFalse(CollectionUtils.isEmpty(entries), "Search results should not be empty"); + boolean fileFound = entries.stream() + .map(SearchNodeModel::getModel) + .anyMatch(e -> fileName.equals(e.getName())); + assertTrue(fileFound, "Search results should contain the file: " + fileName); + + restClient.assertStatusCodeIs(HttpStatus.OK); + }; + Utility.sleep(300, 100000, op); + + restClient.authenticateUser(adminUser) + .withCoreAPI() + .usingNode(ContentModel.my()) + .deleteNode(node); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} diff --git a/packaging/tests/tas-restapi/src/test/resources/shared-resources/testdata/nodecontent.pdf b/packaging/tests/tas-restapi/src/test/resources/shared-resources/testdata/nodecontent.pdf new file mode 100644 index 0000000000..91ffd49a02 Binary files /dev/null and b/packaging/tests/tas-restapi/src/test/resources/shared-resources/testdata/nodecontent.pdf differ diff --git a/packaging/tests/tas-restapi/src/test/resources/test-suites/part2-suite.xml b/packaging/tests/tas-restapi/src/test/resources/test-suites/part2-suite.xml index f4122db9b4..de3460385f 100644 --- a/packaging/tests/tas-restapi/src/test/resources/test-suites/part2-suite.xml +++ b/packaging/tests/tas-restapi/src/test/resources/test-suites/part2-suite.xml @@ -15,6 +15,7 @@ + diff --git a/remote-api/src/test/resources/publicapi/upload/babekyrtso.pdf b/remote-api/src/test/resources/publicapi/upload/babekyrtso.pdf new file mode 100644 index 0000000000..91ffd49a02 Binary files /dev/null and b/remote-api/src/test/resources/publicapi/upload/babekyrtso.pdf differ