@Test
public void testRefreshWhenNoFlowMappingExists() throws FlowMapperException, IOException, FlowRetrievalException, SerializerException, FlowTransformException {

    final String className = "Test Class";
    final AtomicInteger refreshedCounter = new AtomicInteger(0);
    final FlowUri flowUri = new FlowUri("http://localhost:18080", "1234", "5678");
    when(flowMapper.getFlowMapping(className)).thenReturn(Optional.of(flowUri));
    final Integer flowVersion = new Integer(1);
    final VersionedFlowSnapshot flowSnapshot = FlowTestUtils.createSnapshot(flowUri.getBucketId(), flowUri.getFlowId(), flowVersion);
    when(flowRetrievalService.getLatestFlow(flowUri)).thenReturn(flowSnapshot);
    // return no mapping for agent class
    when(flowMappingRepository.findById(className)).thenReturn(Optional.empty());
    // test the refresher
    flowRefresherTask.refreshAgentClass(className, refreshedCounter);
    // refresh should happen because registry url changed
    assertEquals(1, refreshedCounter.get());
    verify(flowTransformService, times(1)).transform(flowSnapshot);
}