@Test public void shouldNotHideAnythingByInvalidID() throws NotFoundException { User user = new User(); user.setId(USER_ID); List<Symbol> archivedSymbols = symbolDAO.hide(user, PROJECT_ID, Collections.singletonList(-1L)); assertTrue(archivedSymbols.isEmpty()); }
public List<Symbol> hide(User user, Long projectId, List<Long> ids) throws NotFoundException { final Project project = projectRepository.findById(projectId).orElse(null); final List<Symbol> symbols = symbolRepository.findAllByIdIn(ids); for (Symbol symbol : symbols) { checkAccess(user, project, symbol); } for (Symbol symbol : symbols) { symbol.setHidden(true); final Timestamp timestamp = new Timestamp(System.currentTimeMillis()); symbol.setName(symbol.getName() + "--" + DATE_FORMAT.format(timestamp)); } final List<Symbol> archivedSymbols = symbolRepository.saveAll(symbols); archivedSymbols.forEach(SymbolDAO::loadLazyRelations); return archivedSymbols; }
SymbolDAO { public List<Symbol> hide(User user, Long projectId, List<Long> ids) throws NotFoundException { final Project project = projectRepository.findById(projectId).orElse(null); final List<Symbol> symbols = symbolRepository.findAllByIdIn(ids); for (Symbol symbol : symbols) { checkAccess(user, project, symbol); } for (Symbol symbol : symbols) { symbol.setHidden(true); final Timestamp timestamp = new Timestamp(System.currentTimeMillis()); symbol.setName(symbol.getName() + "--" + DATE_FORMAT.format(timestamp)); } final List<Symbol> archivedSymbols = symbolRepository.saveAll(symbols); archivedSymbols.forEach(SymbolDAO::loadLazyRelations); return archivedSymbols; } }
SymbolDAO { public List<Symbol> hide(User user, Long projectId, List<Long> ids) throws NotFoundException { final Project project = projectRepository.findById(projectId).orElse(null); final List<Symbol> symbols = symbolRepository.findAllByIdIn(ids); for (Symbol symbol : symbols) { checkAccess(user, project, symbol); } for (Symbol symbol : symbols) { symbol.setHidden(true); final Timestamp timestamp = new Timestamp(System.currentTimeMillis()); symbol.setName(symbol.getName() + "--" + DATE_FORMAT.format(timestamp)); } final List<Symbol> archivedSymbols = symbolRepository.saveAll(symbols); archivedSymbols.forEach(SymbolDAO::loadLazyRelations); return archivedSymbols; } @Autowired  SymbolDAO(ProjectRepository projectRepository, ProjectDAO projectDAO,
                     SymbolGroupRepository symbolGroupRepository, SymbolRepository symbolRepository,
                     SymbolActionRepository symbolActionRepository, SymbolGroupDAO symbolGroupDAO,
                     SymbolParameterRepository symbolParameterRepository, SymbolStepRepository symbolStepRepository,
                     ParameterizedSymbolDAO parameterizedSymbolDAO,
                     ParameterizedSymbolRepository parameterizedSymbolRepository,
                     SymbolSymbolStepRepository symbolSymbolStepRepository,
                     TestCaseStepRepository testCaseStepRepository,
                     TestExecutionResultRepository testExecutionResultRepository,
                     ProjectEnvironmentRepository projectEnvironmentRepository,
                     ObjectMapper objectMapper,
                     @Lazy SymbolParameterDAO symbolParameterDAO); }
SymbolDAO { public List<Symbol> hide(User user, Long projectId, List<Long> ids) throws NotFoundException { final Project project = projectRepository.findById(projectId).orElse(null); final List<Symbol> symbols = symbolRepository.findAllByIdIn(ids); for (Symbol symbol : symbols) { checkAccess(user, project, symbol); } for (Symbol symbol : symbols) { symbol.setHidden(true); final Timestamp timestamp = new Timestamp(System.currentTimeMillis()); symbol.setName(symbol.getName() + "--" + DATE_FORMAT.format(timestamp)); } final List<Symbol> archivedSymbols = symbolRepository.saveAll(symbols); archivedSymbols.forEach(SymbolDAO::loadLazyRelations); return archivedSymbols; } @Autowired  SymbolDAO(ProjectRepository projectRepository, ProjectDAO projectDAO,
                     SymbolGroupRepository symbolGroupRepository, SymbolRepository symbolRepository,
                     SymbolActionRepository symbolActionRepository, SymbolGroupDAO symbolGroupDAO,
                     SymbolParameterRepository symbolParameterRepository, SymbolStepRepository symbolStepRepository,
                     ParameterizedSymbolDAO parameterizedSymbolDAO,
                     ParameterizedSymbolRepository parameterizedSymbolRepository,
                     SymbolSymbolStepRepository symbolSymbolStepRepository,
                     TestCaseStepRepository testCaseStepRepository,
                     TestExecutionResultRepository testExecutionResultRepository,
                     ProjectEnvironmentRepository projectEnvironmentRepository,
                     ObjectMapper objectMapper,
                     @Lazy SymbolParameterDAO symbolParameterDAO); List<Symbol> importSymbols(User user, Project project, List<Symbol> symbols, Map<String, SymbolImportConflictResolutionStrategy> conflictResolutions); Symbol create(User user, Long projectId, Symbol symbol); List<Symbol> importSymbols(User user, Long projectId, SymbolsImportableEntity symbolsImportableEntity); List<Symbol> create(User user, Long projectId, List<Symbol> symbols); void saveSymbolSteps(Long projectId, List<Symbol> createdSymbols, Map<Long, List<SymbolStep>> symbolStepMap); List<Symbol> getByIds(User user, Long projectId, List<Long> ids); List<Symbol> getAll(User user, Long projectId); Symbol get(User user, Long projectId, Long id); Symbol get(User user, Project project, Long symbolId); Symbol update(User user, Long projectId, Symbol symbol); List<Symbol> update(User user, Long projectId, List<Symbol> symbols); Symbol move(User user, Long projectId, Long symbolId, Long newGroupId); List<Symbol> move(User user, Long projectId, List<Long> symbolIds, Long newGroupId); List<Symbol> hide(User user, Long projectId, List<Long> ids); void show(User user, Long projectId, List<Long> ids); void delete(User user, Long projectId, Long symbolId); void delete(User user, Long projectId, List<Long> symbolIds); static void beforeSymbolSave(Symbol symbol); static void loadLazyRelations(Symbol symbol); void checkAccess(User user, Project project, Symbol symbol); }
SymbolDAO { public List<Symbol> hide(User user, Long projectId, List<Long> ids) throws NotFoundException { final Project project = projectRepository.findById(projectId).orElse(null); final List<Symbol> symbols = symbolRepository.findAllByIdIn(ids); for (Symbol symbol : symbols) { checkAccess(user, project, symbol); } for (Symbol symbol : symbols) { symbol.setHidden(true); final Timestamp timestamp = new Timestamp(System.currentTimeMillis()); symbol.setName(symbol.getName() + "--" + DATE_FORMAT.format(timestamp)); } final List<Symbol> archivedSymbols = symbolRepository.saveAll(symbols); archivedSymbols.forEach(SymbolDAO::loadLazyRelations); return archivedSymbols; } @Autowired  SymbolDAO(ProjectRepository projectRepository, ProjectDAO projectDAO,
                     SymbolGroupRepository symbolGroupRepository, SymbolRepository symbolRepository,
                     SymbolActionRepository symbolActionRepository, SymbolGroupDAO symbolGroupDAO,
                     SymbolParameterRepository symbolParameterRepository, SymbolStepRepository symbolStepRepository,
                     ParameterizedSymbolDAO parameterizedSymbolDAO,
                     ParameterizedSymbolRepository parameterizedSymbolRepository,
                     SymbolSymbolStepRepository symbolSymbolStepRepository,
                     TestCaseStepRepository testCaseStepRepository,
                     TestExecutionResultRepository testExecutionResultRepository,
                     ProjectEnvironmentRepository projectEnvironmentRepository,
                     ObjectMapper objectMapper,
                     @Lazy SymbolParameterDAO symbolParameterDAO); List<Symbol> importSymbols(User user, Project project, List<Symbol> symbols, Map<String, SymbolImportConflictResolutionStrategy> conflictResolutions); Symbol create(User user, Long projectId, Symbol symbol); List<Symbol> importSymbols(User user, Long projectId, SymbolsImportableEntity symbolsImportableEntity); List<Symbol> create(User user, Long projectId, List<Symbol> symbols); void saveSymbolSteps(Long projectId, List<Symbol> createdSymbols, Map<Long, List<SymbolStep>> symbolStepMap); List<Symbol> getByIds(User user, Long projectId, List<Long> ids); List<Symbol> getAll(User user, Long projectId); Symbol get(User user, Long projectId, Long id); Symbol get(User user, Project project, Long symbolId); Symbol update(User user, Long projectId, Symbol symbol); List<Symbol> update(User user, Long projectId, List<Symbol> symbols); Symbol move(User user, Long projectId, Long symbolId, Long newGroupId); List<Symbol> move(User user, Long projectId, List<Long> symbolIds, Long newGroupId); List<Symbol> hide(User user, Long projectId, List<Long> ids); void show(User user, Long projectId, List<Long> ids); void delete(User user, Long projectId, Long symbolId); void delete(User user, Long projectId, List<Long> symbolIds); static void beforeSymbolSave(Symbol symbol); static void loadLazyRelations(Symbol symbol); void checkAccess(User user, Project project, Symbol symbol);  }