diff --git a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java index 5ca6b448..5bce87c7 100644 --- a/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java +++ b/custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java @@ -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; @@ -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); @@ -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 files) { + private File[] listFilesForFolder(File folder, List files) { for (File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) { listFilesForFolder(fileEntry, files); diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/invalidItemType/src/main/resources/OH-INF/thing/thing-types.xml b/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/invalidItemType/src/main/resources/OH-INF/thing/thing-types.xml new file mode 100644 index 00000000..8f08f81c --- /dev/null +++ b/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/invalidItemType/src/main/resources/OH-INF/thing/thing-types.xml @@ -0,0 +1,20 @@ + + + + + + Some sample description + + + + + + + Invalid + + Test + + + diff --git a/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/validThingTypeXml/src/main/resources/OH-INF/thing/thing-types.xml b/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/validThingTypeXml/src/main/resources/OH-INF/thing/thing-types.xml index 4cfdf302..71f5c743 100644 --- a/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/validThingTypeXml/src/main/resources/OH-INF/thing/thing-types.xml +++ b/custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/validThingTypeXml/src/main/resources/OH-INF/thing/thing-types.xml @@ -12,7 +12,7 @@ - Text + Number:Energy Test