File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
src/test/java/uk/gov/hmcts/darts Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 55import com .atlassian .oai .validator .model .SimpleRequest ;
66import com .atlassian .oai .validator .report .ValidationReport ;
77import org .junit .jupiter .api .Test ;
8+ import uk .gov .hmcts .darts .util .ValidationConstants ;
89
910import static org .junit .jupiter .api .Assertions .assertTrue ;
1011
@@ -32,15 +33,20 @@ void openApi_ShouldReturnError_WhenNegativeTranscriptionIdUsed() {
3233
3334 @ Test
3435 void openApi_ShouldReturnError_WhenAboveMaximumTranscriptionIdUsed () {
36+ String maxTranscriptionId = ValidationConstants .MaxValues .MAX_LONG_VALUE .toString ();
37+ String exceededTranscriptionId = maxTranscriptionId + "99" ;
3538 Request request = SimpleRequest .Builder
36- .get ("/transcriptions/922337203685477580799 /document" )
39+ .get ("/transcriptions/" + exceededTranscriptionId + " /document" )
3740 .build ();
3841
3942 ValidationReport report = VALIDATOR .validateRequest (request );
4043
41- assertTrue (report .getMessages ().stream ()
42- .anyMatch (m -> m .getMessage ().contains ("Numeric instance is greater than the required" +
43- " maximum (maximum: 9223372036854775807, found: 922337203685477580799)" )));
44+ String expectedSubstring = "Numeric instance is greater than the required maximum (maximum: "
45+ + maxTranscriptionId + ", found: " + exceededTranscriptionId + ")" ;
46+
47+ assertTrue (
48+ report .getMessages ().stream ().anyMatch (m -> m .getMessage ().equals (expectedSubstring ))
49+ );
4450 }
4551
4652 @ Test
Original file line number Diff line number Diff line change @@ -295,4 +295,15 @@ void toBooleanWithDefaultValue_shouldDefaultToValueSpecified() {
295295 assertThat (DataUtil .toBoolean (true )).isTrue ();
296296 assertThat (DataUtil .toBoolean (false )).isFalse ();
297297 }
298+
299+ @ Test
300+ void isWithinBounds_shouldReturnTrue_WhenValueIsWithinBounds () {
301+ assertThat (DataUtil .isWithinBounds (5L , 1L , 10L )).isTrue ();
302+ }
303+
304+ @ Test
305+ void isWithinBounds_shouldReturnFalse_WhenValueIsBelowMin () {
306+ assertThat (DataUtil .isWithinBounds (0L , 1L , 10L )).isFalse ();
307+ }
308+
298309}
You can’t perform that action at this time.
0 commit comments