Skip to content

Commit

Permalink
Improve log message to identify profile's link (#3568)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtng authored Apr 22, 2023
1 parent 7cf0901 commit bff92e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public ScriptProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback, Pr

if (toItemScript.isBlank() && toHandlerScript.isBlank()) {
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;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
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.ProfileContext;
import org.openhab.core.thing.profiles.ProfileTypeUID;
Expand Down Expand Up @@ -70,6 +72,9 @@ public void setUp() throws TransformationException {
public void testScriptNotExecutedAndNoValueForwardedToCallbackIfNoScriptDefined() throws TransformationException {
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);

ScriptProfile scriptProfile = new ScriptProfile(mock(ProfileTypeUID.class), profileCallback, profileContext,
Expand All @@ -85,7 +90,8 @@ public void testScriptNotExecutedAndNoValueForwardedToCallbackIfNoScriptDefined(
verify(profileCallback, never()).sendCommand(any());

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
Expand Down

0 comments on commit bff92e0

Please sign in to comment.