Merge pull request #8425 from YevhenBondarenko/fix/log-node
fexed NPE in log node
This commit is contained in:
commit
b6efa77605
@ -92,12 +92,14 @@ public class TbLogNode implements TbNode {
|
||||
boolean isStandard(TbLogNodeConfiguration conf) {
|
||||
Objects.requireNonNull(conf, "node config is null");
|
||||
final TbLogNodeConfiguration defaultConfig = new TbLogNodeConfiguration().defaultConfiguration();
|
||||
switch (conf.getScriptLang()) {
|
||||
case JS: return defaultConfig.getJsScript().equals(conf.getJsScript());
|
||||
case TBEL: return defaultConfig.getTbelScript().equals(conf.getTbelScript());
|
||||
default:
|
||||
log.warn("No rule to define isStandard script for script language [{}], assuming that is non-standard", conf.getScriptLang());
|
||||
return false;
|
||||
|
||||
if (conf.getScriptLang() == null || conf.getScriptLang().equals(ScriptLanguage.JS)) {
|
||||
return defaultConfig.getJsScript().equals(conf.getJsScript());
|
||||
} else if (conf.getScriptLang().equals(ScriptLanguage.TBEL)) {
|
||||
return defaultConfig.getTbelScript().equals(conf.getTbelScript());
|
||||
} else {
|
||||
log.warn("No rule to define isStandard script for script language [{}], assuming that is non-standard", conf.getScriptLang());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -110,6 +110,19 @@ public class TbLogNodeTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void backwardCompatibility_whenScriptLangIsNull() throws TbNodeException {
|
||||
TbLogNodeConfiguration config = new TbLogNodeConfiguration().defaultConfiguration();
|
||||
TbLogNode node = spy(new TbLogNode());
|
||||
TbNodeConfiguration tbNodeConfiguration = new TbNodeConfiguration(JacksonUtil.valueToTree(config));
|
||||
TbContext ctx = mock(TbContext.class);
|
||||
node.init(ctx, tbNodeConfiguration);
|
||||
|
||||
assertThat(node.isStandard(config)).as("Script is standard for language JS").isTrue();
|
||||
verify(node, never()).createScriptEngine(any(), any());
|
||||
verify(ctx, never()).createScriptEngine(any(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenScriptEngineEnum_whenNewAdded_thenFailed() {
|
||||
assertThat(ScriptLanguage.values().length).as("only two ScriptLanguage supported").isEqualTo(2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user