use of org.eclipse.smarthome.core.service.CommandDescriptionService in project smarthome by eclipse.
the class GenericItemTest method testCommandDescriptionWithLocale.
@Test
public void testCommandDescriptionWithLocale() {
TestItem item = new TestItem("test");
CommandDescriptionService commandDescriptionService = mock(CommandDescriptionService.class);
when(commandDescriptionService.getCommandDescription(eq("test"), any(Locale.class))).thenReturn(new CommandDescription() {
@Override
@NonNull
public List<@NonNull CommandOption> getCommandOptions() {
return Arrays.asList(new CommandOption("C1", "Command 1"), new CommandOption("C2", "Command 2"), new CommandOption("C3", "Command 3"));
}
});
item.setCommandDescriptionService(commandDescriptionService);
assertThat(item.getCommandDescription(Locale.getDefault()).getCommandOptions(), hasSize(3));
}
use of org.eclipse.smarthome.core.service.CommandDescriptionService in project smarthome by eclipse.
the class GenericItemTest method testCommandDescription.
@Test
public void testCommandDescription() {
TestItem item = new TestItem("test");
CommandDescriptionService commandDescriptionService = mock(CommandDescriptionService.class);
when(commandDescriptionService.getCommandDescription("test", null)).thenReturn(new CommandDescription() {
@Override
@NonNull
public List<@NonNull CommandOption> getCommandOptions() {
return Arrays.asList(new CommandOption("ALERT", "Alert"), new CommandOption("REBOOT", "Reboot"));
}
});
item.setCommandDescriptionService(commandDescriptionService);
assertThat(item.getCommandDescription().getCommandOptions(), hasSize(2));
}
use of org.eclipse.smarthome.core.service.CommandDescriptionService in project smarthome by eclipse.
the class ItemRegistryImplTest method assertCommandDescriptionServiceGetsRemoved.
@Test
public void assertCommandDescriptionServiceGetsRemoved() {
CommandDescriptionService commandDescriptionService = mock(CommandDescriptionService.class);
((ItemRegistryImpl) itemRegistry).setCommandDescriptionService(commandDescriptionService);
GenericItem item = spy(new SwitchItem("Item1"));
itemProvider.add(item);
verify(item).setCommandDescriptionService(any(CommandDescriptionService.class));
((ItemRegistryImpl) itemRegistry).unsetCommandDescriptionService(commandDescriptionService);
verify(item).setCommandDescriptionService(null);
}
Aggregations