POLYGENE-265 - method argument names are now used in Constraint Violations.
POLYGENE-264 - Consolidated how the ConstraintViolationException works.
POLYGENE-262 - NoSuchCompositeException and subtypes changed name to NoSuchCompositeTypeException.
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeException.java b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeException.java
deleted file mode 100644
index c3f51bb..0000000
--- a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.api.composite;
-
-import org.apache.polygene.api.common.InvalidApplicationException;
-
-/**
- * This exception is thrown if client code tries to create a non-existing Composite type.
- */
-public class NoSuchCompositeException extends InvalidApplicationException
-{
- private final String compositeType;
- private final String moduleName;
- private final String visibleTypes;
-
- protected NoSuchCompositeException( String metaType, String compositeType, String moduleName, String visibleTypes )
- {
- super( "Could not find any visible " + metaType + " of type [" + compositeType + "] in module [" +
- moduleName + "].\n" + visibleTypes );
- this.compositeType = compositeType;
- this.moduleName = moduleName;
- this.visibleTypes = visibleTypes;
- }
-
- public String compositeType()
- {
- return compositeType;
- }
-
- public String moduleName()
- {
- return moduleName;
- }
-
- public String visibleTypes()
- {
- return visibleTypes;
- }
-}
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java
new file mode 100644
index 0000000..64977ef
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.composite;
+
+import java.util.stream.Stream;
+import org.apache.polygene.api.common.InvalidApplicationException;
+import org.apache.polygene.api.structure.TypeLookup;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * This exception is thrown if client code tries to create a non-existing Composite type.
+ */
+public abstract class NoSuchCompositeTypeException extends InvalidApplicationException
+{
+ private final String compositeType;
+ private final String moduleName;
+ private final String visibleTypes;
+ private final String metaType;
+ private final String candidateTypes;
+
+ protected NoSuchCompositeTypeException( String metaType, String compositeType, String moduleName, TypeLookup typeLookup )
+ {
+ super( "\n\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + moduleName + "]." );
+ this.metaType = metaType;
+ this.compositeType = compositeType;
+ this.moduleName = moduleName;
+ visibleTypes = formatVisibleTypes( typeLookup );
+ candidateTypes = findCandidateTypes( typeLookup );
+ }
+
+ public String compositeType()
+ {
+ return compositeType;
+ }
+
+ public String moduleName()
+ {
+ return moduleName;
+ }
+
+ public String visibleTypes()
+ {
+ return visibleTypes;
+ }
+
+ public String candidateTypes()
+ {
+ return candidateTypes;
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return super.getMessage() + "\n" + candidateTypes + "\n" + visibleTypes;
+ }
+
+ private String formatVisibleTypes( TypeLookup typeLookup )
+ {
+ return descriptors( typeLookup )
+ .map( descriptor ->
+ {
+ String moduleName = descriptor.module().name();
+ String typeName = descriptor.primaryType().getName();
+ return "\t\t[" + typeName + "] in [" + moduleName + "]";
+ } )
+ .sorted()
+ .distinct()
+ .collect( joining( "\n", "\tVisible " + metaType + " types are:\n", "" ) );
+ }
+
+ private String findCandidateTypes( TypeLookup typeLookup )
+ {
+ return "";
+// return descriptors( typeLookup )
+// .filter( type -> compositeType.equals( type.primaryType().getName() ) )
+// .map( descriptor ->
+// {
+// Class<?> primarytype = descriptor.primaryType();
+// String typeName = primarytype.getName();
+// return "\t\t[ " + typeName + "] in [" + descriptor.module().name() + "] with visibility " + descriptor.visibility();
+// } )
+// .collect( joining( "\n", "\tInvisible " + metaType + " types are:\n", "" ) );
+ }
+
+ protected abstract Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup );
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if( this == o )
+ {
+ return true;
+ }
+ if( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ NoSuchCompositeTypeException that = (NoSuchCompositeTypeException) o;
+
+ if( !compositeType.equals( that.compositeType ) )
+ {
+ return false;
+ }
+ if( !moduleName.equals( that.moduleName ) )
+ {
+ return false;
+ }
+ return visibleTypes.equals( that.visibleTypes );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = compositeType.hashCode();
+ result = 31 * result + moduleName.hashCode();
+ result = 31 * result + visibleTypes.hashCode();
+ return result;
+ }
+}
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientException.java b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
similarity index 64%
rename from core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientException.java
rename to core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
index d55c34d..45ecd17 100644
--- a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
@@ -20,6 +20,7 @@
package org.apache.polygene.api.composite;
+import java.util.stream.Stream;
import org.apache.polygene.api.structure.TypeLookup;
import static java.util.stream.Collectors.joining;
@@ -27,19 +28,15 @@
/**
* This exception is thrown if client code tries to create a non-existing TransientComposite type.
*/
-public class NoSuchTransientException extends NoSuchCompositeException
+public class NoSuchTransientTypeException extends NoSuchCompositeTypeException
{
- public NoSuchTransientException( String typeName, String moduleName, TypeLookup typeLookup )
+ public NoSuchTransientTypeException( String typeName, String moduleName, TypeLookup typeLookup )
{
- super( "TransientComposite", typeName, moduleName, formatVisibleTypes( typeLookup ) );
+ super( "TransientComposite", typeName, moduleName, typeLookup );
}
- private static String formatVisibleTypes( TypeLookup typeLookup )
+ protected Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup )
{
- return typeLookup.allTransients()
- .map( descriptor -> descriptor.primaryType().getName() )
- .sorted()
- .distinct()
- .collect( joining( "\n", "Visible transient types are:\n", "" ) );
+ return typeLookup.allTransients();
}
}
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/TransientBuilderFactory.java b/core/api/src/main/java/org/apache/polygene/api/composite/TransientBuilderFactory.java
index 5656c71..12f71e9 100644
--- a/core/api/src/main/java/org/apache/polygene/api/composite/TransientBuilderFactory.java
+++ b/core/api/src/main/java/org/apache/polygene/api/composite/TransientBuilderFactory.java
@@ -39,10 +39,10 @@
*
* @return a TransientBuilder for creation of TransientComposites implementing the interface
*
- * @throws NoSuchTransientException if no composite extending the mixinType has been registered
+ * @throws NoSuchTransientTypeException if no composite extending the mixinType has been registered
*/
<T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType )
- throws NoSuchTransientException;
+ throws NoSuchTransientTypeException;
/**
* Instantiate a TransientComposite of the given type.
@@ -53,10 +53,10 @@
*
* @return a new TransientComposite instance
*
- * @throws NoSuchTransientException if no composite extending the mixinType has been registered
+ * @throws NoSuchTransientTypeException if no composite extending the mixinType has been registered
* @throws org.apache.polygene.api.common.ConstructionException
* if the composite could not be instantiated
*/
<T> T newTransient( Class<T> mixinType, Object... uses )
- throws NoSuchTransientException, ConstructionException;
+ throws NoSuchTransientTypeException, ConstructionException;
}
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java
index a007a11..c54d35d 100644
--- a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java
@@ -20,23 +20,22 @@
package org.apache.polygene.api.constraint;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
import java.lang.reflect.Type;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
-import java.util.MissingResourceException;
+import java.util.Objects;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.polygene.api.composite.Composite;
+import org.apache.polygene.api.composite.CompositeDescriptor;
+import org.apache.polygene.api.entity.EntityDescriptor;
import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.service.ServiceDescriptor;
import org.apache.polygene.api.util.Classes;
-import static java.util.stream.Collectors.joining;
-
/**
* This Exception is thrown when there is one or more Constraint Violations in a method
* call.
@@ -48,65 +47,49 @@
*/
public class ConstraintViolationException extends IllegalArgumentException
{
- private final Collection<ConstraintViolation> constraintViolations;
- private String methodName;
- private String mixinTypeName;
- private String instanceToString;
- private List<? extends Type> instanceTypes;
+ private static final boolean longNames = Boolean.getBoolean( "polygene.constraints.longNames" );
+ private static final String DEFAULT_PATTERN = "\n\tConstraint Violation(s) in {0} of types [{3}].\n";
+ private static final String ENTITY_DEFAULT_PATTERN = "\n\tConstraint Violation(s) in entity {0} with id=[{2}].\n";
+ private static final String SERVICE_DEFAULT_PATTERN = "\n\tConstraint Violation(s) in service {0} with id=[{2}].\n";
+ private static final String MIXIN_DEFAULT_PATTERN = "\t\t@{2}({3}) on {0}.{1}(). Parameter [{4}] does not allow value [{5}].\n";
- public ConstraintViolationException( Composite instance, Member method,
- Collection<ConstraintViolation> constraintViolations
- )
+ private String instanceToString; // arg {0}
+ private Class<?> primaryType; // arg {1}
+ private List<? extends Type> instanceTypes; // arg {2}
+ private Collection<ValueConstraintViolation> constraintViolations; // arg {4} and {5}
+ private String identity; // arg {6}
+ private boolean isService;
+ private boolean isEntity;
+
+ public ConstraintViolationException( Collection<ValueConstraintViolation> violations )
{
- this( instance.toString(), Classes.interfacesOf( instance.getClass() ), method, constraintViolations );
+ this.constraintViolations = new ArrayList<>();
+ this.constraintViolations.addAll( violations );
}
- public ConstraintViolationException( String instanceToString,
- Stream<? extends Type> instanceTypes,
- Member method,
- Collection<ConstraintViolation> violations
- )
- {
- this.instanceToString = instanceToString;
- this.instanceTypes = instanceTypes.collect( Collectors.toList() );
- mixinTypeName = method.getDeclaringClass().getName();
- methodName = method.getName();
- this.constraintViolations = violations;
- }
-
- public ConstraintViolationException( Identity identity,
- List<? extends Type> instanceTypes,
- String mixinTypeName,
- String methodName,
- Collection<ConstraintViolation> violations
- )
- {
- this.instanceToString = identity.toString();
- this.instanceTypes = instanceTypes;
- this.mixinTypeName = mixinTypeName;
- this.methodName = methodName;
- this.constraintViolations = violations;
- }
-
- public Collection<ConstraintViolation> constraintViolations()
+ public Collection<ValueConstraintViolation> constraintViolations()
{
return constraintViolations;
}
/**
- * Creates localized messages of all the constraint violations that has occured.
+ * Creates localized message of all the constraint violations that has occured.
* <p>
- * The key "<code>polygene.constraint.<i><strong>CompositeType</strong></i>.<i><strong>methodName</strong></i></code>"
- * will be used to lookup the text formatting
- * pattern from the ResourceBundle, where <strong><code><i>CompositeType</i></code></strong> is the
- * class name of the Composite where the constraint was violated. If such key does not exist, then the
- * key "<code>polygene.constraint</code>" will be used, and if that one also doesn't exist, or
- * the resourceBundle argument is null, then the default patterns will be used;
+ * Each ConstraintViolationException concerns one Composite instance, but may have many violations on that
+ * instance. For the composite instance related message following entries in the ResourceBundle will be searched
+ * for a pattern in the following order;
+ * <ol>
+ * <li><code>polygene.constraint.<i><strong>CompositeType</strong></i></code></li>
+ * <li><code>polygene.constraint.composite</code></li>
+ * </ol>
+ * where <strong><code><i>CompositeType</i></code></strong> is the
+ * class name of the Composite instance. If such key does not exist, or if the resourceBundle argument is null,
+ * then the default patterns will be used;
* </p>
- * <table summary="Localization of constraint vioations.">
+ * <table summary="Default localization of constraint violations for composite.">
* <tr><th>Type of Composite</th><th>Pattern used</th></tr>
* <tr><td>Composite</td>
- * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in composite \n{0} of type {1}</code></td>
+ * <td><code>\tConstraint Violation(s) in {0} with types {3}\n</code></td>
* </tr>
* <tr><td>EntityComposite</td>
* <td><code>Constraint Violation in {2}.{3} with constraint {4}, in entity {1}[id={0}]</code></td>
@@ -115,144 +98,213 @@
* <td><code>Constraint Violation in {2}.{3} with constraint {4}, in service {0}</code></td>
* </tr>
* </table>
+ * The ResourceBundle arguments are defined as;
+ * <p>
+ * <p>
* Then format each ConstraintViolation according to such pattern, where the following argument are passed;
* <table summary="List of arguments available."><tr><th>Arg</th><th>Value</th></tr>
* <tr>
* <td>{0}</td>
- * <td>Composite instance toString()</td>
+ * <td>Primary Type of Composite</td>
* </tr>
* <tr>
* <td>{1}</td>
- * <td>CompositeType class name</td>
+ * <td>Composite instance toString()</td>
* </tr>
* <tr>
* <td>{2}</td>
- * <td>MixinType class name</td>
+ * <td>Identity if composite implements HasIdentity</td>
* </tr>
* <tr>
* <td>{3}</td>
- * <td>MixinType method name</td>
- * </tr>
- * <tr>
- * <td>{4}</td>
- * <td>Annotation toString()</td>
- * </tr>
- * <tr>
- * <td>{5}</td>
- * <td>toString() of value passed as the argument, or "null" text if argument was null.</td>
+ * <td>Comma-separeated list of types implemented by Composite</td>
* </tr>
* </table>
* <p>
- * <b>NOTE!!!</b> This class is still under construction and will be modified further.
- * </p>
+ * Once the message at the composite type level has been established, the message will contain each of the found
+ * violations. For each such violation, the resource bundle will be searched in the following order;
+ * <ol>
+ * <li><code>polygene.constraint.<i><strong>MixinType</strong></i>.<i><strong>member</strong></i></code></li>
+ * <li><code>polygene.constraint.<i><strong>MixinType</strong></i></code></li>
+ * <li><code>polygene.constraint.mixin</code></li>
+ * </ol>
+ * where <code><i><strong>MixinType</strong></i></code> refers to the mixin type of the member (method, field or
+ * constructor) and the <code><i><strong>member</strong></i></code> is the name of such Member.
+ * <table summary="Default localization of constraint violations for mixin.">
+ * <tr><th>Type of Composite</th><th>Pattern used</th></tr>
+ * <tr><td>Mixin</td>
+ * <td><code>\t\t@{2} {0}.{1} does not allow value [{4}]</code></td>
+ * </tr>
+ * </table>
+ * For these the ResourceBundle arguments are;
+ * <table summary="List of arguments available."><tr><th>Arg</th><th>Value</th></tr>
+ * <tr>
+ * <td>{0}</td>
+ * <td>Mixin Type Name</td>
+ * </tr>
+ * <tr>
+ * <td>{1}</td>
+ * <td>Mixin Member Name</td>
+ * </tr>
+ * <tr>
+ * <td>{2}</td>
+ * <td>Annotation type</td>
+ * </tr>
+ * <tr>
+ * <td>{3}</td>
+ * <td>Annotation toString</td>
+ * </tr>
+ * <tr>
+ * <td>{4}</td>
+ * <td>Name of the Member, see {@link Name}</td>
+ * </tr>
+ * <tr>
+ * <td>{5}</td>
+ * <td>Value attempted</td>
+ * </tr>
+ * </table>
*
* @param bundle The ResourceBundle for Localization, or null if default formatting and locale to be used.
- *
* @return An array of localized messages of the violations incurred.
*/
- public String[] localizedMessagesFrom( ResourceBundle bundle )
+ public String localizedMessageFrom( ResourceBundle bundle )
{
- String pattern = "Constraint violation in {0}.{1} for method ''{3}'' with constraint \"{4}({6})\", for value ''{5}''";
-
- ArrayList<String> list = new ArrayList<>();
- for( ConstraintViolation violation : constraintViolations )
+ Locale locale;
+ if( bundle != null )
{
- Locale locale;
- if( bundle != null )
+ locale = bundle.getLocale();
+ }
+ else
+ {
+ locale = Locale.getDefault();
+ }
+ StringBuffer message = new StringBuffer();
+ {
+ String[] searchKeys = new String[]{ "polygene.constraint." + primaryType, "polygene.constraint.composite" };
+ String compositePattern = findPattern( bundle, searchKeys, defaultPattern() );
+ String types = instanceTypes == null
+ ? null
+ : instanceTypes.stream()
+ .map( this::nameOf )
+ .collect( Collectors.joining( "," ) );
+ String name;
+ if( longNames )
{
- try
- {
- pattern = bundle.getString( "polygene.constraint." + mixinTypeName + "." + methodName );
- }
- catch( MissingResourceException e1 )
- {
- try
- {
- pattern = bundle.getString( "polygene.constraint" );
- }
- catch( MissingResourceException e2 )
- {
- // ignore. The default pattern will be used.
- }
- }
- locale = bundle.getLocale();
+ name = primaryType.getName();
}
else
{
- locale = Locale.getDefault();
+ name = primaryType.getSimpleName();
}
- MessageFormat format = new MessageFormat( pattern, locale );
+ Object[] args = new Object[]{ name, instanceToString, identity, types };
+ MessageFormat formatter = new MessageFormat( compositePattern, locale );
+ formatter.format( args, message, null );
+ }
+ for( ValueConstraintViolation violation : constraintViolations )
+ {
+ String[] searchKeys = new String[]{ "polygene.constraint." + primaryType, "polygene.constraint.composite" };
+ String mixinPattern = findPattern( bundle, searchKeys, MIXIN_DEFAULT_PATTERN );
Annotation annotation = violation.constraint();
- String name = violation.name();
- Object value = violation.value();
- String classes;
- if( instanceTypes.size() == 1 )
- {
- Type type = instanceTypes.stream().findFirst().get();
- classes = Classes.RAW_CLASS.apply( type ).getSimpleName();
- }
- else
- {
- classes = "[" + instanceTypes.stream()
- .map( Classes.RAW_CLASS )
- .map( Class::getSimpleName ).collect( joining( "," ) ) + "]";
- }
+ Class<? extends Annotation> annotatioType = annotation.annotationType();
+ Class<?> mixinType = violation.mixinType();
Object[] args = new Object[]
{
- instanceToString,
- classes,
- mixinTypeName,
- methodName,
+ longNames ? mixinType.getName() : mixinType.getSimpleName(),
+ violation.methodName(),
+ longNames ? annotatioType.getName() : annotatioType.getSimpleName(),
annotation.toString(),
- "" + value,
- name
+ violation.name(),
+ violation.value()
};
- StringBuffer text = new StringBuffer();
- format.format( args, text, null );
- list.add( text.toString() );
+ MessageFormat formatter = new MessageFormat( mixinPattern, locale );
+ formatter.format( args, message, null );
}
- String[] result = new String[ list.size() ];
- list.toArray( result );
+ String result = message.toString();
+ message.setLength( 0 ); // TODO: is this still needed to avoid JVM memory leak??
return result;
}
- public String localizedMessage()
+ private String nameOf( Type type )
{
- String[] messages = localizedMessagesFrom( null );
- StringBuilder result = new StringBuilder();
- boolean first = true;
- for( String message : messages )
+ Class<?> clazz = Classes.RAW_CLASS.apply( type );
+ if( longNames )
{
- if( !first )
- {
- result.append( ',' );
- }
- first = false;
- result.append( message );
+ return clazz.getName();
}
- return result.toString();
- }
-
- @Override
- public String getLocalizedMessage()
- {
- return localizedMessage();
+ else
+ {
+ return clazz.getSimpleName();
+ }
}
@Override
public String getMessage()
{
- return localizedMessage();
+ return localizedMessageFrom( null );
}
- public String methodName()
+ private String findPattern( ResourceBundle bundle, String[] searchKeys, String defaultPattern )
{
- return methodName;
+ String compositePattern;
+ if( bundle != null )
+ {
+ compositePattern = Stream.of( searchKeys )
+ .map( name -> findPattern( bundle, name ) )
+ .filter( Objects::nonNull )
+ .findFirst().orElse( defaultPattern );
+ }
+ else
+ {
+ compositePattern = defaultPattern;
+ }
+ return compositePattern;
}
- public String mixinTypeName()
+ private String findPattern( ResourceBundle bundle, String name )
{
- return mixinTypeName;
+ try
+ {
+ return bundle.getString( name );
+ }
+ catch( Exception e )
+ {
+ return null;
+ }
+ }
+
+ private String defaultPattern()
+ {
+ if( isEntity )
+ {
+ return ENTITY_DEFAULT_PATTERN;
+ }
+ if( isService )
+ {
+ return SERVICE_DEFAULT_PATTERN;
+ }
+ return DEFAULT_PATTERN;
+ }
+
+ public void setCompositeDescriptor( CompositeDescriptor descriptor )
+ {
+ this.primaryType = descriptor.primaryType();
+ this.instanceTypes = descriptor.mixinTypes().collect( Collectors.toList() );
+ this.isEntity = descriptor instanceof EntityDescriptor;
+ this.isService = descriptor instanceof ServiceDescriptor;
+ }
+
+ public void setIdentity( Identity identity )
+ {
+ if( identity == null )
+ {
+ return;
+ }
+ this.identity = identity.toString();
+ }
+
+ public void setInstanceString( String instanceString )
+ {
+ instanceToString = instanceString;
}
}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolation.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ValueConstraintViolation.java
similarity index 71%
rename from core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolation.java
rename to core/api/src/main/java/org/apache/polygene/api/constraint/ValueConstraintViolation.java
index 75bbecb..1da5a4b 100644
--- a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolation.java
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ValueConstraintViolation.java
@@ -21,18 +21,21 @@
package org.apache.polygene.api.constraint;
import java.lang.annotation.Annotation;
+import java.util.List;
/**
* When a constraint violation has occurred (ie Constraint.isValid has returned false) it
* is put in a collection of all violations that have occurred for this value check.
*/
-public final class ConstraintViolation
+public final class ValueConstraintViolation
{
- private String name;
+ private final String name;
private final Annotation constraint;
private final Object value;
+ private Class<?> mixinType;
+ private String methodName;
- public ConstraintViolation( String name, Annotation constraint, Object value )
+ public ValueConstraintViolation( String name, Annotation constraint, Object value )
{
this.name = name;
this.constraint = constraint;
@@ -53,4 +56,24 @@
{
return value;
}
+
+ public void setMixinType( Class<?> mixinType )
+ {
+ this.mixinType = mixinType;
+ }
+
+ public void setMethodName( String methodName )
+ {
+ this.methodName = methodName;
+ }
+
+ public Class<?> mixinType()
+ {
+ return mixinType;
+ }
+
+ public String methodName()
+ {
+ return methodName;
+ }
}
diff --git a/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectException.java b/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java
similarity index 92%
rename from core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectException.java
rename to core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java
index 82b63bd..af1801f 100644
--- a/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java
@@ -26,7 +26,7 @@
/**
* This exception is thrown if no visible Object of the requested type can be found.
*/
-public class NoSuchObjectException
+public class NoSuchObjectTypeException
extends InvalidApplicationException
{
private static final long serialVersionUID = -1121690536365682511L;
@@ -34,7 +34,7 @@
private final String objectType;
private final String moduleName;
- public NoSuchObjectException( String type, String moduleName, Stream<Class<?>> visible )
+ public NoSuchObjectTypeException( String type, String moduleName, Stream<Class<?>> visible )
{
super( "Could not find any visible Object of type [" + type + "] in module ["
+ moduleName
diff --git a/core/api/src/main/java/org/apache/polygene/api/object/ObjectFactory.java b/core/api/src/main/java/org/apache/polygene/api/object/ObjectFactory.java
index fddeeb1..a13a5bf 100644
--- a/core/api/src/main/java/org/apache/polygene/api/object/ObjectFactory.java
+++ b/core/api/src/main/java/org/apache/polygene/api/object/ObjectFactory.java
@@ -36,10 +36,10 @@
* @return new objects.
*
* @throws ConstructionException Thrown if instantiation fails.
- * @throws NoSuchObjectException Thrown if {@code type} class is not an object.
+ * @throws NoSuchObjectTypeException Thrown if {@code type} class is not an object.
*/
<T> T newObject( Class<T> type, Object... uses )
- throws NoSuchObjectException, ConstructionException;
+ throws NoSuchObjectTypeException, ConstructionException;
/**
* Inject an existing instance. Only fields and methods will be called.
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceException.java b/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceException.java
deleted file mode 100644
index 3b98272..0000000
--- a/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.polygene.api.service;
-
-import java.util.stream.Collectors;
-import org.apache.polygene.api.composite.CompositeDescriptor;
-import org.apache.polygene.api.composite.ModelDescriptor;
-import org.apache.polygene.api.composite.NoSuchCompositeException;
-import org.apache.polygene.api.structure.TypeLookup;
-
-/**
- * Thrown when no visible service of the requested type is found.
- */
-public class NoSuchServiceException extends NoSuchCompositeException
-{
- public NoSuchServiceException( String typeName, String moduleName, TypeLookup typeLookup )
- {
- super( "ServiceComposite", typeName, moduleName, formatVisibleTypes( typeLookup ) );
- }
-
- private static String formatVisibleTypes( TypeLookup typeLookup )
- {
- return typeLookup.allServices()
- .map( NoSuchServiceException::typeOf )
- .collect( Collectors.joining( "\n", "Visible service types are:\n", "" ) );
- }
-
- private static String typeOf( ModelDescriptor descriptor )
- {
- if( descriptor instanceof CompositeDescriptor )
- {
- return ( (CompositeDescriptor) descriptor ).primaryType().getName();
- }
- return descriptor.types()
- .map( Class::getName )
- .sorted()
- .distinct()
- .collect( Collectors.joining( ",", "[", "]") );
- }
-}
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java b/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java
new file mode 100644
index 0000000..cc43627
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.service;
+
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.polygene.api.composite.CompositeDescriptor;
+import org.apache.polygene.api.composite.ModelDescriptor;
+import org.apache.polygene.api.composite.NoSuchCompositeTypeException;
+import org.apache.polygene.api.structure.TypeLookup;
+
+/**
+ * Thrown when no visible service of the requested type is found.
+ */
+public class NoSuchServiceTypeException extends NoSuchCompositeTypeException
+{
+ public NoSuchServiceTypeException( String typeName, String moduleName, TypeLookup typeLookup )
+ {
+ super( "ServiceComposite", typeName, moduleName, typeLookup );
+ }
+
+ @Override
+ protected Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup )
+ {
+ return typeLookup.allServices()
+ .filter( descriptor -> descriptor instanceof ServiceDescriptor )
+ .map( descriptor -> (ServiceDescriptor) descriptor );
+ }
+}
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/ServiceFinder.java b/core/api/src/main/java/org/apache/polygene/api/service/ServiceFinder.java
index 8e7e9d5..28389ae 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/ServiceFinder.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/ServiceFinder.java
@@ -50,10 +50,10 @@
*
* @return a ServiceReference if one is found
*
- * @throws NoSuchServiceException if no service of serviceType is found
+ * @throws NoSuchServiceTypeException if no service of serviceType is found
*/
<T> ServiceReference<T> findService( Class<T> serviceType )
- throws NoSuchServiceException;
+ throws NoSuchServiceTypeException;
/**
* Find a ServiceReference that implements the given type.
@@ -63,10 +63,10 @@
*
* @return a ServiceReference if one is found
*
- * @throws NoSuchServiceException if no service of serviceType is found
+ * @throws NoSuchServiceTypeException if no service of serviceType is found
*/
<T> ServiceReference<T> findService( Type serviceType )
- throws NoSuchServiceException;
+ throws NoSuchServiceTypeException;
/**
* Find ServiceReferences that implements the given type.
diff --git a/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java b/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
index d6dbe8d..a020c6e 100644
--- a/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
@@ -19,7 +19,9 @@
*/
package org.apache.polygene.api.unitofwork;
-import org.apache.polygene.api.composite.NoSuchCompositeException;
+import java.util.stream.Stream;
+import org.apache.polygene.api.composite.CompositeDescriptor;
+import org.apache.polygene.api.composite.NoSuchCompositeTypeException;
import org.apache.polygene.api.structure.TypeLookup;
import static java.util.stream.Collectors.joining;
@@ -29,23 +31,16 @@
* was not found during a lookup call.
*/
public class NoSuchEntityTypeException
- extends NoSuchCompositeException
+ extends NoSuchCompositeTypeException
{
public NoSuchEntityTypeException( String typeName, String moduleName, TypeLookup typeLookup )
{
- super( "EntityComposite", typeName, moduleName, formatVisibleTypes( typeLookup ) );
+ super( "EntityComposite", typeName, moduleName, typeLookup );
}
- private static String formatVisibleTypes( TypeLookup typeLookup )
+ @Override
+ protected Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup )
{
- return typeLookup.allEntities()
- .map( descriptor -> {
- String moduleName = descriptor.module().name();
- String entityClassName = descriptor.primaryType().getName();
- return entityClassName + " in " + moduleName;
- } )
- .sorted()
- .distinct()
- .collect( joining( "\n", "Visible entity types are:\n", "" ) );
+ return typeLookup.allEntities();
}
}
diff --git a/core/api/src/main/java/org/apache/polygene/api/unitofwork/UnitOfWork.java b/core/api/src/main/java/org/apache/polygene/api/unitofwork/UnitOfWork.java
index badbe4c..168a55c 100644
--- a/core/api/src/main/java/org/apache/polygene/api/unitofwork/UnitOfWork.java
+++ b/core/api/src/main/java/org/apache/polygene/api/unitofwork/UnitOfWork.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;
import org.apache.polygene.api.association.AssociationDescriptor;
@@ -42,7 +41,6 @@
import org.apache.polygene.api.structure.MetaInfoHolder;
import org.apache.polygene.api.structure.ModuleDescriptor;
import org.apache.polygene.api.usecase.Usecase;
-import org.apache.polygene.api.value.ValueBuilder;
/**
* All operations on entities goes through an UnitOfWork.
diff --git a/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueException.java b/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
similarity index 61%
rename from core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueException.java
rename to core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
index b62b8e1..77d2dc5 100644
--- a/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
@@ -19,7 +19,9 @@
*/
package org.apache.polygene.api.value;
-import org.apache.polygene.api.composite.NoSuchCompositeException;
+import java.util.stream.Stream;
+import org.apache.polygene.api.composite.CompositeDescriptor;
+import org.apache.polygene.api.composite.NoSuchCompositeTypeException;
import org.apache.polygene.api.structure.TypeLookup;
import static java.util.stream.Collectors.joining;
@@ -27,20 +29,17 @@
/**
* Thrown when no visible value of the requested type is found.
*/
-public class NoSuchValueException
- extends NoSuchCompositeException
+public class NoSuchValueTypeException
+ extends NoSuchCompositeTypeException
{
- public NoSuchValueException( String valueType, String moduleName, TypeLookup typeLookup )
+ public NoSuchValueTypeException( String valueType, String moduleName, TypeLookup typeLookup )
{
- super( "ValueComposite", valueType, moduleName, formatVisibleTypes( typeLookup ) );
+ super( "ValueComposite", valueType, moduleName, typeLookup );
}
- private static String formatVisibleTypes( TypeLookup typeLookup )
+ @Override
+ protected Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup )
{
- return typeLookup.allValues()
- .map( descriptor -> descriptor.primaryType().getName() )
- .sorted()
- .distinct()
- .collect( joining( "\n", "Visible value types are:\n", "" ) );
+ return typeLookup.allValues();
}
}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/apache/polygene/api/value/ValueBuilderFactory.java b/core/api/src/main/java/org/apache/polygene/api/value/ValueBuilderFactory.java
index 510c373..65cce37 100644
--- a/core/api/src/main/java/org/apache/polygene/api/value/ValueBuilderFactory.java
+++ b/core/api/src/main/java/org/apache/polygene/api/value/ValueBuilderFactory.java
@@ -41,11 +41,11 @@
*
* @return a new Value instance
*
- * @throws NoSuchValueException if no value extending the mixinType has been registered
+ * @throws NoSuchValueTypeException if no value extending the mixinType has been registered
* @throws ConstructionException if the value could not be instantiated
*/
<T> T newValue( Class<T> valueType )
- throws NoSuchValueException, ConstructionException;
+ throws NoSuchValueTypeException, ConstructionException;
/**
* Create a builder for creating new Values that implements the given Value type.
@@ -56,10 +56,10 @@
*
* @return a ValueBuilder for creation of ValueComposites implementing the interface
*
- * @throws NoSuchValueException if no value extending the mixinType has been registered
+ * @throws NoSuchValueTypeException if no value extending the mixinType has been registered
*/
<T> ValueBuilder<T> newValueBuilder( Class<T> valueType )
- throws NoSuchValueException;
+ throws NoSuchValueTypeException;
/**
* Create a builder for creating a new Value starting with the given prototype.
@@ -70,7 +70,7 @@
*
* @return a ValueBuilder for creation of ValueComposites implementing the interface of the prototype
*
- * @throws NoSuchValueException if no value extending the mixinType has been registered
+ * @throws NoSuchValueTypeException if no value extending the mixinType has been registered
*/
<T> ValueBuilder<T> newValueBuilderWithPrototype( T prototype );
@@ -87,7 +87,7 @@
*
* @return a ValueBuilder for creation of ValueComposites implementing the interface
*
- * @throws NoSuchValueException if no value extending the mixinType has been registered
+ * @throws NoSuchValueTypeException if no value extending the mixinType has been registered
*/
<T> ValueBuilder<T> newValueBuilderWithState( Class<T> mixinType,
Function<PropertyDescriptor, Object> propertyFunction,
@@ -104,7 +104,7 @@
*
* @return a new Value instance
*
- * @throws NoSuchValueException if no value extending the mixinType has been registered
+ * @throws NoSuchValueTypeException if no value extending the mixinType has been registered
* @throws ConstructionException if the value could not be instantiated
*/
<T> T newValueFromSerializedState( Class<T> valueType, String serializedState );
diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java
index f3c933c..4a2211e 100644
--- a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java
+++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java
@@ -22,6 +22,7 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
+import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -29,10 +30,10 @@
*/
public class AssemblyReportException extends AssemblyException
{
- private List<Throwable> problems;
+ private Set<Throwable> problems;
private String modelReport;
- public AssemblyReportException( List<Throwable> problems )
+ public AssemblyReportException( Set<Throwable> problems )
{
this.problems = problems;
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/association/AbstractAssociationModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/association/AbstractAssociationModel.java
index 052ba02..166c601 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/association/AbstractAssociationModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/association/AbstractAssociationModel.java
@@ -123,19 +123,13 @@
public void checkConstraints( Object value )
throws ConstraintViolationException
{
- if( constraints != null )
- {
- constraints.checkConstraints( value, accessor );
- }
+ constraints.checkConstraints( value, accessor );
}
public void checkAssociationConstraints( AbstractAssociation association )
throws ConstraintViolationException
{
- if( associationConstraints != null )
- {
- associationConstraints.checkConstraints( association, accessor );
- }
+ associationConstraints.checkConstraints( association, accessor );
}
public AssociationInfo builderInfo()
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java
index bc3993b..cb1c751 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java
@@ -26,6 +26,7 @@
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Parameter;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -210,7 +211,7 @@
List<Class<?>> mixinClasses
)
{
- List<Throwable> exceptions = new ArrayList<>();
+ Set<Throwable> exceptions = new HashSet<>();
Set<Class<?>> thisDependencies = new HashSet<>();
types.stream()
.peek( mixinType -> mixinsModel.addMixinType( mixinType ) )
@@ -259,7 +260,7 @@
List<Class<?>> constraintClasses,
List<Class<?>> concernClasses,
List<Class<?>> sideEffectClasses,
- List<Throwable> exceptions,
+ Set<Throwable> exceptions,
Set<Class<?>> thisDependencies )
{
try
@@ -476,11 +477,7 @@
optional,
constraintClasses,
accessor );
- ValueConstraintsInstance valueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- valueConstraintsInstance = valueConstraintsModel.newInstance();
- }
+ ValueConstraintsInstance valueConstraintsInstance = valueConstraintsModel.newInstance();
MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
UseDefaults useDefaultsDeclaration = metaInfo.get( UseDefaults.class );
Object initialValue = stateDeclarations.initialValueOf( accessor );
@@ -506,17 +503,19 @@
)
{
List<ValueConstraintsModel> parameterConstraintModels = Collections.emptyList();
- Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+
+ Parameter[] parameters = method.getParameters();
Type[] parameterTypes = method.getGenericParameterTypes();
boolean constrained = false;
- for( int i = 0; i < parameterAnnotations.length; i++ )
+ for( int i = 0; i < parameters.length; i++ )
{
- Annotation[] parameterAnnotation = parameterAnnotations[ i ];
+ Parameter param = parameters[i];
+
+ Annotation[] parameterAnnotation = param.getAnnotations();
Name nameAnnotation = (Name) of( parameterAnnotation ).filter( isType( Name.class ) )
.findFirst().orElse( null );
- String name = nameAnnotation == null ? "param" + ( i + 1 ) : nameAnnotation.value();
-
+ String name = nameAnnotation == null ? param.getName() : nameAnnotation.value();
boolean optional = of( parameterAnnotation )
.anyMatch( isType( Optional.class ) );
ValueConstraintsModel parameterConstraintsModel = constraintsFor(
@@ -865,29 +864,23 @@
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
// Constraints for Association references
- ValueConstraintsModel constraintsModel = constraintsFor( annotations.stream(), GenericAssociationInfo
- .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance valueConstraintsInstance;
- if( constraintsModel.isConstrained() )
- {
- valueConstraintsInstance = constraintsModel.newInstance();
- }
- else
- {
- valueConstraintsInstance = new ValueConstraintsInstance( Collections.emptyList(), ( (Member) accessor ).getName(), true );
- }
+ ValueConstraintsModel constraintsModel =
+ constraintsFor( annotations.stream(),
+ GenericAssociationInfo.associationTypeOf( accessor ),
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
+ ValueConstraintsInstance valueConstraintsInstance = constraintsModel.newInstance();
// Constraints for the Association itself
- constraintsModel = constraintsFor( annotations.stream(), Association.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance associationValueConstraintsInstance;
- if( constraintsModel.isConstrained() )
- {
- associationValueConstraintsInstance = constraintsModel.newInstance();
- }
- else
- {
- associationValueConstraintsInstance = new ValueConstraintsInstance( Collections.emptyList(), ( (Member) accessor ).getName(), true );
- }
+ constraintsModel = constraintsFor( annotations.stream(),
+ Association.class,
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
+ ValueConstraintsInstance associationValueConstraintsInstance = constraintsModel.newInstance();
MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
return new AssociationModel( accessor, valueConstraintsInstance, associationValueConstraintsInstance, metaInfo );
@@ -901,21 +894,24 @@
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
// Constraints for entities in ManyAssociation
- ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations.stream(), GenericAssociationInfo
- .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance valueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- valueConstraintsInstance = valueConstraintsModel.newInstance();
- }
+ ValueConstraintsModel valueConstraintsModel =
+ constraintsFor( annotations.stream(),
+ GenericAssociationInfo.associationTypeOf( accessor ),
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
+ ValueConstraintsInstance valueConstraintsInstance = valueConstraintsModel.newInstance();
// Constraints for the ManyAssociation itself
- valueConstraintsModel = constraintsFor( annotations.stream(), ManyAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance manyValueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- manyValueConstraintsInstance = valueConstraintsModel.newInstance();
- }
+ valueConstraintsModel = constraintsFor( annotations.stream(),
+ ManyAssociation.class,
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
+ ValueConstraintsInstance manyValueConstraintsInstance = valueConstraintsModel.newInstance();
+
MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
return new ManyAssociationModel( accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo );
}
@@ -928,21 +924,24 @@
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
// Constraints for entities in NamedAssociation
- ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations.stream(), GenericAssociationInfo
- .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance valueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- valueConstraintsInstance = valueConstraintsModel.newInstance();
- }
+ ValueConstraintsModel valueConstraintsModel =
+ constraintsFor( annotations.stream(),
+ GenericAssociationInfo.associationTypeOf( accessor ),
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
+ ValueConstraintsInstance valueConstraintsInstance = valueConstraintsModel.newInstance();
// Constraints for the NamedAssociation itself
- valueConstraintsModel = constraintsFor( annotations.stream(), NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance namedValueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- namedValueConstraintsInstance = valueConstraintsModel.newInstance();
- }
+ valueConstraintsModel = constraintsFor( annotations.stream(),
+ NamedAssociation.class,
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
+ ValueConstraintsInstance namedValueConstraintsInstance = valueConstraintsModel.newInstance();
+
MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
return new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
index 5c30117..d4cfa29 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -525,7 +525,7 @@
throws AssemblyException
{
addRequiredAssemblers();
- List<Throwable> exceptions = new ArrayList<>();
+ Set<Throwable> exceptions = new HashSet<>();
List<TransientModel> transientModels = new ArrayList<>();
List<ObjectModel> objectModels = new ArrayList<>();
List<ValueModel> valueModels = new ArrayList<>();
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeModel.java
index 59ad428..72ab757 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeModel.java
@@ -32,6 +32,7 @@
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.composite.Composite;
import org.apache.polygene.api.composite.CompositeDescriptor;
+import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.structure.ModuleDescriptor;
import org.apache.polygene.api.util.AccessibleObjects;
import org.apache.polygene.api.util.HierarchicalVisitor;
@@ -228,7 +229,15 @@
{
try
{
- return compositeMethodsModel.invoke( mixins, proxy, method, args, module );
+ try
+ {
+ return compositeMethodsModel.invoke( mixins, proxy, method, args, module );
+ }
+ catch( ConstraintViolationException e )
+ {
+ e.setCompositeDescriptor(this);
+ throw e;
+ }
}
catch( Throwable throwable )
{
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsInstance.java
index 23e8f98..efa9521 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsInstance.java
@@ -23,11 +23,11 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Stream;
-import org.apache.polygene.api.composite.Composite;
import org.apache.polygene.api.composite.CompositeInstance;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.identity.Identity;
/**
* JAVADOC
@@ -51,11 +51,11 @@
}
// Check constraints
- List<ConstraintViolation> violations = null;
+ List<ValueConstraintViolation> violations = null;
for( int i = 0; i < params.length; i++ )
{
Object param = params[ i ];
- List<ConstraintViolation> paramViolations = valueConstraintsInstances.get( i ).checkConstraints( param );
+ List<ValueConstraintViolation> paramViolations = valueConstraintsInstances.get( i ).checkConstraints( param );
if( !paramViolations.isEmpty() )
{
if( violations == null )
@@ -69,16 +69,20 @@
// Check if any constraint failed
if( violations != null )
{
- if( instance instanceof Composite )
+ for( ValueConstraintViolation violation : violations )
{
- throw new ConstraintViolationException( (Composite) instance, method, violations );
+ violation.setMixinType( method.getDeclaringClass() );
+ violation.setMethodName( method.getName() );
}
+ ConstraintViolationException exception = new ConstraintViolationException( violations );
+ Identity identity = instance instanceof HasIdentity ? ( (HasIdentity) instance ).identity().get() : null;
+ exception.setIdentity( identity );
if( instance instanceof CompositeInstance )
{
- throw new ConstraintViolationException( ( (CompositeInstance) instance ).proxy(), method, violations );
+ instance = ( (CompositeInstance) instance ).proxy();
}
- Stream<Class<?>> types = Stream.of( instance.getClass() );
- throw new ConstraintViolationException( instance.toString(), types, method, violations );
+ exception.setInstanceString( instance.toString() );
+ throw exception;
}
}
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/FragmentInvocationHandler.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/FragmentInvocationHandler.java
index f0dfca6..936db3c 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/FragmentInvocationHandler.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/FragmentInvocationHandler.java
@@ -84,7 +84,7 @@
// Stop removing if the originating method call has been located in the stack.
// For 'semi' and 'extensive' compaction, we don't and do the entire stack instead.
trace[ i ] = new StackTraceElement( proxy.getClass()
- .getInterfaces()[ 0 ].getName(), method.getName(), null, -1 );
+ .getInterfaces()[ 0 ].getName(), method.getName(), null, -1 );
break; // Stop compacting this trace
}
}
@@ -118,19 +118,22 @@
private boolean isApplicationClass( String className )
{
+ boolean jdkInternals = isJdkInternals( className );
if( compactLevel == CompactLevel.semi )
{
- return !isJdkInternals( className );
+ return !jdkInternals;
}
- return !( className.endsWith( FragmentClassLoader.GENERATED_POSTFIX ) ||
- className.startsWith( "org.apache.polygene.runtime" ) ||
- isJdkInternals( className ) );
+ boolean polygeneRuntime = className.startsWith( "org.apache.polygene.runtime" );
+ boolean stubClass = className.endsWith( FragmentClassLoader.GENERATED_POSTFIX );
+ return !( stubClass ||
+ polygeneRuntime ||
+ jdkInternals );
}
private boolean isJdkInternals( String className )
{
return className.startsWith( "java.lang.reflect" )
- || className.startsWith( "jdk.internal.reflect" )
+ || className.startsWith( "reflect" )
|| className.startsWith( "com.sun.proxy" )
|| className.startsWith( "sun.reflect" );
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsInstance.java
index ff53af8..98f6ab9 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsInstance.java
@@ -26,14 +26,10 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.stream.Stream;
import org.apache.polygene.api.common.Optional;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
-/**
- * JAVADOC
- */
public final class ValueConstraintsInstance
{
private static final Optional OPTIONAL;
@@ -43,7 +39,6 @@
OPTIONAL = new OptionalDummy();
}
- @SuppressWarnings( "raw" )
private final List<ConstraintInstance> constraints;
private String name;
private boolean optional;
@@ -60,9 +55,9 @@
}
@SuppressWarnings( { "raw", "unchecked" } )
- public List<ConstraintViolation> checkConstraints( Object value )
+ public List<ValueConstraintViolation> checkConstraints( Object value )
{
- List<ConstraintViolation> violations = null;
+ List<ValueConstraintViolation> violations = null;
// Check optional first - this avoids NPE's in constraints
if( optional )
@@ -77,11 +72,11 @@
if( value == null )
{
violations = new ArrayList<>();
- violations.add( new ConstraintViolation( name, OPTIONAL, null ) );
+ violations.add( new ValueConstraintViolation( name, OPTIONAL, null ) );
}
}
- if( violations == null && value != null )
+ if( violations == null )
{
for( ConstraintInstance constraint : constraints )
{
@@ -102,7 +97,7 @@
{
violations = new ArrayList<>();
}
- ConstraintViolation violation = new ConstraintViolation( name, constraint.annotation(), value );
+ ValueConstraintViolation violation = new ValueConstraintViolation( name, constraint.annotation(), value );
violations.add( violation );
}
}
@@ -116,11 +111,21 @@
public void checkConstraints( Object value, AccessibleObject accessor )
{
- List<ConstraintViolation> violations = checkConstraints( value );
+ List<ValueConstraintViolation> violations = checkConstraints( value );
if( !violations.isEmpty() )
{
- Stream<Class<?>> empty = Stream.empty();
- throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
+ for( ValueConstraintViolation violation : violations )
+ {
+ if( accessor instanceof Member )
+ {
+ Member member = (Member) accessor;
+ String methodName = member.getName();
+ violation.setMixinType( member.getDeclaringClass() );
+ violation.setMethodName( methodName );
+ }
+
+ }
+ throw new ConstraintViolationException( violations );
}
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsModel.java
index 5568881..3e95209 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ValueConstraintsModel.java
@@ -20,13 +20,11 @@
package org.apache.polygene.runtime.composite;
+import java.util.Collections;
import java.util.List;
import org.apache.polygene.api.util.HierarchicalVisitor;
import org.apache.polygene.api.util.VisitableHierarchy;
-/**
- * JAVADOC
- */
public final class ValueConstraintsModel
implements VisitableHierarchy<Object, Object>
{
@@ -43,17 +41,13 @@
public ValueConstraintsInstance newInstance()
{
- return new ValueConstraintsInstance( constraintModels, name, optional );
+ List<AbstractConstraintModel> models = isConstrained() ? this.constraintModels : Collections.emptyList();
+ return new ValueConstraintsInstance( models, name, optional );
}
public boolean isConstrained()
{
- if( !constraintModels.isEmpty() )
- {
- return true;
- }
-
- return !optional;
+ return !constraintModels.isEmpty() || !optional;
}
@Override
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/entity/EntityInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/entity/EntityInstance.java
index 6893225..386a592 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/entity/EntityInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/entity/EntityInstance.java
@@ -20,8 +20,6 @@
package org.apache.polygene.runtime.entity;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -299,12 +297,11 @@
}
catch( ConstraintViolationException e )
{
- List<? extends Type> entityModelList = entityModel.types().collect( toList() );
- throw new ConstraintViolationException( reference.identity(),
- entityModelList,
- e.mixinTypeName(),
- e.methodName(),
- e.constraintViolations() );
+ e.setCompositeDescriptor( descriptor() );
+ e.setIdentity( entityState.entityReference().identity() );
+ e.setInstanceString( proxy.toString() );
+ e.setCompositeDescriptor( entityModel );
+ throw e;
}
}
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/ServiceInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/ServiceInjectionProviderFactory.java
index f3dc70c..f6542e5 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/ServiceInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/ServiceInjectionProviderFactory.java
@@ -27,7 +27,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
-import org.apache.polygene.api.service.NoSuchServiceException;
+import org.apache.polygene.api.service.NoSuchServiceTypeException;
import org.apache.polygene.api.service.ServiceReference;
import org.apache.polygene.api.service.qualifier.Qualifier;
import org.apache.polygene.api.util.Classes;
@@ -203,7 +203,7 @@
.filter( serviceQualifier ).findFirst().orElse( null );
}
}
- catch( NoSuchServiceException e )
+ catch( NoSuchServiceTypeException e )
{
return null;
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/UsesInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/UsesInjectionProviderFactory.java
index 6b21d29..0ebf7e2 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/UsesInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/injection/provider/UsesInjectionProviderFactory.java
@@ -20,8 +20,8 @@
package org.apache.polygene.runtime.injection.provider;
import java.lang.reflect.Constructor;
-import org.apache.polygene.api.composite.NoSuchTransientException;
-import org.apache.polygene.api.object.NoSuchObjectException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
+import org.apache.polygene.api.object.NoSuchObjectTypeException;
import org.apache.polygene.api.structure.Module;
import org.apache.polygene.api.util.AccessibleObjects;
import org.apache.polygene.bootstrap.InvalidInjectionException;
@@ -83,13 +83,13 @@
}
usesObject = moduleInstance.newTransient( injectionType, uses.toArray() );
}
- catch( NoSuchTransientException e )
+ catch( NoSuchTransientTypeException e )
{
try
{
usesObject = moduleInstance.newObject( injectionType, uses.toArray() );
}
- catch( NoSuchObjectException e1 )
+ catch( NoSuchObjectTypeException e1 )
{
// Could not instantiate an instance - to try instantiate as plain class
try
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
index 984d8c4..7ca4395 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
@@ -31,7 +31,7 @@
import java.util.stream.Stream;
import org.apache.polygene.api.common.MetaInfo;
import org.apache.polygene.api.common.QualifiedName;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.entity.Queryable;
import org.apache.polygene.api.property.DefaultValues;
@@ -286,12 +286,7 @@
{
if( constraints != null )
{
- List<ConstraintViolation> violations = constraints.checkConstraints( value );
- if( !violations.isEmpty() )
- {
- Stream<Class<?>> empty = Stream.empty();
- throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
- }
+ constraints.checkConstraints( value, accessor );
}
}
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
index 0f572ea..e01af28 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
@@ -23,7 +23,7 @@
import org.apache.polygene.api.query.NotQueryableException;
import org.apache.polygene.api.query.QueryBuilder;
import org.apache.polygene.api.query.QueryBuilderFactory;
-import org.apache.polygene.api.service.NoSuchServiceException;
+import org.apache.polygene.api.service.NoSuchServiceTypeException;
import org.apache.polygene.api.service.ServiceFinder;
import org.apache.polygene.api.service.ServiceReference;
import org.apache.polygene.spi.query.EntityFinder;
@@ -61,7 +61,7 @@
serviceReference = finder.findService( EntityFinder.class );
return new QueryBuilderImpl<>( serviceReference.get(), resultType, null );
}
- catch( NoSuchServiceException e )
+ catch( NoSuchServiceTypeException e )
{
return new QueryBuilderImpl<>( null, resultType, null );
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
index 20fa0f7..9422816 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
@@ -37,14 +37,14 @@
import org.apache.polygene.api.common.ConstructionException;
import org.apache.polygene.api.composite.Composite;
import org.apache.polygene.api.composite.ModelDescriptor;
-import org.apache.polygene.api.composite.NoSuchTransientException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
import org.apache.polygene.api.composite.TransientBuilder;
import org.apache.polygene.api.composite.TransientBuilderFactory;
import org.apache.polygene.api.composite.TransientDescriptor;
import org.apache.polygene.api.entity.EntityReference;
import org.apache.polygene.api.identity.IdentityGenerator;
import org.apache.polygene.api.metrics.MetricsProvider;
-import org.apache.polygene.api.object.NoSuchObjectException;
+import org.apache.polygene.api.object.NoSuchObjectTypeException;
import org.apache.polygene.api.object.ObjectDescriptor;
import org.apache.polygene.api.object.ObjectFactory;
import org.apache.polygene.api.property.Property;
@@ -53,7 +53,7 @@
import org.apache.polygene.api.query.QueryBuilderFactory;
import org.apache.polygene.api.serialization.Serialization;
import org.apache.polygene.api.serialization.SerializationException;
-import org.apache.polygene.api.service.NoSuchServiceException;
+import org.apache.polygene.api.service.NoSuchServiceTypeException;
import org.apache.polygene.api.service.ServiceFinder;
import org.apache.polygene.api.service.ServiceReference;
import org.apache.polygene.api.structure.LayerDescriptor;
@@ -63,7 +63,7 @@
import org.apache.polygene.api.type.HasTypes;
import org.apache.polygene.api.unitofwork.UnitOfWorkException;
import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import org.apache.polygene.api.value.NoSuchValueException;
+import org.apache.polygene.api.value.NoSuchValueTypeException;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueBuilderFactory;
import org.apache.polygene.api.value.ValueDescriptor;
@@ -166,15 +166,15 @@
// Implementation of ObjectFactory
@Override
public <T> T newObject( Class<T> mixinType, Object... uses )
- throws NoSuchObjectException
+ throws NoSuchObjectTypeException
{
Objects.requireNonNull( mixinType, "mixinType" );
ObjectDescriptor model = typeLookup.lookupObjectModel( mixinType );
if( model == null )
{
- throw new NoSuchObjectException( mixinType.getName(), name(),
- typeLookup.allObjects().flatMap( HasTypes::types ) );
+ throw new NoSuchObjectTypeException( mixinType.getName(), name(),
+ typeLookup.allObjects().flatMap( HasTypes::types ) );
}
InjectionContext injectionContext = new InjectionContext( model.module(), UsesInstance.EMPTY_USES.use( uses ) );
@@ -190,8 +190,8 @@
if( model == null )
{
- throw new NoSuchObjectException( instance.getClass().getName(), name(),
- typeLookup.allObjects().flatMap( HasTypes::types ) );
+ throw new NoSuchObjectTypeException( instance.getClass().getName(), name(),
+ typeLookup.allObjects().flatMap( HasTypes::types ) );
}
InjectionContext injectionContext = new InjectionContext( model.module(), UsesInstance.EMPTY_USES.use( uses ) );
@@ -201,14 +201,14 @@
// Implementation of TransientBuilderFactory
@Override
public <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType )
- throws NoSuchTransientException
+ throws NoSuchTransientTypeException
{
Objects.requireNonNull( mixinType, "mixinType" );
TransientDescriptor model = typeLookup.lookupTransientModel( mixinType );
if( model == null )
{
- throw new NoSuchTransientException( mixinType.getName(), name(), typeLookup );
+ throw new NoSuchTransientTypeException( mixinType.getName(), name(), typeLookup );
}
Map<AccessibleObject, Property<?>> properties = new HashMap<>();
@@ -228,7 +228,7 @@
@Override
public <T> T newTransient( final Class<T> mixinType, Object... uses )
- throws NoSuchTransientException, ConstructionException
+ throws NoSuchTransientTypeException, ConstructionException
{
return newTransientBuilder( mixinType ).use( uses ).newInstance();
}
@@ -236,21 +236,21 @@
// Implementation of ValueBuilderFactory
@Override
public <T> T newValue( Class<T> mixinType )
- throws NoSuchValueException, ConstructionException
+ throws NoSuchValueTypeException, ConstructionException
{
return newValueBuilder( mixinType ).newInstance();
}
@Override
public <T> ValueBuilder<T> newValueBuilder( Class<T> mixinType )
- throws NoSuchValueException
+ throws NoSuchValueTypeException
{
Objects.requireNonNull( mixinType, "mixinType" );
ValueDescriptor compositeModelModule = typeLookup.lookupValueModel( mixinType );
if( compositeModelModule == null )
{
- throw new NoSuchValueException( mixinType.getName(), name(), typeLookup );
+ throw new NoSuchValueTypeException( mixinType.getName(), name(), typeLookup );
}
StateResolver stateResolver = new InitialStateResolver( compositeModelModule.module() );
@@ -274,7 +274,7 @@
if( compositeModelModule == null )
{
- throw new NoSuchValueException( mixinType.getName(), name(), typeLookup );
+ throw new NoSuchValueTypeException( mixinType.getName(), name(), typeLookup );
}
StateResolver stateResolver = new FunctionStateResolver(
@@ -332,7 +332,7 @@
if( model == null )
{
- throw new NoSuchValueException( valueType.getName(), name(), typeLookup );
+ throw new NoSuchValueTypeException( valueType.getName(), name(), typeLookup );
}
return new ValueBuilderWithPrototype<>( model, this, prototype );
@@ -340,14 +340,14 @@
@Override
public <T> T newValueFromSerializedState( Class<T> mixinType, String serializedState )
- throws NoSuchValueException, ConstructionException
+ throws NoSuchValueTypeException, ConstructionException
{
Objects.requireNonNull( mixinType, "mixinType" );
ValueDescriptor model = typeLookup.lookupValueModel( mixinType );
if( model == null )
{
- throw new NoSuchValueException( mixinType.getName(), name(), typeLookup );
+ throw new NoSuchValueTypeException( mixinType.getName(), name(), typeLookup );
}
try
@@ -369,7 +369,7 @@
@Override
public <T> ServiceReference<T> findService( Class<T> serviceType )
- throws NoSuchServiceException
+ throws NoSuchServiceTypeException
{
return findService( (Type) serviceType );
}
@@ -380,7 +380,7 @@
ModelDescriptor serviceModel = typeLookup.lookupServiceModel( serviceType );
if( serviceModel == null )
{
- throw new NoSuchServiceException( serviceType.getTypeName(), name(), typeLookup );
+ throw new NoSuchServiceTypeException( serviceType.getTypeName(), name(), typeLookup );
}
return findServiceReferenceInstance( serviceModel );
}
@@ -482,7 +482,7 @@
{
store = findService( EntityStore.class ).get();
}
- catch( NoSuchServiceException e )
+ catch( NoSuchServiceTypeException e )
{
throw new UnitOfWorkException( "No EntityStore service available in module " + name() );
}
@@ -505,7 +505,7 @@
{
uowf = findService( UnitOfWorkFactory.class ).get();
}
- catch( NoSuchServiceException e )
+ catch( NoSuchServiceTypeException e )
{
throw new UnitOfWorkException( "No UnitOfWorkFactory service available in module " + name() );
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
index 91f975d..d92ad72 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
@@ -22,7 +22,7 @@
import org.apache.polygene.api.association.AssociationStateHolder;
import org.apache.polygene.api.common.ConstructionException;
import org.apache.polygene.api.composite.Composite;
-import org.apache.polygene.api.value.NoSuchValueException;
+import org.apache.polygene.api.value.NoSuchValueTypeException;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueDescriptor;
import org.apache.polygene.runtime.composite.StateResolver;
@@ -86,7 +86,7 @@
if( valueModel == null )
{
- throw new NoSuchValueException( valueType.getName(), currentModule.name(), currentModule.typeLookup() );
+ throw new NoSuchValueTypeException( valueType.getName(), currentModule.name(), currentModule.typeLookup() );
}
return new ValueBuilderWithPrototype<>( valueModel, currentModule, prototype() ).newInstance();
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
index b79b298..9338deb 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
@@ -20,15 +20,20 @@
package org.apache.polygene.runtime.value;
-import java.lang.reflect.Member;
-import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Stream;
+import org.apache.polygene.api.association.AssociationDescriptor;
import org.apache.polygene.api.common.MetaInfo;
import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
+import org.apache.polygene.api.entity.EntityDescriptor;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.identity.Identity;
import org.apache.polygene.api.structure.ModuleDescriptor;
+import org.apache.polygene.api.structure.TypeLookup;
import org.apache.polygene.api.type.ValueCompositeType;
+import org.apache.polygene.api.unitofwork.NoSuchEntityTypeException;
import org.apache.polygene.api.util.Classes;
import org.apache.polygene.api.value.ValueDescriptor;
import org.apache.polygene.runtime.composite.CompositeMethodsModel;
@@ -37,6 +42,7 @@
import org.apache.polygene.runtime.composite.MixinsModel;
import org.apache.polygene.runtime.composite.UsesInstance;
import org.apache.polygene.runtime.injection.InjectionContext;
+import org.apache.polygene.runtime.property.PropertyInstance;
import org.apache.polygene.runtime.unitofwork.UnitOfWorkInstance;
/**
@@ -54,10 +60,11 @@
final MixinsModel mixinsModel,
final ValueStateModel stateModel,
final CompositeMethodsModel compositeMethodsModel
- )
+ )
{
super( module, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
-
+// TODO: When TypeLookup's lazy loading can be disabled during Model building, then uncomment the following line.
+// checkAssociationVisibility();
valueType = ValueCompositeType.of( this );
}
@@ -77,6 +84,8 @@
void checkConstraints( ValueStateInstance state )
throws ConstraintViolationException
{
+ List<ValueConstraintViolation> violations = new ArrayList<>();
+
stateModel.properties().forEach(
propertyModel ->
{
@@ -86,11 +95,10 @@
}
catch( ConstraintViolationException e )
{
- throw new ConstraintViolationException( "<builder>", propertyModel.valueType()
- .types(), (Member) propertyModel.accessor(), e.constraintViolations() );
+ violations.addAll( e.constraintViolations() );
}
}
- );
+ );
// IF no UnitOfWork is active, then the Association checks shouldn't be done.
if( UnitOfWorkInstance.getCurrent().empty() )
@@ -106,21 +114,73 @@
}
catch( ConstraintViolationException e )
{
- Stream<? extends Type> types = Classes.interfacesOf( associationModel.type() );
- throw new ConstraintViolationException( "<builder>", types,
- (Member) associationModel.accessor(),
- e.constraintViolations() );
+ try
+ {
+ PropertyInstance<Identity> identityProperty = state.propertyFor( HasIdentity.IDENTITY_METHOD );
+ e.setIdentity( identityProperty.get() );
+ }
+ catch( IllegalArgumentException e1 )
+ {
+ // ignore. Is not a HasIdentity instance
+ }
+ throw e;
}
}
- );
+ );
( (ValueStateModel) stateModel ).manyAssociations().forEach(
- model -> model.checkAssociationConstraints( state.manyAssociationFor( model.accessor() ) )
- );
+ model ->
+ {
+ try
+ {
+ model.checkAssociationConstraints( state.manyAssociationFor( model.accessor() ) );
+ }
+ catch( ConstraintViolationException e )
+ {
+ try
+ {
+ PropertyInstance<Identity> identityProperty = state.propertyFor( HasIdentity.IDENTITY_METHOD );
+ e.setIdentity( identityProperty.get() );
+ }
+ catch( IllegalArgumentException e1 )
+ {
+ // ignore. is not a HasIdentity value
+ }
+ throw e;
+
+ }
+ }
+ );
( (ValueStateModel) stateModel ).namedAssociations().forEach(
- model -> model.checkAssociationConstraints( state.namedAssociationFor( model.accessor() ) )
- );
+ model ->
+ {
+ try
+ {
+ model.checkAssociationConstraints( state.namedAssociationFor( model.accessor() ) );
+ }
+ catch( ConstraintViolationException e )
+ {
+ PropertyInstance<Identity> propertyInstance = state.propertyFor( HasIdentity.IDENTITY_METHOD );
+ throw e;
+
+ }
+ }
+ );
+ if( ! violations.isEmpty() )
+ {
+ ConstraintViolationException exception = new ConstraintViolationException( violations );
+ try
+ {
+ PropertyInstance<Identity> identityProperty = state.propertyFor( HasIdentity.IDENTITY_METHOD );
+ exception.setIdentity(identityProperty.get());
+ }
+ catch( IllegalArgumentException e )
+ {
+ // ignore, there is no Identity.
+ }
+ throw exception;
+ }
}
public ValueInstance newValueInstance( ValueStateInstance state )
@@ -140,4 +200,24 @@
// Return
return instance;
}
+
+ private void checkAssociationVisibility()
+ {
+ // All referenced entity types in any Associations must be visible from the module of this ValueModel.
+ TypeLookup lookup = module.typeLookup();
+ ValueStateModel stateModel = (ValueStateModel) this.stateModel;
+ stateModel.associations().forEach( model -> checkModel( lookup, model ) );
+ stateModel.manyAssociations().forEach( model -> checkModel( lookup, model ) );
+ stateModel.namedAssociations().forEach( model -> checkModel( lookup, model ) );
+ }
+
+ private void checkModel( TypeLookup lookup, AssociationDescriptor model )
+ {
+ Class<?> rawClass = Classes.RAW_CLASS.apply( model.type() );
+ List<EntityDescriptor> descriptors = lookup.lookupEntityModels( rawClass );
+ if( descriptors.size() == 0 )
+ {
+ throw new NoSuchEntityTypeException( rawClass.getName(), module.name(), lookup );
+ }
+ }
}
\ No newline at end of file
diff --git a/core/runtime/src/test/java/org/apache/polygene/constraints/PropertyConstraintTest.java b/core/runtime/src/test/java/org/apache/polygene/constraints/PropertyConstraintTest.java
index ca3b1fa..51b9e93 100644
--- a/core/runtime/src/test/java/org/apache/polygene/constraints/PropertyConstraintTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/constraints/PropertyConstraintTest.java
@@ -22,7 +22,7 @@
import java.util.Collection;
import org.apache.polygene.api.composite.TransientBuilder;
import org.apache.polygene.api.composite.TransientComposite;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.constraint.Constraints;
import org.apache.polygene.api.property.Property;
@@ -53,7 +53,7 @@
}
catch( ConstraintViolationException e )
{
- Collection<ConstraintViolation> violations = e.constraintViolations();
+ Collection<ValueConstraintViolation> violations = e.constraintViolations();
assertEquals( 2, violations.size() );
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
index f13c0b0..adb0ccb 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
@@ -26,7 +26,7 @@
import org.junit.Test;
import org.apache.polygene.api.common.AppliesTo;
import org.apache.polygene.api.common.AppliesToFilter;
-import org.apache.polygene.api.composite.NoSuchTransientException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
import org.apache.polygene.api.composite.TransientBuilder;
import org.apache.polygene.api.composite.TransientComposite;
import org.apache.polygene.api.mixin.Mixins;
@@ -46,7 +46,7 @@
}
@SuppressWarnings( "unchecked" )
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void testNewInstanceNotExtendingComposite()
throws Exception
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java
index f70ced7..ad9def8 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/InterfaceDefaultMethodsTest.java
@@ -46,7 +46,10 @@
public class InterfaceDefaultMethodsTest extends AbstractPolygeneTest
{
@BeforeClass
- public static void assumeJavaVersionIs8() { assumeJavaVersion( 8 ); }
+ public static void assumeJavaVersionIs8()
+ {
+ assumeJavaVersion( 8 );
+ }
public interface DefaultMethods
{
@@ -236,6 +239,8 @@
catch( ConstraintViolationException ex )
{
assertThat( ex.getMessage(), containsString( "sayHello" ) );
+ assertThat( ex.getMessage(), containsString( "DefaultMethodsConstraints" ) );
+ assertThat( ex.getMessage(), containsString( "NotEmpty" ) );
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java
index f560439..f7d40d5 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/constraints/ConstraintsTest.java
@@ -29,7 +29,7 @@
import org.apache.polygene.api.composite.TransientComposite;
import org.apache.polygene.api.constraint.Constraint;
import org.apache.polygene.api.constraint.ConstraintDeclaration;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.constraint.Constraints;
import org.apache.polygene.api.constraint.Name;
@@ -66,7 +66,7 @@
}
catch( ConstraintViolationException e )
{
- Collection<ConstraintViolation> violations = e.constraintViolations();
+ Collection<ValueConstraintViolation> violations = e.constraintViolations();
assertEquals( 2, violations.size() );
// assertEquals( MyOne.class.getName(), e.mixinTypeName() );
}
@@ -87,7 +87,7 @@
}
catch( ConstraintViolationException e )
{
- Collection<ConstraintViolation> violations = e.constraintViolations();
+ Collection<ValueConstraintViolation> violations = e.constraintViolations();
assertEquals( 2, violations.size() );
// assertEquals( MyOne.class.getName(), e.mixinTypeName() );
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
index 39cb71c..9a6c49f 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
@@ -23,7 +23,7 @@
import org.apache.polygene.api.activation.ActivationException;
import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.injection.scope.Uses;
-import org.apache.polygene.api.object.NoSuchObjectException;
+import org.apache.polygene.api.object.NoSuchObjectTypeException;
import org.apache.polygene.api.structure.Module;
import org.apache.polygene.bootstrap.SingletonAssembler;
import org.junit.Assert;
@@ -43,7 +43,7 @@
*
* @throws Exception expected
*/
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void newBuilderForUnregisteredObject()
throws Exception
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
index 59c5a98..ed0171a 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
@@ -27,7 +27,7 @@
import org.apache.polygene.api.identity.StringIdentity;
import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.object.NoSuchObjectException;
+import org.apache.polygene.api.object.NoSuchObjectTypeException;
import org.apache.polygene.api.service.ServiceComposite;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.api.structure.Module;
@@ -131,7 +131,7 @@
service.besideLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromServiceWhenAccessingBesideModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -145,35 +145,35 @@
service.belowApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromServiceWhenAccessingBelowLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromServiceWhenAccessingBelowModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowModuleVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromServiceWhenAccessingAboveApplicationVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromServiceWhenAccessingAboveLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromServiceWhenAccessingAboveModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -270,7 +270,7 @@
}
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -306,7 +306,7 @@
}
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -324,7 +324,7 @@
}
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -342,7 +342,7 @@
}
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -360,7 +360,7 @@
}
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -378,7 +378,7 @@
}
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -431,7 +431,7 @@
value.besideLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromValueWhenAccessingBesideModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -445,35 +445,35 @@
value.belowApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromValueWhenAccessingBelowLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromValueWhenAccessingBelowModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowModuleVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromValueWhenAccessingAboveApplicationVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromValueWhenAccessingAboveLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromValueWhenAccessingAboveModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -515,7 +515,7 @@
transientt.besideLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromTransientWhenAccessingBesideModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -529,35 +529,35 @@
transientt.belowApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromTransientWhenAccessingBelowLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromTransientWhenAccessingBelowModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowModuleVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromTransientWhenAccessingAboveApplicationVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromTransientWhenAccessingAboveLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromTransientWhenAccessingAboveModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -599,7 +599,7 @@
object.besideLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromObjectWhenAccessingBesideModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
@@ -613,35 +613,35 @@
object.belowApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromObjectWhenAccessingBelowLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromObjectWhenAccessingBelowModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowModuleVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromObjectWhenAccessingAboveApplicationVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveApplicationVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromObjectWhenAccessingAboveLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveLayerVisible();
}
- @Test( expected = NoSuchObjectException.class )
+ @Test( expected = NoSuchObjectTypeException.class )
public void givenFromObjectWhenAccessingAboveModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
index e82a092..9d51f48 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
@@ -27,7 +27,7 @@
import org.apache.polygene.api.identity.StringIdentity;
import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.service.NoSuchServiceException;
+import org.apache.polygene.api.service.NoSuchServiceTypeException;
import org.apache.polygene.api.service.ServiceComposite;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.api.structure.Module;
@@ -130,7 +130,7 @@
service.besideLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromServiceWhenAccessingBesideModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -144,35 +144,35 @@
service.belowApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromServiceWhenAccessingBelowLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromServiceWhenAccessingBelowModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowModuleVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromServiceWhenAccessingAboveApplicationVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromServiceWhenAccessingAboveLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromServiceWhenAccessingAboveModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -269,7 +269,7 @@
}
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -305,7 +305,7 @@
}
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -323,7 +323,7 @@
}
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -341,7 +341,7 @@
}
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -359,7 +359,7 @@
}
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -377,7 +377,7 @@
}
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -430,7 +430,7 @@
value.besideLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromValueWhenAccessingBesideModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -444,35 +444,35 @@
value.belowApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromValueWhenAccessingBelowLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromValueWhenAccessingBelowModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowModuleVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromValueWhenAccessingAboveApplicationVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromValueWhenAccessingAboveLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromValueWhenAccessingAboveModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -514,7 +514,7 @@
transientt.besideLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromTransientWhenAccessingBesideModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -528,35 +528,35 @@
transientt.belowApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromTransientWhenAccessingBelowLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromTransientWhenAccessingBelowModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowModuleVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromTransientWhenAccessingAboveApplicationVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromTransientWhenAccessingAboveLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromTransientWhenAccessingAboveModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -598,7 +598,7 @@
object.besideLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromObjectWhenAccessingBesideModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
@@ -612,35 +612,35 @@
object.belowApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromObjectWhenAccessingBelowLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromObjectWhenAccessingBelowModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowModuleVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromObjectWhenAccessingAboveApplicationVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveApplicationVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromObjectWhenAccessingAboveLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveLayerVisible();
}
- @Test( expected = NoSuchServiceException.class )
+ @Test( expected = NoSuchServiceTypeException.class )
public void givenFromObjectWhenAccessingAboveModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/structure/MixinVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/structure/MixinVisibilityTest.java
index a1ee0e9..1174e2b 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/structure/MixinVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/structure/MixinVisibilityTest.java
@@ -23,7 +23,7 @@
import org.apache.polygene.api.common.Optional;
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.composite.AmbiguousTypeException;
-import org.apache.polygene.api.composite.NoSuchTransientException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
import org.apache.polygene.api.composite.TransientBuilder;
import org.apache.polygene.api.composite.TransientBuilderFactory;
import org.apache.polygene.api.injection.scope.Structure;
@@ -97,7 +97,7 @@
assertEquals( "abc", object.test2() );
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void testMixinInLayerIsNotVisible()
throws Exception
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/structure/PrivateCompositeVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/structure/PrivateCompositeVisibilityTest.java
index 701201a..70ef4b8 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/structure/PrivateCompositeVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/structure/PrivateCompositeVisibilityTest.java
@@ -21,7 +21,7 @@
package org.apache.polygene.runtime.structure;
import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.api.composite.NoSuchTransientException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
import org.apache.polygene.api.composite.TransientBuilderFactory;
import org.apache.polygene.api.composite.TransientComposite;
import org.apache.polygene.api.injection.scope.Structure;
@@ -39,7 +39,7 @@
*/
public class PrivateCompositeVisibilityTest
{
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void testPrivateCompositeVisibility()
throws Exception
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
index 9383841..95dbfff 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
@@ -25,7 +25,7 @@
import org.junit.Test;
import org.apache.polygene.api.activation.ActivationException;
import org.apache.polygene.api.common.UseDefaults;
-import org.apache.polygene.api.composite.NoSuchTransientException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
import org.apache.polygene.api.composite.TransientComposite;
import org.apache.polygene.api.concern.Concerns;
import org.apache.polygene.api.concern.GenericConcern;
@@ -52,7 +52,7 @@
*
* @throws Exception expected
*/
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void newBuilderForUnregisteredComposite()
throws Exception
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
index ba92bf1..c71d526 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
@@ -21,7 +21,7 @@
package org.apache.polygene.runtime.transients;
import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.api.composite.NoSuchTransientException;
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
import org.apache.polygene.api.composite.TransientBuilder;
import org.apache.polygene.api.composite.TransientComposite;
import org.apache.polygene.api.entity.EntityComposite;
@@ -130,7 +130,7 @@
service.besideLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromServiceWhenAccessingBesideModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -144,35 +144,35 @@
service.belowApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromServiceWhenAccessingBelowLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromServiceWhenAccessingBelowModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowModuleVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromServiceWhenAccessingAboveApplicationVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromServiceWhenAccessingAboveLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromServiceWhenAccessingAboveModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -269,7 +269,7 @@
}
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -305,7 +305,7 @@
}
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -323,7 +323,7 @@
}
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -341,7 +341,7 @@
}
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -359,7 +359,7 @@
}
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -377,7 +377,7 @@
}
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -430,7 +430,7 @@
value.besideLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromValueWhenAccessingBesideModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -444,35 +444,35 @@
value.belowApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromValueWhenAccessingBelowLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromValueWhenAccessingBelowModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowModuleVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromValueWhenAccessingAboveApplicationVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromValueWhenAccessingAboveLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromValueWhenAccessingAboveModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -514,7 +514,7 @@
transientt.besideLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromTransientWhenAccessingBesideModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -528,35 +528,35 @@
transientt.belowApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromTransientWhenAccessingBelowLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromTransientWhenAccessingBelowModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowModuleVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromTransientWhenAccessingAboveApplicationVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromTransientWhenAccessingAboveLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromTransientWhenAccessingAboveModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -598,7 +598,7 @@
object.besideLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromObjectWhenAccessingBesideModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
@@ -612,35 +612,35 @@
object.belowApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromObjectWhenAccessingBelowLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromObjectWhenAccessingBelowModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowModuleVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromObjectWhenAccessingAboveApplicationVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveApplicationVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromObjectWhenAccessingAboveLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveLayerVisible();
}
- @Test( expected = NoSuchTransientException.class )
+ @Test( expected = NoSuchTransientTypeException.class )
public void givenFromObjectWhenAccessingAboveModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
index 500d255..35052b4 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
@@ -32,7 +32,7 @@
import org.apache.polygene.api.structure.Module;
import org.apache.polygene.api.unitofwork.UnitOfWork;
import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import org.apache.polygene.api.value.NoSuchValueException;
+import org.apache.polygene.api.value.NoSuchValueTypeException;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.bootstrap.ApplicationAssemblerAdapter;
@@ -131,7 +131,7 @@
service.besideLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromServiceWhenAccessingBesideModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -145,35 +145,35 @@
service.belowApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromServiceWhenAccessingBelowLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromServiceWhenAccessingBelowModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.belowModuleVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromServiceWhenAccessingAboveApplicationVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromServiceWhenAccessingAboveLayerVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
service.aboveLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromServiceWhenAccessingAboveModuleVisibleExpectException()
{
FromService service = module.findService( FromService.class ).get();
@@ -270,7 +270,7 @@
}
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -306,7 +306,7 @@
}
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -324,7 +324,7 @@
}
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -342,7 +342,7 @@
}
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -360,7 +360,7 @@
}
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -378,7 +378,7 @@
}
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
UnitOfWork unitOfWork = uowf.newUnitOfWork();
@@ -431,7 +431,7 @@
value.besideLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromValueWhenAccessingBesideModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -445,35 +445,35 @@
value.belowApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromValueWhenAccessingBelowLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromValueWhenAccessingBelowModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.belowModuleVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromValueWhenAccessingAboveApplicationVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromValueWhenAccessingAboveLayerVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
value.aboveLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromValueWhenAccessingAboveModuleVisibleExpectException()
{
FromValue value = module.newValue( FromValue.class );
@@ -515,7 +515,7 @@
transientt.besideLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromTransientWhenAccessingBesideModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -529,35 +529,35 @@
transientt.belowApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromTransientWhenAccessingBelowLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromTransientWhenAccessingBelowModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.belowModuleVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromTransientWhenAccessingAboveApplicationVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromTransientWhenAccessingAboveLayerVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
transientt.aboveLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromTransientWhenAccessingAboveModuleVisibleExpectException()
{
FromTransient transientt = module.newTransient( FromTransient.class );
@@ -599,7 +599,7 @@
object.besideLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromObjectWhenAccessingBesideModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
@@ -613,35 +613,35 @@
object.belowApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromObjectWhenAccessingBelowLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromObjectWhenAccessingBelowModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.belowModuleVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromObjectWhenAccessingAboveApplicationVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveApplicationVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromObjectWhenAccessingAboveLayerVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
object.aboveLayerVisible();
}
- @Test( expected = NoSuchValueException.class )
+ @Test( expected = NoSuchValueTypeException.class )
public void givenFromObjectWhenAccessingAboveModuleVisibleExpectException()
{
FromObject object = module.newObject( FromObject.class );
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
index 937c03a..358070d 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
@@ -21,15 +21,18 @@
import java.util.Collection;
import java.util.Random;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.spi.cache.Cache;
import org.apache.polygene.spi.cache.CachePool;
import org.apache.polygene.test.AbstractPolygeneTest;
import org.junit.Test;
+import static org.hamcrest.core.AnyOf.anyOf;
+import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
/**
@@ -75,11 +78,11 @@
catch( ConstraintViolationException e )
{
// expected
- Collection<ConstraintViolation> violations = e.constraintViolations();
+ Collection<ValueConstraintViolation> violations = e.constraintViolations();
assertEquals( 1, violations.size() );
- ConstraintViolation violation = violations.iterator().next();
+ ValueConstraintViolation violation = violations.iterator().next();
assertEquals( "not optional", violation.constraint().toString() );
- assertEquals( "param1", violation.name() );
+ assertThat( violation.name(), anyOf(equalTo("cacheId"), equalTo( "arg0" )) ); // depends on whether -parameters was given at compile time.
}
}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
index 8a004a7..20f0b1f 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
@@ -19,6 +19,9 @@
*/
package org.apache.polygene.test.entity.model;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.polygene.api.association.NamedAssociation;
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.constraint.ConstraintViolationException;
@@ -33,6 +36,8 @@
import org.apache.polygene.api.unitofwork.UnitOfWork;
import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.api.value.ValueBuilderFactory;
import org.apache.polygene.bootstrap.ApplicationAssembly;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.LayerAssembly;
@@ -45,6 +50,7 @@
import org.apache.polygene.test.entity.model.legal.WillAmount;
import org.apache.polygene.test.entity.model.legal.WillItem;
import org.apache.polygene.test.entity.model.legal.WillPercentage;
+import org.apache.polygene.test.entity.model.monetary.Currency;
import org.apache.polygene.test.entity.model.people.Address;
import org.apache.polygene.test.entity.model.people.City;
import org.apache.polygene.test.entity.model.people.Country;
@@ -69,6 +75,9 @@
@Structure
private ObjectFactory obf;
+ @Structure
+ private ValueBuilderFactory vbf;
+
@Service
private LegalService legalService;
@@ -77,18 +86,7 @@
@Structure
private UnitOfWorkFactory uowf;
- private Identity baselId;
- private Identity montpellierId;
- private Identity hannoverId;
- private Identity malmoId;
- private Identity cherasId;
- private Identity unknown3Id;
- private Identity unknown2Id;
- private Identity unknown1Id;
- private Identity varnhemId;
-
- private Identity canaryId;
private Identity switzerlandId;
private Identity franceId;
private Identity denmarkId;
@@ -97,6 +95,20 @@
private Identity usId;
private Identity malaysiaId;
+ private Identity kualaLumpurId;
+ private Identity cherasId;
+ private Identity zurichId;
+ private Identity malmoId;
+ private Identity montpellierId;
+
+ private Identity hannoverId;
+ private Identity canaryId;
+ private Identity angkasaImpian4Id;
+ private Identity varnhemId;
+ private Identity unknown1Id;
+ private Identity unknown2Id;
+ private Identity unknown3Id;
+
@Before
public void setupTestData()
{
@@ -127,17 +139,24 @@
{
try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCitiesPresent" ) ) )
{
- assertThat( peopleRepository.findCity( baselId ).name().get(), equalTo( "Basel" ) );
+ assertThat( peopleRepository.findCity( zurichId ).name().get(), equalTo( "Zurich" ) );
assertThat( peopleRepository.findCity( malmoId ).name().get(), equalTo( "Malmo" ) );
assertThat( peopleRepository.findCity( cherasId ).name().get(), equalTo( "Cheras" ) );
assertThat( peopleRepository.findCity( hannoverId ).name().get(), equalTo( "Hannover" ) );
assertThat( peopleRepository.findCity( montpellierId ).name().get(), equalTo( "Montpellier" ) );
+ assertThat( peopleRepository.findCity( kualaLumpurId ).name().get(), equalTo( "Kuala Lumpur" ) );
}
}
@Test
public void validateAllAddressesPresent()
{
+ Currency.Builder currencyBuilder = obf.newObject( Currency.Builder.class );
+ Currency eur1000 = currencyBuilder.create( 1000, "EUR" );
+ Currency eur1500 = currencyBuilder.create( 1500, "EUR" );
+ Currency chf2000 = currencyBuilder.create( 2000, "CHF" );
+ Currency myr3000 = currencyBuilder.create( 3000, "MYR" );
+ Currency sek9000 = currencyBuilder.create( 9000, "SEK" );
try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllAddressesPresent" ) ) )
{
Address canary = peopleRepository.findAddress( canaryId );
@@ -145,30 +164,42 @@
assertThat( canary.country().get().identity().get(), equalTo( malaysiaId ) );
assertThat( canary.city().get().identity().get(), equalTo( cherasId ) );
assertThat( canary.zipCode().get(), equalTo( "43200" ) );
+ assertThat( canary.rent().get().amount().get(), equalTo( myr3000 ) );
Address varnhem = peopleRepository.findAddress( varnhemId );
assertThat( varnhem.street().get(), equalTo( "Varnhemsgatan 25" ) );
assertThat( varnhem.city().get().identity().get(), equalTo( malmoId ) );
assertThat( varnhem.country().get().identity().get(), equalTo( swedenId ) );
assertThat( varnhem.zipCode().get(), equalTo( "215 00" ) );
+ assertThat( varnhem.rent().get().amount().get(), equalTo( sek9000 ) );
+
+ Address angkasaImpian = peopleRepository.findAddress( angkasaImpian4Id );
+ assertThat( angkasaImpian.street().get(), equalTo( "B-19-4, Jalan Sehabat" ) );
+ assertThat( angkasaImpian.country().get().identity().get(), equalTo( malaysiaId ) );
+ assertThat( angkasaImpian.city().get().identity().get(), equalTo( kualaLumpurId ) );
+ assertThat( angkasaImpian.zipCode().get(), equalTo( "50200" ) );
+ assertThat( angkasaImpian.rent().get().amount().get(), equalTo( myr3000 ) );
Address unknown = peopleRepository.findAddress( unknown1Id );
assertThat( unknown.street().get(), equalTo( "" ) );
assertThat( unknown.city().get().identity().get(), equalTo( montpellierId ) );
assertThat( unknown.country().get().identity().get(), equalTo( franceId ) );
assertThat( unknown.zipCode().get(), equalTo( "" ) );
+ assertThat( unknown.rent().get().amount().get(), equalTo( eur1000 ) );
unknown = peopleRepository.findAddress( unknown2Id );
assertThat( unknown.street().get(), equalTo( "" ) );
assertThat( unknown.city().get().identity().get(), equalTo( hannoverId ) );
assertThat( unknown.country().get().identity().get(), equalTo( germanyId ) );
assertThat( unknown.zipCode().get(), equalTo( "" ) );
+ assertThat( unknown.rent().get().amount().get(), equalTo( eur1500 ) );
unknown = peopleRepository.findAddress( unknown3Id );
assertThat( unknown.street().get(), equalTo( "" ) );
- assertThat( unknown.city().get().identity().get(), equalTo( baselId ) );
+ assertThat( unknown.city().get().identity().get(), equalTo( zurichId ) );
assertThat( unknown.country().get().identity().get(), equalTo( switzerlandId ) );
assertThat( unknown.zipCode().get(), equalTo( "" ) );
+ assertThat( unknown.rent().get().amount().get(), equalTo( chf2000 ) );
}
}
@@ -195,6 +226,10 @@
assertThat( kalle.name().get(), equalTo( "Kalle" ) );
Person andreas = peopleRepository.findPersonByName( "Andreas" );
assertThat( andreas.name().get(), equalTo( "Andreas" ) );
+ Person lars = peopleRepository.findPersonByName( "Lars" );
+ assertThat( lars.name().get(), equalTo( "Lars" ) );
+ Person mia = peopleRepository.findPersonByName( "Mia" );
+ assertThat( mia.name().get(), equalTo( "Mia" ) );
}
}
@@ -241,7 +276,7 @@
try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
{
Person niclas = peopleRepository.findPersonByName( "Niclas" );
- assertThat( niclas.phoneNumbers(), containsInAnyOrder("Home", "Chinese", "Swedish", "German"));
+ assertThat( niclas.phoneNumbers(), containsInAnyOrder( "Home", "Chinese", "Swedish", "German" ) );
}
}
@@ -314,9 +349,9 @@
chinesePhoneId = niclas.phoneNumbers().get( "Chinese" ).identity().get();
germanPhoneId = niclas.phoneNumbers().get( "German" ).identity().get();
- City basel = peopleRepository.findCity( baselId );
+ City zurich = peopleRepository.findCity( zurichId );
Country switzerland = peopleRepository.findCountryByCountryCode( "ch" );
- niclas.movedToNewAddress( "DespairStreet 12A", "43HQ21", basel, switzerland, obf.newObject( Rent.Builder.class ).create( 1000, "EUR" ) );
+ niclas.movedToNewAddress( "DespairStreet 12A", "43HQ21", zurich, switzerland, obf.newObject( Rent.Builder.class ).create( 1000, "EUR" ) );
uow.complete();
}
try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
@@ -410,6 +445,58 @@
peopleRepository.findCountryByIdentity( switzerlandId );
}
+ @Test
+ public void givenEntityInheritanceWhenStoreRetrieveExpectSuccess()
+ {
+ Currency.Builder currencyBuilder = obf.newObject( Currency.Builder.class );
+ Identity willId;
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenEntityInheritanceWhenStoreRetrieveExpectSuccess" ) ) )
+ {
+ Person peter = peopleRepository.findPersonByName( "Peter" );
+ Person kalle = peopleRepository.findPersonByName( "Kalle" );
+ Person oscar = peopleRepository.findPersonByName( "Oscar" );
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ Person andreas = peopleRepository.findPersonByName( "Andreas" );
+ Map<Person, Currency> amountsMap = new HashMap<>();
+ Map<Person, Float> percentagesMap = new HashMap<>();
+ Map<Person, String> specificItemsMap = new HashMap<>();
+ amountsMap.put( niclas, currencyBuilder.create( 10, "USD" ) );
+ percentagesMap.put( kalle, 50f );
+ percentagesMap.put( oscar, 50f );
+ specificItemsMap.put( niclas, "Toothpick Collection\n" );
+ specificItemsMap.put( andreas, "Black/Yellow Lederhosen\n" );
+ Will will = legalService.createWill( peter, amountsMap, percentagesMap, specificItemsMap );
+ willId = will.identity().get();
+ uow.complete();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenEntityInheritanceWhenStoreRetrieveExpectSuccess" ) ) )
+ {
+ Person kalle = peopleRepository.findPersonByName( "Kalle" );
+ Person oscar = peopleRepository.findPersonByName( "Oscar" );
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ Person andreas = peopleRepository.findPersonByName( "Andreas" );
+
+ Will will = legalService.findWillById(willId);
+ List<WillAmount> amounts = will.amounts().get();
+ List<WillPercentage> percentages = will.percentages().get();
+ List<WillItem> items = will.items().get();
+ assertThat( amounts.size(), equalTo( 1 ) );
+ assertThat( percentages.size(), equalTo( 2 ) );
+ assertThat( items.size(), equalTo( 2 ) );
+
+ WillAmount willAmount = amounts.get( 0 );
+ assertThat( willAmount.amount().get(), equalTo( currencyBuilder.create( 10, "USD" ) ) );
+
+ WillPercentage kallePercentage = legalService.createPercentage( kalle, 50 );
+ WillPercentage oscarPercentage = legalService.createPercentage( oscar, 50 );
+ assertThat( percentages, containsInAnyOrder( kallePercentage, oscarPercentage ) );
+
+ WillItem niclasItem = legalService.createItem( niclas, "Toothpick Collection\n" );
+ WillItem andreasItem = legalService.createItem( andreas, "Black/Yellow Lederhosen\n" );
+ assertThat( items, containsInAnyOrder( niclasItem, andreasItem ) );
+ }
+ }
+
private void testData()
{
Country malaysia = peopleRepository.createCountry( "my", "Malaysia" );
@@ -434,14 +521,16 @@
hannoverId = hannover.identity().get();
City montpellier = peopleRepository.createCity( "Montpellier" );
montpellierId = montpellier.identity().get();
- City basel = peopleRepository.createCity( "Basel" );
- baselId = basel.identity().get();
+ City kualalumpur = peopleRepository.createCity( "Kuala Lumpur" );
+ kualaLumpurId = kualalumpur.identity().get();
+ City zurich = peopleRepository.createCity( "Zurich" );
+ zurichId = zurich.identity().get();
Rent.Builder rentBuilder = obf.newObject( Rent.Builder.class );
Rent rentCanary = rentBuilder.create( 3000, "MYR" );
Rent rentVarnhem = rentBuilder.create( 9000, "SEK" );
- Rent rentUnknown1 = rentBuilder.create( 1200, "EUR" );
- Rent rentUnknown2 = rentBuilder.create( 900, "EUR" );
- Rent rentUnknown3 = rentBuilder.create( 2200, "EUR" );
+ Rent rentUnknown1 = rentBuilder.create( 1000, "EUR" );
+ Rent rentUnknown2 = rentBuilder.create( 1500, "EUR" );
+ Rent rentUnknown3 = rentBuilder.create( 2000, "CHF" );
Address canaryResidence = peopleRepository.createAddress( "10, CH5A, Jalan Cheras Hartamas", "43200", cheras, malaysia, rentCanary );
canaryId = canaryResidence.identity().get();
Address varnhem = peopleRepository.createAddress( "Varnhemsgatan 25", "215 00", malmo, sweden, rentVarnhem );
@@ -450,8 +539,10 @@
unknown1Id = unknown1.identity().get();
Address unknown2 = peopleRepository.createAddress( "", "", hannover, germany, rentUnknown2 );
unknown2Id = unknown2.identity().get();
- Address unknown3 = peopleRepository.createAddress( "", "", basel, switzerland, rentUnknown3 );
+ Address unknown3 = peopleRepository.createAddress( "", "", zurich, switzerland, rentUnknown3 );
unknown3Id = unknown3.identity().get();
+ Address angkasaImpian = peopleRepository.createAddress( "B-19-4, Jalan Sehabat", "50200", kualalumpur, malaysia, rentCanary );
+ angkasaImpian4Id = angkasaImpian.identity().get();
Person eric = peopleRepository.createPerson( "Eric", malaysia, canaryResidence, null, null );
Person niclas = peopleRepository.createPerson( "Niclas", sweden, canaryResidence, null, peopleRepository.createPhoneNumber( "+60-16-7636344" ) );
niclas.children().add( eric );
@@ -465,6 +556,9 @@
Person toni = peopleRepository.createPerson( "Toni", france, unknown2, janna, peopleRepository.createPhoneNumber( "+49-12-99887766" ) );
janna.spouse().set( toni );
Person andreas = peopleRepository.createPerson( "Andreas", germany, unknown3, null, peopleRepository.createPhoneNumber( "+41-98-1234567" ) );
+ Person mia = peopleRepository.createPerson( "Mia", malaysia, angkasaImpian, null, null );
+ Person lars = peopleRepository.createPerson( "Lars", denmark, angkasaImpian, mia, null );
+ mia.spouse().set( lars );
NamedAssociation<Person> niclasRels = niclas.relationships();
niclasRels.put( FRIEND, peter );
niclasRels.put( FRIEND, toni );
@@ -486,6 +580,7 @@
defineConfigModule( configLayer.module( "Configuration Module" ) );
defineSerializationModule( configLayer.module( "Serialization Module" ) );
defineStorageModule( infrastructureLayer.module( "Storage Module" ) );
+ defineMonetaryModule( domainLayer.module( "Monetary Module" ) );
definePeopleModule( domainLayer.module( "People Module" ) );
defineLegalModule( domainLayer.module( "Legal Module" ) );
defineTestModule( accessLayer.module( "TestCase Module" ) );
@@ -509,8 +604,8 @@
protected void definePeopleModule( ModuleAssembly module )
{
module.defaultServices();
- module.entities( Address.class, City.class, PhoneNumber.class );
- module.entities( Country.class, Person.class );
+ module.entities( Address.class, Country.class, City.class, PhoneNumber.class );
+ module.entities( Person.class ).visibleIn( Visibility.layer );
module.services( PeopleRepository.class ).visibleIn( Visibility.application );
module.values( Rent.class );
module.objects( Rent.Builder.class ).visibleIn( Visibility.application );
@@ -520,7 +615,15 @@
{
module.defaultServices();
module.services( LegalService.class ).visibleIn( Visibility.application );
- module.entities( Will.class, WillItem.class, WillPercentage.class, WillAmount.class );
+ module.entities( Will.class );
+ module.values( WillAmount.class, WillItem.class, WillPercentage.class );
+ }
+
+ protected void defineMonetaryModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ module.values( Currency.class ).visibleIn( Visibility.layer );
+ module.objects( Currency.Builder.class ).visibleIn( Visibility.application );
}
protected void defineSerializationModule( ModuleAssembly module )
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
index c90a64c..6079a2e 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
@@ -19,7 +19,8 @@
*/
package org.apache.polygene.test.entity.model.legal;
-import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import org.apache.polygene.api.entity.EntityBuilder;
import org.apache.polygene.api.identity.Identity;
@@ -31,13 +32,21 @@
import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueBuilderFactory;
+import org.apache.polygene.test.entity.model.monetary.Currency;
import org.apache.polygene.test.entity.model.people.Person;
@Mixins( LegalService.Mixin.class )
public interface LegalService
{
@UnitOfWorkPropagation
- Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems );
+ Will findWillById( Identity willId );
+
+ @UnitOfWorkPropagation
+ Will createWill( Person principal, Map<Person, Currency> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems );
+
+ WillPercentage createPercentage( Person beneficiary, float percentage );
+
+ WillItem createItem( Person beneficiary, String item );
class Mixin
implements LegalService
@@ -49,36 +58,46 @@
private UnitOfWorkFactory uowf;
@Override
- public Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems )
+ public Will findWillById( Identity willId )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ return uow.get( Will.class, willId );
+ }
+
+ @Override
+ public Will createWill( Person principal, Map<Person, Currency> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems )
{
UnitOfWork uow = uowf.currentUnitOfWork();
Identity identity = StringIdentity.identityOf( "will-" + principal.name().get() );
EntityBuilder<Will> builder = uow.newEntityBuilder( Will.class, identity );
- Will instance = builder.instance();
- for( Map.Entry<Person, BigDecimal> entry : amounts.entrySet() )
+ List<WillAmount> amountsList = new ArrayList<>();
+ for( Map.Entry<Person, Currency> entry : amounts.entrySet() )
{
WillAmount amount = createAmount( entry.getKey(), entry.getValue() );
- instance.amounts().add( amount );
+ amountsList.add( amount );
}
+ List<WillPercentage> percentagesList = new ArrayList<>();
for( Map.Entry<Person, Float> entry : percentages.entrySet() )
{
WillPercentage amount = createPercentage( entry.getKey(), entry.getValue() );
- instance.percentages().add( amount );
+ percentagesList.add( amount );
}
+ List<WillItem> itemsList = new ArrayList<>();
for( Map.Entry<Person, String> entry : specificItems.entrySet() )
{
String value = entry.getValue();
- int pos = value.indexOf( '\n' );
- String item = value.substring( 0, pos );
- String description = value.substring( pos + 1 );
- WillItem amount = createItem( entry.getKey(), item, description );
- instance.items().add( amount );
+ WillItem amount = createItem( entry.getKey(), value );
+ itemsList.add( amount );
}
- builder.newInstance();
- return identity;
+ Will instance = builder.instance();
+ instance.principal().set(principal);
+ instance.percentages().set( percentagesList );
+ instance.amounts().set( amountsList );
+ instance.items().set( itemsList );
+ return builder.newInstance();
}
- private WillAmount createAmount( Person beneficiary, BigDecimal amount )
+ private WillAmount createAmount( Person beneficiary, Currency amount )
{
ValueBuilder<WillAmount> builder = vbf.newValueBuilder( WillAmount.class );
builder.prototype().amount().set( amount );
@@ -98,9 +117,26 @@
{
ValueBuilder<WillItem> builder = vbf.newValueBuilder( WillItem.class );
builder.prototype().item().set( item );
- builder.prototype().item().set( description );
+ builder.prototype().description().set( description );
builder.prototype().beneficiary().set( beneficiary );
return builder.newInstance();
}
+
+ public WillItem createItem( Person beneficiary, String value )
+ {
+ int pos = value.indexOf( '\n' );
+ String item = value.substring( 0, pos );
+ String description = value.substring( pos + 1 );
+ return createItem( beneficiary, item, description );
+ }
+
+ public WillPercentage createPercentage( Person beneficiary, float percentage )
+ {
+ ValueBuilder<WillPercentage> builder = vbf.newValueBuilder( WillPercentage.class );
+ builder.prototype().beneficiary().set( beneficiary );
+ builder.prototype().percentage().set( percentage );
+ return builder.newInstance();
+ }
+
}
}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java
index 1c66efb..dd41bba 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java
@@ -19,18 +19,22 @@
*/
package org.apache.polygene.test.entity.model.legal;
+import java.util.List;
import org.apache.polygene.api.association.Association;
import org.apache.polygene.api.association.ManyAssociation;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.property.Property;
import org.apache.polygene.test.entity.model.people.Person;
-public interface Will
+public interface Will extends HasIdentity
{
-
Association<Person> principal();
- ManyAssociation<WillItem> items();
+ ManyAssociation<Person> witnesses();
- ManyAssociation<WillPercentage> percentages();
+ Property<List<WillItem>> items();
- ManyAssociation<WillAmount> amounts();
+ Property<List<WillPercentage>> percentages();
+
+ Property<List<WillAmount>> amounts();
}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java
index 6661375..52b4b58 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java
@@ -21,8 +21,9 @@
import java.math.BigDecimal;
import org.apache.polygene.api.property.Property;
+import org.apache.polygene.test.entity.model.monetary.Currency;
public interface WillAmount extends WillBenefit
{
- Property<BigDecimal> amount();
+ Property<Currency> amount();
}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java
index 0347a6c..3c44e7a 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java
@@ -21,6 +21,7 @@
import org.apache.polygene.api.association.Association;
import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.identity.HasIdentity;
import org.apache.polygene.api.property.Property;
import org.apache.polygene.test.entity.model.people.Person;
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java
new file mode 100644
index 0000000..6ca2c9b
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.monetary;
+
+import java.math.BigDecimal;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+
+public interface Currency
+{
+ Property<BigDecimal> amount();
+ Property<String> name();
+
+ class Builder
+ {
+ @Structure
+ private ValueBuilderFactory vbf;
+
+ public Currency create( int amount, String currencyName )
+ {
+ return create( new BigDecimal( amount ), currencyName );
+ }
+
+ public Currency create( BigDecimal amount, String currencyName )
+ {
+ ValueBuilder<Currency> builder = vbf.newValueBuilder( Currency.class );
+ builder.prototype().name().set( currencyName );
+ builder.prototype().amount().set( amount );
+ return builder.newInstance();
+ }
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java
index 576b3dc..b05aec5 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java
@@ -19,29 +19,33 @@
*/
package org.apache.polygene.test.entity.model.people;
-import java.math.BigDecimal;
import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.object.ObjectFactory;
import org.apache.polygene.api.property.Property;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueBuilderFactory;
+import org.apache.polygene.test.entity.model.monetary.Currency;
public interface Rent
{
- Property<BigDecimal> amount();
-
- Property<String> currency();
+ Property<Currency> amount();
class Builder
{
+ private final Currency.Builder currencyBuilder;
+
@Structure
private ValueBuilderFactory vbf;
- public Rent create( Integer amount, String currency )
+ public Builder( @Structure ObjectFactory objectFactory)
+ {
+ currencyBuilder = objectFactory.newObject( Currency.Builder.class );
+ }
+
+ public Rent create( int amount, String currency )
{
ValueBuilder<Rent> builder = vbf.newValueBuilder( Rent.class );
- Rent prototype = builder.prototype();
- prototype.amount().set( new BigDecimal( amount ) );
- prototype.currency().set( currency );
+ builder.prototype().amount().set( currencyBuilder.create( amount, currency ) );
return builder.newInstance();
}
}
diff --git a/core/testsupport/src/test/java/org/apache/polygene/test/cache/MemoryCacheTest.java b/core/testsupport/src/test/java/org/apache/polygene/test/cache/MemoryCacheTest.java
index c9e2fe1..d91c6c0 100644
--- a/core/testsupport/src/test/java/org/apache/polygene/test/cache/MemoryCacheTest.java
+++ b/core/testsupport/src/test/java/org/apache/polygene/test/cache/MemoryCacheTest.java
@@ -22,8 +22,7 @@
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
-public class MemoryCacheTest
- extends AbstractCachePoolTest
+public class MemoryCacheTest extends AbstractCachePoolTest
{
@Override
public void assemble( ModuleAssembly module )
diff --git a/internals/testsupport-internal/src/main/java/org/apache/polygene/test/docker/DockerRule.java b/internals/testsupport-internal/src/main/java/org/apache/polygene/test/docker/DockerRule.java
index 18fab0f..07cf07a 100644
--- a/internals/testsupport-internal/src/main/java/org/apache/polygene/test/docker/DockerRule.java
+++ b/internals/testsupport-internal/src/main/java/org/apache/polygene/test/docker/DockerRule.java
@@ -86,7 +86,7 @@
.builder()
.imageName( "org.apache.polygene:org.apache.polygene.internal.docker-" + image )
.publishAllPorts( true )
- .waitForTimeout( 120 )
+ .waitForTimeout( 180 )
.waitFor( rule -> new AndChecker( rule, waitFor ) );
environment.forEach( builder::env );
dockerRule = builder.build();
diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
index 2c526b5..8b697b9 100644
--- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
+++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
@@ -31,8 +31,7 @@
import static org.junit.Assert.fail;
-public class ConstraintTest
- extends AbstractPolygeneTest
+public class ConstraintTest extends AbstractPolygeneTest
{
@Override
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/api/ContextResource.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/api/ContextResource.java
index 4b701fb..2fb2fe1 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/api/ContextResource.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/api/ContextResource.java
@@ -34,7 +34,7 @@
import org.apache.polygene.api.association.ManyAssociation;
import org.apache.polygene.api.association.NamedAssociation;
import org.apache.polygene.api.common.Optional;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.constraint.Name;
import org.apache.polygene.api.entity.EntityComposite;
@@ -808,7 +808,7 @@
// CVE are considered client faults
String messages = "";
Locale locale = ObjectSelection.type( Locale.class );
- for( ConstraintViolation constraintViolation : e.constraintViolations() )
+ for( ValueConstraintViolation constraintViolation : e.constraintViolations() )
{
if( !messages.isEmpty() )
{
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ConstraintViolationMessages.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ConstraintViolationMessages.java
index 17b43d5..253284d 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ConstraintViolationMessages.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ConstraintViolationMessages.java
@@ -24,14 +24,14 @@
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
/**
* TODO
*/
public class ConstraintViolationMessages
{
- public String getMessage( ConstraintViolation violation, Locale locale )
+ public String getMessage( ValueConstraintViolation violation, Locale locale )
throws IllegalArgumentException
{
try
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/InteractionConstraintsService.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/InteractionConstraintsService.java
index b04edef..03d70c3 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/InteractionConstraintsService.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/InteractionConstraintsService.java
@@ -32,7 +32,7 @@
import org.apache.polygene.api.constraint.ConstraintDeclaration;
import org.apache.polygene.api.constraint.Constraints;
import org.apache.polygene.api.injection.scope.Structure;
-import org.apache.polygene.api.object.NoSuchObjectException;
+import org.apache.polygene.api.object.NoSuchObjectTypeException;
import org.apache.polygene.api.structure.Module;
import org.apache.polygene.library.rest.server.api.ObjectSelection;
import org.apache.polygene.library.rest.server.api.constraint.InteractionConstraint;
@@ -150,7 +150,7 @@
{
constraint = module.newObject( constraintClass );
}
- catch( NoSuchObjectException e )
+ catch( NoSuchObjectTypeException e )
{
constraint = constraintClass.newInstance();
}
@@ -214,7 +214,7 @@
{
constraint = module.newObject( constraintClass );
}
- catch( NoSuchObjectException e )
+ catch( NoSuchObjectTypeException e )
{
constraint = constraintClass.newInstance();
}
diff --git a/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/ParameterViolationConcern.java b/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/ParameterViolationConcern.java
index a7dd18d..eb03280 100644
--- a/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/ParameterViolationConcern.java
+++ b/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/ParameterViolationConcern.java
@@ -23,7 +23,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import org.apache.polygene.api.concern.ConcernOf;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
// START SNIPPET: report
@@ -39,7 +39,7 @@
}
catch( ConstraintViolationException e )
{
- for( ConstraintViolation violation : e.constraintViolations() )
+ for( ValueConstraintViolation violation : e.constraintViolations() )
{
String name = violation.name();
Object value = violation.value();
diff --git a/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/PhoneNumberParameterViolationConcern.java b/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/PhoneNumberParameterViolationConcern.java
index 92db8a2..82c27c0 100644
--- a/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/PhoneNumberParameterViolationConcern.java
+++ b/manual/src/main/java/org/apache/polygene/manual/recipes/createConstraint/PhoneNumberParameterViolationConcern.java
@@ -22,7 +22,7 @@
import java.util.Collection;
import org.apache.polygene.api.concern.ConcernOf;
import org.apache.polygene.api.concern.Concerns;
-import org.apache.polygene.api.constraint.ConstraintViolation;
+import org.apache.polygene.api.constraint.ValueConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.api.property.Property;
@@ -44,7 +44,7 @@
}
catch( ConstraintViolationException e )
{
- Collection<ConstraintViolation> violations = e.constraintViolations();
+ Collection<ValueConstraintViolation> violations = e.constraintViolations();
report( violations );
}
}
@@ -52,7 +52,7 @@
// END SNIPPET: property
// START SNIPPET: property
- private void report( Collection<ConstraintViolation> violations )
+ private void report( Collection<ValueConstraintViolation> violations )
{
}
}