Skip to content

Commit bd0d18c

Browse files
Address PR #532 feedback: document supported constraint types
- Add class-level Javadoc to ContextBuilder listing supported constraint types (IAllowedValuesConstraint, IMatchesConstraint, IExpectConstraint, IIndexHasKeyConstraint) and noting which types will throw UnsupportedOperationException - Add source assertions to test methods and clarify that constraint application is tested in ExternalConstraintsModulePostProcessorTest
1 parent 346e3b3 commit bd0d18c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

core/src/test/java/gov/nist/secauto/metaschema/core/testsupport/builder/ContextBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727

2828
/**
2929
* Implementation of {@link IContextBuilder} for creating constraint contexts.
30+
* <p>
31+
* This builder supports the following constraint types:
32+
* <ul>
33+
* <li>{@link IAllowedValuesConstraint}</li>
34+
* <li>{@link IMatchesConstraint}</li>
35+
* <li>{@link IExpectConstraint}</li>
36+
* <li>{@link IIndexHasKeyConstraint}</li>
37+
* </ul>
38+
* Other constraint types (such as {@code ICardinalityConstraint},
39+
* {@code IIndexConstraint}, or {@code IUniqueConstraint}) will throw an
40+
* {@link UnsupportedOperationException} when added. To support additional
41+
* constraint types, extend the {@link #addConstraint} method.
3042
*/
3143
public class ContextBuilder implements IContextBuilder {
3244
@NonNull

core/src/test/java/gov/nist/secauto/metaschema/core/testsupport/tests/ConstraintSetBuilderTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ void testConstraintSetWithAllowedValuesContext() {
7575

7676
// Then
7777
assertNotNull(constraintSet, "Constraint set should not be null");
78+
assertEquals(source, constraintSet.getSource(), "Source should match");
79+
// Note: Verifying the constraint was actually added requires applying the
80+
// constraint set to a module, which is tested in
81+
// ExternalConstraintsModulePostProcessorTest
7882
}
7983

8084
@Test
@@ -102,6 +106,7 @@ void testConstraintSetWithMatchesContext() {
102106

103107
// Then
104108
assertNotNull(constraintSet, "Constraint set should not be null");
109+
assertEquals(source, constraintSet.getSource(), "Source should match");
105110
}
106111

107112
@Test
@@ -129,6 +134,7 @@ void testConstraintSetWithNestedContexts() {
129134

130135
// Then
131136
assertNotNull(constraintSet, "Constraint set should not be null");
137+
assertEquals(source, constraintSet.getSource(), "Source should match");
132138
}
133139

134140
@Test
@@ -180,5 +186,6 @@ void testConstraintSetWithMultipleContexts() {
180186

181187
// Then
182188
assertNotNull(constraintSet, "Constraint set should not be null");
189+
assertEquals(source, constraintSet.getSource(), "Source should match");
183190
}
184191
}

0 commit comments

Comments
 (0)