Adding the new test data set to the test context.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@41633 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2012-09-16 20:30:02 +00:00
parent 65e4c7707e
commit 15bcee05c8
2 changed files with 48 additions and 64 deletions

View File

@@ -1,28 +1,19 @@
package org.alfresco.module.org_alfresco_module_rm.test.service; package org.alfresco.module.org_alfresco_module_rm.test.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet; import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet;
import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.view.ImporterService;
public class DataSetServiceImplTest extends BaseRMTestCase public class DataSetServiceImplTest extends BaseRMTestCase
{ {
/** Services */ /** Services */
protected DataSetService dataSetService; private DataSetService dataSetService;
protected ImporterService importerService;
/** List of data set ids */ /** Id of the test data set*/
private List<String> dataSetIds; private static final String DATA_SET_ID = "testExampleData";
/** Constants for data set ids */
private static final String DATA_SET_ID_DOD5015 = "dod5015";
/** Enum for checking the condition */ /** Enum for checking the condition */
private enum Condition private enum Condition
@@ -31,19 +22,6 @@ public class DataSetServiceImplTest extends BaseRMTestCase
AFTER; // Test a file plan after a data set has been imported AFTER; // Test a file plan after a data set has been imported
} }
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp()
*/
@Override
protected void setUp() throws Exception
{
super.setUp();
// Add the id's of the data sets to the list
dataSetIds = new ArrayList<String>();
dataSetIds.add(DATA_SET_ID_DOD5015);
}
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
*/ */
@@ -52,9 +30,8 @@ public class DataSetServiceImplTest extends BaseRMTestCase
{ {
super.initServices(); super.initServices();
// Get Services // Get RM Services
dataSetService = (DataSetService) applicationContext.getBean("DataSetService"); dataSetService = (DataSetService) applicationContext.getBean("DataSetService");
importerService = (ImporterService) applicationContext.getBean("ImporterService");
} }
/** /**
@@ -111,7 +88,7 @@ public class DataSetServiceImplTest extends BaseRMTestCase
@Override @Override
public Void run() throws Exception public Void run() throws Exception
{ {
// This will be tested in testFilePlanBeforeImportingDOD5015DataSet() and testFilePlanAfterImportingDOD5015DataSet() // This will be tested in testFilePlanBeforeImportingDataSet() and testFilePlanAfterImportingDataSet()
return null; return null;
} }
}); });
@@ -127,7 +104,7 @@ public class DataSetServiceImplTest extends BaseRMTestCase
@Override @Override
public Void run() throws Exception public Void run() throws Exception
{ {
// This will be tested in testFilePlanBeforeImportingDOD5015DataSet() and testFilePlanAfterImportingDOD5015DataSet() // This will be tested in testFilePlanBeforeImportingDataSet() and testFilePlanAfterImportingDataSet()
return null; return null;
} }
}); });
@@ -146,20 +123,17 @@ public class DataSetServiceImplTest extends BaseRMTestCase
// Test the file plan // Test the file plan
assertNotNull(filePlan); assertNotNull(filePlan);
for (String dataSetId : dataSetIds)
{
// Test the data set id // Test the data set id
assertNotNull(dataSetId); assertNotNull(DATA_SET_ID);
// Test the file plan before importing the data sets // Test the file plan before importing the data sets
testFilePlan(filePlan, dataSetId, Condition.BEFORE); testFilePlan(filePlan, DATA_SET_ID, Condition.BEFORE);
// Load the data set into the specified file plan // Load the data set into the specified file plan
dataSetService.loadDataSet(filePlan, dataSetId); dataSetService.loadDataSet(filePlan, DATA_SET_ID);
// Test the file plan after importing the data sets // Test the file plan after importing the data sets
testFilePlan(filePlan, dataSetId, Condition.AFTER); testFilePlan(filePlan, DATA_SET_ID, Condition.AFTER);
}
return null; return null;
} }
@@ -172,29 +146,29 @@ public class DataSetServiceImplTest extends BaseRMTestCase
* @param condition Indicates whether the filePlan should be tested before or after importing the test data * @param condition Indicates whether the filePlan should be tested before or after importing the test data
*/ */
private void testFilePlan(NodeRef filePlan, String dataSetId, Condition condition) private void testFilePlan(NodeRef filePlan, String dataSetId, Condition condition)
{
if (dataSetId.equals(DATA_SET_ID_DOD5015))
{ {
switch (condition) switch (condition)
{ {
case BEFORE: case BEFORE:
testFilePlanBeforeImportingDOD5015DataSet(filePlan); testFilePlanBeforeImportingDataSet(filePlan);
break; break;
case AFTER: case AFTER:
testFilePlanAfterImportingDOD5015DataSet(filePlan); testFilePlanAfterImportingDataSet(filePlan);
break; break;
} }
} }
}
// FIXME: Change the tests according to the new data set
/** /**
* Helper method for testing the file plan before importing the DOD5015 data * Helper method for testing the test file plan before importing the data
* *
* @param filePlan The NodeRef of the filePlan which is to test * @param filePlan The NodeRef of the filePlan which is to test
*/ */
private void testFilePlanBeforeImportingDOD5015DataSet(NodeRef filePlan) private void testFilePlanBeforeImportingDataSet(NodeRef filePlan)
{ {
/*
// There should not be any categories before importing // There should not be any categories before importing
assertNull(getRecordCategory(filePlan, "Civilian Files")); assertNull(getRecordCategory(filePlan, "Civilian Files"));
assertNull(getRecordCategory(filePlan, "Military Files")); assertNull(getRecordCategory(filePlan, "Military Files"));
@@ -206,18 +180,20 @@ public class DataSetServiceImplTest extends BaseRMTestCase
// At the beginning the file plan is empty. So there should not be any data sets // At the beginning the file plan is empty. So there should not be any data sets
assertTrue(dataSetService.getLoadedDataSets(filePlan).size() == 0); assertTrue(dataSetService.getLoadedDataSets(filePlan).size() == 0);
assertFalse(dataSetService.isLoadedDataSet(filePlan, DATA_SET_ID_DOD5015)); assertFalse(dataSetService.isLoadedDataSet(filePlan, dataSetId));
assertTrue(dataSetService.getDataSets(filePlan, true).size() == 1); assertTrue(dataSetService.getDataSets(filePlan, true).size() == 1);
assertTrue(dataSetService.getDataSets(filePlan, false).size() == 1); assertTrue(dataSetService.getDataSets(filePlan, false).size() == 1);
*/
} }
/** /**
* Helper method for testing the file plan after importing the DOD5015 data * Helper method for testing the test file plan after importing the data
* *
* @param filePlan The NodeRef of the filePlan which is to test * @param filePlan The NodeRef of the filePlan which is to test
*/ */
private void testFilePlanAfterImportingDOD5015DataSet(NodeRef filePlan) private void testFilePlanAfterImportingDataSet(NodeRef filePlan)
{ {
/*
// Test the "first level" categories after importing if they exist // Test the "first level" categories after importing if they exist
NodeRef civFil = getRecordCategory(filePlan, "Civilian Files"); NodeRef civFil = getRecordCategory(filePlan, "Civilian Files");
assertNotNull(civFil); assertNotNull(civFil);
@@ -309,15 +285,16 @@ public class DataSetServiceImplTest extends BaseRMTestCase
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<String> loadedDataSetIds = (ArrayList<String>)nodeProperty; ArrayList<String> loadedDataSetIds = (ArrayList<String>)nodeProperty;
assertTrue(loadedDataSetIds.size() == 1); assertTrue(loadedDataSetIds.size() == 1);
assertTrue(loadedDataSetIds.contains(DATA_SET_ID_DOD5015)); assertTrue(loadedDataSetIds.contains(dataSetId));
// The data set has been loaded into the file plan, so the file plan should contain the data set id // The data set has been loaded into the file plan, so the file plan should contain the data set id
Map<String, DataSet> loadedDataSets = dataSetService.getLoadedDataSets(filePlan); Map<String, DataSet> loadedDataSets = dataSetService.getLoadedDataSets(filePlan);
assertTrue(loadedDataSets.size() == 1); assertTrue(loadedDataSets.size() == 1);
assertTrue(loadedDataSets.containsKey(DATA_SET_ID_DOD5015)); assertTrue(loadedDataSets.containsKey(dataSetId));
assertTrue(dataSetService.isLoadedDataSet(filePlan, DATA_SET_ID_DOD5015)); assertTrue(dataSetService.isLoadedDataSet(filePlan, dataSetId));
assertTrue(dataSetService.getDataSets(filePlan, true).size() == 0); assertTrue(dataSetService.getDataSets(filePlan, true).size() == 0);
assertTrue(dataSetService.getDataSets(filePlan, false).size() == 1); assertTrue(dataSetService.getDataSets(filePlan, false).size() == 1);
*/
} }
/** /**
@@ -327,10 +304,12 @@ public class DataSetServiceImplTest extends BaseRMTestCase
* @param recordCategoryName the record category name * @param recordCategoryName the record category name
* @return Returns the record category nodeRef or null if not found * @return Returns the record category nodeRef or null if not found
*/ */
/*
private NodeRef getRecordCategory(NodeRef parentNode, String recordCategoryName) private NodeRef getRecordCategory(NodeRef parentNode, String recordCategoryName)
{ {
return nodeService.getChildByName(parentNode, ContentModel.ASSOC_CONTAINS, recordCategoryName); return nodeService.getChildByName(parentNode, ContentModel.ASSOC_CONTAINS, recordCategoryName);
} }
*/
/** /**
* Helper method for getting the record folder with the given folder name within the context of the record category * Helper method for getting the record folder with the given folder name within the context of the record category
@@ -339,10 +318,12 @@ public class DataSetServiceImplTest extends BaseRMTestCase
* @param recordFolderName the folder name * @param recordFolderName the folder name
* @return Returns the record folder nodeRef or null if not found * @return Returns the record folder nodeRef or null if not found
*/ */
/*
private NodeRef getRecordFolder(NodeRef recordCategory, String recordFolderName) private NodeRef getRecordFolder(NodeRef recordCategory, String recordFolderName)
{ {
return nodeService.getChildByName(recordCategory, ContentModel.ASSOC_CONTAINS, recordFolderName); return nodeService.getChildByName(recordCategory, ContentModel.ASSOC_CONTAINS, recordFolderName);
} }
*/
}); });
} }
@@ -355,12 +336,9 @@ public class DataSetServiceImplTest extends BaseRMTestCase
{ {
@Override @Override
public Void run() throws Exception public Void run() throws Exception
{
for (String dataSetId : dataSetIds)
{ {
// Test if a data set with the specified data set id exists // Test if a data set with the specified data set id exists
assertTrue(dataSetService.existsDataSet(dataSetId)); assertTrue(dataSetService.existsDataSet(DATA_SET_ID));
}
return null; return null;
} }
@@ -377,7 +355,7 @@ public class DataSetServiceImplTest extends BaseRMTestCase
@Override @Override
public Void run() throws Exception public Void run() throws Exception
{ {
// This will be tested in testFilePlanBeforeImportingDOD5015DataSet() and testFilePlanAfterImportingDOD5015DataSet() // This will be tested in testFilePlanBeforeImportingDataSet() and testFilePlanAfterImportingDataSet()
return null; return null;
} }
}); });

View File

@@ -67,4 +67,10 @@
</list> </list>
</property> </property>
</bean> </bean>
<bean id="dataSetTest" parent="dataSetBase">
<property name="label" value="Test Example Data"/>
<property name="id" value="testExampleData"/>
<property name="path" value="test-filePlan.xml" />
</bean>
</beans> </beans>