Skip to content

Commit

Permalink
Created ObjectMapper object to test the extenions.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Owais Kazi <[email protected]>
  • Loading branch information
owaiskazi19 committed Jul 14, 2022
1 parent f88f7f5 commit ebd8804
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
11 changes: 5 additions & 6 deletions src/main/java/org/opensearch/sdk/ExtensionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ public class ExtensionSettings {
*/
public static final String EXTENSION_DESCRIPTOR = "src/test/resources/extension.yml";

public ExtensionSettings(String extensionname, String hostaddress, String hostport) {
this.extensionname = extensionname;
this.hostaddress = hostaddress;
this.hostport = hostport;
/**
* Jackson requires a default constructor.
*/
private ExtensionSettings() {
super();
}

public ExtensionSettings() {}

public String getExtensionname() {
return extensionname;
}
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/org/opensearch/sdk/TestExtensionSettings.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package org.opensearch.sdk;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opensearch.test.OpenSearchTestCase;

import java.io.File;
import java.io.IOException;

public class TestExtensionSettings extends OpenSearchTestCase {

private ExtensionSettings extensionSettings;

@BeforeEach
public void setUp() {
extensionSettings = new ExtensionSettings("test-extension", "127.0.0.1", "1234");
public void setUp() throws IOException {
File file = new File(ExtensionSettings.EXTENSION_DESCRIPTOR);
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
extensionSettings = objectMapper.readValue(file, ExtensionSettings.class);
}

@Test
public void testExtensionName() {
assertEquals(extensionSettings.getExtensionname(), "test-extension");
assertEquals(extensionSettings.getExtensionname(), "extension");
}

@Test
Expand All @@ -25,6 +32,6 @@ public void testHostAddress() {

@Test
public void testHostPort() {
assertEquals(extensionSettings.getHostport(), "1234");
assertEquals(extensionSettings.getHostport(), "4532");
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/opensearch/sdk/TestExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void testClusterStateRequest() {
@Test
public void testClusterSettingRequest() {

extensionsRunner.sendClusterSettingRequest(transportService);
extensionsRunner.sendClusterSettingsRequest(transportService);

verify(transportService, times(1)).sendRequest(any(), anyString(), any(), any());
}
Expand Down

0 comments on commit ebd8804

Please sign in to comment.