|
| 1 | +package org.openapitools.openapidiff.core.backcompat; |
| 2 | + |
| 3 | +import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; |
| 4 | +import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; |
| 5 | +import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; |
| 6 | + |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | + |
| 9 | +public class NumericRangeBCTest { |
| 10 | + private final String BASE = "bc_numericrange_base.yaml"; |
| 11 | + |
| 12 | + @Test |
| 13 | + public void unchanged() { |
| 14 | + assertSpecUnchanged(BASE, BASE); |
| 15 | + } |
| 16 | + |
| 17 | + @Test |
| 18 | + public void changedButCompatible() { |
| 19 | + // TODO: Fix bug where response range-narrowing is deemed incompatible, then test here |
| 20 | + assertSpecChangedButCompatible(BASE, "bc_numericrange_changed_but_compatible.yaml"); |
| 21 | + } |
| 22 | + |
| 23 | + @Test |
| 24 | + public void requestExclusiveMaxCreated() { |
| 25 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_max_created.yaml"); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void requestExclusiveMaxSet() { |
| 30 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_max_set.yaml"); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + public void requestExclusiveMinCreated() { |
| 35 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_min_created.yaml"); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void requestExclusiveMinSet() { |
| 40 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_min_set.yaml"); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void requestMaxAdded() { |
| 45 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_max_added.yaml"); |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + public void requestMaxDecreased() { |
| 50 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_max_decreased.yaml"); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + public void requestMinAdded() { |
| 55 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_min_added.yaml"); |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + public void requestMinIncreased() { |
| 60 | + assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_min_increased.yaml"); |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + public void responseExclusiveMaxDeleted() { |
| 65 | + // TODO: Should be incompatible because clients may be unprepared for wider range |
| 66 | + // (test added to avoid unintentional regression) |
| 67 | + assertSpecChangedButCompatible(BASE, "bc_response_numericrange_exclusive_max_deleted.yaml"); |
| 68 | + } |
| 69 | + |
| 70 | + @Test |
| 71 | + public void responseExclusiveMaxUnset() { |
| 72 | + assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_max_unset.yaml"); |
| 73 | + } |
| 74 | + |
| 75 | + @Test |
| 76 | + public void responseExclusiveMinDeleted() { |
| 77 | + // TODO: Should be incompatible because clients may be unprepared for wider range |
| 78 | + // (test added to avoid unintentional regression) |
| 79 | + assertSpecChangedButCompatible(BASE, "bc_response_numericrange_exclusive_min_deleted.yaml"); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void responseExclusiveMinUnset() { |
| 84 | + assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_min_unset.yaml"); |
| 85 | + } |
| 86 | + |
| 87 | + @Test |
| 88 | + public void responseMaxDeleted() { |
| 89 | + // TODO: Should be incompatible because clients may be unprepared for wider range |
| 90 | + // (test added to avoid unintentional regression) |
| 91 | + assertSpecChangedButCompatible(BASE, "bc_response_numericrange_max_deleted.yaml"); |
| 92 | + } |
| 93 | + |
| 94 | + @Test |
| 95 | + public void responseMaxIncreased() { |
| 96 | + // TODO: Should be incompatible because clients may be unprepared |
| 97 | + // (test added to avoid unintentional regression) |
| 98 | + assertSpecChangedButCompatible(BASE, "bc_response_numericrange_max_increased.yaml"); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + public void responseMinDecreased() { |
| 103 | + // TODO: Should be incompatible because clients may be unprepared for wider range |
| 104 | + // (test added to avoid unintentional regression) |
| 105 | + assertSpecChangedButCompatible(BASE, "bc_response_numericrange_min_decreased.yaml"); |
| 106 | + } |
| 107 | + |
| 108 | + @Test |
| 109 | + public void responseMinDeleted() { |
| 110 | + // TODO: Should be incompatible because clients may be unprepared for wider range |
| 111 | + // (test added to avoid unintentional regression) |
| 112 | + assertSpecChangedButCompatible(BASE, "bc_response_numericrange_min_deleted.yaml"); |
| 113 | + } |
| 114 | +} |
0 commit comments