Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced raise NPE by IAE In amadeus.builder #259

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
replaced raise NPE by IAE In amadeus.builder
  • Loading branch information
Sprokof committed Mar 15, 2024
commit 6c07d4dd67147398a62064d7ec290fa450ef61c1
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>
@@ -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);
}

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

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

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -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);
}

4 changes: 2 additions & 2 deletions src/test/java/com/amadeus/AmadeusTest.java
Original file line number Diff line number Diff line change
@@ -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() {