@Test public void testValidationRecordFormatNoRecordWriter() throws IOException { ValidationContext validationContext = Mockito.mock(ValidationContext.class); final String urlEL = "http: final String url = "http: final MockSiteToSiteMetricsReportingTask task = new MockSiteToSiteMetricsReportingTask(); Map<PropertyDescriptor, String> properties = new HashMap<>(); for (final PropertyDescriptor descriptor : task.getSupportedPropertyDescriptors()) { properties.put(descriptor, descriptor.getDefaultValue()); } properties.put(SiteToSiteMetricsReportingTask.FORMAT, SiteToSiteMetricsReportingTask.RECORD_FORMAT.getValue()); properties.put(SiteToSiteMetricsReportingTask.DESTINATION_URL, url); properties.put(SiteToSiteMetricsReportingTask.INSTANCE_URL, url); properties.put(SiteToSiteMetricsReportingTask.PORT_NAME, "port"); final PropertyValue pValueUrl = Mockito.mock(StandardPropertyValue.class); Mockito.when(validationContext.newPropertyValue(url)).thenReturn(pValueUrl); Mockito.when(validationContext.newPropertyValue(urlEL)).thenReturn(pValueUrl); Mockito.when(pValueUrl.evaluateAttributeExpressions()).thenReturn(pValueUrl); Mockito.when(pValueUrl.getValue()).thenReturn(url); Mockito.doAnswer(new Answer<PropertyValue>() { @Override public PropertyValue answer(final InvocationOnMock invocation) throws Throwable { final PropertyDescriptor descriptor = invocation.getArgumentAt(0, PropertyDescriptor.class); return new MockPropertyValue(properties.get(descriptor)); } }).when(validationContext).getProperty(Mockito.any(PropertyDescriptor.class)); final PropertyValue pValue = Mockito.mock(StandardPropertyValue.class); Mockito.when(validationContext.getProperty(MockSiteToSiteMetricsReportingTask.RECORD_WRITER)).thenReturn(pValue); Mockito.when(pValue.isSet()).thenReturn(false); Collection<ValidationResult> list = task.validate(validationContext); Assert.assertEquals(1, list.size()); Assert.assertEquals(SiteToSiteMetricsReportingTask.RECORD_WRITER.getDisplayName(), list.iterator().next().getInput()); }
@Override protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors()); properties.add(HOSTNAME); properties.add(APPLICATION_ID); properties.add(FORMAT); properties.remove(BATCH_SIZE); return properties; }
SiteToSiteMetricsReportingTask extends AbstractSiteToSiteReportingTask { @Override protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors()); properties.add(HOSTNAME); properties.add(APPLICATION_ID); properties.add(FORMAT); properties.remove(BATCH_SIZE); return properties; } }
SiteToSiteMetricsReportingTask extends AbstractSiteToSiteReportingTask { @Override protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors()); properties.add(HOSTNAME); properties.add(APPLICATION_ID); properties.add(FORMAT); properties.remove(BATCH_SIZE); return properties; } SiteToSiteMetricsReportingTask(); }
SiteToSiteMetricsReportingTask extends AbstractSiteToSiteReportingTask { @Override protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors()); properties.add(HOSTNAME); properties.add(APPLICATION_ID); properties.add(FORMAT); properties.remove(BATCH_SIZE); return properties; } SiteToSiteMetricsReportingTask(); @Override void onTrigger(final ReportingContext context); }
SiteToSiteMetricsReportingTask extends AbstractSiteToSiteReportingTask { @Override protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors()); properties.add(HOSTNAME); properties.add(APPLICATION_ID); properties.add(FORMAT); properties.remove(BATCH_SIZE); return properties; } SiteToSiteMetricsReportingTask(); @Override void onTrigger(final ReportingContext context);  }