Search in sources :

Example 46 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project nifi by apache.

the class TestJettyWebSocketServer method testValidationRequiredProperties.

@Test
public void testValidationRequiredProperties() throws Exception {
    final JettyWebSocketServer service = new JettyWebSocketServer();
    final ControllerServiceTestContext context = new ControllerServiceTestContext(service, "service-id");
    service.initialize(context.getInitializationContext());
    final Collection<ValidationResult> results = service.validate(context.getValidationContext());
    assertEquals(1, results.size());
    final ValidationResult result = results.iterator().next();
    assertEquals(JettyWebSocketServer.LISTEN_PORT.getDisplayName(), result.getSubject());
}
Also used : ValidationResult(org.apache.nifi.components.ValidationResult) Test(org.junit.Test)

Example 47 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project nifi by apache.

the class TestCSVValidators method testSingleCharTab.

@Test
public void testSingleCharTab() {
    CSVValidators.SingleCharacterValidator validator = new CSVValidators.SingleCharacterValidator();
    ValidationContext mockContext = Mockito.mock(ValidationContext.class);
    ValidationResult result = validator.validate("EscapeChar", "\\t", mockContext);
    assertTrue(result.isValid());
}
Also used : ValidationResult(org.apache.nifi.components.ValidationResult) ValidationContext(org.apache.nifi.components.ValidationContext) Test(org.junit.Test)

Example 48 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project nifi by apache.

the class TestCSVValidators method testUnescapedSingleCharGoodChar.

@Test
public void testUnescapedSingleCharGoodChar() {
    Validator validator = CSVValidators.UNESCAPED_SINGLE_CHAR_VALIDATOR;
    ValidationContext mockContext = Mockito.mock(ValidationContext.class);
    ValidationResult result = validator.validate("Delimiter", ",", mockContext);
    assertTrue(result.isValid());
}
Also used : ValidationResult(org.apache.nifi.components.ValidationResult) Validator(org.apache.nifi.components.Validator) ValidationContext(org.apache.nifi.components.ValidationContext) Test(org.junit.Test)

Example 49 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project nifi by apache.

the class TestCSVValidators method testUnescapedSingleCharUnicodeChar.

@Test
public void testUnescapedSingleCharUnicodeChar() {
    Validator validator = CSVValidators.UNESCAPED_SINGLE_CHAR_VALIDATOR;
    ValidationContext mockContext = Mockito.mock(ValidationContext.class);
    ValidationResult result = validator.validate("Delimiter", "\\u0001", mockContext);
    assertTrue(result.isValid());
}
Also used : ValidationResult(org.apache.nifi.components.ValidationResult) Validator(org.apache.nifi.components.Validator) ValidationContext(org.apache.nifi.components.ValidationContext) Test(org.junit.Test)

Example 50 with ValidationResult

use of org.apache.nifi.components.ValidationResult in project nifi by apache.

the class TestCSVValidators method testSingleCharIllegalChar.

@Test
public void testSingleCharIllegalChar() {
    CSVValidators.SingleCharacterValidator validator = new CSVValidators.SingleCharacterValidator();
    ValidationContext mockContext = Mockito.mock(ValidationContext.class);
    ValidationResult result = validator.validate("EscapeChar", "\\r", mockContext);
    assertEquals("\\r is not a valid character for this property", result.getExplanation());
    assertFalse(result.isValid());
}
Also used : ValidationResult(org.apache.nifi.components.ValidationResult) ValidationContext(org.apache.nifi.components.ValidationContext) Test(org.junit.Test)

Aggregations

ValidationResult (org.apache.nifi.components.ValidationResult)179 Test (org.junit.Test)80 ArrayList (java.util.ArrayList)64 TestRunner (org.apache.nifi.util.TestRunner)46 ValidationContext (org.apache.nifi.components.ValidationContext)37 MockProcessContext (org.apache.nifi.util.MockProcessContext)26 TdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.api.TdchConnectionService)23 Validator (org.apache.nifi.components.Validator)21 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)20 DevTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DevTdchConnectionService)18 DummyTdchConnectionService (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.controllerservice.DummyTdchConnectionService)18 HashSet (java.util.HashSet)18 ProcessContext (org.apache.nifi.processor.ProcessContext)15 File (java.io.File)12 HashMap (java.util.HashMap)12 Collection (java.util.Collection)11 SSLContextService (org.apache.nifi.ssl.SSLContextService)11 Map (java.util.Map)10 List (java.util.List)9 ComponentLog (org.apache.nifi.logging.ComponentLog)9