Improve log message to identify profile's link (#3568)
parent
7cf090140c
commit
bff92e0349
|
@ -76,7 +76,8 @@ public class ScriptProfile implements StateProfile {
|
||||||
|
|
||||||
if (toItemScript.isBlank() && toHandlerScript.isBlank()) {
|
if (toItemScript.isBlank() && toHandlerScript.isBlank()) {
|
||||||
logger.error(
|
logger.error(
|
||||||
"Neither 'toItem' nor 'toHandler' script defined. Profile will discard all states and commands.");
|
"Neither 'toItemScript' nor 'toHandlerScript' defined in link '{}'. Profile will discard all states and commands.",
|
||||||
|
callback.getItemChannelLink());
|
||||||
isConfigured = false;
|
isConfigured = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ import org.openhab.core.library.types.HSBType;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.library.types.PercentType;
|
import org.openhab.core.library.types.PercentType;
|
||||||
import org.openhab.core.test.java.JavaTest;
|
import org.openhab.core.test.java.JavaTest;
|
||||||
|
import org.openhab.core.thing.ChannelUID;
|
||||||
|
import org.openhab.core.thing.link.ItemChannelLink;
|
||||||
import org.openhab.core.thing.profiles.ProfileCallback;
|
import org.openhab.core.thing.profiles.ProfileCallback;
|
||||||
import org.openhab.core.thing.profiles.ProfileContext;
|
import org.openhab.core.thing.profiles.ProfileContext;
|
||||||
import org.openhab.core.thing.profiles.ProfileTypeUID;
|
import org.openhab.core.thing.profiles.ProfileTypeUID;
|
||||||
|
@ -70,6 +72,9 @@ public class ScriptProfileTest extends JavaTest {
|
||||||
public void testScriptNotExecutedAndNoValueForwardedToCallbackIfNoScriptDefined() throws TransformationException {
|
public void testScriptNotExecutedAndNoValueForwardedToCallbackIfNoScriptDefined() throws TransformationException {
|
||||||
ProfileContext profileContext = ProfileContextBuilder.create().build();
|
ProfileContext profileContext = ProfileContextBuilder.create().build();
|
||||||
|
|
||||||
|
ItemChannelLink link = new ItemChannelLink("DummyItem", new ChannelUID("foo:bar:baz:qux"));
|
||||||
|
when(profileCallback.getItemChannelLink()).thenReturn(link);
|
||||||
|
|
||||||
setupInterceptedLogger(ScriptProfile.class, LogLevel.ERROR);
|
setupInterceptedLogger(ScriptProfile.class, LogLevel.ERROR);
|
||||||
|
|
||||||
ScriptProfile scriptProfile = new ScriptProfile(mock(ProfileTypeUID.class), profileCallback, profileContext,
|
ScriptProfile scriptProfile = new ScriptProfile(mock(ProfileTypeUID.class), profileCallback, profileContext,
|
||||||
|
@ -85,7 +90,8 @@ public class ScriptProfileTest extends JavaTest {
|
||||||
verify(profileCallback, never()).sendCommand(any());
|
verify(profileCallback, never()).sendCommand(any());
|
||||||
|
|
||||||
assertLogMessage(ScriptProfile.class, LogLevel.ERROR,
|
assertLogMessage(ScriptProfile.class, LogLevel.ERROR,
|
||||||
"Neither 'toItem' nor 'toHandler' script defined. Profile will discard all states and commands.");
|
"Neither 'toItemScript' nor 'toHandlerScript' defined in link '" + link.toString()
|
||||||
|
+ "'. Profile will discard all states and commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue