|
From: <lh...@us...> - 2008-08-14 11:46:38
|
Revision: 64
http://tmapi.svn.sourceforge.net/tmapi/?rev=64&view=rev
Author: lheuer
Date: 2008-08-14 11:46:44 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
- ModelConstraintException for all factory methods
- Explicit tests for IllegalArgumentException and ModelConstraintException
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/Association.java
trunk/src/main/java/org/tmapi/core/DatatypeAware.java
trunk/src/main/java/org/tmapi/core/Name.java
trunk/src/main/java/org/tmapi/core/Role.java
trunk/src/main/java/org/tmapi/core/Scoped.java
trunk/src/main/java/org/tmapi/core/Topic.java
trunk/src/main/java/org/tmapi/core/TopicMap.java
trunk/src/main/java/org/tmapi/core/Typed.java
trunk/src/main/java/org/tmapi/core/Variant.java
trunk/src/test/java/org/tmapi/core/TestAssociation.java
trunk/src/test/java/org/tmapi/core/TestConstruct.java
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestName.java
trunk/src/test/java/org/tmapi/core/TestRole.java
trunk/src/test/java/org/tmapi/core/TestScoped.java
trunk/src/test/java/org/tmapi/core/TestTopic.java
trunk/src/test/java/org/tmapi/core/TestTopicMap.java
trunk/src/test/java/org/tmapi/core/TestTyped.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
Modified: trunk/src/main/java/org/tmapi/core/Association.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Association.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Association.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -78,6 +78,7 @@
* must not be <tt>null</tt>.
* @return An unmodifiable (maybe empty) set of roles with the specified
* <tt>type</tt> property.
+ * @throws IllegalArgumentException In case the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Role> getRoles(Topic type);
@@ -87,6 +88,8 @@
* @param type The role type; MUST NOT be <tt>null</tt>.
* @param player The role player; MUST NOT be <tt>null</tt>.
* @return A newly created association role.
+ * @throws ModelConstraintException In case the role <tt>type</tt> or
+ * <tt>player</tt> is <tt>null</tt>.
*/
public Role createRole(Topic type, Topic player);
Modified: trunk/src/main/java/org/tmapi/core/DatatypeAware.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -68,6 +68,7 @@
* </p>
*
* @param value The IRI value.
+ * @throws ModelConstraintException In case the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(Locator value);
@@ -76,6 +77,8 @@
*
* @param value The string value.
* @param datatype The value's datatype.
+ * @throws ModelConstraintException In case the <tt>value</tt> or <tt>datatype</tt>
+ * is <tt>null</tt>.
*/
public void setValue(String value, Locator datatype);
@@ -87,6 +90,7 @@
* </p>
*
* @param value The decimal value.
+ * @throws ModelConstraintException In case the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(BigDecimal value);
@@ -98,6 +102,7 @@
* </p>
*
* @param value The integer value.
+ * @throws ModelConstraintException In case the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(BigInteger value);
Modified: trunk/src/main/java/org/tmapi/core/Name.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Name.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Name.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -47,6 +47,7 @@
* The previous value is overridden.
*
* @param value The name string to be assigned to the name.
+ * @throws ModelConstraintException If the the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(String value);
@@ -70,8 +71,9 @@
* @param value The string value.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(String value, Topic... scope);
@@ -86,8 +88,9 @@
* @param value The string value.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(String value, Collection<Topic> scope);
@@ -102,8 +105,9 @@
* @param value A locator which represents an IRI.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(Locator value, Topic... scope);
@@ -118,8 +122,9 @@
* @param value A locator which represents an IRI.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(Locator value, Collection<Topic> scope);
@@ -135,8 +140,9 @@
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> or <tt>datatype</tt>
+ * is <tt>null</tt>, or the scope of the variant would not be a
+ * true superset of the name's scope.
*/
public Variant createVariant(String value, Locator datatype, Topic... scope);
@@ -152,8 +158,9 @@
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> or <tt>datatype</tt>
+ * is <tt>null</tt>, or the scope of the variant would not be a
+ * true superset of the name's scope.
*/
public Variant createVariant(String value, Locator datatype,
Collection<Topic> scope);
Modified: trunk/src/main/java/org/tmapi/core/Role.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Role.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Role.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -44,6 +44,7 @@
* Any previous role player will be overriden by <tt>player</tt>.
*
* @param player The topic which should play this role.
+ * @throws ModelConstraintException If the <tt>player</tt> is <tt>null</tt>.
*/
public void setPlayer(Topic player);
}
Modified: trunk/src/main/java/org/tmapi/core/Scoped.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -41,6 +41,7 @@
* Adds a topic to the scope.
*
* @param theme The topic which should be added to the scope.
+ * @throws ModelConstraintException If the <tt>theme</tt> is <tt>null</tt>.
*/
public void addTheme(Topic theme);
Modified: trunk/src/main/java/org/tmapi/core/Topic.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -142,6 +142,7 @@
* must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Name}s with the specified
* <tt>type</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Name> getNames(Topic type);
@@ -155,6 +156,8 @@
* the array's length is <tt>0</tt>, the name will be
* in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(Topic type, String value, Topic... scope);
@@ -167,6 +170,8 @@
* @param scope A collection of themes or <tt>null</tt> if the name should
* be in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(Topic type, String value, Collection<Topic> scope);
@@ -184,6 +189,8 @@
* the array's length is <tt>0</tt>, the name will be
* in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>value</tt>, or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(String value, Topic... scope);
@@ -200,6 +207,8 @@
* @param scope A collection of themes or <tt>null</tt> if the name should
* be in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>value</tt>, or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(String value, Collection<Topic> scope);
@@ -232,6 +241,7 @@
* must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Occurrence}s with the
* specified <tt>type</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Occurrence> getOccurrences(Topic type);
@@ -249,6 +259,8 @@
* the array's length is <tt>0</tt>, the occurrence will be
* in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value, Topic... scope);
@@ -265,6 +277,8 @@
* @param scope A collection of themes or <tt>null</tt> if the occurrence
* should be in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value,
Collection<Topic> scope);
@@ -283,6 +297,8 @@
* the array's length is <tt>0</tt>, the occurrence will be
* in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, Locator value,
Topic... scope);
@@ -300,6 +316,8 @@
* @param scope A collection of themes or <tt>null</tt> if the occurrence
* should be in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, Locator value,
Collection<Topic> scope);
@@ -319,6 +337,9 @@
* the array's length is <tt>0</tt>, the occurrence will be
* in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, the <tt>datatype</tt> or <tt>scope</tt> is
+ * <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value,
Locator datatype, Topic... scope);
@@ -337,6 +358,9 @@
* @param scope A collection of themes or <tt>null</tt> if the occurrence
* should be in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, the <tt>datatype</tt> or <tt>scope</tt> is
+ * <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value,
Locator datatype, Collection<Topic> scope);
@@ -370,6 +394,7 @@
* @param type The type of the {@link Role}s to be returned; must not
* be <tt>null</tt>.
* @return An unmodifiable set of {@link Role}s with the specified <tt>type</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Role> getRolesPlayed(Topic type);
@@ -396,6 +421,8 @@
* @return An unmodifiable set of {@link Role}s with the specified <tt>type</tt>
* which are part of {@link Association}s with the specified
* <tt>assocType</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> or <tt>assocType</tt>
+ * is <tt>null</tt>.
*/
public Set<Role> getRolesPlayed(Topic type, Topic assocType);
@@ -423,6 +450,7 @@
*
* @param type The type of which this topic should become an instance of;
* must not be <tt>null</tt>.
+ * @throws ModelConstraintException If the <tt>type</tt> is <tt>null</tt>.
*/
public void addType(Topic type);
Modified: trunk/src/main/java/org/tmapi/core/TopicMap.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -125,6 +125,7 @@
*
* @param sid The subject identifier the topic should contain.
* @return A {@link Topic} instance with the specified subject identifier.
+ * @throws ModelConstraintException If the subject identifier <tt>sid</tt> is <tt>null</tt>.
*/
public Topic createTopicBySubjectIdentifier(Locator sid);
@@ -137,6 +138,7 @@
*
* @param slo The subject locator the topic should contain.
* @return A {@link Topic} instance with the specified subject locator.
+ * @throws ModelConstraintException If the subject locator <tt>slo</tt> is <tt>null</tt>.
*/
public Topic createTopicBySubjectLocator(Locator slo);
@@ -158,6 +160,9 @@
*
* @param iid The item identifier the topic should contain.
* @return A {@link Topic} instance with the specified item identifier.
+ * @throws ModelConstraintException If the item identifier <tt>iid</tt> is <tt>null</tt>.
+ * @throws IdentityConstraintException If an other {@link Construct} with the
+ * specified item identifier exists which is not a {@link Topic}.
*/
public Topic createTopicByItemIdentifier(Locator iid);
@@ -184,6 +189,8 @@
* the array's length is <tt>0</tt>, the association will be
* in the unconstrained scope.
* @return The newly created {@link Association}
+ * @throws ModelConstraintException If either the <tt>type</tt> or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Association createAssociation(Topic type, Topic... scope);
@@ -195,6 +202,8 @@
* @param scope A collection of themes or <tt>null</tt> if the association
* should be in the unconstrained scope.
* @return The newly created {@link Association}
+ * @throws ModelConstraintException If either the <tt>type</tt> or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Association createAssociation(Topic type, Collection<Topic> scope);
Modified: trunk/src/main/java/org/tmapi/core/Typed.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -38,6 +38,7 @@
*
* @param type The topic that should define the nature of this construct;
* MUST NOT be <tt>null</tt>.
+ * @throws ModelConstraintException If the <tt>type</tt> is <tt>null</tt>.
*/
public void setType(Topic type);
Modified: trunk/src/main/java/org/tmapi/core/Variant.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -38,8 +38,7 @@
*
* The returned scope is a true superset of the parent's scope.
*
- * @return An unmodifiable set of {@link Topic}s which define
- * the scope.
+ * @return An unmodifiable set of {@link Topic}s which define the scope.
*/
public Set<Topic> getScope();
Modified: trunk/src/test/java/org/tmapi/core/TestAssociation.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -134,7 +134,7 @@
assoc.getRoles(null);
fail("getRoles(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -147,7 +147,7 @@
assoc.createRole(createTopic(), null);
fail("Role creation where player is null shouldn't be allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -160,7 +160,7 @@
assoc.createRole(null, createTopic());
fail("Role creation where type is null shouldn't be allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestConstruct.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestConstruct.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestConstruct.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -51,7 +51,7 @@
construct.addItemIdentifier(null);
fail("addItemIdentifier(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
if (construct instanceof TopicMap) {
Modified: trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -238,7 +238,7 @@
dt.setValue("value", null);
fail("datatypeAware.setValue(\"value\", null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -249,7 +249,7 @@
dt.setValue((String)null);
fail("datatypeAware.setValue((String)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -260,7 +260,7 @@
dt.setValue(null, _xsdString);
fail("datatypeAware.setValue(null, datatype) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -271,7 +271,7 @@
dt.setValue((Locator)null);
fail("datatypeAware.setValue((Locator)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -282,7 +282,7 @@
dt.setValue((BigInteger)null);
fail("datatypeAware.setValue((BigInteger)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -293,44 +293,11 @@
dt.setValue((BigDecimal)null);
fail("datatypeAware.setValue((BigDecimal)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
- public void testIllegalFloatValue() {
- final DatatypeAware dt = getDatatypeAware();
- try {
- dt.setValue((Float)null);
- fail("datatypeAware.setValue((Float)null) is illegal");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
- public void testIllegalLongValue() {
- final DatatypeAware dt = getDatatypeAware();
- try {
- dt.setValue((Long)null);
- fail("datatypeAware.setValue((Long)null) is illegal");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
- public void testIllegalIntValue() {
- final DatatypeAware dt = getDatatypeAware();
- try {
- dt.setValue((Integer)null);
- fail("datatypeAware.setValue((Integer)null) is illegal");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
protected void assertFailInteger(final DatatypeAware dt) {
try {
dt.integerValue();
Modified: trunk/src/test/java/org/tmapi/core/TestName.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -59,7 +59,7 @@
name.setValue(null);
fail("setValue(null) is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
// Old value kept.
@@ -108,7 +108,7 @@
name.createVariant((String)null, theme);
fail("Creation of a variant with (String) null value is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -120,7 +120,7 @@
name.createVariant((Locator)null, theme);
fail("Creation of a variant with (Locator) null value is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -132,7 +132,7 @@
name.createVariant("Variant", (Locator)null, theme);
fail("Creation of a variant with datatype == null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -158,7 +158,7 @@
name.createVariant("Variant", Collections.<Topic>emptySet());
fail("Creation of a variant with an empty scope is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -169,7 +169,7 @@
name.createVariant("Variant", (Topic[])null);
fail("Creation of a variant with a null scope is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestRole.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestRole.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestRole.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -67,11 +67,15 @@
role.setPlayer(player);
assertEquals("Unexpected role player after setting to 'player'",
player, role.getPlayer());
+ }
+
+ public void testIllegalPlayer() {
+ Role role = createRole();
try {
role.setPlayer(null);
fail("Setting the role player to null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestScoped.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestScoped.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestScoped.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -58,7 +58,7 @@
scoped.addTheme(null);
fail("addTheme(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopic.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopic.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestTopic.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -56,7 +56,7 @@
topic.addSubjectIdentifier(null);
fail("addSubjectIdentifier(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -67,7 +67,7 @@
topic.addSubjectLocator(null);
fail("addSubjectLocator(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -124,7 +124,7 @@
topic.addType(null);
fail("addType(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -161,7 +161,7 @@
player.getRolesPlayed(null);
fail("topic.getRolesPlayed(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -217,7 +217,7 @@
player.getRolesPlayed(role.getType(), null);
fail("topic.getRolesPlayed(type, null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -229,7 +229,7 @@
player.getRolesPlayed(null, role.getParent().getType());
fail("topic.getRolesPlayed(null, type) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -265,7 +265,7 @@
parent.getOccurrences(null);
fail("topic.getOccurrences(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -301,7 +301,7 @@
parent.getNames(null);
fail("topic.getNames(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -505,7 +505,7 @@
topic.createOccurrence(createTopic(), "Occurrence", (Locator)null);
fail("createOccurrence(topic, \"Occurrence\", (Locator)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -516,7 +516,7 @@
topic.createOccurrence(null, "Occurrence");
fail("createOccurrence(null, \"Occurrence\" is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -527,7 +527,7 @@
topic.createOccurrence(createTopic(), "Occurrence", (Topic[])null);
fail("createOccurrence(topic, \"Occurrence\", (Topic[])null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -538,7 +538,7 @@
topic.createOccurrence(createTopic(), "Occurrence", (Collection<Topic>)null);
fail("createOccurrence(topic, \"Occurrence\", (Collection<Topic>)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -651,7 +651,7 @@
topic.createName(createTopic(), (String)null);
fail("createName(topic, null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -662,7 +662,7 @@
topic.createName(createTopic(), "Name", (Topic[])null);
fail("createName(topic, \"Name\", (Topic[])null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -673,7 +673,7 @@
topic.createName(createTopic(), "Name", (Collection<Topic>)null);
fail("createName(topic, \"Name\", (Collection<Topic>)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -684,7 +684,7 @@
topic.createName((String)null);
fail("createName(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -695,7 +695,7 @@
topic.createName("Name", (Topic[])null);
fail("createName(\"Name\", (Topic[])null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -706,7 +706,7 @@
topic.createName("Name", (Collection<Topic>)null);
fail("createName(\"Name\", (Collection<Topic>)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMap.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -13,6 +13,7 @@
*/
package org.tmapi.core;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -56,7 +57,7 @@
_tm.createTopicBySubjectIdentifier(null);
fail("Subject identifier == null is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -79,7 +80,7 @@
_tm.createTopicBySubjectLocator(null);
fail("Subject locator == null is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -102,7 +103,7 @@
_tm.createTopicByItemIdentifier(null);
fail("item identifier == null is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -182,29 +183,42 @@
assertTrue(assoc.getScope().contains(theme2));
}
- public void testAssociationCreationIllegalType() {
+ public void testAssociationCreationIllegalTypeScopeArray() {
try {
_tm.createAssociation(null);
fail("Creating an association with type == null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
- public void testAssociationCreationIllegalNullScope() {
+ public void testAssociationCreationIllegalTypeScopeCollection() {
try {
+ _tm.createAssociation(null, Arrays.asList(createTopic()));
+ fail("Creating an association with type == null is not allowed");
+ }
+ catch (ModelConstraintException ex) {
+ // noop.
+ }
+ }
+
+ public void testAssociationCreationIllegalNullCollectionScope() {
+ try {
_tm.createAssociation(createTopic(), (Topic[])null);
fail("Creating an association with scope == null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
+ }
+
+ public void testAssociationCreationIllegalNullArrayScope() {
try {
_tm.createAssociation(createTopic(), (Collection<Topic>)null);
fail("Creating an association with scope == (Collection) null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTyped.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTyped.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestTyped.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -38,7 +38,7 @@
typed.setType(null);
fail("Setting the type to null should be disallowed.");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -20,6 +20,7 @@
import org.tmapi.core.Occurrence;
import org.tmapi.core.TMAPITestCase;
import org.tmapi.core.Topic;
+import org.tmapi.core.Variant;
/**
* Tests against the {@link ScopedIndex} interface.
@@ -63,7 +64,7 @@
}
public void testAssociation() {
- Topic theme = _tm.createTopic();
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getAssociations(null).isEmpty());
assertTrue(_scopedIdx.getAssociations(theme).isEmpty());
@@ -89,8 +90,8 @@
assertFalse(_scopedIdx.getAssociationThemes().contains(theme));
}
- public void testOccurrence() throws Exception {
- Topic theme = _tm.createTopic();
+ public void testOccurrence() {
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getOccurrences(null).isEmpty());
assertTrue(_scopedIdx.getOccurrences(theme).isEmpty());
@@ -116,8 +117,8 @@
assertFalse(_scopedIdx.getOccurrenceThemes().contains(theme));
}
- public void testName() throws Exception {
- Topic theme = _tm.createTopic();
+ public void testName() {
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getNames(null).isEmpty());
assertTrue(_scopedIdx.getNames(theme).isEmpty());
@@ -143,8 +144,8 @@
assertFalse(_scopedIdx.getNameThemes().contains(theme));
}
- public void testName2() throws Exception {
- Topic theme = _tm.createTopic();
+ public void testName2() {
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getNames(null).isEmpty());
assertTrue(_scopedIdx.getNames(theme).isEmpty());
@@ -166,4 +167,93 @@
assertFalse(_scopedIdx.getNameThemes().contains(theme));
}
+ public void testVariant() {
+ final Topic theme = createTopic();
+ final Topic theme2 = createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getVariants(theme).isEmpty());
+ assertTrue(_scopedIdx.getVariantThemes().isEmpty());
+ final Name name = createName();
+ assertEquals(0, name.getScope().size());
+ final Variant scoped = name.createVariant("Variant", theme);
+ assertEquals(1, scoped.getScope().size());
+ _updateIndex();
+ assertFalse(_scopedIdx.getVariantThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ // Add theme to name
+ name.addTheme(theme2);
+ assertEquals(1, name.getScope().size());
+ assertEquals("The scope change of the parent is not reflected in the variant's scope",
+ 2, scoped.getScope().size());
+ _updateIndex();
+ assertEquals("Change of the parent's scope is not reflected in the index",
+ 2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ // Remove theme from name
+ name.removeTheme(theme2);
+ _updateIndex();
+ assertFalse(_scopedIdx.getVariantThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ scoped.addTheme(theme2);
+ _updateIndex();
+ assertEquals("Change of the variant's scope is not reflected in the index",
+ 2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ // Add theme to name
+ name.addTheme(theme2);
+ _updateIndex();
+ assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ // Remove theme from name
+ name.removeTheme(theme2);
+ _updateIndex();
+ assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ scoped.removeTheme(theme2);
+ assertFalse(_scopedIdx.getVariantThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ }
+
+ public void testVariant2() {
+ final Topic theme = createTopic();
+ final Topic theme2 = createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getVariants(theme).isEmpty());
+ assertTrue(_scopedIdx.getVariants(theme2).isEmpty());
+ assertTrue(_scopedIdx.getVariantThemes().isEmpty());
+ final Name name = createTopic().createName("Name", theme2);
+ assertEquals(1, name.getScope().size());
+ final Variant scoped = name.createVariant("Variant", theme);
+ assertEquals(2, scoped.getScope().size());
+ _updateIndex();
+ assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ name.removeTheme(theme2);
+ assertEquals(0, name.getScope().size());
+ _updateIndex();
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|