@Test public void testHasOpNonStringExpression() { FormValidation validation = testValidator.validateFilterExpression("VersionCounter has 1"); assertEquals( "Invalid if has operator used with number", FormValidation.Kind.WARNING, validation.kind); validation = testValidator.validateFilterExpression("VersionCounter has True"); assertEquals( "Invalid if has operator used with boolean", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testMissingQuoteExpression() { FormValidation validation = testValidator.validateFilterExpression("Name = 'test"); assertEquals( "Invalid if closing quotation mark is missing", FormValidation.Kind.WARNING, validation.kind); validation = testValidator.validateFilterExpression("Name = test\""); assertEquals( "Invalid if opening quotation mark is missing", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testRelOpNotNumberExpression() { FormValidation validation = testValidator.validateFilterExpression("Name > 'test'"); assertEquals( "Invalid if relational operator used with string", FormValidation.Kind.WARNING, validation.kind); validation = testValidator.validateFilterExpression("VersionCounter >= False'"); assertEquals( "Invalid if relational operator used with boolean", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testSingleQuotedExpression() { final FormValidation validation = testValidator.validateFilterExpression("'Test Comment' = 'test'"); assertEquals( "Valid if single quotes used with string", FormValidation.Kind.OK, validation.kind); }
@Test public void testEqualsOpNumberExpression() { final FormValidation validation = testValidator.validateFilterExpression("'Estimated Duration [min]'=1"); assertEquals( "Valid if equals operator used with number", FormValidation.Kind.OK, validation.kind); }
@Test public void testInvalidParameterName() { final FormValidation validation = testValidator.validateParameterName("123param"); assertEquals( "Invalid parameter name starts with non-letter char", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testMissingBracketExpression() { final FormValidation validation = testValidator.validateFilterExpression("(Name='test'"); assertEquals( "Error if bracket missing in filter expression", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testValidComplexExpression() { final FormValidation validation = testValidator.validateFilterExpression( "(Name=\"test\" and (Status='FAILED' or 'Test Comment' has 't?st*') " + "or 'Execution Priority'>=1 and VersionCounter=True)"); assertEquals("Valid complex filter expression", FormValidation.Kind.OK, validation.kind); }
@Test public void testInvalidConstantName() { final FormValidation validation = testValidator.validateGlobalConstantName("123constant"); assertEquals( "Invalid global constant name starts with non-letter char", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testInvalidAlphanumericConstantName() { final FormValidation validation = testValidator.validateGlobalConstantName("!constant123"); assertEquals( "Error if global constant name is not alphanumeric", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testValidConstantValue() { final FormValidation validation = testValidator.validateGlobalConstantValue("value"); assertEquals( "Valid global constant value starts with a letter char", FormValidation.Kind.OK, validation.kind); }
@Test public void testParameterizedConstantValue() { final FormValidation validation = testValidator.validateGlobalConstantValue("${VALUE}"); assertEquals( "Warning if parameterized global constant value", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testMissingLogicOperatorExpression() { final FormValidation validation = testValidator.validateFilterExpression("Name='test' Status='FAILED'"); assertEquals( "Error if logical operator missing in filter expression", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testRelOpNumberExpression() { FormValidation validation = testValidator.validateFilterExpression("VersionCounter < 1"); assertEquals( "Valid if less than operator used with number", FormValidation.Kind.OK, validation.kind); validation = testValidator.validateFilterExpression("VersionCounter > 1"); assertEquals( "Valid if greater than operator used with number", FormValidation.Kind.OK, validation.kind); validation = testValidator.validateFilterExpression("VersionCounter <= 1"); assertEquals( "Valid if less than equals operator used with number", FormValidation.Kind.OK, validation.kind); validation = testValidator.validateFilterExpression("VersionCounter >= 1"); assertEquals( "Valid if greater than equals operator used with number", FormValidation.Kind.OK, validation.kind); }
@Test public void testNullParameterValue() { final FormValidation validation = testValidator.validateParameterValue(null); assertEquals("Error if empty parameter value", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testDoubleQuotedExpression() { final FormValidation validation = testValidator.validateFilterExpression("Name = \"test\""); assertEquals( "Valid if double quotes used with string", FormValidation.Kind.OK, validation.kind); }
@Test public void testNullConstantValue() { final FormValidation validation = testValidator.validateGlobalConstantValue(null); assertEquals( "Error if empty global constant value", FormValidation.Kind.ERROR, validation.kind); }
// Validation of global constants parameters @Test public void testEmptyConstantName() { final FormValidation validation = testValidator.validateGlobalConstantName(""); assertEquals("Error if empty global constant name", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testBooleanFilterExpression() { final FormValidation validation = testValidator.validateFilterExpression("VersionCounter=True"); assertEquals("Valid boolean filter expression", FormValidation.Kind.OK, validation.kind); }
@Test public void testNumericFilterExpression() { final FormValidation validation = testValidator.validateFilterExpression("'Estimated Duration [min]'=1"); assertEquals("Valid numeric filter expression", FormValidation.Kind.OK, validation.kind); }
@Test public void testNullProjectFile() { final FormValidation validation = testValidator.validateProjectFile(null); assertEquals("Error if project file not defined", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testInvalidPackageFile() { final FormValidation validation = testValidator.validatePackageFile("test"); assertEquals("Error if invalid package file", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testInvalidExpression() { final FormValidation validation = testValidator.validateFilterExpression("invalid filter"); assertEquals( "Error if invalid filter expression", FormValidation.Kind.WARNING, validation.kind); }
// Validation of package parameters @Test public void testEmptyParameterName() { final FormValidation validation = testValidator.validateParameterName(""); assertEquals("Error if empty parameter name", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testValidPackageFile() { final FormValidation validation = testValidator.validatePackageFile("test.pkg"); assertEquals("Valid package file has .pkg extension", FormValidation.Kind.OK, validation.kind); }
@Test public void testParameterizedParameterValue() { final FormValidation validation = testValidator.validateParameterValue("${VALUE}"); assertEquals( "Warning if parameterized parameter value", FormValidation.Kind.WARNING, validation.kind); }
// Validation of project file @Test public void testEmptyProjectFile() { final FormValidation validation = testValidator.validateProjectFile(""); assertEquals("Error if empty project file", FormValidation.Kind.ERROR, validation.kind); }
@Test public void testValidParameterValue() { final FormValidation validation = testValidator.validateParameterValue("value"); assertEquals( "Valid parameter value starts with a letter char", FormValidation.Kind.OK, validation.kind); }
@Test public void testParameterizedProjectFile() { final FormValidation validation = testValidator.validateProjectFile("${TEST}"); assertEquals( "Warning if parameterized project file", FormValidation.Kind.WARNING, validation.kind); }
@Test public void testHasnotOpStringExpression() { final FormValidation validation = testValidator.validateFilterExpression("Name hasnot 'test'"); assertEquals( "Valid if hasnot operator used with string", FormValidation.Kind.OK, validation.kind); }