
package org.apache.polygene.constraints;

import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.property.Property;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.test.AbstractPolygeneTest;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

public class ValueConstraintTest extends AbstractPolygeneTest {

    @Test
    public void testProhibitNewInstanceWithViolation() {
        assertThrows( ConstraintViolationException.class, () -> {
            ValueBuilder<Value1> builder = valueBuilderFactory.newValueBuilder( Value1.class );
            builder.newInstance();
        } );
    }

    public void assemble(ModuleAssembly module)
        throws AssemblyException {
        module.values(Value1.class);
    }

    public interface Value1 {
        Property<String> test();
    }
}