mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2045 Check that content is not re-classified.
Currently this is not supported, although it will be needed in the future. Also take the opportunity to change the unit tests to use: when(x.y()).thenReturn(z)); rather than: doReturn(z).when(x).y(); This is because I noticed the javadoc for "doReturn" gives a good explanation of when to use each (use the former whenever possible for readability; use the latter if there's no choice). +review RM-25 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@102231 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -230,6 +230,11 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
throw new InvalidNode(content, "The supplied node is not a content node.");
|
throw new InvalidNode(content, "The supplied node is not a content node.");
|
||||||
}
|
}
|
||||||
|
if (nodeService.hasAspect(content, ASPECT_CLASSIFIED))
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"The content has already been classified. Reclassification is currently not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||||
checkClassificationLevelId(classificationLevelId);
|
checkClassificationLevelId(classificationLevelId);
|
||||||
|
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -268,12 +267,13 @@ public class ClassificationServiceImplUnitTest
|
|||||||
ClassificationReason reason1 = new ClassificationReason("reasonId1", "displayLabelKey1");
|
ClassificationReason reason1 = new ClassificationReason("reasonId1", "displayLabelKey1");
|
||||||
ClassificationReason reason2 = new ClassificationReason("reasonId2", "displayLabelKey2");
|
ClassificationReason reason2 = new ClassificationReason("reasonId2", "displayLabelKey2");
|
||||||
// Set up the managers to return these objects when the ids are provided.
|
// Set up the managers to return these objects when the ids are provided.
|
||||||
doReturn(level).when(mockLevelManager).findLevelById("levelId1");
|
when(mockLevelManager.findLevelById("levelId1")).thenReturn(level);
|
||||||
doReturn(reason1).when(mockReasonManager).findReasonById("reasonId1");
|
when(mockReasonManager.findReasonById("reasonId1")).thenReturn(reason1);
|
||||||
doReturn(reason2).when(mockReasonManager).findReasonById("reasonId2");
|
when(mockReasonManager.findReasonById("reasonId2")).thenReturn(reason2);
|
||||||
// Create a content node.
|
// Create a content node.
|
||||||
NodeRef content = new NodeRef("fake://content/");
|
NodeRef content = new NodeRef("fake://content/");
|
||||||
doReturn(ContentModel.TYPE_CONTENT).when(mockNodeService).getType(content);
|
when(mockNodeService.getType(content)).thenReturn(ContentModel.TYPE_CONTENT);
|
||||||
|
when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
|
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
|
||||||
@@ -301,10 +301,24 @@ public class ClassificationServiceImplUnitTest
|
|||||||
{
|
{
|
||||||
// Create a folder node.
|
// Create a folder node.
|
||||||
NodeRef notAPieceOfContent = new NodeRef("not://a/piece/of/content/");
|
NodeRef notAPieceOfContent = new NodeRef("not://a/piece/of/content/");
|
||||||
doReturn(ContentModel.TYPE_FOLDER).when(mockNodeService).getType(notAPieceOfContent);
|
when(mockNodeService.getType(notAPieceOfContent)).thenReturn(ContentModel.TYPE_FOLDER);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
|
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
|
||||||
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
|
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Classify a piece of content that has already been classified. */
|
||||||
|
@Test(expected = UnsupportedOperationException.class)
|
||||||
|
public void classifyContent_alreadyClassified()
|
||||||
|
{
|
||||||
|
// Create a classified piece of content.
|
||||||
|
NodeRef classifiedContent = new NodeRef("classified://content/");
|
||||||
|
when(mockNodeService.getType(classifiedContent)).thenReturn(ContentModel.TYPE_CONTENT);
|
||||||
|
when(mockNodeService.hasAspect(classifiedContent, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(true);
|
||||||
|
|
||||||
|
// Call the method under test.
|
||||||
|
classificationServiceImpl.classifyContent("levelId1", "classificationAuthority",
|
||||||
|
Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user