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 77f7a50 commit 520bbf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/main/java/org/opensearch/sdk/ExtensionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ public class ExtensionSettings {
// Change the location to extension.yml file of the extension
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;
public 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");
}
}

0 comments on commit 520bbf1

Please sign in to comment.