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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations