@Test
public void getDefaultWidgetsForNumberItem() {

    // NumberItem without CommandOptions or StateOptions should return Text element
    Widget defaultWidget = uiRegistry.getDefaultWidget(NumberItem.class, ITEM_NAME);
    assertThat(defaultWidget, is(instanceOf(Text.class)));
    // NumberItem with one to four CommandOptions should return Switch element
    final CommandDescriptionBuilder builder = CommandDescriptionBuilder.create()
            .withCommandOptions(Stream
                    .of(new CommandOption("command1", "label1"), new CommandOption("command2", "label2"),
                            new CommandOption("command3", "label3"), new CommandOption("command4", "label4"))
                    .collect(Collectors.toList()));
    when(item.getCommandDescription()).thenReturn(builder.build());
    defaultWidget = uiRegistry.getDefaultWidget(NumberItem.class, ITEM_NAME);
    assertThat(defaultWidget, is(instanceOf(Switch.class)));
    // NumberItem with more than four CommandOptions should return Selection element
    builder.withCommandOption(new CommandOption("command5", "label5"));
    when(item.getCommandDescription()).thenReturn(builder.build());
    defaultWidget = uiRegistry.getDefaultWidget(NumberItem.class, ITEM_NAME);
    assertThat(defaultWidget, is(instanceOf(Selection.class)));
    // NumberItem with one or more StateOptions should return Selection element
    when(item.getStateDescription()).thenReturn(StateDescriptionFragmentBuilder.create()
            .withOption(new StateOption("value", "label")).build().toStateDescription());
    defaultWidget = uiRegistry.getDefaultWidget(NumberItem.class, ITEM_NAME);
    assertThat(defaultWidget, is(instanceOf(Selection.class)));
}