-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SD-589 Handle exception and add unit test cases (#238)
- Loading branch information
1 parent
7dcce1f
commit 1ef13f3
Showing
6 changed files
with
95 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../test/java/org/dcsa/conformance/standards/booking/party/BookingCancellationStateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.dcsa.conformance.standards.booking.party; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class BookingCancellationStateTest { | ||
|
||
@Test | ||
void testFromString_validInput() { | ||
assertEquals( | ||
BookingCancellationState.CANCELLATION_RECEIVED, | ||
BookingCancellationState.fromString("CANCELLATION_RECEIVED")); | ||
assertEquals( | ||
BookingCancellationState.CANCELLATION_CONFIRMED, | ||
BookingCancellationState.fromString("CANCELLATION_CONFIRMED")); | ||
assertEquals( | ||
BookingCancellationState.CANCELLATION_DECLINED, | ||
BookingCancellationState.fromString("CANCELLATION_DECLINED")); | ||
} | ||
|
||
@Test | ||
void testFromString_invalidInput() { | ||
assertThrows( | ||
IllegalArgumentException.class, () -> BookingCancellationState.fromString("INVALID_STATE")); | ||
assertThrows(IllegalArgumentException.class, () -> BookingCancellationState.fromString(null)); | ||
assertThrows(IllegalArgumentException.class, () -> BookingCancellationState.fromString(" ")); | ||
assertThrows(IllegalArgumentException.class, () -> BookingCancellationState.fromString("")); | ||
} | ||
|
||
@Test | ||
void testFromString_caseInsensitiveInput() { | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> BookingCancellationState.fromString("cancellation_confirmed")); | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> BookingCancellationState.fromString("Cancellation_received")); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
booking/src/test/java/org/dcsa/conformance/standards/booking/party/BookingStateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.dcsa.conformance.standards.booking.party; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class BookingStateTest { | ||
|
||
@Test | ||
void testFromString_validInput() { | ||
assertEquals(BookingState.START, BookingState.fromString("START")); | ||
assertEquals(BookingState.RECEIVED, BookingState.fromString("RECEIVED")); | ||
} | ||
|
||
@Test | ||
void testFromString_invalidInput() { | ||
assertThrowsExactly( | ||
IllegalArgumentException.class, () -> BookingState.fromString("INVALID_STATE")); | ||
assertThrowsExactly(IllegalArgumentException.class, () -> BookingState.fromString(null)); | ||
assertThrowsExactly(IllegalArgumentException.class, () -> BookingState.fromString(" ")); | ||
assertThrowsExactly(IllegalArgumentException.class, () -> BookingState.fromString("")); | ||
} | ||
|
||
@Test | ||
void testFromString_caseInsensitiveInput() { | ||
assertThrowsExactly(IllegalArgumentException.class, () -> BookingState.fromString("start")); | ||
assertThrowsExactly(IllegalArgumentException.class, () -> BookingState.fromString("received")); | ||
} | ||
} |