001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.webapp;
007
008import org.fcrepo.kernel.api.exception.MultipleConstraintViolationException;
009import org.junit.Assert;
010import org.fcrepo.kernel.api.exception.ConstraintViolationException;
011import org.fcrepo.kernel.api.exception.RelaxableServerManagedPropertyException;
012
013import org.junit.Test;
014import org.reflections.Reflections;
015
016import java.io.File;
017import java.util.Set;
018
019/**
020 * @author awoods
021 * @since 6/25/15
022 */
023public class ConstraintExceptionsTest {
024
025    @Test
026    public void testConstraintRdfExists() {
027        final Reflections reflections = new Reflections("org.fcrepo");
028        final Set<Class<? extends ConstraintViolationException>> subTypes =
029                reflections.getSubTypesOf(ConstraintViolationException.class);
030        // Multiple is a wrapper to hold other constraint violations, it has no static file.
031        subTypes.remove(MultipleConstraintViolationException.class);
032        // Relaxable is a sub-type of ServerManagedPropertyException to specially handle relaxable properties, it has
033        // no static file.
034        subTypes.remove(RelaxableServerManagedPropertyException.class);
035        subTypes.add(ConstraintViolationException.class);
036
037        for (final Class<? extends ConstraintViolationException> c : subTypes) {
038            final File file = new File("src/main/webapp/static/constraints/" + c.getSimpleName() + ".rdf");
039            Assert.assertTrue("Expected to find: " + file.getPath(), file.exists());
040        }
041    }
042
043}