From bef8e33cb0d261c7fd040e4eef2c6067d6232434 Mon Sep 17 00:00:00 2001 From: I538344 Date: Thu, 15 Aug 2024 08:23:46 +0200 Subject: [PATCH 1/2] Remove requireNonNull --- README.md | 2 -- core/src/main/java/com/sap/ai/sdk/core/Core.java | 2 -- .../com/sap/ai/sdk/app/controllers/DeploymentController.java | 5 ++--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f18aaaab8..a6f88820c 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,6 @@ public AiDeploymentCreationResponse createDeployment() { AiDeploymentCreationRequest.create() .configurationId("12345-123-123-123-123456abcdefg")); - Objects.requireNonNull(deployment, "Deployment creation failed"); - String id = deployment.getId(); AiExecutionStatus status = deployment.getStatus(); diff --git a/core/src/main/java/com/sap/ai/sdk/core/Core.java b/core/src/main/java/com/sap/ai/sdk/core/Core.java index d831b6b4c..ef7e230e5 100644 --- a/core/src/main/java/com/sap/ai/sdk/core/Core.java +++ b/core/src/main/java/com/sap/ai/sdk/core/Core.java @@ -62,7 +62,6 @@ public static ApiClient getOrchestrationClient(@Nonnull final String resourceGro private static String getOrchestrationDeployment(@Nonnull final String resourceGroup) throws NoSuchElementException { final var deployments = new DeploymentApi(getClient(getDestination())).deploymentQuery(resourceGroup); - Objects.requireNonNull(deployments, "Deployment get request failed"); return deployments.getResources().stream() .filter(deployment -> "orchestration".equals(deployment.getScenarioId())) @@ -244,7 +243,6 @@ private static String getDeploymentForModel( @Nonnull final String modelName, @Nonnull final String resourceGroup) throws NoSuchElementException { final var deployments = new DeploymentApi(getClient()).deploymentQuery(resourceGroup); - Objects.requireNonNull(deployments, "Deployment get request failed"); return deployments.getResources().stream() .filter(deployment -> isDeploymentOfModel(modelName, deployment)) diff --git a/e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java b/e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java index a77c39988..708a3c80d 100644 --- a/e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java +++ b/e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java @@ -11,7 +11,6 @@ import com.sap.ai.sdk.core.client.model.AiDeploymentModificationResponse; import com.sap.ai.sdk.core.client.model.AiDeploymentTargetStatus; import java.util.List; -import java.util.Objects; import javax.annotation.Nonnull; import javax.annotation.Nullable; import lombok.extern.slf4j.Slf4j; @@ -44,7 +43,7 @@ public AiDeploymentDeletionResponse createAndDeleteDeploymentByConfigId( // shortly after creation, the deployment will be status UNKNOWN. // We can directly DELETE it, without going through STOPPED - return API.deploymentDelete("default", Objects.requireNonNull(deployment).getId()); + return API.deploymentDelete("default", deployment.getId()); } /** @@ -108,7 +107,7 @@ public List deleteByConfigId( public List getAllByConfigId(@Nonnull @PathVariable("id") final String configId) { final AiDeploymentList deploymentList = API.deploymentQuery("default"); - return Objects.requireNonNull(deploymentList).getResources().stream() + return deploymentList.getResources().stream() .filter(deployment -> configId.equals(deployment.getConfigurationId())) .toList(); } From a91bf1b69301b1d8433feaf4f7702369d6fb8da6 Mon Sep 17 00:00:00 2001 From: I538344 Date: Thu, 15 Aug 2024 08:27:58 +0200 Subject: [PATCH 2/2] PMD --- core/src/main/java/com/sap/ai/sdk/core/Core.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/com/sap/ai/sdk/core/Core.java b/core/src/main/java/com/sap/ai/sdk/core/Core.java index ef7e230e5..d4e03a38e 100644 --- a/core/src/main/java/com/sap/ai/sdk/core/Core.java +++ b/core/src/main/java/com/sap/ai/sdk/core/Core.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import javax.annotation.Nonnull; import lombok.extern.slf4j.Slf4j; import org.springframework.http.client.BufferingClientHttpRequestFactory;