@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void yesEnvironment() {
when(configurationHolder.isInitialized()).thenReturn(true);
when(configurationHolder.getAgentConfiguration()).thenReturn(updateConfiguration);
doReturn(Collections.singletonList(classType)).when(instrumentationService).addInstrumentationPoints(any(AgentConfig.class), any(Collection.class));
job.setEnvironment(updateEnvironment);
job.run();
verify(instrumentationService, times(1)).removeInstrumentationPoints();
verify(configurationHolder, times(1)).update(updateEnvironment, PLATFORM_ID);
Collection<IInstrumentationApplier> appliers = configurationHolder.getInstrumentationAppliers();
verify(instrumentationService, times(1)).addInstrumentationPoints(updateConfiguration, appliers);
ArgumentCaptor<Collection> typeCaptor = ArgumentCaptor.forClass(Collection.class);
verify(instrumentationService).getInstrumentationResults(typeCaptor.capture());
assertThat((Collection<Type>) typeCaptor.getValue(), hasItems((Type) classType));
verify(eventPublisher).publishEvent(any(ClassInstrumentationChangedEvent.class));
verifyNoMoreInteractions(instrumentationService, updateConfiguration, updateEnvironment, eventPublisher);
}
}