RM-2280 (Move the code for checking if the content is classified to the service layer)

* moved the check to content classification service
   
+review RM-87

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@106090 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-06-12 20:39:33 +00:00
parent ac56441fc3
commit f2010a9f2f
5 changed files with 91 additions and 29 deletions

View File

@@ -37,9 +37,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import org.alfresco.model.ContentModel;
import org.alfresco.model.QuickShareModel;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode;
@@ -60,6 +57,9 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
/**
* Unit tests for {@link ContentClassificationServiceImpl}.
*
@@ -301,4 +301,48 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
assertFalse(contentClassificationServiceImpl.hasClearance(nodeRef));
}
/**
* Given that I classify a node with a level not equal to "Unclassified"
* When I ask if the node is classified
* Then return true
*/
@Test public void contentClassified_levelNotUnclassified()
{
NodeRef nodeRef = generateNodeRef(mockNodeService);
when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn("level1");
when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true);
assertTrue(contentClassificationServiceImpl.isClassified(nodeRef));
}
/**
* Given that I classify a node with level "Unclassified"
* When I ask if the node is classified
* Then return false
*/
@Test public void contentClassified_levelUnclassified()
{
NodeRef nodeRef = generateNodeRef(mockNodeService);
when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn(ClassificationLevelManager.UNCLASSIFIED_ID);
when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true);
assertFalse(contentClassificationServiceImpl.isClassified(nodeRef));
}
/**
* Given that a node is not classified
* When I ask if the node is classified
* Then return false
*/
@Test public void contentNotClassified()
{
NodeRef nodeRef = generateNodeRef(mockNodeService);
when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(false);
assertFalse(contentClassificationServiceImpl.isClassified(nodeRef));
}
}