Search in sources :

Example 11 with StringType

use of org.eclipse.smarthome.core.library.types.StringType in project smarthome by eclipse.

the class ItemUIRegistryImplTest method getLabel_labelWithStringValue.

@Test
public void getLabel_labelWithStringValue() throws ItemNotFoundException {
    String testLabel = "Label [%s]";
    when(widget.getLabel()).thenReturn(testLabel);
    when(item.getState()).thenReturn(new StringType("State"));
    String label = uiRegistry.getLabel(widget);
    assertEquals("Label [State]", label);
}
Also used : StringType(org.eclipse.smarthome.core.library.types.StringType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 12 with StringType

use of org.eclipse.smarthome.core.library.types.StringType in project smarthome by eclipse.

the class ItemUIRegistryImplTest method getLabel_labelWithEmptyPattern.

@Test
public void getLabel_labelWithEmptyPattern() throws ItemNotFoundException {
    String testLabel = "Label []";
    StateDescription stateDescription = mock(StateDescription.class);
    when(widget.getLabel()).thenReturn(testLabel);
    when(item.getStateDescription()).thenReturn(stateDescription);
    when(stateDescription.getPattern()).thenReturn("%s");
    when(item.getState()).thenReturn(new StringType("State"));
    String label = uiRegistry.getLabel(widget);
    assertEquals("Label", label);
}
Also used : StringType(org.eclipse.smarthome.core.library.types.StringType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StateDescription(org.eclipse.smarthome.core.types.StateDescription) Test(org.junit.Test)

Example 13 with StringType

use of org.eclipse.smarthome.core.library.types.StringType in project smarthome by eclipse.

the class ItemUIRegistryImplTest method getLabel_labelWithFunctionValue.

@Test
public void getLabel_labelWithFunctionValue() throws ItemNotFoundException {
    String testLabel = "Label [MAP(de.map):%s]";
    when(widget.getLabel()).thenReturn(testLabel);
    when(item.getState()).thenReturn(new StringType("State"));
    String label = uiRegistry.getLabel(widget);
    assertEquals("Label [State]", label);
}
Also used : StringType(org.eclipse.smarthome.core.library.types.StringType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 14 with StringType

use of org.eclipse.smarthome.core.library.types.StringType in project smarthome by eclipse.

the class ItemUIRegistryImplTest method getLabel_labelWithoutPatternInStateDescription.

@Test
public void getLabel_labelWithoutPatternInStateDescription() throws ItemNotFoundException {
    String testLabel = "Label";
    StateDescription stateDescription = mock(StateDescription.class);
    when(widget.getLabel()).thenReturn(testLabel);
    when(item.getStateDescription()).thenReturn(stateDescription);
    when(stateDescription.getPattern()).thenReturn(null);
    when(item.getState()).thenReturn(new StringType("State"));
    String label = uiRegistry.getLabel(widget);
    assertEquals("Label", label);
}
Also used : StringType(org.eclipse.smarthome.core.library.types.StringType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StateDescription(org.eclipse.smarthome.core.types.StateDescription) Test(org.junit.Test)

Example 15 with StringType

use of org.eclipse.smarthome.core.library.types.StringType in project smarthome by eclipse.

the class ItemUIRegistryImplTest method getLabel_itemNotFound.

@Test
public void getLabel_itemNotFound() throws ItemNotFoundException {
    String testLabel = "Label [%s]";
    when(widget.getLabel()).thenReturn(testLabel);
    when(widget.eClass()).thenReturn(SitemapFactory.eINSTANCE.createText().eClass());
    when(registry.getItem("Item")).thenThrow(new ItemNotFoundException("Item"));
    when(item.getState()).thenReturn(new StringType("State"));
    String label = uiRegistry.getLabel(widget);
    assertEquals("Label [-]", label);
}
Also used : StringType(org.eclipse.smarthome.core.library.types.StringType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ItemNotFoundException(org.eclipse.smarthome.core.items.ItemNotFoundException) Test(org.junit.Test)

Aggregations

StringType (org.eclipse.smarthome.core.library.types.StringType)43 State (org.eclipse.smarthome.core.types.State)13 Test (org.junit.Test)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)9 PercentType (org.eclipse.smarthome.core.library.types.PercentType)8 StateDescription (org.eclipse.smarthome.core.types.StateDescription)6 SonosEntry (org.eclipse.smarthome.binding.sonos.internal.SonosEntry)5 DateTimeType (org.eclipse.smarthome.core.library.types.DateTimeType)5 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)5 Date (java.util.Date)3 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)3 RefreshType (org.eclipse.smarthome.core.types.RefreshType)3 ArrayList (java.util.ArrayList)2 SensorEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum)2 DeviceStateUpdateImpl (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)2 Event (org.eclipse.smarthome.core.events.Event)2 Item (org.eclipse.smarthome.core.items.Item)2 ItemNotFoundException (org.eclipse.smarthome.core.items.ItemNotFoundException)2 ColorItem (org.eclipse.smarthome.core.library.items.ColorItem)2