mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1679 (Write unit tests for inplace record methods)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@84079 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 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.module.org_alfresco_module_rm.test.integration.record;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
|
||||
/**
|
||||
* Hide Inplace Record Test
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class HideInplaceRecordTest extends BaseRMTestCase
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest()
|
||||
*/
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests hiding inplace records
|
||||
*/
|
||||
public void testHideInplaceRecord()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
public void given()
|
||||
{
|
||||
// Check that the document is not a record
|
||||
assertFalse(recordService.isRecord(dmDocument));
|
||||
|
||||
// Check that the record has one parent association
|
||||
assertEquals(1, nodeService.getParentAssocs(dmDocument).size());
|
||||
|
||||
// Declare the document as a record
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Declare record
|
||||
recordService.createRecord(filePlan, dmDocument);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, dmCollaborator);
|
||||
|
||||
// Check that the document is a record
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
|
||||
// Check that the record has two parent associations
|
||||
assertEquals(2, nodeService.getParentAssocs(dmDocument).size());
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// Hide the document
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Hide record
|
||||
inplaceRecordService.hideRecord(dmDocument);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, dmCollaborator);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// Check that the record has one parent association
|
||||
assertEquals(1, nodeService.getParentAssocs(dmDocument).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 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.module.org_alfresco_module_rm.test.integration.record;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Move Inplace Record Test
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class MoveInplaceRecordTest extends BaseRMTestCase
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest()
|
||||
*/
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests moving inplace records
|
||||
*/
|
||||
public void testMoveInplaceRecord()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
// The destination folder in collaboration site
|
||||
private NodeRef destinationDmFolder;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// Create the destination folder
|
||||
destinationDmFolder = fileFolderService.create(documentLibrary, "destinationCollabFolder", ContentModel.TYPE_FOLDER).getNodeRef();
|
||||
|
||||
// Check that the document is not a record
|
||||
assertFalse(recordService.isRecord(dmDocument));
|
||||
|
||||
// Declare the document as a record
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Declare record
|
||||
recordService.createRecord(filePlan, dmDocument);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, dmCollaborator);
|
||||
|
||||
// Check that the document is a record now
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// Move the document
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Move record
|
||||
inplaceRecordService.moveRecord(dmDocument, destinationDmFolder);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, dmCollaborator);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// Check that the source folder is empty now and the destination folder has the document
|
||||
assertEquals(0, nodeService.getChildAssocs(dmFolder).size());
|
||||
List<ChildAssociationRef> destinationFolderChildAssocs = nodeService.getChildAssocs(destinationDmFolder);
|
||||
assertEquals(1, destinationFolderChildAssocs.size());
|
||||
assertEquals(dmDocument, destinationFolderChildAssocs.get(0).getChildRef());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -33,7 +33,9 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
{
|
||||
RejectRecordTest.class,
|
||||
CreateRecordTest.class,
|
||||
MoveRecordTest.class
|
||||
MoveRecordTest.class,
|
||||
HideInplaceRecordTest.class,
|
||||
MoveInplaceRecordTest.class
|
||||
})
|
||||
public class RecordTestSuite
|
||||
{
|
||||
|
@@ -39,6 +39,7 @@ import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||
@@ -156,6 +157,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected RecordsManagementAuditService rmAuditService;
|
||||
protected IdentifierService identifierService;
|
||||
protected HoldService holdService;
|
||||
protected InplaceRecordService inplaceRecordService;
|
||||
|
||||
/** test data */
|
||||
protected String siteId;
|
||||
@@ -391,6 +393,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
rmAuditService = (RecordsManagementAuditService) applicationContext.getBean("RecordsManagementAuditService");
|
||||
identifierService = (IdentifierService) applicationContext.getBean("recordsManagementIdentifierService");
|
||||
holdService = (HoldService) applicationContext.getBean("HoldService");
|
||||
inplaceRecordService = (InplaceRecordService) applicationContext.getBean("InplaceRecordService");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user