TaskDataProviderServiceImpl implements TaskDataProviderService, OsgiServiceLifecycleListener { @Override @Transactional public void unregister(String providerName) { TaskDataProvider provider = dataProviderDataService.findByName(providerName); if (provider != null) { dataProviderDataService.delete(provider); } else { LOGGER.info("A request to unregister the task data provider with name {} has been received, " + "but the provider with such name does not exist.", providerName); } } @Autowired  TaskDataProviderServiceImpl(EventRelay eventRelay);  TaskDataProviderServiceImpl(EventRelay eventRelay, MotechJsonReader motechJsonReader); @Override @Transactional void registerProvider(final String body); @Override @Transactional void registerProvider(final InputStream stream); @Override @Transactional TaskDataProvider getProvider(String name); @Override @Transactional TaskDataProvider getProviderById(Long providerId); @Override @Transactional List<TaskDataProvider> getProviders(); @Override @Transactional void bind(Object service, Map properties); @Override void unbind(Object service, Map properties); @Override @Transactional void unregister(String providerName);  }
@Test public void shouldUnregisterDataProvider() { List<LookupFieldsParameter> lookupFields = asList(new LookupFieldsParameter("lookupField", asList("lookupField"))); List<FieldParameter> fields = asList(new FieldParameter("displayName", "fieldKey")); List<TaskDataProviderObject> objects = new ArrayList<>(); objects.add(new TaskDataProviderObject("displayName", "type", lookupFields, fields)); TaskDataProvider provider = new TaskDataProvider(PROVIDER_NAME, objects); when(dataProviderDataService.findByName(PROVIDER_NAME)).thenReturn(provider); taskDataProviderService.unregister(PROVIDER_NAME); verify(dataProviderDataService).delete(provider); }