Merge pull request #8425 from YevhenBondarenko/fix/log-node
fexed NPE in log node
This commit is contained in:
commit
b6efa77605
@ -92,10 +92,12 @@ public class TbLogNode implements TbNode {
|
|||||||
boolean isStandard(TbLogNodeConfiguration conf) {
|
boolean isStandard(TbLogNodeConfiguration conf) {
|
||||||
Objects.requireNonNull(conf, "node config is null");
|
Objects.requireNonNull(conf, "node config is null");
|
||||||
final TbLogNodeConfiguration defaultConfig = new TbLogNodeConfiguration().defaultConfiguration();
|
final TbLogNodeConfiguration defaultConfig = new TbLogNodeConfiguration().defaultConfiguration();
|
||||||
switch (conf.getScriptLang()) {
|
|
||||||
case JS: return defaultConfig.getJsScript().equals(conf.getJsScript());
|
if (conf.getScriptLang() == null || conf.getScriptLang().equals(ScriptLanguage.JS)) {
|
||||||
case TBEL: return defaultConfig.getTbelScript().equals(conf.getTbelScript());
|
return defaultConfig.getJsScript().equals(conf.getJsScript());
|
||||||
default:
|
} 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());
|
log.warn("No rule to define isStandard script for script language [{}], assuming that is non-standard", conf.getScriptLang());
|
||||||
return false;
|
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
|
@Test
|
||||||
void givenScriptEngineEnum_whenNewAdded_thenFailed() {
|
void givenScriptEngineEnum_whenNewAdded_thenFailed() {
|
||||||
assertThat(ScriptLanguage.values().length).as("only two ScriptLanguage supported").isEqualTo(2);
|
assertThat(ScriptLanguage.values().length).as("only two ScriptLanguage supported").isEqualTo(2);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user