Package org.openhab.core.library.types

Examples of org.openhab.core.library.types.DecimalType


      maxValue = BigDecimal.valueOf(100);
    }

    // if the current state is a valid value, we calculate the up and down step values
    if(state instanceof DecimalType) {
      DecimalType actState = (DecimalType) state;
      BigDecimal newLower = actState.toBigDecimal().subtract(step);
      BigDecimal newHigher = actState.toBigDecimal().add(step);
      if(newLower.compareTo(minValue) < 0) {
        newLower = minValue;
      }
      if(newHigher.compareTo(maxValue) > 0) {
        newHigher = maxValue;
View Full Code Here


          return new Date(year-1900, 0, 1);
        }
       
        @Override
        public State getState() {
          return new DecimalType(year);
        }
       
        @Override
        public String getName() {
          return "Test";
View Full Code Here

    assertEquals("2000", historicItem.getState().toString());
  }

  @Test
  public void testMinimumSince() {
    item.setState(new DecimalType(5000));
    HistoricItem historicItem = PersistenceExtensions.minimumSince(item, new DateMidnight(1940, 1, 1), "test");
    assertNotNull(historicItem);
    assertEquals("5000", historicItem.getState().toString());
   
    historicItem = PersistenceExtensions.minimumSince(item, new DateMidnight(2005, 1, 1), "test");
View Full Code Here

    assertEquals(new DateMidnight(2005, 1, 1).toDate(), historicItem.getTimestamp());
  }

  @Test
  public void testMaximumSince() {
    item.setState(new DecimalType(1));
    HistoricItem historicItem = PersistenceExtensions.maximumSince(item, new DateMidnight(2012, 1, 1), "test");
    assertNotNull(historicItem);
    assertEquals("1", historicItem.getState().toString());
   
    historicItem = PersistenceExtensions.maximumSince(item, new DateMidnight(2005, 1, 1), "test");
View Full Code Here

    assertEquals(new DateMidnight(2012, 1, 1).toDate(), historicItem.getTimestamp());
  }

  @Test
  public void testAverageSince() {
    item.setState(new DecimalType(3025));
    DecimalType average = PersistenceExtensions.averageSince(item, new DateMidnight(2003, 1, 1), "test");
    assertEquals("2100", average.toString());
  }
View Full Code Here

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(20));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(20));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [20]", label);
  }
View Full Code Here

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(20));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(20));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [ 20]", label);
  }
View Full Code Here

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(20));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(20));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [ 14]", label);
  }
View Full Code Here

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(10f/3f));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(10f/3f));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [3" + sep + "333]", label);
  }
View Full Code Here

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(10f/3f));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(10f/3f));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [3" + sep + "3 %]", label);
  }
View Full Code Here

TOP

Related Classes of org.openhab.core.library.types.DecimalType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.