-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Santhosh Gandhe <[email protected]>
- Loading branch information
Showing
20 changed files
with
244 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...st/java/org/opensearch/dataprepper/plugins/source/atlassian/utils/ConfigUtilForTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.opensearch.dataprepper.plugins.source.atlassian.utils; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import org.opensearch.dataprepper.plugins.source.atlassian.AtlassianSourceConfig; | ||
import org.opensearch.dataprepper.plugins.source.atlassian.configuration.Oauth2Config; | ||
import org.opensearch.dataprepper.test.helper.ReflectivelySetField; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class ConfigUtilForTests { | ||
|
||
public static final Logger log = LoggerFactory.getLogger(ConfigUtilForTests.class); | ||
|
||
private static InputStream getResourceAsStream(String resourceName) { | ||
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName); | ||
if (inputStream == null) { | ||
inputStream = ConfigUtilForTests.class.getResourceAsStream("/" + resourceName); | ||
} | ||
return inputStream; | ||
} | ||
|
||
public static AtlassianSourceConfig createJiraConfigurationFromYaml(String fileName) { | ||
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); | ||
try (InputStream inputStream = getResourceAsStream(fileName)) { | ||
AtlassianSourceConfig confluenceSourceConfig = objectMapper.readValue(inputStream, AtlassianSourceConfig.class); | ||
Oauth2Config oauth2Config = confluenceSourceConfig.getAuthenticationConfig().getOauth2Config(); | ||
if (oauth2Config != null) { | ||
ReflectivelySetField.setField(Oauth2Config.class, oauth2Config, "accessToken", | ||
new MockPluginConfigVariableImpl("mockAccessToken")); | ||
ReflectivelySetField.setField(Oauth2Config.class, oauth2Config, "refreshToken", | ||
new MockPluginConfigVariableImpl("mockRefreshToken")); | ||
} | ||
return confluenceSourceConfig; | ||
} catch (IOException ex) { | ||
log.error("Failed to parse pipeline Yaml", ex); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
return null; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...g/opensearch/dataprepper/plugins/source/atlassian/utils/MockPluginConfigVariableImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.atlassian.utils; | ||
|
||
import org.opensearch.dataprepper.model.plugin.PluginConfigVariable; | ||
|
||
/** | ||
* Mock implementation of PluginConfigVariable interface used only for Unit Testing. | ||
*/ | ||
public class MockPluginConfigVariableImpl implements PluginConfigVariable { | ||
|
||
private Object defaultValue; | ||
|
||
public MockPluginConfigVariableImpl(Object defaultValue) { | ||
this.defaultValue = defaultValue; | ||
} | ||
|
||
@Override | ||
public Object getValue() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setValue(Object someValue) { | ||
this.defaultValue = someValue; | ||
} | ||
|
||
@Override | ||
public void refresh() { | ||
} | ||
|
||
@Override | ||
public boolean isUpdatable() { | ||
return true; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.