mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-6364 Convert search integration tests to end to end tests done through api
This commit is contained in:
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* 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/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.rest.rm.community.recordcategories;
|
||||||
|
|
||||||
|
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||||
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.model.record.Record;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
|
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||||
|
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
public class AutomaticDispositionTest extends BaseRMRestTest
|
||||||
|
{
|
||||||
|
private static final String CUT_OFF_ASPECT = "rma:cutOff";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DispositionScheduleService dispositionScheduleService;
|
||||||
|
|
||||||
|
private RecordCategory categoryWithRSOnRecords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given there is a complete record eligible for cut off
|
||||||
|
* When the correct frequency of time passes
|
||||||
|
* Then the record will be automatically cut off
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAutomaticCutOff() throws Exception
|
||||||
|
{
|
||||||
|
STEP("Create record category with retention schedule and apply it to records.");
|
||||||
|
categoryWithRSOnRecords = createRootCategory(getRandomName("categoryWithRSOnRecords"));
|
||||||
|
dispositionScheduleService.createCategoryRetentionSchedule(categoryWithRSOnRecords.getName(), true);
|
||||||
|
|
||||||
|
STEP("Add retention schedule cut off step with immediate period.");
|
||||||
|
dispositionScheduleService.addCutOffAfterPeriodStep(categoryWithRSOnRecords.getName(), "immediately");
|
||||||
|
|
||||||
|
STEP("Create a record folder with a record");
|
||||||
|
RecordCategoryChild recordFolder = createRecordFolder(categoryWithRSOnRecords.getId(), getRandomName
|
||||||
|
("recordFolder"));
|
||||||
|
|
||||||
|
STEP("Complete the record and wait upon to 5 minutes for automatic job to execute");
|
||||||
|
Record record = createElectronicRecord(recordFolder.getId(), getRandomName("elRecord"));
|
||||||
|
completeRecord(record.getId());
|
||||||
|
|
||||||
|
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||||
|
List<String> aspects = recordsAPI.getRecord(record.getId()).getAspectNames();
|
||||||
|
int count = 0;
|
||||||
|
while (!aspects.contains(CUT_OFF_ASPECT) && count < 30)
|
||||||
|
{
|
||||||
|
// sleep .. allowing the job time to execute
|
||||||
|
Thread.sleep(10000);
|
||||||
|
count++;
|
||||||
|
aspects = recordsAPI.getRecord(record.getId()).getAspectNames();
|
||||||
|
}
|
||||||
|
aspects = recordsAPI.getRecord(record.getId()).getAspectNames();
|
||||||
|
assertTrue(aspects.contains(CUT_OFF_ASPECT), "Record should now be cut off");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass (alwaysRun = true)
|
||||||
|
public void deleteCategory()
|
||||||
|
{
|
||||||
|
deleteRecordCategory(categoryWithRSOnRecords.getId());
|
||||||
|
}
|
||||||
|
}
|
@@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* 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/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.job;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.util.GUID;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test automatic disposition via scheduled job.
|
|
||||||
*
|
|
||||||
* @author Roy Wetherall
|
|
||||||
* @since 2.2
|
|
||||||
*/
|
|
||||||
public class AutomaticDispositionTest extends BaseRMTestCase
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private RecordsManagementAuditService auditService;
|
|
||||||
|
|
||||||
/** additional job context to override job frequency */
|
|
||||||
protected String[] getConfigLocations()
|
|
||||||
{
|
|
||||||
return ArrayUtils.add(super.getConfigLocations(), "classpath:test-job-context.xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void initServices()
|
|
||||||
{
|
|
||||||
super.initServices();
|
|
||||||
auditService = (RecordsManagementAuditService)applicationContext.getBean("recordsManagementAuditService");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given there is a complete record eligible for cut off, when the correct frequency of time passes, then
|
|
||||||
* the record will be automatically cut off
|
|
||||||
*/
|
|
||||||
public void testAutomaticCutOff()
|
|
||||||
{
|
|
||||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
|
||||||
{
|
|
||||||
NodeRef sourceCategory;
|
|
||||||
NodeRef sourceRecordFolder;
|
|
||||||
NodeRef record;
|
|
||||||
|
|
||||||
public void given()
|
|
||||||
{
|
|
||||||
// create test data
|
|
||||||
sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
|
||||||
DispositionSchedule dis = utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, false);
|
|
||||||
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
|
||||||
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
|
||||||
adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
|
|
||||||
adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
|
||||||
dispositionService.addDispositionActionDefinition(dis, adParams);
|
|
||||||
sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate());
|
|
||||||
|
|
||||||
// create and complete record
|
|
||||||
record = utils.createRecord(sourceRecordFolder, GUID.generate());
|
|
||||||
utils.completeRecord(record);
|
|
||||||
|
|
||||||
// check the disposition action details
|
|
||||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
|
|
||||||
assertNotNull(dispositionAction);
|
|
||||||
assertNotNull(CutOffAction.NAME, dispositionAction.getName());
|
|
||||||
assertTrue(dispositionService.isNextDispositionActionEligible(record));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void when() throws Exception
|
|
||||||
{
|
|
||||||
// sleep .. allowing the job time to execute
|
|
||||||
Thread.sleep(30000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void then()
|
|
||||||
{
|
|
||||||
// record should now be cut off
|
|
||||||
assertTrue(dispositionService.isDisposableItemCutoff(record));
|
|
||||||
|
|
||||||
// TODO .. automatic dispoistion does not log entry in audit
|
|
||||||
// .. the following test checks for this, but is currently commented out
|
|
||||||
// .. because it doesn't work!
|
|
||||||
// RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters();
|
|
||||||
// params.setEvent(CutOffAction.NAME);
|
|
||||||
// params.setMaxEntries(1);
|
|
||||||
// List<RecordsManagementAuditEntry> entries = auditService.getAuditTrail(params);
|
|
||||||
// assertNotNull(entries);
|
|
||||||
// assertEquals(1, entries.size());
|
|
||||||
//
|
|
||||||
// RecordsManagementAuditEntry entry = entries.get(0);
|
|
||||||
// assertEquals(record, entry.getNodeRef());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO automatic retain
|
|
||||||
|
|
||||||
// TODO automatic destroy
|
|
||||||
}
|
|
@@ -117,30 +117,6 @@ public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase
|
|||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSearch()
|
|
||||||
{
|
|
||||||
// Full text search
|
|
||||||
doTestInTransaction(new Test<Void>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void run()
|
|
||||||
{
|
|
||||||
String query = "keywords:\"elephant\"";
|
|
||||||
RecordsManagementSearchParameters params = new RecordsManagementSearchParameters();
|
|
||||||
params.setIncludeUndeclaredRecords(true);
|
|
||||||
List<Pair<NodeRef, NodeRef>> results = rmSearchService.search(siteId, query, params);
|
|
||||||
assertNotNull(results);
|
|
||||||
assertEquals(2, results.size());
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
|
||||||
|
|
||||||
// Property search
|
|
||||||
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSaveSearch()
|
public void testSaveSearch()
|
||||||
{
|
{
|
||||||
// Add some saved searches (as admin user)
|
// Add some saved searches (as admin user)
|
||||||
|
Reference in New Issue
Block a user