mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
SEARCH-44 Ported last of the cmis tests
This commit is contained in:
@@ -783,4 +783,160 @@ public class LoadCMISData extends AbstractAlfrescoSolrTests
|
|||||||
{
|
{
|
||||||
return String.format("*[count(//doc)=%d]", count);
|
return String.format("*[count(//doc)=%d]", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addSortableNode(NodeRef folder00NodeRef,
|
||||||
|
NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName,
|
||||||
|
Date date1, int position) throws IOException
|
||||||
|
{
|
||||||
|
HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
|
||||||
|
MLTextPropertyValue desc00 = new MLTextPropertyValue();
|
||||||
|
desc00.addValue(Locale.ENGLISH, "Test " + position);
|
||||||
|
content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
|
||||||
|
content00Properties.put(ContentModel.PROP_TITLE, desc00);
|
||||||
|
content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test " + position));
|
||||||
|
content00Properties.put(ContentModel.PROP_CREATED,
|
||||||
|
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
|
||||||
|
|
||||||
|
StringPropertyValue single = new StringPropertyValue(orderable[position]);
|
||||||
|
content00Properties.put(singleTextUntokenised, single);
|
||||||
|
content00Properties.put(singleTextTokenised, single);
|
||||||
|
content00Properties.put(singleTextBoth, single);
|
||||||
|
MultiPropertyValue multi = new MultiPropertyValue();
|
||||||
|
multi.addValue(single);
|
||||||
|
multi.addValue(new StringPropertyValue(orderable[position + 1]));
|
||||||
|
content00Properties.put(multipleTextUntokenised, multi);
|
||||||
|
content00Properties.put(multipleTextTokenised, multi);
|
||||||
|
content00Properties.put(multipleTextBoth, multi);
|
||||||
|
content00Properties.put(singleMLTextUntokenised, makeMLText(position));
|
||||||
|
content00Properties.put(singleMLTextTokenised, makeMLText(position));
|
||||||
|
content00Properties.put(singleMLTextBoth, makeMLText(position));
|
||||||
|
content00Properties.put(multipleMLTextUntokenised, makeMLTextMVP(position));
|
||||||
|
content00Properties.put(multipleMLTextTokenised, makeMLTextMVP(position));
|
||||||
|
content00Properties.put(multipleMLTextBoth, makeMLTextMVP());
|
||||||
|
StringPropertyValue one = new StringPropertyValue("" + (1.1 * position));
|
||||||
|
StringPropertyValue two = new StringPropertyValue("" + (2.2 * position));
|
||||||
|
MultiPropertyValue multiDec = new MultiPropertyValue();
|
||||||
|
multiDec.addValue(one);
|
||||||
|
multiDec.addValue(two);
|
||||||
|
content00Properties.put(singleFloat, one);
|
||||||
|
content00Properties.put(multipleFloat, multiDec);
|
||||||
|
content00Properties.put(singleDouble, one);
|
||||||
|
content00Properties.put(multipleDouble, multiDec);
|
||||||
|
one = new StringPropertyValue("" + (1 * position));
|
||||||
|
two = new StringPropertyValue("" + (2 * position));
|
||||||
|
MultiPropertyValue multiInt = new MultiPropertyValue();
|
||||||
|
multiInt.addValue(one);
|
||||||
|
multiInt.addValue(two);
|
||||||
|
content00Properties.put(singleInteger, one);
|
||||||
|
content00Properties.put(multipleInteger, multiInt);
|
||||||
|
content00Properties.put(singleLong, one);
|
||||||
|
content00Properties.put(multipleLong, multiInt);
|
||||||
|
|
||||||
|
GregorianCalendar cal = new GregorianCalendar();
|
||||||
|
cal.setTime(date1);
|
||||||
|
cal.add(Calendar.DAY_OF_MONTH, position);
|
||||||
|
|
||||||
|
Date newdate1 = cal.getTime();
|
||||||
|
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||||||
|
cal.add(Calendar.DAY_OF_MONTH, 2);
|
||||||
|
Date date2 = cal.getTime();
|
||||||
|
StringPropertyValue d1 = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, newdate1));
|
||||||
|
StringPropertyValue d2 = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date2));
|
||||||
|
MultiPropertyValue multiDate = new MultiPropertyValue();
|
||||||
|
multiDate.addValue(d1);
|
||||||
|
multiDate.addValue(d2);
|
||||||
|
content00Properties.put(singleDate, d1);
|
||||||
|
content00Properties.put(multipleDate, multiDate);
|
||||||
|
content00Properties.put(singleDatetime, d1);
|
||||||
|
content00Properties.put(multipleDatetime, multiDate);
|
||||||
|
|
||||||
|
StringPropertyValue b = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class,
|
||||||
|
position % 2 == 0 ? true : false));
|
||||||
|
StringPropertyValue bTrue = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, true));
|
||||||
|
StringPropertyValue bFalse = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, false));
|
||||||
|
MultiPropertyValue multiBool = new MultiPropertyValue();
|
||||||
|
multiBool.addValue(bTrue);
|
||||||
|
multiBool.addValue(bFalse);
|
||||||
|
|
||||||
|
content00Properties.put(singleBoolean, b);
|
||||||
|
content00Properties.put(multipleBoolean, multiBool);
|
||||||
|
|
||||||
|
NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
|
||||||
|
QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test " + position);
|
||||||
|
ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef,
|
||||||
|
content00QName, content00NodeRef, true, 0);
|
||||||
|
addNode(h.getCore(),
|
||||||
|
dataModel, 1, 1000 + position, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE,
|
||||||
|
ContentModel.ASPECT_TITLED }, content00Properties, null, "andy",
|
||||||
|
new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef,
|
||||||
|
folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/"
|
||||||
|
+ folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String[] orderable = new String[] { "zero loons", "one banana", "two apples", "three fruit",
|
||||||
|
"four lemurs", "five rats", "six badgers", "seven cards", "eight cabbages", "nine zebras", "ten lemons" };
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param folder00NodeRef
|
||||||
|
* @param rootNodeRef
|
||||||
|
* @param baseFolderNodeRef
|
||||||
|
* @param baseFolderQName
|
||||||
|
* @param folder00QName
|
||||||
|
* @param date1
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
protected void addTypeSortTestData(NodeRef folder00NodeRef, NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName, Date date1)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
addSortableNull(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
||||||
|
folder00QName, date1, "start", 0);
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
addSortableNode(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
||||||
|
folder00QName, date1, i);
|
||||||
|
if (i == 5)
|
||||||
|
{
|
||||||
|
addSortableNull(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
||||||
|
folder00QName, date1, "mid", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addSortableNull(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
||||||
|
folder00QName, date1, "end", 2);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param folder00NodeRef
|
||||||
|
* @param rootNodeRef
|
||||||
|
* @param baseFolderNodeRef
|
||||||
|
* @param baseFolderQName
|
||||||
|
* @param folder00QName
|
||||||
|
* @param date1
|
||||||
|
* @param id
|
||||||
|
* @param offset
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private void addSortableNull(NodeRef folder00NodeRef,
|
||||||
|
NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName,
|
||||||
|
Date date1, String id, int offset) throws IOException
|
||||||
|
{
|
||||||
|
HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
|
||||||
|
MLTextPropertyValue desc00 = new MLTextPropertyValue();
|
||||||
|
desc00.addValue(Locale.ENGLISH, "Test null");
|
||||||
|
content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
|
||||||
|
content00Properties.put(ContentModel.PROP_TITLE, desc00);
|
||||||
|
content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test null"));
|
||||||
|
content00Properties.put(ContentModel.PROP_CREATED,
|
||||||
|
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
|
||||||
|
|
||||||
|
NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
|
||||||
|
QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test null");
|
||||||
|
ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef,
|
||||||
|
content00QName, content00NodeRef, true, 0);
|
||||||
|
addNode(h.getCore(), dataModel, 1, 200 + offset, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE,
|
||||||
|
ContentModel.ASPECT_TITLED }, content00Properties, null, "andy",
|
||||||
|
new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef,
|
||||||
|
folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/"
|
||||||
|
+ folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,27 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.solr.query.cmis;
|
package org.alfresco.solr.query.cmis;
|
||||||
|
|
||||||
import static org.alfresco.solr.AlfrescoSolrUtils.addNode;
|
|
||||||
import static org.alfresco.solr.AlfrescoSolrUtils.createGUID;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.solr.client.MLTextPropertyValue;
|
|
||||||
import org.alfresco.solr.client.MultiPropertyValue;
|
|
||||||
import org.alfresco.solr.client.PropertyValue;
|
|
||||||
import org.alfresco.solr.client.StringPropertyValue;
|
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -70,48 +51,8 @@ public class SortCMISTest extends LoadCMISData
|
|||||||
testCMISDate00);
|
testCMISDate00);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTypeSortTestData(NodeRef folder00NodeRef, NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName, Date date1)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
addSortableNull(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
|
||||||
folder00QName, date1, "start", 0);
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
addSortableNode(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
|
||||||
folder00QName, date1, i);
|
|
||||||
if (i == 5)
|
|
||||||
{
|
|
||||||
addSortableNull(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
|
||||||
folder00QName, date1, "mid", 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addSortableNull(folder00NodeRef, rootNodeRef, baseFolderNodeRef, baseFolderQName,
|
|
||||||
folder00QName, date1, "end", 2);
|
|
||||||
}
|
|
||||||
private void addSortableNull(NodeRef folder00NodeRef,
|
|
||||||
NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName,
|
|
||||||
Date date1, String id, int offset) throws IOException
|
|
||||||
{
|
|
||||||
HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
|
|
||||||
MLTextPropertyValue desc00 = new MLTextPropertyValue();
|
|
||||||
desc00.addValue(Locale.ENGLISH, "Test null");
|
|
||||||
content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
|
|
||||||
content00Properties.put(ContentModel.PROP_TITLE, desc00);
|
|
||||||
content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test null"));
|
|
||||||
content00Properties.put(ContentModel.PROP_CREATED,
|
|
||||||
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
|
|
||||||
|
|
||||||
NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
|
|
||||||
QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test null");
|
|
||||||
ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef,
|
|
||||||
content00QName, content00NodeRef, true, 0);
|
|
||||||
addNode(h.getCore(), dataModel, 1, 200 + offset, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE,
|
|
||||||
ContentModel.ASPECT_TITLED }, content00Properties, null, "andy",
|
|
||||||
new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef,
|
|
||||||
folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/"
|
|
||||||
+ folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
|
|
||||||
}
|
|
||||||
@Test
|
@Test
|
||||||
public void checkOrder() throws IOException
|
public void checkOrder() throws IOException
|
||||||
{
|
{
|
||||||
@@ -193,96 +134,4 @@ public class SortCMISTest extends LoadCMISData
|
|||||||
+ propertyQueryName
|
+ propertyQueryName
|
||||||
+ " DESC, cmis:objectId DESC"),expectedDocCount(14));
|
+ " DESC, cmis:objectId DESC"),expectedDocCount(14));
|
||||||
}
|
}
|
||||||
private void addSortableNode(NodeRef folder00NodeRef,
|
|
||||||
NodeRef rootNodeRef, NodeRef baseFolderNodeRef, Object baseFolderQName, Object folder00QName,
|
|
||||||
Date date1, int position) throws IOException
|
|
||||||
{
|
|
||||||
HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
|
|
||||||
MLTextPropertyValue desc00 = new MLTextPropertyValue();
|
|
||||||
desc00.addValue(Locale.ENGLISH, "Test " + position);
|
|
||||||
content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
|
|
||||||
content00Properties.put(ContentModel.PROP_TITLE, desc00);
|
|
||||||
content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Test " + position));
|
|
||||||
content00Properties.put(ContentModel.PROP_CREATED,
|
|
||||||
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date1)));
|
|
||||||
|
|
||||||
StringPropertyValue single = new StringPropertyValue(orderable[position]);
|
|
||||||
content00Properties.put(singleTextUntokenised, single);
|
|
||||||
content00Properties.put(singleTextTokenised, single);
|
|
||||||
content00Properties.put(singleTextBoth, single);
|
|
||||||
MultiPropertyValue multi = new MultiPropertyValue();
|
|
||||||
multi.addValue(single);
|
|
||||||
multi.addValue(new StringPropertyValue(orderable[position + 1]));
|
|
||||||
content00Properties.put(multipleTextUntokenised, multi);
|
|
||||||
content00Properties.put(multipleTextTokenised, multi);
|
|
||||||
content00Properties.put(multipleTextBoth, multi);
|
|
||||||
content00Properties.put(singleMLTextUntokenised, makeMLText(position));
|
|
||||||
content00Properties.put(singleMLTextTokenised, makeMLText(position));
|
|
||||||
content00Properties.put(singleMLTextBoth, makeMLText(position));
|
|
||||||
content00Properties.put(multipleMLTextUntokenised, makeMLTextMVP(position));
|
|
||||||
content00Properties.put(multipleMLTextTokenised, makeMLTextMVP(position));
|
|
||||||
content00Properties.put(multipleMLTextBoth, makeMLTextMVP());
|
|
||||||
StringPropertyValue one = new StringPropertyValue("" + (1.1 * position));
|
|
||||||
StringPropertyValue two = new StringPropertyValue("" + (2.2 * position));
|
|
||||||
MultiPropertyValue multiDec = new MultiPropertyValue();
|
|
||||||
multiDec.addValue(one);
|
|
||||||
multiDec.addValue(two);
|
|
||||||
content00Properties.put(singleFloat, one);
|
|
||||||
content00Properties.put(multipleFloat, multiDec);
|
|
||||||
content00Properties.put(singleDouble, one);
|
|
||||||
content00Properties.put(multipleDouble, multiDec);
|
|
||||||
one = new StringPropertyValue("" + (1 * position));
|
|
||||||
two = new StringPropertyValue("" + (2 * position));
|
|
||||||
MultiPropertyValue multiInt = new MultiPropertyValue();
|
|
||||||
multiInt.addValue(one);
|
|
||||||
multiInt.addValue(two);
|
|
||||||
content00Properties.put(singleInteger, one);
|
|
||||||
content00Properties.put(multipleInteger, multiInt);
|
|
||||||
content00Properties.put(singleLong, one);
|
|
||||||
content00Properties.put(multipleLong, multiInt);
|
|
||||||
|
|
||||||
GregorianCalendar cal = new GregorianCalendar();
|
|
||||||
cal.setTime(date1);
|
|
||||||
cal.add(Calendar.DAY_OF_MONTH, position);
|
|
||||||
|
|
||||||
Date newdate1 = cal.getTime();
|
|
||||||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
Date date0 = cal.getTime();
|
|
||||||
cal.add(Calendar.DAY_OF_MONTH, 2);
|
|
||||||
Date date2 = cal.getTime();
|
|
||||||
StringPropertyValue d1 = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, newdate1));
|
|
||||||
StringPropertyValue d2 = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date2));
|
|
||||||
MultiPropertyValue multiDate = new MultiPropertyValue();
|
|
||||||
multiDate.addValue(d1);
|
|
||||||
multiDate.addValue(d2);
|
|
||||||
content00Properties.put(singleDate, d1);
|
|
||||||
content00Properties.put(multipleDate, multiDate);
|
|
||||||
content00Properties.put(singleDatetime, d1);
|
|
||||||
content00Properties.put(multipleDatetime, multiDate);
|
|
||||||
|
|
||||||
StringPropertyValue b = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class,
|
|
||||||
position % 2 == 0 ? true : false));
|
|
||||||
StringPropertyValue bTrue = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, true));
|
|
||||||
StringPropertyValue bFalse = new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, false));
|
|
||||||
MultiPropertyValue multiBool = new MultiPropertyValue();
|
|
||||||
multiBool.addValue(bTrue);
|
|
||||||
multiBool.addValue(bFalse);
|
|
||||||
|
|
||||||
content00Properties.put(singleBoolean, b);
|
|
||||||
content00Properties.put(multipleBoolean, multiBool);
|
|
||||||
|
|
||||||
NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
|
|
||||||
QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Test " + position);
|
|
||||||
ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef,
|
|
||||||
content00QName, content00NodeRef, true, 0);
|
|
||||||
addNode(h.getCore(),
|
|
||||||
dataModel, 1, 1000 + position, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE,
|
|
||||||
ContentModel.ASPECT_TITLED }, content00Properties, null, "andy",
|
|
||||||
new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef,
|
|
||||||
folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/"
|
|
||||||
+ folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] orderable = new String[] { "zero loons", "one banana", "two apples", "three fruit",
|
|
||||||
"four lemurs", "five rats", "six badgers", "seven cards", "eight cabbages", "nine zebras", "ten lemons" };
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2016 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.solr.query.cmis;
|
||||||
|
|
||||||
|
import static org.alfresco.solr.AlfrescoSolrUtils.addNode;
|
||||||
|
import static org.alfresco.solr.AlfrescoSolrUtils.createGUID;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.solr.client.MLTextPropertyValue;
|
||||||
|
import org.alfresco.solr.client.PropertyValue;
|
||||||
|
import org.alfresco.solr.client.StringPropertyValue;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
/**
|
||||||
|
* Ported tests relating to cmis from AlfrescoCoreAdminTester (Legacy embedded
|
||||||
|
* tests).
|
||||||
|
* @author Michael Suzuki
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TrieFieldsCMISTest extends LoadCMISData
|
||||||
|
{
|
||||||
|
@Before
|
||||||
|
public void setup() throws Exception
|
||||||
|
{
|
||||||
|
/******** Load record ************/
|
||||||
|
|
||||||
|
addTypeTestData(testCMISFolder00NodeRef,
|
||||||
|
testCMISRootNodeRef,
|
||||||
|
testCMISBaseFolderNodeRef,
|
||||||
|
testCMISBaseFolderQName,
|
||||||
|
testCMISFolder00QName,
|
||||||
|
testCMISDate00);
|
||||||
|
|
||||||
|
addTypeSortTestData(testCMISFolder00NodeRef,
|
||||||
|
testCMISRootNodeRef,
|
||||||
|
testCMISBaseFolderNodeRef,
|
||||||
|
testCMISBaseFolderQName,
|
||||||
|
testCMISFolder00QName,
|
||||||
|
testCMISDate00);
|
||||||
|
|
||||||
|
addTrieTypeTestData(testCMISFolder00NodeRef,
|
||||||
|
testCMISRootNodeRef,
|
||||||
|
testCMISBaseFolderNodeRef,
|
||||||
|
testCMISBaseFolderQName,
|
||||||
|
testCMISFolder00QName,
|
||||||
|
testCMISDate00);
|
||||||
|
|
||||||
|
}
|
||||||
|
private void addTrieTypeTestData(NodeRef folder00NodeRef, NodeRef rootNodeRef, NodeRef baseFolderNodeRef,
|
||||||
|
QName baseFolderQName, QName folder00QName, Date date00) throws IOException
|
||||||
|
{
|
||||||
|
HashMap<QName, PropertyValue> content00Properties = new HashMap<QName, PropertyValue>();
|
||||||
|
MLTextPropertyValue desc00 = new MLTextPropertyValue();
|
||||||
|
desc00.addValue(Locale.ENGLISH, "Trie test1");
|
||||||
|
content00Properties.put(ContentModel.PROP_DESCRIPTION, desc00);
|
||||||
|
content00Properties.put(ContentModel.PROP_TITLE, desc00);
|
||||||
|
content00Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Trie test1"));
|
||||||
|
content00Properties.put(ContentModel.PROP_CREATED,
|
||||||
|
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date00)));
|
||||||
|
|
||||||
|
StringPropertyValue firstIntValue = new StringPropertyValue("98198");
|
||||||
|
content00Properties.put(singleInteger,firstIntValue);
|
||||||
|
|
||||||
|
StringPropertyValue firstLongValue = new StringPropertyValue("3956650");
|
||||||
|
content00Properties.put(singleLong,firstLongValue);
|
||||||
|
|
||||||
|
NodeRef content00NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
|
||||||
|
QName content00QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Trie test1");
|
||||||
|
ChildAssociationRef content00CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef,
|
||||||
|
content00QName, content00NodeRef, true, 0);
|
||||||
|
addNode(h.getCore(), dataModel, 1, 300, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE,
|
||||||
|
ContentModel.ASPECT_TITLED }, content00Properties, null, "andy",
|
||||||
|
new ChildAssociationRef[] { content00CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef,
|
||||||
|
folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/"
|
||||||
|
+ folder00QName.toString() + "/" + content00QName.toString() }, content00NodeRef, true);
|
||||||
|
|
||||||
|
HashMap<QName, PropertyValue> content01Properties = new HashMap<QName, PropertyValue>();
|
||||||
|
MLTextPropertyValue desc01 = new MLTextPropertyValue();
|
||||||
|
desc01.addValue(Locale.ENGLISH, "Trie test2");
|
||||||
|
content01Properties.put(ContentModel.PROP_DESCRIPTION, desc01);
|
||||||
|
content01Properties.put(ContentModel.PROP_TITLE, desc01);
|
||||||
|
content01Properties.put(ContentModel.PROP_NAME, new StringPropertyValue("Trie test2"));
|
||||||
|
content01Properties.put(ContentModel.PROP_CREATED,
|
||||||
|
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, date00)));
|
||||||
|
|
||||||
|
StringPropertyValue secondIntValue = new StringPropertyValue("98200");
|
||||||
|
content01Properties.put(singleInteger,secondIntValue);
|
||||||
|
|
||||||
|
StringPropertyValue secondLongValue = new StringPropertyValue("3956651");
|
||||||
|
content01Properties.put(singleLong,secondLongValue);
|
||||||
|
|
||||||
|
NodeRef content01NodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
|
||||||
|
QName content01QName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Trie test1");
|
||||||
|
ChildAssociationRef content01CAR = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, folder00NodeRef,
|
||||||
|
content01QName, content01NodeRef, true, 0);
|
||||||
|
addNode(h.getCore(), dataModel, 1, 301, 1, extendedContent, new QName[] { ContentModel.ASPECT_OWNABLE,
|
||||||
|
ContentModel.ASPECT_TITLED }, content01Properties, null, "andy",
|
||||||
|
new ChildAssociationRef[] { content01CAR }, new NodeRef[] { baseFolderNodeRef, rootNodeRef,
|
||||||
|
folder00NodeRef }, new String[] { "/" + baseFolderQName.toString() + "/"
|
||||||
|
+ folder00QName.toString() + "/" + content01QName.toString() }, content01NodeRef, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkOrder() throws IOException
|
||||||
|
{
|
||||||
|
//See MNT-14322 for the origin of the numbers
|
||||||
|
assertQ(qurySolr("SELECT * FROM cmistest:extendedContent WHERE cmistest:singleInteger = 98218"),expectedDocCount(0));
|
||||||
|
assertQ(qurySolr("SELECT * FROM cmistest:extendedContent WHERE cmistest:singleInteger = 98198"),expectedDocCount(1));
|
||||||
|
assertQ(qurySolr("SELECT * FROM cmistest:extendedContent WHERE cmistest:singleInteger = 98200"),expectedDocCount(1));
|
||||||
|
assertQ(qurySolr("SELECT * FROM cmistest:extendedContent WHERE cmistest:singleLong = 3956650"),expectedDocCount(1));
|
||||||
|
assertQ(qurySolr("SELECT * FROM cmistest:extendedContent WHERE cmistest:singleLong = 3956651"),expectedDocCount(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user