diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1cd7d9..955c226 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: meridianbancorg/maven-jdk11 +image: adoptopenjdk/maven-openjdk11 stages: - test diff --git a/pom.xml b/pom.xml index e94dfe5..7f98865 100644 --- a/pom.xml +++ b/pom.xml @@ -200,17 +200,6 @@ minimal-json 0.9.5 - - org.apache.commons - commons-lang3 - 3.8.1 - - - junit - junit - 4.12 - test - diff --git a/src/main/java/de/svenkubiak/jpushover/JPushover.java b/src/main/java/de/svenkubiak/jpushover/JPushover.java index b301f32..c1c536e 100644 --- a/src/main/java/de/svenkubiak/jpushover/JPushover.java +++ b/src/main/java/de/svenkubiak/jpushover/JPushover.java @@ -11,13 +11,14 @@ import java.time.Duration; import java.util.Objects; import com.eclipsesource.json.Json; -import org.apache.commons.lang3.StringUtils; import de.svenkubiak.jpushover.enums.Constants; import de.svenkubiak.jpushover.enums.Priority; import de.svenkubiak.jpushover.enums.Sound; /** + * + * Minimalist convenient class for sending messages to Pushover * * @author svenkubiak * @@ -265,7 +266,7 @@ public class JPushover { var valid = false; if (httpResponse.statusCode() == HTTP_OK) { var response = httpResponse.body(); - if (StringUtils.isNotBlank(response) && response.contains("\"status\":1")) { + if (response != null && response.contains("\"status\":1")) { valid = true; } } @@ -278,8 +279,8 @@ public class JPushover { * * @return JPushoverResponse instance * - * @throws IOException if validation fails - * @throws InterruptedException if validation fails + * @throws IOException if sending the message fails + * @throws InterruptedException if sending the message fails */ public final JPushoverResponse push() throws IOException, InterruptedException { Objects.requireNonNull(this.pushoverToken, "Token is required for a message"); @@ -309,7 +310,7 @@ public class JPushover { var httpResponse = getResponse(body.toString(), Constants.MESSAGES_URL.toString()); - JPushoverResponse jPushoverResponse = new JPushoverResponse().isSuccessful(false); + var jPushoverResponse = new JPushoverResponse().isSuccessful(false); jPushoverResponse .httpStatus(httpResponse.statusCode()) .response(httpResponse.body()) @@ -319,16 +320,16 @@ public class JPushover { } private HttpResponse getResponse(String body, String url) throws IOException, InterruptedException { - HttpRequest httpRequest = HttpRequest.newBuilder() + var httpRequest = HttpRequest.newBuilder() .uri(URI.create(url)) .timeout(Duration.ofSeconds(5)) .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(body)) .build(); - HttpClient.Builder httpClientBuilder = HttpClient.newBuilder(); + var httpClientBuilder = HttpClient.newBuilder(); - if (StringUtils.isNotBlank(this.proxyHost) && this.proxyPort > 0) { + if (this.proxyHost != null && this.proxyPort > 0) { httpClientBuilder.proxy(ProxySelector.of(new InetSocketAddress(this.proxyHost, this.proxyPort))); }