RM-4619 - replaced unit tests with integration tests

This commit is contained in:
Ana Bozianu
2017-02-07 16:24:10 +02:00
parent 5b041f31f2
commit 161ec4eaee
3 changed files with 84 additions and 46 deletions

View File

@@ -0,0 +1,84 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2017 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.issue;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.model.FileInfo;
import org.springframework.extensions.webscripts.GUID;
/**
* Unit test for RM-4619
*
* When creating regular folders through clients that are not RM aware
* the folders must be converted to the appropriate RM container
*
* @author Ana Bozianu
* @since 2.6
*/
public class RM4619Test extends BaseRMTestCase
{
/**
* Given the RM site is created
* When we create a regular folder in the fileplan
* Then the folder is immediately converted to a record category
*/
public void testConvertFolderToCategory() throws Exception
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER);
assertEquals(info.getType(), TYPE_RECORD_CATEGORY);
return null;
}
}, ADMIN_USER);
}
/**
* Given an existing category
* When we create a regular folder in the category
* Then the folder is immediately converted to a record folder
*/
public void testConvertFolderToRecordFolder() throws Exception
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER);
assertEquals(info.getType(), TYPE_RECORD_FOLDER);
return null;
}
}, ADMIN_USER);
}
}

View File

@@ -182,29 +182,6 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
filePlanType.onCreateChildAssociation(childAssoc, true);
}
/**
* Given that we try to add "cm:folder" type to a record category,
* Then operation is successful and the folder is automatically converted to a record folder
*/
@Test
public void testConversionToRecordFolder() throws Exception
{
NodeRef fileplan = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(fileplan, nodeRef);
try
{
filePlanType.onCreateChildAssociation(childAssocRef, true);
}
catch(IntegrityException ex)
{
// this will throw an exception because unit tests can't detect type change
}
verify(mockedNodeService).setType(nodeRef, TYPE_RECORD_CATEGORY);
}
/**
* Helper method that creates a child of the fileplan container with the provided type
* @param childType the node type of the child to be created

View File

@@ -109,27 +109,4 @@ public class RecordCategoryTypeUnitTest extends BaseUnitTest
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef);
recordCategoryType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add "cm:folder" type to a record category,
* Then operation is successful and the folder is automatically converted to a record folder
*/
@Test
public void testConversionToRecordFolder() throws Exception
{
NodeRef recordCategoryNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_CATEGORY);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef);
try
{
recordCategoryType.onCreateChildAssociation(childAssocRef, true);
}
catch(IntegrityException ex)
{
// this will throw an exception because unit tests can't detect type change
}
verify(mockedNodeService).setType(nodeRef, TYPE_RECORD_FOLDER);
}
}