forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[miio] Implement alternative MiIoQuantityTypes (openhab#9203)
* [miio] Implement alternative MiIoQuantityTypes * Improved way avoiding multiple entries for Unit * Test cases for the MiIoQuantityTypes class * Apply suggestions from code review Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com> Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
- Loading branch information
Showing
2 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...b.binding.miio/src/test/java/org/openhab/binding/miio/internal/MiIoQuantityTypesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2010-2020 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miio.internal; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static tec.uom.se.unit.Units.SQUARE_METRE; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.junit.jupiter.api.Test; | ||
import org.openhab.core.library.unit.SmartHomeUnits; | ||
|
||
/** | ||
* Test case for {@link MiIoQuantityTypes} | ||
* | ||
* @author Marcel Verpaalen - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class MiIoQuantityTypesTest { | ||
|
||
@Test | ||
public void UnknownUnitTest() { | ||
|
||
String unitName = "some none existent unit"; | ||
assertNull(MiIoQuantiyTypes.get(unitName)); | ||
} | ||
|
||
@Test | ||
public void regularsUnitTest() { | ||
|
||
String unitName = "minute"; | ||
assertEquals(SmartHomeUnits.MINUTE, MiIoQuantiyTypes.get(unitName)); | ||
|
||
unitName = "Minute"; | ||
assertEquals(SmartHomeUnits.MINUTE, MiIoQuantiyTypes.get(unitName)); | ||
} | ||
|
||
@Test | ||
public void aliasUnitsTest() { | ||
|
||
String unitName = "square_meter"; | ||
assertEquals(SQUARE_METRE, MiIoQuantiyTypes.get(unitName)); | ||
|
||
unitName = "Square_meter"; | ||
assertEquals(SQUARE_METRE, MiIoQuantiyTypes.get(unitName)); | ||
|
||
unitName = "squaremeter"; | ||
assertEquals(SQUARE_METRE, MiIoQuantiyTypes.get(unitName)); | ||
} | ||
} |