From dac9f630decac09d9d9284fbbfa538ae3d96eb2b Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 5 Apr 2017 12:04:31 +0300 Subject: [PATCH] RM-3727 - added unit test for reviewed action and removed notification issued property --- .../messages/records-model.properties | 2 - .../messages/records-model_de.properties | 2 - .../messages/records-model_es.properties | 2 - .../messages/records-model_fr.properties | 2 - .../messages/records-model_it.properties | 2 - .../messages/records-model_ja.properties | 2 - .../messages/records-model_nb.properties | 2 - .../messages/records-model_nl.properties | 2 - .../messages/records-model_pt_BR.properties | 2 - .../messages/records-model_ru.properties | 2 - .../messages/records-model_zh_CN.properties | 2 - .../model/recordsModel.xml | 7 - ...otifyOfRecordsDueForReviewJobExecuter.java | 15 -- .../model/RecordsManagementModel.java | 1 - .../vital/ReviewedActionUnitTest.java | 140 ++++++++++++++++++ 15 files changed, 140 insertions(+), 45 deletions(-) create mode 100644 rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedActionUnitTest.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties index 911edd0680..6b10759f5e 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Vital Record rma_recordsmanagement.aspect.rma_vitalRecord.decription=Vital Record rma_recordsmanagement.property.rma_reviewAsOf.title=Next Review rma_recordsmanagement.property.rma_reviewAsOf.decription=Next Review -rma_recordsmanagement.property.rma_notificationIssued.title=Indicates that a due for review notification has been issued for this record -rma_recordsmanagement.property.rma_notificationIssued.decription=Indicates that a due for review notification has been issued for this record rma_recordsmanagement.aspect.rma_scheduled.title=Scheduled rma_recordsmanagement.aspect.rma_scheduled.decription=Scheduled diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties index aaa1b7ba53..925c0eb2f9 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_de.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Besonders relevanter Record rma_recordsmanagement.aspect.rma_vitalRecord.decription=Besonders relevanter Record rma_recordsmanagement.property.rma_reviewAsOf.title=N\u00e4chste \u00dcberpr\u00fcfung rma_recordsmanagement.property.rma_reviewAsOf.decription=N\u00e4chste \u00dcberpr\u00fcfung -rma_recordsmanagement.property.rma_notificationIssued.title=Gibt an, dass f\u00fcr diesen Record eine Benachrichtigung aufgrund einer f\u00e4lligen \u00dcberpr\u00fcfung ausgegeben wurde. -rma_recordsmanagement.property.rma_notificationIssued.decription=Gibt an, dass f\u00fcr diesen Record eine Benachrichtigung aufgrund einer f\u00e4lligen \u00dcberpr\u00fcfung ausgegeben wurde. rma_recordsmanagement.aspect.rma_scheduled.title=Geplant rma_recordsmanagement.aspect.rma_scheduled.decription=Geplant diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties index 94e539b653..b92e54128a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_es.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Documento de archivo vital rma_recordsmanagement.aspect.rma_vitalRecord.decription=Documento de archivo vital rma_recordsmanagement.property.rma_reviewAsOf.title=Pr\u00f3xima revisi\u00f3n rma_recordsmanagement.property.rma_reviewAsOf.decription=Pr\u00f3xima revisi\u00f3n -rma_recordsmanagement.property.rma_notificationIssued.title=Indica que se ha emitido una notificaci\u00f3n de pendiente de revisi\u00f3n para este documento de archivo -rma_recordsmanagement.property.rma_notificationIssued.decription=Indica que se ha emitido una notificaci\u00f3n de pendiente de revisi\u00f3n para este documento de archivo rma_recordsmanagement.aspect.rma_scheduled.title=Planificado rma_recordsmanagement.aspect.rma_scheduled.decription=Planificado diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties index 3eac7bb3ca..0b2796087e 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_fr.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Document d'archives essentiel rma_recordsmanagement.aspect.rma_vitalRecord.decription=Document d'archives essentiel rma_recordsmanagement.property.rma_reviewAsOf.title=V\u00e9rification suivante rma_recordsmanagement.property.rma_reviewAsOf.decription=V\u00e9rification suivante -rma_recordsmanagement.property.rma_notificationIssued.title=Indique qu'une notification d'arriv\u00e9e \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification a \u00e9t\u00e9 \u00e9mise pour ce document d'archives -rma_recordsmanagement.property.rma_notificationIssued.decription=Indique qu'une notification d'arriv\u00e9e \u00e0 \u00e9ch\u00e9ance pour v\u00e9rification a \u00e9t\u00e9 \u00e9mise pour ce document d'archives rma_recordsmanagement.aspect.rma_scheduled.title=Planifi\u00e9 rma_recordsmanagement.aspect.rma_scheduled.decription=Planifi\u00e9 diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties index fc08522813..2d88a6bc7e 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_it.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Record fondamentale rma_recordsmanagement.aspect.rma_vitalRecord.decription=Record fondamentale rma_recordsmanagement.property.rma_reviewAsOf.title=Prossimo esame rma_recordsmanagement.property.rma_reviewAsOf.decription=Prossimo esame -rma_recordsmanagement.property.rma_notificationIssued.title=Indica che \u00e8 stata rilasciata una notifica di esame per questo record -rma_recordsmanagement.property.rma_notificationIssued.decription=Indica che \u00e8 stata rilasciata una notifica di esame per questo record rma_recordsmanagement.aspect.rma_scheduled.title=Programmato rma_recordsmanagement.aspect.rma_scheduled.decription=Programmato diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties index ee8cb1667a..cc8e60eb71 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ja.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=\u30d0\u30a4\u30bf\u30eb\u30e rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u30d0\u30a4\u30bf\u30eb\u30ec\u30b3\u30fc\u30c9 rma_recordsmanagement.property.rma_reviewAsOf.title=\u6b21\u56de\u306e\u30ec\u30d3\u30e5\u30fc rma_recordsmanagement.property.rma_reviewAsOf.decription=\u6b21\u56de\u306e\u30ec\u30d3\u30e5\u30fc -rma_recordsmanagement.property.rma_notificationIssued.title=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u304c\u901a\u77e5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059 -rma_recordsmanagement.property.rma_notificationIssued.decription=\u3053\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u30ec\u30d3\u30e5\u30fc\u671f\u9650\u304c\u901a\u77e5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u793a\u3059 rma_recordsmanagement.aspect.rma_scheduled.title=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f rma_recordsmanagement.aspect.rma_scheduled.decription=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u6e08\u307f diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nb.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nb.properties index 09ec7810c3..c3b1ddb282 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nb.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nb.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Sv\u00e6rt viktig oppf\u00f8r rma_recordsmanagement.aspect.rma_vitalRecord.decription=Sv\u00e6rt viktig oppf\u00f8ring rma_recordsmanagement.property.rma_reviewAsOf.title=Neste gjennomgang rma_recordsmanagement.property.rma_reviewAsOf.decription=Neste gjennomgang -rma_recordsmanagement.property.rma_notificationIssued.title=Indikerer at en melding om at denne oppf\u00f8ringen skal gjennomg\u00e5s, er blitt utstedt -rma_recordsmanagement.property.rma_notificationIssued.decription=Indikerer at en melding om at denne oppf\u00f8ringen skal gjennomg\u00e5s, er blitt utstedt rma_recordsmanagement.aspect.rma_scheduled.title=Planlagt rma_recordsmanagement.aspect.rma_scheduled.decription=Planlagt diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties index 2f5a74961f..64a899ed7f 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_nl.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Vitale record rma_recordsmanagement.aspect.rma_vitalRecord.decription=Vitale record rma_recordsmanagement.property.rma_reviewAsOf.title=Volgende revisie rma_recordsmanagement.property.rma_reviewAsOf.decription=Volgende revisie -rma_recordsmanagement.property.rma_notificationIssued.title=Geeft aan dat er een revisie-gereedmelding is afgegeven voor deze record -rma_recordsmanagement.property.rma_notificationIssued.decription=Geeft aan dat er een revisie-gereedmelding is afgegeven voor deze record rma_recordsmanagement.aspect.rma_scheduled.title=Gepland rma_recordsmanagement.aspect.rma_scheduled.decription=Gepland diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_pt_BR.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_pt_BR.properties index d67dc2d5a1..db49f04ecd 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_pt_BR.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_pt_BR.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=Documento arquiv\u00edstico v rma_recordsmanagement.aspect.rma_vitalRecord.decription=Documento arquiv\u00edstico vital rma_recordsmanagement.property.rma_reviewAsOf.title=Pr\u00f3xima revis\u00e3o rma_recordsmanagement.property.rma_reviewAsOf.decription=Pr\u00f3xima revis\u00e3o -rma_recordsmanagement.property.rma_notificationIssued.title=Indica que foi emitida uma notifica\u00e7\u00e3o de prazo para revis\u00e3o para este documento arquiv\u00edstico -rma_recordsmanagement.property.rma_notificationIssued.decription=Indica que foi emitida uma notifica\u00e7\u00e3o de prazo para revis\u00e3o para este documento arquiv\u00edstico rma_recordsmanagement.aspect.rma_scheduled.title=Programado rma_recordsmanagement.aspect.rma_scheduled.decription=Programado diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties index 5831e3cd81..b3eafcfdfb 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_ru.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=\u041a\u043b\u044e\u0447\u043 rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c rma_recordsmanagement.property.rma_reviewAsOf.title=\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 rma_recordsmanagement.property.rma_reviewAsOf.decription=\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 -rma_recordsmanagement.property.rma_notificationIssued.title=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u043f\u043e\u0434\u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 -rma_recordsmanagement.property.rma_notificationIssued.decription=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u043f\u043e\u0434\u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 rma_recordsmanagement.aspect.rma_scheduled.title=\u0417\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043e rma_recordsmanagement.aspect.rma_scheduled.decription=\u0417\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043e diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties index d036c0f257..979f6c7ac8 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-model_zh_CN.properties @@ -174,8 +174,6 @@ rma_recordsmanagement.aspect.rma_vitalRecord.title=\u6838\u5fc3\u8bb0\u5f55 rma_recordsmanagement.aspect.rma_vitalRecord.decription=\u6838\u5fc3\u8bb0\u5f55 rma_recordsmanagement.property.rma_reviewAsOf.title=\u4e0b\u4e2a\u5ba1\u67e5 rma_recordsmanagement.property.rma_reviewAsOf.decription=\u4e0b\u4e2a\u5ba1\u67e5 -rma_recordsmanagement.property.rma_notificationIssued.title=\u6307\u793a\u5df2\u7ecf\u4e3a\u8be5\u8bb0\u5f55\u53d1\u51fa\u5ba1\u67e5\u5230\u671f\u901a\u77e5 -rma_recordsmanagement.property.rma_notificationIssued.decription=\u6307\u793a\u5df2\u7ecf\u4e3a\u8be5\u8bb0\u5f55\u53d1\u51fa\u5ba1\u67e5\u5230\u671f\u901a\u77e5 rma_recordsmanagement.aspect.rma_scheduled.title=\u5df2\u8ba1\u5212 rma_recordsmanagement.aspect.rma_scheduled.decription=\u5df2\u8ba1\u5212 diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml index 70bec9a312..1afe8754bc 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml @@ -866,13 +866,6 @@ d:date false - - Indicates whether a notification that this record is due for review has been issued - d:boolean - true - false - false - rma:filePlanComponent diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java index ec5f0707eb..61a04ca070 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/NotifyOfRecordsDueForReviewJobExecuter.java @@ -120,27 +120,12 @@ public class NotifyOfRecordsDueForReviewJobExecuter extends RecordsManagementJob } }; - RetryingTransactionCallback txUpdateNodesCallback = new RetryingTransactionCallback() - { - // Set the notification issued property. - public Boolean execute() - { - for (NodeRef node : resultNodes) - { - nodeService.setProperty(node, RecordsManagementModel.PROP_NOTIFICATION_ISSUED, "true"); - } - return Boolean.TRUE; - } - }; - /** * Now do the work, one action in each transaction */ // don't retry the send email retryingTransactionHelper.setMaxRetries(0); retryingTransactionHelper.doInTransaction(txCallbackSendEmail); - retryingTransactionHelper.setMaxRetries(10); - retryingTransactionHelper.doInTransaction(txUpdateNodesCallback); } return null; } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java index 40fb398c41..3aa95d9fc6 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/RecordsManagementModel.java @@ -133,7 +133,6 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel // Vital record aspect QName ASPECT_VITAL_RECORD = QName.createQName(RM_URI, "vitalRecord"); QName PROP_REVIEW_AS_OF = QName.createQName(RM_URI, "reviewAsOf"); - QName PROP_NOTIFICATION_ISSUED = QName.createQName(RM_URI, "notificationIssued"); // Cut off aspect QName ASPECT_CUT_OFF = QName.createQName(RM_URI, "cutOff"); diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedActionUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedActionUnitTest.java new file mode 100644 index 0000000000..8b28cc049a --- /dev/null +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedActionUnitTest.java @@ -0,0 +1,140 @@ +/* + * #%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 . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.vital; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.repo.dictionary.types.period.Days; +import org.alfresco.repo.dictionary.types.period.Immediately; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Date; + +import static org.mockito.Mockito.verify; + +import org.alfresco.service.cmr.repository.Period; +import org.alfresco.service.cmr.repository.StoreRef; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.extensions.webscripts.GUID; + +/** + * Unit test for {@link ReviewedAction} class + * + * @author Ana Bozianu + * @sincev 2.6 + */ +public class ReviewedActionUnitTest implements RecordsManagementModel +{ + private @Mock VitalRecordService mockedVitalRecordService; + private @Mock RecordService mockedRecordService; + private @Mock NodeService mockedNodeService; + + private @InjectMocks ReviewedAction reviewedAction; + + @Before + public void testSetup() + { + MockitoAnnotations.initMocks(this); + } + + /** + * Given a record having the vital record definition of immediately + * When I mark the record as reviewed + * Then review as of date is removed from the record + */ + @Test + public void testReviewRecordWithAdHocReviewPeriod() + { + /* + * Given + */ + NodeRef mockedRecord = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); + when(mockedRecordService.isRecord(mockedRecord)).thenReturn(true); + + VitalRecordDefinition mockedVRDef = mock(VitalRecordDefinition.class); + when(mockedVRDef.isEnabled()).thenReturn(true); + when(mockedVitalRecordService.getVitalRecordDefinition(mockedRecord)).thenReturn(mockedVRDef); + + Period mockedReviewPeriod = mock(Period.class); + when(mockedReviewPeriod.getPeriodType()).thenReturn(Immediately.PERIOD_TYPE); + when(mockedVRDef.getReviewPeriod()).thenReturn(mockedReviewPeriod); + + /* + * When + */ + reviewedAction.executeImpl(null, mockedRecord); + + /* + * Then + */ + verify(mockedNodeService).removeProperty(mockedRecord, PROP_REVIEW_AS_OF); + } + + /** + * Given a record having a recurent vital record definition + * When I mark the record as reviewed + * Then the review as of date is updated according to the next review period computed by the vital record definition + */ + @Test + public void testReviewRecordWithRecurentReviewPeriod() + { + /* + * Given + */ + NodeRef mockedRecord = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); + when(mockedRecordService.isRecord(mockedRecord)).thenReturn(true); + + VitalRecordDefinition mockedVRDef = mock(VitalRecordDefinition.class); + when(mockedVRDef.isEnabled()).thenReturn(true); + when(mockedVitalRecordService.getVitalRecordDefinition(mockedRecord)).thenReturn(mockedVRDef); + + Date mockedNextReviewDate = mock(Date.class); + when(mockedVRDef.getNextReviewDate()).thenReturn(mockedNextReviewDate); + + Period mockedReviewPeriod = mock(Period.class); + when(mockedReviewPeriod.getPeriodType()).thenReturn(Days.PERIOD_TYPE); + when(mockedVRDef.getReviewPeriod()).thenReturn(mockedReviewPeriod); + + /* + * When + */ + reviewedAction.executeImpl(null, mockedRecord); + + /* + * Then + */ + verify(mockedNodeService).setProperty(mockedRecord, PROP_REVIEW_AS_OF, mockedNextReviewDate); + } +}