Skip to content

Commit

Permalink
Merge pull request #259 from Sprokof/amadeus.builder-raise-IAE
Browse files Browse the repository at this point in the history
replaced raise NPE by IAE In amadeus.builder
  • Loading branch information
tsolakoua authored Apr 1, 2024
2 parents d6b95a4 + 6c07d4d commit 70786e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lombok.config
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lombok.addLombokGeneratedAnnotation = true
lombok.addLombokGeneratedAnnotation = true
lombok.nonNull.exceptionType = NullPointerException
9 changes: 7 additions & 2 deletions src/main/java/com/amadeus/Amadeus.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.amadeus;

import java.util.Map;
import lombok.NonNull;

/**
* <p>
Expand Down Expand Up @@ -138,7 +137,13 @@ protected Amadeus(Configuration configuration) {
* @param clientSecret Your API com.amadeus.client credential secret
* @return a Configuration object
*/
public static Configuration builder(@NonNull String clientId, @NonNull String clientSecret) {
public static Configuration builder(String clientId, String clientSecret) {
if (clientId == null) {
throw new IllegalArgumentException("clientId can't be null");
}
if (clientSecret == null) {
throw new IllegalArgumentException("clientSecret can't be null");
}
return new Configuration(clientId, clientSecret);
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/amadeus/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;
import java.util.logging.Logger;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand Down Expand Up @@ -110,9 +111,9 @@ protected Configuration(String clientId, String clientSecret) {
* Builds an Amadeus client with the provided credentials.
*
* @return an Amadeus client
* @throws NullPointerException when a client ID or client secret is missing
* @throws IllegalArgumentException when a client ID or client secret is missing
*/
public Amadeus build() throws NullPointerException {
public Amadeus build() throws IllegalArgumentException {
return new Amadeus(this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/amadeus/AmadeusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class AmadeusTest {
}

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

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

@Test public void testBuilderWithEnvironment() {
Expand Down

0 comments on commit 70786e7

Please sign in to comment.