mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1194: As a records manager I want to create a 'standard' RM site that only displays records meta-data types relevant to standard RM practices, so that I don't get confused by unwanted DoD records meta-data types.
* record metadata aspects are now configured via spring and includes which file plan type they are relevant for * added 'unit test' structure .. for 'real' unit tests, ie anything that doesn't load the application context * included Mockito, new source location and unit test suite into POM * added unit and functional tests for feature (server) * refactored accordingly (webscripts, UI, etc) * visual test of UI .. automation tests to follow git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63013 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordMetadataBootstrapUnitTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImplUnitTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
/**
|
||||
* All unit test suite.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(
|
||||
{
|
||||
RecordMetadataBootstrapUnitTest.class,
|
||||
RecordServiceImplUnitTest.class
|
||||
})
|
||||
public class AllUnitTestSuite
|
||||
{
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.junit.Before;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
/**
|
||||
* Unit test for RecordServiceImpl
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class BaseUnitTest implements RecordsManagementModel
|
||||
{
|
||||
protected static NodeRef FILE_PLAN_COMPONENT = generateNodeRef();
|
||||
protected static NodeRef FILE_PLAN = generateNodeRef();
|
||||
|
||||
@Mock(name="nodeService") protected NodeService mockedNodeService;
|
||||
@Mock(name="dictionaryService") protected DictionaryService mockedDictionaryService;
|
||||
@Mock(name="namespaceService") protected NamespaceService mockedNamespaceService;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
// set-up node service
|
||||
when(mockedNodeService.getProperty(FILE_PLAN_COMPONENT, PROP_ROOT_NODEREF)).thenReturn(FILE_PLAN);
|
||||
when(mockedNodeService.getType(FILE_PLAN)).thenReturn(TYPE_FILE_PLAN);
|
||||
|
||||
// set-up namespace service
|
||||
when(mockedNamespaceService.getNamespaceURI(RM_PREFIX)).thenReturn(RM_URI);
|
||||
|
||||
}
|
||||
|
||||
protected static QName generateQName()
|
||||
{
|
||||
return QName.createQName(RM_URI, GUID.generate());
|
||||
}
|
||||
|
||||
protected static NodeRef generateNodeRef()
|
||||
{
|
||||
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.record;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.BaseUnitTest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/**
|
||||
* Unit test for RecordMetadataBootstrap
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordMetadataBootstrapUnitTest extends BaseUnitTest
|
||||
{
|
||||
@Mock(name="recordService") private RecordService mockedRecordService;
|
||||
|
||||
@InjectMocks private RecordMetadataBootstrap bootstrap;
|
||||
|
||||
/**
|
||||
* Test init method to ensure set map will register correctly with record service.
|
||||
*/
|
||||
@Test
|
||||
public void testInit()
|
||||
{
|
||||
// create and set map
|
||||
Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put("rma:test1", "rma:filePlan");
|
||||
map.put("rma:test2", "rma:filePlan");
|
||||
bootstrap.setRecordMetadataAspects(map);
|
||||
|
||||
// call init
|
||||
bootstrap.init();
|
||||
|
||||
// verify that the metedata aspects where registered
|
||||
QName test1 = QName.createQName(RM_URI, "test1");
|
||||
QName test2 = QName.createQName(RM_URI, "test2");
|
||||
verify(mockedRecordService).registerRecordMetadataAspect(test1, TYPE_FILE_PLAN);
|
||||
verify(mockedRecordService).registerRecordMetadataAspect(test2, TYPE_FILE_PLAN);
|
||||
}
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.record;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.BaseUnitTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
/**
|
||||
* Unit test for RecordServiceImpl
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordServiceImplUnitTest extends BaseUnitTest
|
||||
{
|
||||
private static NodeRef NON_STANDARD_FILE_PLAN_COMPONENT = generateNodeRef();
|
||||
private static NodeRef NON_STANDARD_FILE_PLAN = generateNodeRef();
|
||||
|
||||
private static QName TYPE_MY_FILE_PLAN = generateQName();
|
||||
private static QName ASPECT_FOR_FILE_PLAN = generateQName();
|
||||
private static QName ASPECT_FOR_MY_FILE_PLAN = generateQName();
|
||||
private static QName ASPECT_FOR_BOTH = generateQName();
|
||||
|
||||
@InjectMocks private RecordServiceImpl recordService;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
@Override
|
||||
public void before()
|
||||
{
|
||||
super.before();
|
||||
|
||||
// set-up node service
|
||||
when(mockedNodeService.getProperty(NON_STANDARD_FILE_PLAN_COMPONENT, PROP_ROOT_NODEREF)).thenReturn(NON_STANDARD_FILE_PLAN);
|
||||
when(mockedNodeService.getType(NON_STANDARD_FILE_PLAN)).thenReturn(TYPE_MY_FILE_PLAN);
|
||||
|
||||
// set-up dictionary service
|
||||
when(mockedDictionaryService.getAllAspects()).thenReturn(CollectionUtils.EMPTY_COLLECTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterRecordMetadataAspect()
|
||||
{
|
||||
Map<QName, Set<QName>> map = recordService.getRecordMetadataAspectsMap();
|
||||
assertTrue(map.isEmpty());
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_FILE_PLAN, TYPE_FILE_PLAN);
|
||||
map = recordService.getRecordMetadataAspectsMap();
|
||||
assertEquals(1, map.size());
|
||||
assertTrue(map.containsKey(ASPECT_FOR_FILE_PLAN));
|
||||
Set<QName> types = map.get(ASPECT_FOR_FILE_PLAN);
|
||||
assertNotNull(types);
|
||||
assertEquals(1, types.size());
|
||||
assertTrue(types.contains(TYPE_FILE_PLAN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordMetadataAspects()
|
||||
{
|
||||
// register a couple of record meta-data aspects
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_FILE_PLAN, TYPE_FILE_PLAN);
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_MY_FILE_PLAN, TYPE_MY_FILE_PLAN);
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_BOTH, TYPE_FILE_PLAN);
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_BOTH, TYPE_MY_FILE_PLAN);
|
||||
|
||||
Set<QName> set = recordService.getRecordMetadataAspects(FILE_PLAN_COMPONENT);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
set = recordService.getRecordMetadataAspects(NON_STANDARD_FILE_PLAN_COMPONENT);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_MY_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
set = recordService.getRecordMetadataAspects(TYPE_FILE_PLAN);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
set = recordService.getRecordMetadataAspects(TYPE_MY_FILE_PLAN);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_MY_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user