mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2319 Create a general classification scheme entity validator.
Replace the existing classification level validator with the new class. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@106528 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,39 +23,55 @@ import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtil
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.IllegalConfiguration;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingConfiguration;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link ClassificationLevelValidation}.
|
||||
* Unit tests for the {@link ClassificationSchemeEntityValidator}.
|
||||
*
|
||||
* @author Neil Mc Erlean
|
||||
* @author tpage
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ClassificationLevelValidationUnitTest
|
||||
public class ClassificationSchemeEntityValidatorUnitTest
|
||||
{
|
||||
private final ClassificationLevelValidation validation = new ClassificationLevelValidation();
|
||||
private static final String ENTITY_NAME = "ENTITY_NAME";
|
||||
@Mock
|
||||
private EntityFieldsValidator<ClassificationLevel> mockFieldsValidator;
|
||||
/** The class under test. */
|
||||
private ClassificationSchemeEntityValidator<ClassificationLevel> classificationEntitySchemeValidator = new ClassificationSchemeEntityValidator<>(mockFieldsValidator );
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
initMocks(this);
|
||||
}
|
||||
|
||||
@Test(expected=MissingConfiguration.class)
|
||||
public void classificationLevelsAreRequired()
|
||||
{
|
||||
validation.validateLevels(Collections.emptyList());
|
||||
classificationEntitySchemeValidator.validate(Collections.emptyList(), ENTITY_NAME);
|
||||
}
|
||||
|
||||
@Test public void ensureUniquenessOfAbbreviationIds()
|
||||
{
|
||||
IllegalConfiguration e = expectedException(IllegalConfiguration.class, () ->
|
||||
{
|
||||
validation.validateLevels(asList(new ClassificationLevel("FOO", "value.does.not.matter"),
|
||||
new ClassificationLevel("BAR", "value.does.not.matter"),
|
||||
new ClassificationLevel("---", "value.does.not.matter"),
|
||||
new ClassificationLevel("BAR", "value.does.not.matter"),
|
||||
new ClassificationLevel("FOO", "value.does.not.matter")));
|
||||
List<ClassificationLevel> objects = asList(new ClassificationLevel("FOO", "value.does.not.matter"),
|
||||
new ClassificationLevel("BAR", "value.does.not.matter"),
|
||||
new ClassificationLevel("---", "value.does.not.matter"),
|
||||
new ClassificationLevel("BAR", "value.does.not.matter"),
|
||||
new ClassificationLevel("FOO", "value.does.not.matter"));
|
||||
classificationEntitySchemeValidator.validate(objects, ENTITY_NAME);
|
||||
return null;
|
||||
});
|
||||
assertThat("Exception message did not identify the duplicate IDs", e.getMessage(),
|
Reference in New Issue
Block a user