RM-2333, RM-2341, RM-2342, RM-2343, RM-2344, RM-2346.

Changed Classification Agency to optional throughtout the stack and added a new mandatory property Classified By throughout the stack.
Addressing the fallout in the existing tests due to these changes.
Also enhanced some existing tests to validate the classified by value persistence.

Still to do: need to initialise the Classified By field in the Classify dialog to the current user's full name (not as easy as I'd thought) and add additional AC tests.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@107433 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2015-06-30 15:32:47 +00:00
parent 1303566099
commit fa3f1230a4
18 changed files with 77 additions and 48 deletions

View File

@@ -145,6 +145,7 @@
class="org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceServiceImpl"
parent="baseService" init-method="init">
<property name="personService" ref="PersonService"/>
<property name="authenticationUtil" ref="rm.authenticationUtil" />
<property name="classificationServiceBootstrap" ref="classificationServiceBootstrap"/>
</bean>

View File

@@ -64,6 +64,14 @@
<title>Classification Agency</title>
<description>The classification agency</description>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="clf:classifiedBy">
<!-- Note that this need not be a username. It can be any text. -->
<title>Classified By</title>
<description>Name of whoever has applied the classification</description>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="clf:classificationReasons">
<title>Classification Reasons</title>

View File

@@ -6,6 +6,7 @@
The body of the post should be in the form, e.g.<br/>
{<br/>
"classificationLevelId": "aLevelId",<br/>
"classifiedBy": "some person or entity",<br/>
"classificationAgency": "anAgency",<br/>
"classificationReasons": [<br/>
{<br/>

View File

@@ -45,6 +45,7 @@ public interface ContentClassificationService
* Classify a piece of content.
*
* @param classificationLevelId The security clearance needed to access the content.
* @param classifiedBy Free-form text identifying who classified the content.
* @param classificationAgency The name of the agency responsible for the classification of this content.
* @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way.
* @param content The node to classify.
@@ -53,7 +54,8 @@ public interface ContentClassificationService
* @throws InvalidNodeRefException If the node could not be found.
* @throws InvalidNode If the supplied node is not a content node.
*/
void classifyContent(String classificationLevelId, String classificationAgency, Set<String> classificationReasonIds, NodeRef content)
void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency,
Set<String> classificationReasonIds, NodeRef content)
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
/**

View File

@@ -85,11 +85,11 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
};
@Override
public void classifyContent(String classificationLevelId, String classificationAgency,
public void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency,
Set<String> classificationReasonIds, final NodeRef content)
{
checkNotBlank("classificationLevelId", classificationLevelId);
checkNotBlank("classificationAgency", classificationAgency);
mandatory("classifiedBy", classifiedBy);
mandatory("classificationReasonIds", classificationReasonIds);
mandatory("content", content);
@@ -111,7 +111,7 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
throw new LevelIdNotFound(classificationLevelId);
}
final Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
final Map<QName, Serializable> properties = new HashMap<>();
// Initial classification id
if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null)
{
@@ -124,6 +124,8 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
// Classification agency
properties.put(PROP_CLASSIFICATION_AGENCY, classificationAgency);
properties.put(PROP_CLASSIFIED_BY, classifiedBy);
// Classification reason ids
HashSet<String> classificationReasons = new HashSet<>();
for (String classificationReasonId : classificationReasonIds)

View File

@@ -45,6 +45,7 @@ public interface ClassifiedContentModel
QName PROP_INITIAL_CLASSIFICATION = QName.createQName(CLF_URI, "initialClassification");
QName PROP_CURRENT_CLASSIFICATION = QName.createQName(CLF_URI, "currentClassification");
QName PROP_CLASSIFICATION_AGENCY = QName.createQName(CLF_URI, "classificationAgency");
QName PROP_CLASSIFIED_BY = QName.createQName(CLF_URI, "classifiedBy");
QName PROP_CLASSIFICATION_REASONS = QName.createQName(CLF_URI, "classificationReasons");
/** Security Clearance aspect. */

View File

@@ -47,6 +47,7 @@ public class ClassifyContentPost extends AbstractRmWebScript
{
/** Constants */
public static final String CLASSIFICATION_LEVEL_ID = "classificationLevelId";
public static final String CLASSIFIED_BY = "classifiedBy";
public static final String CLASSIFICATION_AGENCY = "classificationAgency";
public static final String CLASSIFICATION_REASONS = "classificationReasons";
@@ -73,11 +74,13 @@ public class ClassifyContentPost extends AbstractRmWebScript
{
JSONObject jsonObject = getRequestContentAsJsonObject(req);
String classificationLevelId = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_LEVEL_ID);
String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY);
String classifiedBy = getStringValueFromJSONObject(jsonObject, CLASSIFIED_BY);
String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY, false, false);
Set<String> classificationReasonIds = getClassificationReasonIds(jsonObject);
NodeRef document = parseRequestForNodeRef(req);
contentClassificationService.classifyContent(classificationLevelId, classificationAgency, classificationReasonIds, document);
contentClassificationService.classifyContent(classificationLevelId, classifiedBy, classificationAgency,
classificationReasonIds, document);
Map<String, Object> model = new HashMap<>(1);
model.put(SUCCESS, true);

View File

@@ -43,6 +43,7 @@ public class ClassifyTest extends BaseRMTestCase
private static final String LOWER_CLASSIFICATION_LEVEL = "level2";
private static final String CLASSIFICATION_REASON = "Test Reason 1";
private static final String CLASSIFICATION_AGENCY = "classification agency";
private static final String CLASSIFIED_BY = "classified by text";
private static final String RECORD_NAME = "recordname.txt";
/**
@@ -69,6 +70,7 @@ public class ClassifyTest extends BaseRMTestCase
{
contentClassificationService.classifyContent(
CLASSIFICATION_LEVEL,
CLASSIFIED_BY,
CLASSIFICATION_AGENCY,
Collections.singleton(CLASSIFICATION_REASON),
record);
@@ -97,6 +99,7 @@ public class ClassifyTest extends BaseRMTestCase
{
contentClassificationService.classifyContent(
CLASSIFICATION_LEVEL,
CLASSIFIED_BY,
CLASSIFICATION_AGENCY,
Collections.singleton(CLASSIFICATION_REASON),
record);
@@ -106,10 +109,11 @@ public class ClassifyTest extends BaseRMTestCase
public void then() throws Exception
{
assertTrue(nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED));
assertEquals(CLASSIFICATION_LEVEL, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION));
assertEquals(CLASSIFICATION_LEVEL, (String) nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION));
assertEquals(CLASSIFICATION_LEVEL, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION));
assertEquals(CLASSIFICATION_AGENCY, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY));
assertEquals(Collections.singletonList(CLASSIFICATION_REASON), (List<String>)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS));
assertEquals(CLASSIFIED_BY, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFIED_BY));
assertEquals(Collections.singletonList(CLASSIFICATION_REASON), nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS));
}
});
}
@@ -148,7 +152,7 @@ public class ClassifyTest extends BaseRMTestCase
@Override
public Void run()
{
contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFICATION_AGENCY,
contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFIED_BY, CLASSIFICATION_AGENCY,
Sets.newHashSet(CLASSIFICATION_REASON), record);
return null;
}
@@ -199,7 +203,7 @@ public class ClassifyTest extends BaseRMTestCase
@Override
public Void run()
{
contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFICATION_AGENCY,
contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFIED_BY, CLASSIFICATION_AGENCY,
Sets.newHashSet(CLASSIFICATION_REASON), record);
return null;
}

View File

@@ -80,7 +80,7 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific
doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
}
/**
@@ -172,8 +172,8 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
}
/**
@@ -267,8 +267,8 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
}
/**

View File

@@ -83,7 +83,7 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific
doc1 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
}
/**
@@ -174,8 +174,8 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific
doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
}
/**
@@ -266,8 +266,8 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific
doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef();
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2);
}
/**

View File

@@ -74,7 +74,7 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat
record1 = utils.createRecord(folder, generate());
record2 = utils.createRecord(folder, generate());
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
}
/**
@@ -169,8 +169,8 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat
record2 = utils.createRecord(folder, generate());
record3 = utils.createRecord(folder, generate());
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
}
/**
@@ -267,8 +267,8 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat
record2 = utils.createRecord(folder, generate());
record3 = utils.createRecord(folder, generate());
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
}
/**

View File

@@ -76,7 +76,7 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat
record1 = utils.createRecord(folder, searchQuery + generate());
record2 = utils.createRecord(folder, searchQuery + generate());
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
}
/**
@@ -170,8 +170,8 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat
record2 = utils.createRecord(folder, searchQuery + generate());
record3 = utils.createRecord(folder, searchQuery + generate());
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
}
/**
@@ -265,8 +265,8 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat
record2 = utils.createRecord(folder, searchQuery + generate());
record3 = utils.createRecord(folder, searchQuery + generate());
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2);
}
/**

View File

@@ -94,7 +94,7 @@ public class RelationshipClassificationEnforcementTest extends BaseRMTestCase
{
filePlanPermissionService.setPermission(category, myUser, FILING);
securityClearanceService.setUserSecurityClearance(myUser, LEVEL3);
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
relationshipService.addRelationship(CUSTOM_REF_RENDITION.getLocalName(), record1, record2);
}

View File

@@ -96,9 +96,9 @@ public class SavedSearchClassificationEnforcementTest extends SearchClassificati
searchParameters.setIncludeUndeclaredRecords(true);
rmSearchService.saveSearch(siteId, savedSearchName, generate(), searchQuery + "*", searchParameters, true);
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record3);
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record5);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1);
contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record3);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record5);
}
/**

View File

@@ -86,7 +86,7 @@ public class RM2260Test extends BaseRMTestCase
@Override
public Void run()
{
contentClassificationService.classifyContent(LEVEL, generate(), newHashSet(REASON), record);
contentClassificationService.classifyContent(LEVEL, generate(), generate(), newHashSet(REASON), record);
return null;
}
}, myUser);

View File

@@ -92,7 +92,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
@Override
public void when() throws Exception
{
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON1), record);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON1), record);
jsonString = converter.toJSON(record, true);
}
@@ -131,7 +131,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
@Override
public void when() throws Exception
{
contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), newHashSet(REASON1), record);
contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), generate(), newHashSet(REASON1), record);
jsonString = converter.toJSON(record, true);
}
@@ -206,7 +206,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
@Override
public void when() throws Exception
{
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON1), file);
contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON1), file);
jsonString = converter.toJSON(file, true);
}
@@ -243,7 +243,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase
@Override
public void when() throws Exception
{
contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), newHashSet(REASON1), file);
contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), generate(), newHashSet(REASON1), file);
jsonString = converter.toJSON(file, true);
}

View File

@@ -83,6 +83,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
{
MockitoAnnotations.initMocks(this);
MockAuthenticationUtilHelper.setup(mockAuthenticationUtil);
contentClassificationServiceImpl.setAuthenticationUtil(mockAuthenticationUtil);
}
/** Classify a piece of content with a couple of reasons and check the NodeService is called correctly. */
@@ -102,8 +103,8 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false);
when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(true);
// Call the method under test.
contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency",
// Call the method under test
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
Sets.newHashSet("reasonId1", "reasonId2"), content);
verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED),
@@ -113,10 +114,12 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
HashSet<QName> expectedPropertyKeys = Sets.newHashSet(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION,
ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION,
ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY,
ClassifiedContentModel.PROP_CLASSIFIED_BY,
ClassifiedContentModel.PROP_CLASSIFICATION_REASONS);
assertEquals("Aspect created with unexpected set of keys.", expectedPropertyKeys, properties.keySet());
assertEquals("Unexpected initial classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION));
assertEquals("Unexpected current classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION));
assertEquals("Unexpected classifiedBy.", "classifiedBy", properties.get(ClassifiedContentModel.PROP_CLASSIFIED_BY));
assertEquals("Unexpected agency.", "classificationAgency", properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY));
Set<String> expectedReasonIds = Sets.newHashSet("reasonId1", "reasonId2");
assertEquals("Unexpected set of reasons.", expectedReasonIds, properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_REASONS));
@@ -131,7 +134,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
when(mockNodeService.getType(notAPieceOfContent)).thenReturn(ContentModel.TYPE_FOLDER);
// Call the method under test.
contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency",
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent);
}
@@ -145,7 +148,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
when(mockNodeService.hasAspect(classifiedContent, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(true);
// Call the method under test.
contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency",
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent);
}
@@ -158,7 +161,8 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
when(mockNodeService.hasAspect(sharedContent, QuickShareModel.ASPECT_QSHARE)).thenReturn(true);
// Call the method under test.
contentClassificationServiceImpl.classifyContent(generateText(), generateText(), newHashSet(generateText(), generateText()), sharedContent);
contentClassificationServiceImpl.classifyContent(generateText(), generateText(), generateText(),
newHashSet(generateText(), generateText()), sharedContent);
}
/**
@@ -175,7 +179,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(false);
// Call the method under test.
contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency",
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy","classificationAgency",
Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent);
}

View File

@@ -22,6 +22,7 @@ import static com.google.common.collect.Sets.newHashSet;
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_AGENCY;
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_LEVEL_ID;
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_REASONS;
import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFIED_BY;
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
import static org.alfresco.util.WebScriptUtils.putValuetoJSONObject;
import static org.junit.Assert.assertEquals;
@@ -61,6 +62,7 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest
private static final String ID = "id";
private static final String SUCCESS = "success";
private static final String LEVEL_ID = "aLevelId";
private static final String BY = "bySomeone";
private static final String AGENCY = "anAgency";
private static final String REASON1_ID = "reason1Id";
private static final String REASON2_ID = "reason2Id";
@@ -116,7 +118,7 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest
assertEquals(getStringValueFromJSONObject(json, SUCCESS), Boolean.TRUE.toString());
// Verify that the classify content method was called
verify(mockedContentClassificationService, times(1)).classifyContent(LEVEL_ID, AGENCY, newHashSet(REASON1_ID, REASON2_ID), record);
verify(mockedContentClassificationService, times(1)).classifyContent(LEVEL_ID, BY, AGENCY, newHashSet(REASON1_ID, REASON2_ID), record);
}
/**
@@ -128,6 +130,7 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest
{
JSONObject content = new JSONObject();
putValuetoJSONObject(content, CLASSIFICATION_LEVEL_ID, LEVEL_ID);
putValuetoJSONObject(content, CLASSIFIED_BY, BY);
putValuetoJSONObject(content, CLASSIFICATION_AGENCY, AGENCY);
JSONObject classificationReason1 = new JSONObject();