use of org.apache.nifi.reporting.AbstractSiteToSiteReportingTask.NiFiUrlValidator in project nifi by apache.
the class TestSiteToSiteBulletinReportingTask method testUrls.
@Test
public void testUrls() throws IOException {
final ValidationContext context = Mockito.mock(ValidationContext.class);
Mockito.when(context.newPropertyValue(Mockito.anyString())).then(new Answer<PropertyValue>() {
@Override
public PropertyValue answer(InvocationOnMock invocation) throws Throwable {
String value = (String) invocation.getArguments()[0];
return new StandardPropertyValue(value, null);
}
});
assertTrue(new NiFiUrlValidator().validate("url", "http://localhost:8080/nifi", context).isValid());
assertTrue(new NiFiUrlValidator().validate("url", "http://localhost:8080", context).isValid());
assertFalse(new NiFiUrlValidator().validate("url", "", context).isValid());
assertTrue(new NiFiUrlValidator().validate("url", "https://localhost:8080/nifi", context).isValid());
assertTrue(new NiFiUrlValidator().validate("url", "https://localhost:8080/nifi,https://localhost:8080/nifi", context).isValid());
assertTrue(new NiFiUrlValidator().validate("url", "https://localhost:8080/nifi, https://localhost:8080/nifi", context).isValid());
assertFalse(new NiFiUrlValidator().validate("url", "http://localhost:8080/nifi, https://localhost:8080/nifi", context).isValid());
assertTrue(new NiFiUrlValidator().validate("url", "http://localhost:8080/nifi,http://localhost:8080/nifi", context).isValid());
assertTrue(new NiFiUrlValidator().validate("url", "http://localhost:8080/nifi,http://localhost:8080", context).isValid());
}
Aggregations