use of org.apache.nifi.util.MockReportingContext in project nifi by apache.
the class MetricsReportingTaskTest method setUp.
/**
* Set up the test environment and mock behaviour. This includes registering {@link #reporterServiceStub} in the
* different contexts, overriding {@link MetricsReportingTask#currentStatusReference} and instantiating the test
* subject.
*/
@Before
public void setUp() throws Exception {
Map<String, ControllerService> services = new HashMap<>();
services.put(REPORTER_SERVICE_IDENTIFIER, reporterServiceStub);
testedReportingTask = new MetricsReportingTask();
reportingContextStub = new MockReportingContext(services, new MockStateManager(testedReportingTask), new MockVariableRegistry());
rootGroupStatus = new ProcessGroupStatus();
innerGroupStatus = new ProcessGroupStatus();
when(reporterServiceStub.createReporter(any())).thenReturn(reporterMock);
when(reporterServiceStub.getIdentifier()).thenReturn(REPORTER_SERVICE_IDENTIFIER);
reportingContextStub.setProperty(MetricsReportingTask.REPORTER_SERVICE.getName(), REPORTER_SERVICE_IDENTIFIER);
reportingContextStub.addControllerService(reporterServiceStub, REPORTER_SERVICE_IDENTIFIER);
configurationContextStub = new MockConfigurationContext(reportingContextStub.getProperties(), reportingContextStub.getControllerServiceLookup());
reportingInitContextStub = new MockReportingInitializationContext(TEST_INIT_CONTEXT_ID, TEST_INIT_CONTEXT_NAME, new MockComponentLog(TEST_TASK_ID, testedReportingTask));
}
Aggregations