mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
SEARCH-2833 Add field for association Qname in NodeResource and ChildAssociationResource (#678)
This commit is contained in:
@@ -36,6 +36,7 @@ import java.util.List;
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.dictionary.NamespaceDAO;
|
||||
import org.alfresco.repo.event.v1.model.ChildAssociationResource;
|
||||
import org.alfresco.repo.event.v1.model.DataAttributes;
|
||||
import org.alfresco.repo.event.v1.model.EventType;
|
||||
@@ -114,6 +115,9 @@ public abstract class AbstractContextAwareRepoEvent extends BaseSpringTest
|
||||
@Qualifier("eventGeneratorQueue")
|
||||
protected EventGeneratorQueue eventQueue;
|
||||
|
||||
@Autowired
|
||||
private NamespaceDAO namespaceDAO;
|
||||
|
||||
protected NodeRef rootNodeRef;
|
||||
|
||||
@BeforeClass
|
||||
@@ -152,9 +156,19 @@ public abstract class AbstractContextAwareRepoEvent extends BaseSpringTest
|
||||
return nodeService.getRootNode(storeRef);
|
||||
});
|
||||
|
||||
initTestNamespacePrefixMapping();
|
||||
|
||||
flushSpuriousEvents();
|
||||
}
|
||||
|
||||
protected void initTestNamespacePrefixMapping() {
|
||||
if(namespaceDAO.getNamespaceURI("ce") == null)
|
||||
{
|
||||
namespaceDAO.addURI(TEST_NAMESPACE);
|
||||
namespaceDAO.addPrefix("ce", TEST_NAMESPACE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When running with an empty database some events related to the creation may
|
||||
* creep up here making the test fails. After attempting several other
|
||||
@@ -207,11 +221,16 @@ public abstract class AbstractContextAwareRepoEvent extends BaseSpringTest
|
||||
}
|
||||
|
||||
protected NodeRef createNode(QName contentType, PropertyMap propertyMap)
|
||||
{
|
||||
return createNode(contentType, GUID.generate(), propertyMap);
|
||||
}
|
||||
|
||||
protected NodeRef createNode(QName contentType, String localName, PropertyMap propertyMap)
|
||||
{
|
||||
return retryingTransactionHelper.doInTransaction(() -> nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(TEST_NAMESPACE, GUID.generate()),
|
||||
QName.createQName(TEST_NAMESPACE, localName),
|
||||
contentType,
|
||||
propertyMap).getChildRef());
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
@Test
|
||||
public void testAddChildAssociation()
|
||||
{
|
||||
String assocLocalName = GUID.generate();
|
||||
final NodeRef parentNodeRef = createNode(ContentModel.TYPE_FOLDER);
|
||||
final NodeRef childNodeRef = createNode(ContentModel.TYPE_CONTENT);
|
||||
|
||||
@@ -64,11 +65,11 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
resultRepoEvent.getType());
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.addChild(
|
||||
parentNodeRef,
|
||||
childNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(TEST_NAMESPACE, GUID.generate())));
|
||||
nodeService.addChild(
|
||||
parentNodeRef,
|
||||
childNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(TEST_NAMESPACE, assocLocalName)));
|
||||
|
||||
List<ChildAssociationRef> childAssociationRefs = retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.getChildAssocs(parentNodeRef));
|
||||
@@ -101,6 +102,7 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertEquals("Wrong parent", parentNodeRef.getId(), childAssociationResource.getParent().getId());
|
||||
assertEquals("Wrong child", childNodeRef.getId(), childAssociationResource.getChild().getId());
|
||||
assertEquals("Wrong assoc type", "cm:contains", childAssociationResource.getAssocType());
|
||||
assertEquals("Wrong assoc name", "ce:" + assocLocalName, childAssociationResource.getAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -53,16 +53,17 @@ public class CreateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
@Autowired
|
||||
private NodeDAO nodeDAO;
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateEvent()
|
||||
{
|
||||
// Create a node without content
|
||||
final String name = "TestFile-" + System.currentTimeMillis() + ".txt";
|
||||
String localName = GUID.generate();
|
||||
PropertyMap propertyMap = new PropertyMap();
|
||||
propertyMap.put(ContentModel.PROP_TITLE, "test title");
|
||||
propertyMap.put(ContentModel.PROP_NAME, name);
|
||||
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, propertyMap);
|
||||
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, localName, propertyMap);
|
||||
|
||||
final RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEvent(1);
|
||||
// Repo event attributes
|
||||
@@ -103,6 +104,7 @@ public class CreateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertEquals("Wrong node modifier display name.", "Administrator",
|
||||
nodeResource.getModifiedByUser().getDisplayName());
|
||||
assertNotNull("Missing modifiedAt property.", nodeResource.getModifiedAt());
|
||||
assertEquals("Wrong primaryAssocQName prefix.", "ce:" + localName, nodeResource.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -45,9 +45,10 @@ public class DeleteRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
@Test
|
||||
public void testDeleteContent()
|
||||
{
|
||||
String localName = GUID.generate();
|
||||
PropertyMap propertyMap = new PropertyMap();
|
||||
propertyMap.put(ContentModel.PROP_TITLE, "test title");
|
||||
NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, propertyMap);
|
||||
NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, localName, propertyMap);
|
||||
|
||||
NodeResource createdResource = getNodeResource(1);
|
||||
|
||||
@@ -64,6 +65,7 @@ public class DeleteRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
assertEquals("Repo event type:", EventType.NODE_DELETED.getType(), resultRepoEvent.getType());
|
||||
assertEquals(createdResource.getId(), getNodeResource(resultRepoEvent).getId());
|
||||
assertEquals("Wrong primaryAssocQName prefix.", "ce:" + localName, createdResource.getPrimaryAssocQName());
|
||||
|
||||
// There should be no resourceBefore
|
||||
EventData<NodeResource> eventData = getEventData(resultRepoEvent);
|
||||
|
@@ -33,7 +33,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.dictionary.M2Model;
|
||||
@@ -59,6 +58,7 @@ import org.junit.Test;
|
||||
*/
|
||||
public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testUpdateNodeResourceContent()
|
||||
{
|
||||
@@ -138,6 +138,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNull(resourceBefore.getProperties());
|
||||
assertNull(resourceBefore.getAspectNames());
|
||||
assertNull(resourceBefore.getPrimaryHierarchy());
|
||||
assertNull(resourceBefore.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -198,6 +199,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNull(resourceBefore.getProperties());
|
||||
assertNull(resourceBefore.getAspectNames());
|
||||
assertNull(resourceBefore.getPrimaryHierarchy());
|
||||
assertNull(resourceBefore.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -274,6 +276,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNull(resourceBefore.getProperties());
|
||||
assertNull(resourceBefore.getAspectNames());
|
||||
assertNull(resourceBefore.getPrimaryHierarchy());
|
||||
assertNull(resourceBefore.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -539,6 +542,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNull(resourceBefore.getProperties());
|
||||
assertNull(resourceBefore.getAspectNames());
|
||||
assertNull(resourceBefore.getPrimaryHierarchy());
|
||||
assertNull(resourceBefore.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -574,6 +578,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
NodeResource nodeResource = getNodeResource(resultRepoEvent);
|
||||
assertEquals("Incorrect node type was found", "cm:dictionaryModel", nodeResource.getNodeType());
|
||||
|
||||
initTestNamespacePrefixMapping();
|
||||
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT);
|
||||
// old node's type
|
||||
assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(nodeRef));
|
||||
@@ -613,7 +618,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNull(resourceBefore.getProperties());
|
||||
assertNull(resourceBefore.getAspectNames());
|
||||
assertNull(resourceBefore.getPrimaryHierarchy());
|
||||
|
||||
assertNull(resourceBefore.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -660,6 +665,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNull(resourceBefore.getProperties());
|
||||
assertNull(resourceBefore.getAspectNames());
|
||||
assertNull(resourceBefore.getPrimaryHierarchy());
|
||||
assertNull(resourceBefore.getPrimaryAssocQName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user