Merged 5.1-MNT1 (5.1.0) to HEAD (5.1)

115460 adavis: Merged 5.1.N (5.1.1) to 5.1-MNT1 (5.1.0)
      113727 amorarasu: Merged 5.0.N (5.0.3) to 5.1.N (5.1.1)
         113684 adavis: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3) (PARTIAL MERGE)
            113603 cturlica: Merged DEV to V4.2-BUG-FIX (4.2.6)
               113602 cturlica: MNT-14504: Cloud pull process not working after large delete


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@115670 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-10-30 00:10:30 +00:00
parent 9f4fdeb0e4
commit 4165e47032
10 changed files with 327 additions and 8 deletions

View File

@@ -75,6 +75,7 @@ import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.springframework.context.ApplicationContext;
@@ -2805,7 +2806,79 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
setComplete();
endTransaction();
}
/**
* Tests get target associations by property value.</p>
* See <b>MNT-14504</b> for more details.
*
* @throws Exception
*/
public void testGetTargetAssocsByPropertyValue() throws Exception
{
// Create test data.
AssociationRef assocRef = createAssociation();
NodeRef sourceRef = assocRef.getSourceRef();
createAssociation(sourceRef);
NodeRef targetRef = assocRef.getTargetRef();
QName qname = assocRef.getTypeQName();
/* Positive tests of various types that should be accepted by the query. */
List<AssociationRef> targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, null, null);
assertEquals("Incorrect number of targets", 2, targetAssocs.size());
Map<QName, Serializable> checkProperties = new HashMap<QName, Serializable>();
checkProperties.put(ContentModel.PROP_ENABLED, Boolean.TRUE);
checkProperties.put(ContentModel.PROP_COUNTER, 100);
checkProperties.put(ContentModel.PROP_LATITUDE, new Double(51.521));
checkProperties.put(ContentModel.PROP_SUBJECT, "Hello World");
for (QName propertyQName : checkProperties.keySet())
{
Serializable propertyValue = checkProperties.get(propertyQName);
nodeService.setProperty(targetRef, propertyQName, propertyValue);
targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, propertyQName, propertyValue);
assertEquals("Incorrect number of targets", 1, targetAssocs.size());
assertTrue("Target not found", targetAssocs.contains(assocRef));
AssociationRef targetAssoc = targetAssocs.get(0);
// Check that ID is present
assertNotNull("Association does not have ID", targetAssoc.getId());
NodeRef targetRefFound = targetAssoc.getTargetRef();
assertEquals("Incorrect value found", propertyValue, this.nodeService.getProperty(targetRefFound, propertyQName));
}
/* Negative tests. */
// Invalid to search on sys:node-dbid
try
{
targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, ContentModel.PROP_NODE_DBID, "Fail");
fail("sys:node-dbid not rejected");
}
catch (IllegalArgumentException ie)
{
// Expect to go here.
}
// Invalid to search on type MLText.
try
{
Serializable title = (String) nodeService.getProperty(sourceRef, ContentModel.PROP_TITLE);
targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, ContentModel.PROP_NAME, title);
fail("MLText type not rejected");
}
catch (IllegalArgumentException ie)
{
// Expect to go here.
}
}
public void testGetSourceAssocs() throws Exception
{
AssociationRef assocRef = createAssociation();

View File

@@ -263,7 +263,31 @@ public class NodeServiceImplTest extends BaseVersionStoreTest
assertNotNull(assocs);
assertEquals(origAssocs.size(), assocs.size());
}
/**
* Tests get target associations by property value.</p>
* See <b>MNT-14504</b> for more details.
*/
public void testGetTargetAssocsByPropertyValue()
{
// Create a new versionable node
NodeRef versionableNode = createNewVersionableNode();
QName propertyQName = PROP_1;
Serializable propertyValue = VALUE_1;
// Store the current details of the target associations
List<AssociationRef> origAssocs = this.dbNodeService.getTargetAssocsByPropertyValue(versionableNode, RegexQNamePattern.MATCH_ALL,
propertyQName, propertyValue);
// Create a new version
Version version = createVersion(versionableNode, this.versionProperties);
List<AssociationRef> assocs = this.versionStoreNodeService.getTargetAssocsByPropertyValue(version.getFrozenStateNodeRef(),
RegexQNamePattern.MATCH_ALL, propertyQName, propertyValue);
assertNotNull(assocs);
assertEquals(origAssocs.size(), assocs.size());
}
/**
* Test hasAspect
*/