    @Test
    public void testOnTrigger() throws InitializationException {

        final String metricsUrl = "http://localhost:9091";
        final String applicationId = "nifi";
        final String hostName = "localhost";
        final String jobName = "nifi_reporting_job";
        final boolean jvmMetrics = true;
        final boolean authentication = false;

        // create the jersey client mocks for handling the post
        final Client client = Mockito.mock(Client.class);
        final WebTarget target = Mockito.mock(WebTarget.class);
        final Invocation.Builder builder = Mockito.mock(Invocation.Builder.class);

        final Response response = Mockito.mock(Response.class);
        Mockito.when(response.getStatus()).thenReturn(200);

        Mockito.when(client.target(metricsUrl)).thenReturn(target);
        Mockito.when(target.request()).thenReturn(builder);
        Mockito.when(builder.post(Matchers.any(Entity.class))).thenReturn(response);

        // mock the ReportingInitializationContext for initialize(...)
        final ComponentLog logger = Mockito.mock(ComponentLog.class);
        final ReportingInitializationContext initContext = Mockito.mock(ReportingInitializationContext.class);
        Mockito.when(initContext.getIdentifier()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(initContext.getLogger()).thenReturn(logger);


        // mock the ReportingContext for onTrigger(...)
        final ReportingContext context = Mockito.mock(ReportingContext.class);
        Mockito.when(context.getProperty(PrometheusReportingTask.METRICS_COLLECTOR_URL))
                .thenReturn(new MockPropertyValue(metricsUrl));
        Mockito.when(context.getProperty(PrometheusReportingTask.APPLICATION_ID))
                .thenReturn(new MockPropertyValue(applicationId));
        Mockito.when(context.getProperty(PrometheusReportingTask.INSTANCE_ID))
                .thenReturn(new MockPropertyValue(hostName));
        Mockito.when(context.getProperty(PrometheusReportingTask.PROCESS_GROUP_IDS))
                .thenReturn(new MockPropertyValue("1234"));
        Mockito.when(context.getProperty(PrometheusReportingTask.JOB_NAME))
                .thenReturn(new MockPropertyValue(jobName));
        Mockito.when(context.getProperty(PrometheusReportingTask.SEND_JVM_METRICS))
                .thenReturn(new MockPropertyValue(Boolean.toString(jvmMetrics)));
        Mockito.when(context.getProperty(PrometheusReportingTask.USE_AUTHENTICATION))
                .thenReturn(new MockPropertyValue(Boolean.toString(authentication)));

        final EventAccess eventAccess = Mockito.mock(EventAccess.class);
        Mockito.when(context.getEventAccess()).thenReturn(eventAccess);
        Mockito.when(eventAccess.getControllerStatus()).thenReturn(status);
        Mockito.when(eventAccess.getGroupStatus("1234")).thenReturn(status);

        // create a testable instance of the reporting task
        final PrometheusReportingTask task = new PrometheusReportingTask();
        task.initialize(initContext);
        task.onTrigger(context);
    }