use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddOneFolderTypeToRmSite.
/**
* Given that we try to add one cm:folder to rm site,
* Then operation is successful.
*/
@Test
public void testAddOneFolderTypeToRmSite() {
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
SiteInfo mockedSiteInfo = mock(SiteInfo.class);
when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
assocs.add(mockedChildAssoc);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddNonAcceptedTypeToRmSite.
/**
* Given that we try to add non allowed type to rm site,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToRmSite() {
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
QName type = AlfMock.generateQName();
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
when(mockedChildAssoc.getParentRef()).thenReturn(rmSiteNodeRef);
SiteInfo mockedSiteInfo = mock(SiteInfo.class);
when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddDODFilePlanTypeToStandardRmSite.
/**
* Given that we try to add one dod:filePlan to standard rm site,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testAddDODFilePlanTypeToStandardRmSite() {
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
SiteInfo mockedSiteInfo = mock(SiteInfo.class);
when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_DOD_5015_FILE_PLAN);
ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddMoreThanTwhoFolderTypeToRmSite.
/**
* Given that we try to add more than two cm:folder to rm site,
* Then IntegrityException is thrown.
*/
@Test
public void testAddMoreThanTwhoFolderTypeToRmSite() {
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
SiteInfo mockedSiteInfo = mock(SiteInfo.class);
when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(new ArrayList<ChildAssociationRef>());
// create first folder
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
assocs.add(mockedChildAssoc);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
// create second cm:folder
nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
assocs.add(mockedChildAssoc);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
// create third cm:folder
nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
assocs.add(mockedChildAssoc);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class DataLoadSystemTest method loadInPlace.
private void loadInPlace() {
AuthenticationUtil.runAs(new RunAsWork<Void>() {
public Void doWork() throws Exception {
final SiteInfo site = siteService.getSite("test");
if (site == null) {
throw new AlfrescoRuntimeException("The collab site test is not present.");
}
final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan == null) {
Assert.fail("The default RM site is not present.");
}
// create users and add to site
repeatInTransactionBatches(new RunAsWork<Void>() {
public Void doWork() throws Exception {
// create user
String userName = GUID.generate();
System.out.println("Creating user " + userName);
createPerson(userName, true);
// add to collab site
siteService.setMembership("test", userName, SiteRole.SiteCollaborator.toString());
return null;
}
}, USER_COUNT);
// create content and declare as record
repeatInTransactionBatches(new RunAsWork<Void>() {
public Void doWork() throws Exception {
// create document
NodeRef docLib = siteService.getContainer(site.getShortName(), SiteService.DOCUMENT_LIBRARY);
NodeRef document = fileFolderService.create(docLib, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
recordService.createRecord(filePlan, document);
return null;
}
}, INPLACE_RECORD_COUNT);
return null;
}
}, AuthenticationUtil.getAdminUserName());
}
Aggregations