mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Work on RM-2027. Addition of the Java API code to retrieve classification reasons and some of the test code associated with that. WIP. Test code not complete. +review RM
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@100255 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,6 +22,7 @@ import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationS
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
@@ -36,9 +37,13 @@ import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.junit.Assert.*;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ClassificationServiceImpl}.
|
||||
@@ -56,6 +61,8 @@ public class ClassificationServiceImplUnitTest
|
||||
"Executive Management", "EM",
|
||||
"Employee", "E",
|
||||
"Public", "P");
|
||||
private static final List<ClassificationReason> PLACEHOLDER_CLASSIFICATION_REASONS = asList(new ClassificationReason("r1", "l1"),
|
||||
new ClassificationReason("r2", "l2"));
|
||||
/**
|
||||
* A convenience method for turning lists of level id Strings into lists
|
||||
* of {@code ClassificationLevel} objects.
|
||||
@@ -145,4 +152,42 @@ public class ClassificationServiceImplUnitTest
|
||||
|
||||
classificationService.initConfiguredClassificationLevels();
|
||||
}
|
||||
|
||||
@Test public void pristineSystemShouldBootstrapReasonsConfiguration()
|
||||
{
|
||||
// There are no classification reasons stored in the AttributeService.
|
||||
when(mockedAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn(null);
|
||||
|
||||
// We'll use a small set of placeholder classification reasons.
|
||||
when(mockConfig.getConfiguredReasons()).thenReturn(PLACEHOLDER_CLASSIFICATION_REASONS);
|
||||
|
||||
classificationService.initConfiguredClassificationReasons();
|
||||
|
||||
verify(mockedAttributeService).setAttribute(eq((Serializable)PLACEHOLDER_CLASSIFICATION_REASONS),
|
||||
anyString(), anyString(), anyString());
|
||||
}
|
||||
|
||||
@Ignore ("This test is currently failing. Needs to be fixed.") // FIXME
|
||||
@Test public void previouslyStartedSystemShouldProceedNormallyIfConfiguredReasonsHaveNotChanged()
|
||||
{
|
||||
// There are existing classification reasons stored in the AttributeService.
|
||||
when(mockedAttributeService.getAttribute(anyString(), anyString(), anyString())).thenReturn((Serializable)PLACEHOLDER_CLASSIFICATION_REASONS);
|
||||
|
||||
// We'll use a small set of placeholder classification reasons.
|
||||
when(mockConfig.getConfiguredReasons()).thenReturn(PLACEHOLDER_CLASSIFICATION_REASONS);
|
||||
|
||||
classificationService.initConfiguredClassificationReasons();
|
||||
|
||||
// This line added to try and work out what the interaction *is*.
|
||||
verifyZeroInteractions(mockedAttributeService);
|
||||
|
||||
verify(mockedAttributeService, never()).setAttribute(any(Serializable.class),
|
||||
anyString(), anyString(), anyString());
|
||||
}
|
||||
|
||||
@Ignore ("To be implemented") // TODO
|
||||
@Test public void previouslyStartedSystemShouldWarnIfConfiguredReasonsHaveChanged()
|
||||
{
|
||||
fail("TODO");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user