amadeus-java icon indicating copy to clipboard operation
amadeus-java copied to clipboard

Amadeus should not raise a NPE in the constructor.

Open jabrena opened this issue 2 years ago • 0 comments

Reviewing the Unit Tests from the SDK, exist some cases where the current behaviour raise a NPE.

@Test 
public void testBuilderWithNullClientId() {
    assertThrows(NullPointerException.class, () -> Amadeus.builder(null, "secret").build());
}

@Test 
public void testBuilderWithNullClientSecret() {
    assertThrows(NullPointerException.class, () -> Amadeus.builder("client", null).build());
}

https://github.com/amadeus4dev/amadeus-java/blob/master/src/test/java/com/amadeus/AmadeusTest.java

Actions:

  • Review current preconditions to avoid a NPE.
  • Raise another Exception from Java SDK or a defined Exception from the Amadeus SDK.
  • Review builder to not throw NPE in build method

Classes involved:

  • https://github.com/amadeus4dev/amadeus-java/blob/master/src/main/java/com/amadeus/Amadeus.java#L156-#L164
  • https://github.com/amadeus4dev/amadeus-java/blob/master/src/main/java/com/amadeus/Configuration.java
  • https://github.com/amadeus4dev/amadeus-java/blob/master/src/test/java/com/amadeus/AmadeusTest.java

Exceptions to discuss:

  • https://github.com/amadeus4dev/amadeus-java/tree/master/src/main/java/com/amadeus/exceptions
  • https://docs.oracle.com/javase/7/docs/api/index.html (Exceptions)
  • https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html

Juan Antonio

jabrena avatar Jun 20 '22 13:06 jabrena