Skip to content

Commit 6c07d4d

Browse files
committed
replaced raise NPE by IAE In amadeus.builder
1 parent d6b95a4 commit 6c07d4d

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

lombok.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
lombok.addLombokGeneratedAnnotation = true
1+
lombok.addLombokGeneratedAnnotation = true
2+
lombok.nonNull.exceptionType = NullPointerException

src/main/java/com/amadeus/Amadeus.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.amadeus;
22

33
import java.util.Map;
4-
import lombok.NonNull;
54

65
/**
76
* <p>
@@ -138,7 +137,13 @@ protected Amadeus(Configuration configuration) {
138137
* @param clientSecret Your API com.amadeus.client credential secret
139138
* @return a Configuration object
140139
*/
141-
public static Configuration builder(@NonNull String clientId, @NonNull String clientSecret) {
140+
public static Configuration builder(String clientId, String clientSecret) {
141+
if (clientId == null) {
142+
throw new IllegalArgumentException("clientId can't be null");
143+
}
144+
if (clientSecret == null) {
145+
throw new IllegalArgumentException("clientSecret can't be null");
146+
}
142147
return new Configuration(clientId, clientSecret);
143148
}
144149

src/main/java/com/amadeus/Configuration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Map;
44
import java.util.logging.Logger;
5+
56
import lombok.Getter;
67
import lombok.Setter;
78
import lombok.ToString;
@@ -110,9 +111,9 @@ protected Configuration(String clientId, String clientSecret) {
110111
* Builds an Amadeus client with the provided credentials.
111112
*
112113
* @return an Amadeus client
113-
* @throws NullPointerException when a client ID or client secret is missing
114+
* @throws IllegalArgumentException when a client ID or client secret is missing
114115
*/
115-
public Amadeus build() throws NullPointerException {
116+
public Amadeus build() throws IllegalArgumentException {
116117
return new Amadeus(this);
117118
}
118119

src/test/java/com/amadeus/AmadeusTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public class AmadeusTest {
2020
}
2121

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

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

3030
@Test public void testBuilderWithEnvironment() {

0 commit comments

Comments
 (0)