mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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,9 +103,9 @@ 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",
|
||||
Sets.newHashSet("reasonId1", "reasonId2"), content);
|
||||
// Call the method under test
|
||||
contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency",
|
||||
Sets.newHashSet("reasonId1", "reasonId2"), content);
|
||||
|
||||
verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED),
|
||||
propertiesCaptor.capture());
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user