-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unittest and documentations for BDK configuration #176
Conversation
Move BdkConfigException to com.symphony.bdk.core.config.exceptions to avoid many types of exceptions in a single packages Add a condition in BdkConfigParser#parse to check if invalid YAML config is parsed to a single text node.
@@ -35,7 +35,9 @@ public static JsonNode parse(InputStream inputStream) throws BdkConfigException | |||
} | |||
|
|||
try { | |||
return YAML_MAPPER.readTree(content); | |||
JsonNode jsonNode = YAML_MAPPER.readTree(content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make BdkConfigParser internal right?
I see it is already does not have public visibility, maybe annotate it with API guardian?
docs/configuration.md
Outdated
@@ -0,0 +1,46 @@ | |||
#BDK Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just # Configuration
public void loadFromYamlFileTest() throws JsonProcessingException, BdkConfigException { | ||
String configPath = System.getProperty("user.dir") + "/src/test/resources/config.yaml"; | ||
public void loadFromYamlFileTest() throws BdkConfigException { | ||
String configPath = System.getProperty("user.dir") + "/src/test/resources/config/config.yaml"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is the safest way to locate the test resources. I'd personally use another strategy :
- using https://www.baeldung.com/junit-5-temporary-directory#1-tempdir-as-a-method-parameter
- copy the config file from the classpath to tempdir
- read config from tempdir
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea! I will try that way. 👍
assertEquals(config.getBot().getPrivateKeyPath(), "/Users/thibault.pensec/local/conf/agent/privatekey.pem"); | ||
assertEquals(config.getApp().getPrivateKeyPath(), "/Users/thibault.pensec/local/conf/agent/privatekey.pem"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove "thibault.pensec" from the test data 😅 I'll do the same with my PR !
"agentHost": "devx1.symphony.com", | ||
"keyAuthHost": "devx1.symphony.com", | ||
"botUsername": "tibot", | ||
"botPrivateKeyPath": "/Users/thibault.pensec/local/conf/agent/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove "thibault.pensec" !
"botPrivateKeyPath": "/Users/thibault.pensec/local/conf/agent/", | ||
"botPrivateKeyName": "privatekey.pem", | ||
"appId": "tibapp", | ||
"appPrivateKeyPath": "/Users/thibault.pensec/local/conf/agent/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
Update documentation for configuration. Update test resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Add unittest and documentations for BDK configuration
Move BdkConfigException to com.symphony.bdk.core.config.exceptions
to avoid many types of exceptions in a single packages
Add a condition in BdkConfigParser#parse to check if invalid YAML config is parsed to a single
text node.