Skip to content

Commit

Permalink
Fix broken build (#465)
Browse files Browse the repository at this point in the history
* Use valid item type to fix the test
* Add new test to for testing an invalid item type

Caused by openhab/website#461

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn authored Jun 15, 2024
1 parent 2dba777 commit bcdadac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -176,6 +177,26 @@ public void testInvalidConfig() throws Exception {
verifyWithPath("invalidConfig", RELATIVE_PATH_TO_CONFIG, expectedMessages);
}

@Test
public void testInvalidItemType() throws Exception {
assumeTrue(isResourceAvailable);

int lineNumber = 15;
String[] expectedMessages = generateExpectedMessages(lineNumber,
"Value Invalid is not facet-valid with respect to enumeration "
+ "[Call, Color, Contact, DateTime, Dimmer, Group, Image, Location, Number, Number:Acceleration, Number:AmountOfSubstance, "
+ "Number:Angle, Number:Area, Number:ArealDensity, Number:CatalyticActivity, Number:Currency, Number:DataAmount, "
+ "Number:DataTransferRate, Number:Density, Number:Dimensionless, Number:ElectricCapacitance, Number:ElectricCharge, "
+ "Number:ElectricConductance, Number:ElectricConductivity, Number:ElectricCurrent, Number:ElectricInductance, "
+ "Number:ElectricPotential, Number:ElectricResistance, Number:EmissionIntensity, Number:Energy, Number:EnergyPrice, "
+ "Number:Force, Number:Frequency, Number:Illuminance, Number:Intensity, Number:Length, Number:LuminousFlux, "
+ "Number:LuminousIntensity, Number:MagneticFlux, Number:MagneticFluxDensity, Number:Mass, Number:Power, Number:Pressure, "
+ "Number:RadiationDoseAbsorbed, Number:RadiationDoseEffective, Number:RadiationSpecificActivity, Number:RadioactiveActivity, "
+ "Number:SolidAngle, Number:Speed, Number:Temperature, Number:Time, Number:Volume, Number:VolumetricFlowRate, Player, "
+ "Rollershutter, String, Switch]. It must be a value from the enumeration.");
verifyWithPath("invalidItemType", RELATIVE_PATH_TO_THING, expectedMessages);
}

@Test
public void testMissingThingDescriptionsContent() throws Exception {
assumeTrue(isResourceAvailable);
Expand Down Expand Up @@ -203,7 +224,7 @@ private void verifyWithPath(String testSubDirectory, String testFilePath, String
verify(createChecker(CONFIGURATION), testFiles, directoryPath + testFilePath, expectedMessages);
}

private File[] listFilesForFolder(File folder, ArrayList<File> files) {
private File[] listFilesForFolder(File folder, List<File> files) {
for (File fileEntry : folder.listFiles()) {
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry, files);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="check" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<thing-type id="check">
<label>Sample Thing</label>
<description>Some sample description</description>
<channels>
<channel id="check" typeId="check" />
</channels>
</thing-type>

<channel-type id="check">
<item-type>Invalid</item-type>
<label>Test</label>
<description>Test</description>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</thing-type>

<channel-type id="check">
<item-type>Text</item-type>
<item-type>Number:Energy</item-type>
<label>Test</label>
<description>Test</description>
</channel-type>
Expand Down

0 comments on commit bcdadac

Please sign in to comment.