ServiceTaskServiceImpl implements ServiceTaskService { @Override public String removeServiceTask(ServiceTaskSummary serviceTaskSummary) { repoService.removeServiceTask(serviceTaskSummary.getId()); return serviceTaskSummary.getName(); }  @PostConstruct void initialLoad(); @Override List<ServiceTaskSummary> getServiceTasks(); @Override List<ServiceTaskSummary> getEnabledServiceTasks(String branchName); @Override void enableServiceTask(String id); @Override void disableServiceTask(String id); @Override void installServiceTask(String id, String target, List<String> parameters, String branchName); @Override void uninstallServiceTask(String id, String target, String branchName); @Override ServiceTasksConfiguration getConfiguration(); @Override void saveConfiguration(ServiceTasksConfiguration configuration); @Override Map<String, List<String>> addServiceTasks(String gav); @Override String removeServiceTask(ServiceTaskSummary serviceTaskSummary); @Override void updateInstalledServiceTasks(String newBranchName, String fromBranchName);  }
@Test public void testRemoveServiceTask() { List<RepoData> currentServices = new ArrayList<>(); String stName = "Test1"; loadServices(stName, currentServices); RepoData rd = currentServices.get(0); ServiceTaskSummary st = new ServiceTaskSummary(); st.setName(rd.getName()); st.setId(rd.getId()); st.setInstalledOn(Collections.emptySet()); assertEquals(serviceTaskSize + 1, serviceTaskServiceImpl.getServiceTasks().size()); assertEquals(stName, serviceTaskServiceImpl.removeServiceTask(st)); List<ServiceTaskSummary> afterRemoveAction = serviceTaskServiceImpl.getServiceTasks(); assertEquals(serviceTaskSize, afterRemoveAction.size()); Optional<ServiceTaskSummary> optionalServiceTaskSummary = afterRemoveAction.stream().filter(s -> s.getName().equals(stName)).findFirst(); assertFalse(optionalServiceTaskSummary.isPresent()); }