/* * Copyright (C) 2017 Alfresco Software Limited. * * This file is part of Alfresco * * 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 . */ package org.alfresco.rest.search; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.Test; /** * Search end point Public API test. * @author Michael Suzuki * */ public class SearchTest extends AbstractSearchTest { @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchCreatedData() throws Exception { SearchResponse nodes = query("fox"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); SearchNodeModel entity = nodes.getEntryByIndex(0); Assert.assertEquals(entity.getSearch().getScore(), 1); entity.assertThat().field("name").contains("pangram.txt"); nodes = query("car"); restClient.assertStatusCodeIs(HttpStatus.OK); entity = nodes.getEntryByIndex(0); nodes.assertThat().entriesListIsNotEmpty(); Assert.assertEquals(entity.getSearch().getScore(), 1); entity.assertThat().field("search").contains("score"); entity.assertThat().field("name").contains("cars.txt"); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) public void searchNonIndexedData() throws Exception { SearchResponse nodes = query("yeti"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsEmpty(); } }