Skip to content

Commit b6f1b48

Browse files
committed
Add test coverage
1 parent 72bbe10 commit b6f1b48

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/test/java/uk/gov/hmcts/darts/openapi/TranscriptionOpenApiContractTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.atlassian.oai.validator.model.SimpleRequest;
66
import com.atlassian.oai.validator.report.ValidationReport;
77
import org.junit.jupiter.api.Test;
8+
import uk.gov.hmcts.darts.util.ValidationConstants;
89

910
import 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

src/test/java/uk/gov/hmcts/darts/util/DataUtilTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)