Skip to content
Snippets Groups Projects
Commit fc43c175 authored by vkovtun's avatar vkovtun
Browse files

SSDM-10317 Added testSearchMatchingSampleProperty() to GlobalSearchTest.

parent 65a296bc
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,9 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id.CreationId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id.IObjectId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id.ObjectPermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.DataSetCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.delete.DataSetDeletionOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.IDataSetId;
......@@ -32,6 +34,7 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.delete.ExperimentDele
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.IExperimentId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.global.fetchoptions.GlobalSearchObjectSortOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.project.id.ProjectIdentifier;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.id.PropertyTypePermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.create.SampleCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.delete.SampleDeletionOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.id.ISampleId;
......@@ -1177,6 +1180,45 @@ public class GlobalSearchTest extends AbstractTest
assertMaterial(objects.get(3), "BACTERIUM-Y", "BACTERIUM", "Identifier: BACTERIUM-Y (BACTERIUM)");
}
@Test
public void testSearchMatchingSampleProperty()
{
final String sessionToken = v3api.login(TEST_USER, PASSWORD);
final String propertyTypeValue = "/CISD/CL1";
final String sampleCode = "TEST-SAMPLE-FULL-TEXT-SEARCH";
final PropertyTypePermId propertyTypeId = createASamplePropertyType(sessionToken, null);
createSample(sessionToken, propertyTypeId, propertyTypeValue, sampleCode);
final GlobalSearchCriteria criteria = new GlobalSearchCriteria();
criteria.withText().thatContains(propertyTypeValue);
final GlobalSearchObjectFetchOptions fo = new GlobalSearchObjectFetchOptions();
fo.sortBy().objectPermId().asc();
fo.withMatch();
final SearchResult<GlobalSearchObject> result = search(TEST_USER, criteria, fo);
final List<GlobalSearchObject> objects = result.getObjects();
assertEquals(result.getTotalCount(), 2);
assertEquals(objects.size(), 2);
assertSample(objects.get(0), "200811050919915-8", propertyTypeValue, "Identifier: /CISD/CL1");
assertSample(objects.get(1), null, "/CISD/" + sampleCode, "Property 'label': " + propertyTypeValue);
}
private ObjectPermId createSample(final String sessionToken, final PropertyTypePermId propertyTypeId,
final String value, final String code)
{
final EntityTypePermId entityTypeId = createASampleType(sessionToken, false, propertyTypeId);
final SampleCreation sampleCreation = new SampleCreation();
sampleCreation.setAutoGeneratedCode(false);
sampleCreation.setCode(code);
sampleCreation.setTypeId(entityTypeId);
sampleCreation.setSpaceId(new SpacePermId("CISD"));
sampleCreation.setProperty(propertyTypeId.getPermId(), value);
return v3api.createSamples(sessionToken, Collections.singletonList(sampleCreation)).get(0);
}
private List<GlobalSearchObject> filterSearchResults(final List<GlobalSearchObject> results,
final boolean withDataset, final boolean withSample, final boolean withExperiment)
{
......@@ -1417,7 +1459,10 @@ public class GlobalSearchTest extends AbstractTest
{
assertNotNull(object);
assertEquals(object.getObjectKind(), GlobalSearchObjectKind.SAMPLE);
assertEquals(object.getObjectPermId(), new SamplePermId(permId));
if (permId != null)
{
assertEquals(object.getObjectPermId(), new SamplePermId(permId));
}
assertEquals(object.getObjectIdentifier(), new SampleIdentifier(identifier));
assertEquals(object.getMatch(), match);
assertTrue(object.getScore() > 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment