Skip to content

Commit

Permalink
Add more UT on config class
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen authored and vmmusings committed Oct 5, 2023
1 parent ff192ed commit 3128499
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.spark.config;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.junit.jupiter.api.Test;

public class SparkExecutionEngineConfigTest {

@Test
public void testToSparkExecutionEngineConfigWithoutAllFields() {
String json =
"{"
+ "\"applicationId\": \"app-1\","
+ "\"executionRoleARN\": \"role-1\","
+ "\"region\": \"us-west-1\""
+ "}";
SparkExecutionEngineConfig config =
SparkExecutionEngineConfig.toSparkExecutionEngineConfig(json);

assertEquals("app-1", config.getApplicationId());
assertEquals("role-1", config.getExecutionRoleARN());
assertEquals("us-west-1", config.getRegion());
assertNull(config.getSparkSubmitParameters());
}

@Test
public void testToSparkExecutionEngineConfigWithAllFields() {
String json =
"{"
+ "\"applicationId\": \"app-1\","
+ "\"executionRoleARN\": \"role-1\","
+ "\"region\": \"us-west-1\","
+ "\"sparkSubmitParameters\": \"--conf A=1\""
+ "}";
SparkExecutionEngineConfig config =
SparkExecutionEngineConfig.toSparkExecutionEngineConfig(json);

assertEquals("app-1", config.getApplicationId());
assertEquals("role-1", config.getExecutionRoleARN());
assertEquals("us-west-1", config.getRegion());
assertEquals("--conf A=1", config.getSparkSubmitParameters());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,6 @@ void testGetQueryResponseWithSuccess() {
dataSourceUserAuthorizationHelper,
jobExecutionResponseReader,
flintIndexMetadataReader);
when(emrServerlessClient.getJobRunResult(EMRS_APPLICATION_ID, EMR_JOB_ID))
.thenReturn(new GetJobRunResult().withJobRun(new JobRun().withState(JobRunState.SUCCESS)));
JSONObject queryResult = new JSONObject();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(STATUS_FIELD, "SUCCESS");
Expand Down

0 comments on commit 3128499

Please sign in to comment.