diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/advices/ServiceAdvice.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/advices/ServiceAdvice.java index 90316dda15eebfe1d3c815ddf7c5bd4f1903df61..023fe551e97c1f472f27b8627c6ea45762b9b4b1 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/advices/ServiceAdvice.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/advices/ServiceAdvice.java @@ -1,6 +1,5 @@ package de.deadlocker8.budgetmaster.advices; -import de.deadlocker8.budgetmaster.migration.MigrationService; import de.deadlocker8.budgetmaster.services.CurrencyService; import de.deadlocker8.budgetmaster.services.DateService; import de.deadlocker8.budgetmaster.services.HelpersService; @@ -24,9 +23,6 @@ public class ServiceAdvice @Autowired BudgetMasterUpdateService updateService; - @Autowired - MigrationService migrationService; - @ModelAttribute("helpers") public HelpersService getHelpers() { @@ -50,10 +46,4 @@ public class ServiceAdvice { return updateService; } - - @ModelAttribute("migrationService") - public MigrationService getMigrationService() - { - return migrationService; - } } \ No newline at end of file diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/ApplicationSupportFolderProvider.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/ApplicationSupportFolderProvider.java deleted file mode 100644 index bfca5d8d7ece34c37b920271c37f41865c45426f..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/ApplicationSupportFolderProvider.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import de.deadlocker8.budgetmaster.BudgetMasterServerMain; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -import java.nio.file.Path; - -@Component -public class ApplicationSupportFolderProvider -{ - @Bean("applicationSupportFolder") - public Path applicationSupportFolder() - { - return BudgetMasterServerMain.getApplicationSupportFolder(true); - } -} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationArguments.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationArguments.java deleted file mode 100644 index 3813be96bf0ea55964e830139e15cb0ac84af70f..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationArguments.java +++ /dev/null @@ -1,69 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -public class MigrationArguments -{ - static class MigrationArgumentBuilder - { - private String sourceUrl; - private String destinationUrl; - private String destinationDriverClassName; - private String destinationUsername; - private String destinationPassword; - - public MigrationArgumentBuilder withSourceUrl(String databasePath) - { - databasePath = databasePath.replace("\\", "/"); - this.sourceUrl = MessageFormat.format("jdbc:h2:/{0}", databasePath); - return this; - } - - public MigrationArgumentBuilder withDestinationUrl(DatabaseType databaseType, String hostname, Integer port, String databaseName) - { - this.destinationDriverClassName = databaseType.getDriverClassName(); - this.destinationUrl = MessageFormat.format("jdbc:{0}://{1}:{2,number,#}/{3}", databaseType.getName().toLowerCase(), hostname, port, databaseName); - return this; - } - - public MigrationArgumentBuilder withDestinationCredentials(String username, String password) - { - this.destinationUsername = username; - this.destinationPassword = password; - return this; - } - - public MigrationArguments build() - { - return new MigrationArguments(sourceUrl, destinationUrl, destinationDriverClassName, destinationUsername, destinationPassword); - } - } - - private final String sourceUrl; - private final String destinationUrl; - private final String destinationDriverClassName; - private final String destinationUsername; - private final String destinationPassword; - - private MigrationArguments(String sourceUrl, String destinationUrl, String driverClassName, String destinationUsername, String destinationPassword) - { - this.sourceUrl = sourceUrl; - this.destinationUrl = destinationUrl; - this.destinationDriverClassName = driverClassName; - this.destinationUsername = destinationUsername; - this.destinationPassword = destinationPassword; - } - - public List<String> getArguments() - { - final ArrayList<String> arguments = new ArrayList<>(); - arguments.add(MessageFormat.format("--spring.datasource.jdbc-url={0}", sourceUrl)); - arguments.add(MessageFormat.format("--spring.seconddatasource.jdbc-url={0}", destinationUrl)); - arguments.add(MessageFormat.format("--spring.seconddatasource.driver-class-name={0}", destinationDriverClassName)); - arguments.add(MessageFormat.format("--spring.seconddatasource.username={0}", destinationUsername)); - arguments.add(MessageFormat.format("--spring.seconddatasource.password={0}", destinationPassword)); - return arguments; - } -} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationController.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationController.java deleted file mode 100644 index ad871cd10fef31d4ce4c6d94f509de9221996fc5..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationController.java +++ /dev/null @@ -1,132 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import de.deadlocker8.budgetmaster.authentication.UserService; -import de.deadlocker8.budgetmaster.controller.BaseController; -import de.deadlocker8.budgetmaster.database.DatabaseService; -import de.deadlocker8.budgetmaster.settings.SettingsService; -import de.deadlocker8.budgetmaster.utils.Mappings; -import de.deadlocker8.budgetmaster.utils.Strings; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; -import org.springframework.validation.FieldError; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.List; - - -@Controller -@RequestMapping(Mappings.MIGRATION) -public class MigrationController extends BaseController -{ - private static class ModelAttributes - { - public static final String ERROR = "error"; - public static final String MIGRATION_SETTINGS = "migrationSettings"; - public static final String STATUS = "status"; - public static final String SUMMARY = "summary"; - public static final String DATABASE_TYPES = "databaseTypes"; - } - - private static class ReturnValues - { - public static final String MIGRATION_SETTINGS = "migration/migration"; - public static final String REDIRECT_STATUS = "redirect:migration/status"; - public static final String STATUS = "migration/status"; - public static final String STATUS_FRAGMENT = "migration/statusFragment"; - } - - private final MigrationService migrationService; - private final SettingsService settingsService; - private final UserService userService; - private final DatabaseService databaseService; - - @Autowired - public MigrationController(MigrationService migrationService, SettingsService settingsService, UserService userService, DatabaseService databaseService) - { - this.migrationService = migrationService; - this.settingsService = settingsService; - this.userService = userService; - this.databaseService = databaseService; - } - - @GetMapping("/cancel") - public String cancel(HttpServletRequest request) - { - settingsService.updateMigrationDeclined(true); - return "redirect:" + request.getHeader("Referer"); - } - - @GetMapping - public String migrate(Model model) - { - model.addAttribute(ModelAttributes.MIGRATION_SETTINGS, migrationService.getPrefilledMigrationSettings()); - model.addAttribute(ModelAttributes.DATABASE_TYPES, List.of(DatabaseType.values())); - return ReturnValues.MIGRATION_SETTINGS; - } - - @PostMapping - public String post(Model model, - @ModelAttribute("MigrationSettings") @Valid MigrationSettings migrationSettings, BindingResult bindingResult, - @RequestParam(value = "databaseTypeName") String databaseTypeName, - @RequestParam(value = "verificationPassword") String verificationPassword) - { - migrationSettings.setDatabaseType(DatabaseType.fromName(databaseTypeName)); - final MigrationSettingsValidator migrationSettingsValidator = new MigrationSettingsValidator(); - migrationSettingsValidator.validate(migrationSettings, bindingResult); - - final boolean isVerificationPasswordValid = userService.isPasswordValid(verificationPassword); - if(!isVerificationPasswordValid) - { - final FieldError verificationError = new FieldError("MigrationSettings", "verificationPassword", verificationPassword, false, new String[]{Strings.WARNING_WRONG_MIGRATION_VERIFICATION_PASSWORD}, null, Strings.WARNING_WRONG_MIGRATION_VERIFICATION_PASSWORD); - bindingResult.addError(verificationError); - } - - model.addAttribute(ModelAttributes.MIGRATION_SETTINGS, migrationSettings); - - if(bindingResult.hasErrors()) - { - model.addAttribute(ModelAttributes.ERROR, bindingResult); - model.addAttribute(ModelAttributes.DATABASE_TYPES, List.of(DatabaseType.values())); - return ReturnValues.MIGRATION_SETTINGS; - } - - final MigrationArguments migrationArguments = new MigrationArguments.MigrationArgumentBuilder() - .withSourceUrl(migrationService.getDatabaseFromPreviousVersionPathWithoutExtension().toString()) - .withDestinationUrl(migrationSettings.databaseType(), migrationSettings.hostname(), migrationSettings.port(), migrationSettings.databaseName()) - .withDestinationCredentials(migrationSettings.username(), migrationSettings.password()) - .build(); - migrationService.startMigration(migrationArguments); - - return ReturnValues.REDIRECT_STATUS; - } - - @GetMapping("/status") - public String status(Model model) - { - model.addAttribute(ModelAttributes.STATUS, migrationService.getMigrationStatus()); - return ReturnValues.STATUS; - } - - @GetMapping("/getStatus") - public String getMigrationStatus(Model model) - { - final MigrationStatus migrationStatus = migrationService.getMigrationStatus(); - model.addAttribute(ModelAttributes.STATUS, migrationStatus); - - if(migrationStatus == MigrationStatus.SUCCESS) - { - model.addAttribute(ModelAttributes.SUMMARY, migrationService.getSummary()); - databaseService.createDefaults(); - } - if(migrationStatus == MigrationStatus.ERROR) - { - model.addAttribute(ModelAttributes.SUMMARY, migrationService.getCollectedStdout()); - } - - return ReturnValues.STATUS_FRAGMENT; - } -} \ No newline at end of file diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationException.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationException.java deleted file mode 100644 index 182d761075decc61492767e6994f6b3808d868ce..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationException.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -public class MigrationException extends Exception -{ - public MigrationException(String message) - { - super(message); - } - - public MigrationException(String message, Throwable cause) - { - super(message, cause); - } -} - diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationService.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationService.java deleted file mode 100644 index 493c73e809541d69153355417220cf0f04257d48..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationService.java +++ /dev/null @@ -1,132 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import de.deadlocker8.budgetmaster.accounts.AccountRepository; -import de.deadlocker8.budgetmaster.categories.CategoryRepository; -import de.deadlocker8.budgetmaster.categories.CategoryType; -import de.deadlocker8.budgetmaster.settings.SettingsService; -import de.deadlocker8.budgetmaster.templates.TemplateRepository; -import de.deadlocker8.budgetmaster.transactions.TransactionRepository; -import de.deadlocker8.budgetmaster.utils.DatabaseConfigurationProperties; -import de.deadlocker8.budgetmaster.utils.Mappings; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.stereotype.Service; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Date; -import java.util.List; - -@Service -public class MigrationService -{ - public static final String PREVIOUS_DATABASE_FILE_NAME = "budgetmaster.mv.db"; - public static final String PREVIOUS_DATABASE_FILE_NAME_WITHOUT_EXTENSION = "budgetmaster"; - - private final SettingsService settingsService; - private final Path applicationSupportFolder; - private final AccountRepository accountRepository; - private final CategoryRepository categoryRepository; - private final TransactionRepository transactionRepository; - private final TemplateRepository templateRepository; - private final DatabaseConfigurationProperties databaseConfig; - private final TaskScheduler scheduler; - - private final MigrationTask migrationTask; - - @Autowired - public MigrationService(SettingsService settingsService, Path applicationSupportFolder, AccountRepository accountRepository, CategoryRepository categoryRepository, TransactionRepository transactionRepository, TemplateRepository templateRepository, DatabaseConfigurationProperties databaseConfig, TaskScheduler scheduler) - { - this.settingsService = settingsService; - this.applicationSupportFolder = applicationSupportFolder; - this.accountRepository = accountRepository; - this.categoryRepository = categoryRepository; - this.transactionRepository = transactionRepository; - this.templateRepository = templateRepository; - this.databaseConfig = databaseConfig; - this.migrationTask = new MigrationTask(applicationSupportFolder, settingsService); - this.scheduler = scheduler; - } - - public MigrationSettings getPrefilledMigrationSettings() - { - return new MigrationSettings(databaseConfig.getHostname(), databaseConfig.getPort(), databaseConfig.getDatabaseName(), databaseConfig.getUsername(), databaseConfig.getPassword(), databaseConfig.getDatabaseType()); - } - - public boolean needToShowMigrationDialog(String loadedPage) - { - loadedPage = "/" + loadedPage; - if(loadedPage.equals(Mappings.MIGRATION)) - { - return false; - } - - if(!isDatabaseEmpty()) - { - return false; - } - - if(!isDatabaseFromPreviousVersionExisting()) - { - return false; - } - - return !settingsService.getSettings().getMigrationDeclined(); - } - - private boolean isDatabaseEmpty() - { - if(accountRepository.findAll().size() > 2) - { - return false; - } - - if(!categoryRepository.findAllByTypeOrderByNameAsc(CategoryType.CUSTOM).isEmpty()) - { - return false; - } - - if(!transactionRepository.findAll().isEmpty()) - { - return false; - } - - return templateRepository.findAll().isEmpty(); - } - - private Path getDatabaseFromPreviousVersionPath() - { - return applicationSupportFolder.resolve(PREVIOUS_DATABASE_FILE_NAME); - } - - public Path getDatabaseFromPreviousVersionPathWithoutExtension() - { - return applicationSupportFolder.resolve(PREVIOUS_DATABASE_FILE_NAME_WITHOUT_EXTENSION); - } - - private boolean isDatabaseFromPreviousVersionExisting() - { - return Files.exists(getDatabaseFromPreviousVersionPath()); - } - - public void startMigration(MigrationArguments migrationArguments) - { - migrationTask.setMigrationArguments(migrationArguments); - scheduler.schedule(migrationTask, new Date()); - } - - public MigrationStatus getMigrationStatus() - { - return migrationTask.getMigrationStatus(); - } - - public List<String> getSummary() - { - return migrationTask.getSummary(); - } - - public List<String> getCollectedStdout() - { - return migrationTask.getCollectedStdout(); - } -} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationSettings.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationSettings.java deleted file mode 100644 index b4f9682ac02a5b8de00938775230fa64589c91e8..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationSettings.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import java.util.Objects; - -public final class MigrationSettings -{ - private final String hostname; - private final Integer port; - private final String databaseName; - private final String username; - private final String password; - private DatabaseType databaseType; - - public MigrationSettings(String hostname, Integer port, String databaseName, String username, String password, DatabaseType databaseType) - { - this.hostname = hostname; - this.port = port; - this.databaseName = databaseName; - this.username = username; - this.password = password; - this.databaseType = databaseType; - } - - public String hostname() - { - return hostname; - } - - public Integer port() - { - return port; - } - - public String databaseName() - { - return databaseName; - } - - public String username() - { - return username; - } - - public String password() - { - return password; - } - - public DatabaseType databaseType() - { - return databaseType; - } - - public void setDatabaseType(DatabaseType databaseType) - { - this.databaseType = databaseType; - } - - @Override - public boolean equals(Object obj) - { - if(obj == this) return true; - if(obj == null || obj.getClass() != this.getClass()) return false; - var that = (MigrationSettings) obj; - return Objects.equals(this.hostname, that.hostname) && - Objects.equals(this.port, that.port) && - Objects.equals(this.databaseName, that.databaseName) && - Objects.equals(this.username, that.username) && - Objects.equals(this.password, that.password) && - Objects.equals(this.databaseType, that.databaseType); - } - - @Override - public int hashCode() - { - return Objects.hash(hostname, port, databaseName, username, password, databaseType); - } - - @Override - public String toString() - { - return "MigrationSettings[" + - "hostname=" + hostname + ", " + - "port=" + port + ", " + - "databaseName=" + databaseName + ", " + - "username=" + username + ", " + - "password=" + password + ", " + - "databaseType=" + databaseType + ']'; - } - -} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationSettingsValidator.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationSettingsValidator.java deleted file mode 100644 index 5deef2f7279ac721e3e7761c1a31f18735847cad..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationSettingsValidator.java +++ /dev/null @@ -1,33 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import de.deadlocker8.budgetmaster.utils.Strings; -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; -import org.springframework.validation.Validator; - - -public class MigrationSettingsValidator implements Validator -{ - public boolean supports(Class clazz) - { - return MigrationSettings.class.equals(clazz); - } - - public void validate(Object obj, Errors errors) - { - final MigrationSettings migrationSettings = (MigrationSettings) obj; - - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "hostname", Strings.WARNING_EMPTY_MIGRATION_HOSTNAME); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "port", Strings.WARNING_EMPTY_MIGRATION_PORT); - - final Integer port = migrationSettings.port(); - if(port != null && (port < 1 || port > 65535)) - { - errors.rejectValue("port", Strings.WARNING_EMPTY_MIGRATION_PORT); - } - - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "databaseName", Strings.WARNING_EMPTY_MIGRATION_DATABASE_NAME); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", Strings.WARNING_EMPTY_MIGRATION_USERNAME); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", Strings.WARNING_EMPTY_MIGRATION_PASSWORD); - } -} \ No newline at end of file diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationStatus.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationStatus.java deleted file mode 100644 index 87ece294d90ebe14565741bbf3335e33e9184ce7..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationStatus.java +++ /dev/null @@ -1,46 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -public enum MigrationStatus -{ - NOT_RUNNING("fas fa-ban", "migration.status.not.running", "text-blue"), - RUNNING("fas fa-gears", "migration.status.running", "text-blue"), - SUCCESS("fas fa-check", "migration.status.success", "text-green"), - ERROR("fas fa-exclamation-triangle", "migration.status.error", "red-text"); // red-text is better readable than text-red - - private final String icon; - private final String localizationKey; - private final String textColor; - - MigrationStatus(String icon, String localizationKey, String textColor) - { - this.icon = icon; - this.localizationKey = localizationKey; - this.textColor = textColor; - } - - public String getIcon() - { - return icon; - } - - public String getLocalizationKey() - { - return localizationKey; - } - - - public String getTextColor() - { - return textColor; - } - - @Override - public String toString() - { - return "MigrationStatus{" + - "icon='" + icon + '\'' + - ", localizationKey='" + localizationKey + '\'' + - ", textColor='" + textColor + '\'' + - "} " + super.toString(); - } -} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationTask.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationTask.java deleted file mode 100644 index 60f5340d3807d0410832f4150cae146e5fad6816..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/migration/MigrationTask.java +++ /dev/null @@ -1,213 +0,0 @@ -package de.deadlocker8.budgetmaster.migration; - -import de.deadlocker8.budgetmaster.settings.SettingsService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class MigrationTask implements Runnable -{ - private static final Logger LOGGER = LoggerFactory.getLogger(MigrationTask.class); - private static final String BUDGET_MASTER_MIGRATOR_JAR = "BudgetMasterDatabaseMigrator.jar"; - private static final Pattern PATTERN_SUMMARY = Pattern.compile(".*(\\[COMPLETED\\] Migrate .*)"); - - private static final int NUMBER_OF_MIGRATION_STEPS = 25; - - private final Path applicationSupportFolder; - - private final SettingsService settingsService; - - private MigrationArguments migrationArguments; - private MigrationStatus migrationStatus; - private List<String> collectedStdout; - private List<String> summary; - - public MigrationTask(Path applicationSupportFolder, SettingsService settingsService) - { - this.applicationSupportFolder = applicationSupportFolder; - this.settingsService = settingsService; - this.migrationStatus = MigrationStatus.NOT_RUNNING; - } - - public void setMigrationArguments(MigrationArguments migrationArguments) - { - this.migrationArguments = migrationArguments; - this.collectedStdout = new ArrayList<>(); - this.summary = new ArrayList<>(); - } - - @Override - public void run() - { - if(migrationArguments == null) - { - throw new IllegalArgumentException("No migration arguments set!"); - } - - if(migrationStatus != MigrationStatus.NOT_RUNNING) - { - this.migrationStatus = MigrationStatus.NOT_RUNNING; - this.collectedStdout = new ArrayList<>(); - this.summary = new ArrayList<>(); - } - - LOGGER.debug("Start migration..."); - setMigrationStatus(MigrationStatus.RUNNING); - - try - { - final Path migratorPath = extractMigrator(); - try - { - runMigrator(migratorPath, migrationArguments); - } - finally - { - // if any error happens during migration the settings table might be still empty and lead to errors - // and an infinite progress indicator loop during fetch of the migration status due to SettingsAdvice.class - // Therefore ensure settings exist at this point - settingsService.createDefaultSettingsIfNotExists(); - - Files.deleteIfExists(migratorPath); - } - - summary = collectSummary(); - if(summary.size() == NUMBER_OF_MIGRATION_STEPS) - { - setMigrationStatus(MigrationStatus.SUCCESS); - } - else - { - setMigrationStatus(MigrationStatus.ERROR); - } - } - catch(MigrationException | IOException e) - { - LOGGER.error("Migration failed", e); - setMigrationStatus(MigrationStatus.ERROR); - } - } - - private Path extractMigrator() throws MigrationException - { - final Path destinationPath = applicationSupportFolder.resolve(BUDGET_MASTER_MIGRATOR_JAR); - - try - { - Files.copy(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(BUDGET_MASTER_MIGRATOR_JAR)), destinationPath, StandardCopyOption.REPLACE_EXISTING); - return destinationPath; - } - catch(IOException e) - { - throw new MigrationException(MessageFormat.format("Could not copy migrator to {0}", destinationPath), e); - } - } - - private void runMigrator(Path migratorPath, MigrationArguments migrationArguments) throws MigrationException - { - final String javaCommand = determineJavaCommand(); - - final List<String> command = new ArrayList<>(); - command.add(javaCommand); - command.add("-jar"); - command.add(migratorPath.toString()); - command.addAll(migrationArguments.getArguments()); - LOGGER.debug("Starting migration with command: {}", command); - - try - { - final ProcessBuilder processBuilder = new ProcessBuilder(command).redirectErrorStream(true); - final Process process = processBuilder.start(); - - try(BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()))) - { - while(true) - { - String line = in.readLine(); - if(line == null) - { - break; - } - - LOGGER.debug("[MIGRATOR] {}", line); - collectedStdout.add(line); - } - } - - LOGGER.debug("Migration process finished"); - } - catch(IOException e) - { - final MigrationException exception = new MigrationException("Error during migration process", e); - collectedStdout.add(MessageFormat.format("{0}: {1}", e.getMessage(), e.getCause())); - throw exception; - } - } - - private String determineJavaCommand() throws MigrationException - { - final Optional<String> commandResultOptional = ProcessHandle.current().info().command(); - if(commandResultOptional.isEmpty()) - { - throw new MigrationException("Could not determine java executable"); - } - - return commandResultOptional.get().replace("\\", "/"); - } - - public MigrationStatus getMigrationStatus() - { - return migrationStatus; - } - - public void setMigrationStatus(MigrationStatus migrationStatus) - { - this.migrationStatus = migrationStatus; - } - - public List<String> getCollectedStdout() - { - return collectedStdout; - } - - public List<String> getSummary() - { - return summary; - } - - private List<String> collectSummary() - { - if(collectedStdout == null) - { - return new ArrayList<>(); - } - - LOGGER.debug("Collecting summary..."); - - final List<String> matchingLines = new ArrayList<>(); - for(String line : collectedStdout) - { - final Matcher matcher = PATTERN_SUMMARY.matcher(line); - if(matcher.find()) - { - matchingLines.add(matcher.group(1)); - } - } - - LOGGER.debug("Summary collected"); - return matchingLines; - } -} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Mappings.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Mappings.java index 332d2b61c76ad5889ffc6de1f89cd49de7c0e7d3..e0c652444569f37be50de5225af62dd773abd202 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Mappings.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Mappings.java @@ -26,6 +26,4 @@ public final class Mappings public static final String TAGS = "/tags"; public static final String HINTS = "/hints"; public static final String KEYWORDS = "/keywords"; - - public static final String MIGRATION = "/migration"; } diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Strings.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Strings.java index ae70213a142e7a430d660dd0a5fca0b64ae1b1e1..191b8515d4c5e1ccb9a11f75468fe70d99786fd5 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Strings.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/utils/Strings.java @@ -39,14 +39,6 @@ public class Strings public static final String WARNING_EMPTY_GIT_USER_NAME = "warning.empty.git.user.name"; public static final String WARNING_EMPTY_GIT_TOKEN = "warning.empty.git.token"; - public static final String WARNING_EMPTY_MIGRATION_HOSTNAME = "warning.empty.migration.hostname"; - public static final String WARNING_EMPTY_MIGRATION_PORT = "warning.empty.migration.port"; - public static final String WARNING_EMPTY_MIGRATION_DATABASE_NAME = "warning.empty.migration.databaseName"; - public static final String WARNING_EMPTY_MIGRATION_USERNAME = "warning.empty.migration.username"; - public static final String WARNING_EMPTY_MIGRATION_PASSWORD = "warning.empty.migration.password"; - - public static final String WARNING_WRONG_MIGRATION_VERIFICATION_PASSWORD = "migration.settings.verification.password.wrong"; - //REPORT public static final String REPORT_FOOTER_LEFT = "report.footer.left"; diff --git a/BudgetMasterServer/src/main/resources/languages/base_de.properties b/BudgetMasterServer/src/main/resources/languages/base_de.properties index cfebfe72cedfefb1416b8acd6af277f816ce294b..5242b87130ded3241feddb5b4efb5e4fe81a31a0 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_de.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_de.properties @@ -57,7 +57,6 @@ title.template.group.button.new=Neue Gruppe title.template.group.new=Neue Vorlagengruppe title.template.group.edit=Vorlagengruppe bearbeiten title.template.group.edit.short=Gruppen bearbeiten -title.migration=Datenbankmigration # MISC category.none=Keine Kategorie @@ -169,10 +168,6 @@ info.text.update=Es ist ein Update für BudgetMaster verfügbar<br><br>Installie info.title.backup.reminder=Zeit für ein Backup info.text.backup.reminder=Schon mal über ein Backup nachgedacht?<br>Du solltest deine BudgetMaster Datenbank regelmäßig sichern.<br>Dies geht besonders einfach in den Einstellungen.<br>Du kannst auch ein automatisches Backup konfigurieren.<br><br>(Du wilst diese Erinnerung nicht jeden Monat sehen? Dann deaktiviere die Backuperinnerung in den Einstellungen.) info.button.backup.reminder=Zu den Einstellungen -info.title.migration=Kommst du von einer früheren Version? -info.text.migration=BudgetMaster 2.10.0 führt ein neues Datenbank-Backend ein.<br>Deine aktuelle Datenbank scheint leer zu sein.<br>Hast du BudgetMaster bereits vor Version 2.10.0 benutzt und möchtest deine bestehende Datenbank migrieren?<br><br><span class="red-text bold">ACHTUNG: Wenn du diesen Dialog abbrichst, wirst du nicht mehr nach der Migration gefragt!</span> -info.button.migration=Bestehende Datenbank migrieren -info.button.migration.start=Datenbank migrieren notification.settings.saved=Einstellungen gespeichert notification.settings.security.saved=Passwort gespeichert notification.settings.security.warning=Passwort entspricht bereits gespeicherten Passwort @@ -191,7 +186,6 @@ notification.settings.hints.reset=Alle Tipps zurückgesetzt notification.settings.database.delete.success=Datenbank erfolgreich gelöscht notification.settings.backup.run.success=Backup erfolgreich notification.settings.backup.run.error=Backup fehlgeschlagen -notification.migration.error=Migration fehlgeschlagen: {0} upload.image.success=Erfolgreich hochgeladen upload.image.error=Fehler: {0} upload.image.error.no.file=Fehler: Keine Datei für Upload angegeben @@ -236,11 +230,6 @@ warning.empty.git.url=Bitte gib die URL zum git-Server ein. warning.empty.git.branch.name=Bitte gib den Namen des git-Branches ein. warning.empty.git.user.name=Bitte gib deinen git-Nutzernamen ein. warning.empty.git.token=Bitte gib dein git-Zugriffstoken ein. -warning.empty.migration.hostname=Bitte gib den Hostnamen des Datenbankservers ein. -warning.empty.migration.port=Bitte gib eine gültige Zahl größer 0 and kleiner 65535 ein. -warning.empty.migration.databaseName=Bitte gib den Namen der Datenbank ein. -warning.empty.migration.username=Bitte gib den Nutzernamen ein. -warning.empty.migration.password=Bitte gib das Datenbankpasswort ein. # UI @@ -671,21 +660,3 @@ import.entity.image=Icons werden automatisch mit den zugehörigen Konten, Vorlag import.entity.chart=Es werden nur die benutzerdefinierten Diagramme importiert.<br>Der Import von Diagrammen ist optional. copied=Kopiert! - -migration.settings.description=Alle Daten aus deiner bestehenden BudgetMaster Datenbank werden in die neue Datenbank migriert.<br> Bitte gib die Einstellungen für das neue Datenbank-Backend (z.B. postgresql) ein.<br><br><span class="bold">Bitte stelle sicher, dass deine bestehende Datenbank mindestens einmal mit BudgetMaster v2.9.2 geöffnet wurde, bevor du diese Migration durchführst!</span> -migration.settings.description.warning=Alle vorhandenen Daten der Zieldatenbank werden unwiderruflich gelöscht! -migration.settings.description.info=Die Einstellungen werden mit der aktuell verwendeten Datenbank vorbefüllt. -migration.settings.databaseType=Datenbanktyp -migration.settings.hostname=Hostname -migration.settings.port=Port -migration.settings.databaseName=Datenbankname -migration.settings.username=Nutzername -migration.settings.password=Passwort -migration.settings.verification.password.description=Bitte gib dein aktuelles BudgetMaster Passwort ein, um den Migrationsprozess zu bestätigen.<br><span class="red-text bold">Die Migration kann nicht abgebrochen werden.</span><br>Deine bestehende BudgetMaster Datenbank wird weder geändert noch gelöscht. -migration.settings.verification.password=Aktuelles BudgetMaster Passwort -migration.settings.verification.password.wrong=Ungültiges Bestätigungspasswort -migration.status.not.running=Migration wurde nicht gestartet. -migration.status.running=Migration läuft... -migration.status.success=Migration fertiggestellt! -migration.status.error=Migration fehlgeschlagen! -migration.status.summary=Details diff --git a/BudgetMasterServer/src/main/resources/languages/base_en.properties b/BudgetMasterServer/src/main/resources/languages/base_en.properties index a6c510ef521b0202994fba662c07f04d32fcce65..1bbe6c93dfcaa2c1b4fc32b4fe4c8c91fddd137b 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_en.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_en.properties @@ -58,7 +58,6 @@ title.template.group.button.new=New Group title.template.group.new=New Template Group title.template.group.edit=Edit Template Group title.template.group.edit.short=Edit Groups -title.migration=Database Migration # MISC category.none=No Category @@ -170,10 +169,6 @@ info.text.update=An update for BudgetMaster is available<br><br>Installed: v{0}< info.title.backup.reminder=Time for a backup info.text.backup.reminder=Have you ever thought about a backup?<br>You should back up your BudgetMaster database regularly.<br>This can be done on the settings page.<br>You can also enable an automatic backup.<br><br>(You don''t want to see this reminder every month? Disable the backup reminder in the settings.) info.button.backup.reminder=To the settings -info.title.migration=Are you coming from a previous version? -info.text.migration=BudgetMaster 2.10.0 introduces a new database backend.<br>Your current database seems to be empty.<br>Have you used BudgetMaster before version 2.10.0 and want to migrate your existing database?<br><br><span class="red-text bold">CAUTION: If you cancel this dialog, you will not be asked again about the migration!</span> -info.button.migration=Migrate existing database -info.button.migration.start=Migrate database notification.settings.saved=Settings saved notification.settings.security.saved=Password saved notification.settings.security.warning=Password equals already saved password @@ -192,7 +187,6 @@ notification.settings.update.not.available=No update available notification.settings.database.delete.success=Successfully deleted database notification.settings.backup.run.success=Backup successful notification.settings.backup.run.error=Backup failed -notification.migration.error=Migration failed: {0} upload.image.success=Upload successful upload.image.error=Error: {0} upload.image.error.no.file=Error: No file provided for upload @@ -237,11 +231,6 @@ warning.empty.git.url=Please insert the git server's URL. warning.empty.git.branch.name=Please insert the git branch name. warning.empty.git.user.name=Please insert your git username. warning.empty.git.token=Please insert your git access token. -warning.empty.migration.hostname=Please insert the hostname of the database server. -warning.empty.migration.port=Please insert a valid number greater than 0 and less than 65535. -warning.empty.migration.databaseName=Please insert the database name -warning.empty.migration.username=Please insert the username. -warning.empty.migration.password=Please insert the database password. # UI @@ -670,20 +659,3 @@ import.entity.chart=Only user-defined charts will be imported.<br>The import of copied=Copied! -migration.settings.description=All data from your existing BudgetMaster database will be migrated to the new database.<br>Please enter the settings for the new database backend (e.g. postgresql).<br><br><span class="bold">Please make sure your existing database has been opened at least once with BudgetMaster v2.9.2 before running this migration!</span> -migration.settings.description.warning=All existing data of the target database will be permanently deleted! -migration.settings.description.info=The settings are prefilled with the currently used database. -migration.settings.databaseType=Database type -migration.settings.hostname=Hostname -migration.settings.port=Port -migration.settings.databaseName=Database name -migration.settings.username=Username -migration.settings.password=Password -migration.settings.verification.password.description=Please enter your current BudgetMaster password to confirm the migration process.<br><span class="red-text bold">The migration can not be canceled.</span><br>Your existing BudgetMaster database will neither be modified nor deleted. -migration.settings.verification.password=Current BudgetMaster password -migration.settings.verification.password.wrong=Invalid verification password -migration.status.not.running=Migration is not started. -migration.status.running=Migration is running... -migration.status.success=Migration finished! -migration.status.error=Migration failed! -migration.status.summary=Details diff --git a/BudgetMasterServer/src/main/resources/static/css/style.css b/BudgetMasterServer/src/main/resources/static/css/style.css index 53c2f5d6409d77429ccc0920ad62027c9c630eef..b891f66b64375141a3ef750cee6c5264c013d5a8 100644 --- a/BudgetMasterServer/src/main/resources/static/css/style.css +++ b/BudgetMasterServer/src/main/resources/static/css/style.css @@ -572,19 +572,6 @@ input[type="radio"]:checked + span::after, [type="radio"].with-gap:checked + spa margin-top: 3rem; } -.migration-status { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; -} - -.migration-status-icon { - padding-right: 1rem; - font-size: 2rem; -} - - .tag-input-container { display: flex; flex-direction: row; diff --git a/BudgetMasterServer/src/main/resources/static/js/main.js b/BudgetMasterServer/src/main/resources/static/js/main.js index cc2b0c0c3b82336ff0b6ce67798244ad19fe6ffd..368ec0fb3e59986865e8bd99f68dca392e8127a4 100644 --- a/BudgetMasterServer/src/main/resources/static/js/main.js +++ b/BudgetMasterServer/src/main/resources/static/js/main.js @@ -25,11 +25,6 @@ $(document).ready(function() fetchAndShowModal(document.getElementById('whatsNewModelContainer'), 'whatsNewModelContainer', '#modalWhatsNew'); } - if($("#modalMigration").length) - { - $('#modalMigration').modal('open'); - } - $('.tooltipped').tooltip(); $('select').formSelect(); diff --git a/BudgetMasterServer/src/main/resources/static/js/migration.js b/BudgetMasterServer/src/main/resources/static/js/migration.js deleted file mode 100644 index 93ddf30255e91520fe396772c12a9e55fb268690..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/resources/static/js/migration.js +++ /dev/null @@ -1,31 +0,0 @@ -$(document).ready(function() -{ - getMigrationStatus(); -}); - -function getMigrationStatus() -{ - if(typeof migrationStatus !== 'undefined') - { - if(migrationStatus === 'SUCCESS' || migrationStatus === 'ERROR') - { - return; - } - } - - $.ajax({ - type: 'GET', - url: $('#migration-status').attr('data-url'), - data: {}, - success: function(data) - { - $('#migration-status').html(data); - $('.collapsible').collapsible(); - }, - complete: function() - { - // schedule the next request when the current one is complete - setTimeout(getMigrationStatus, 3000); - } - }); -} \ No newline at end of file diff --git a/BudgetMasterServer/src/main/resources/templates/helpers/navbar.ftl b/BudgetMasterServer/src/main/resources/templates/helpers/navbar.ftl index 6f18e45f9d032c27fea0f63dfe7de9554c9d6c77..c0b256a848f0d2915c3ef2f5f17bbea103346c2b 100644 --- a/BudgetMasterServer/src/main/resources/templates/helpers/navbar.ftl +++ b/BudgetMasterServer/src/main/resources/templates/helpers/navbar.ftl @@ -55,7 +55,6 @@ <@backupReminder settings/> <@whatsNewModal settings/> - <@migrationModal activeID/> <div id="globalAccountSelectModalOnDemand"></div> </#macro> @@ -167,18 +166,3 @@ <div id="whatsNewModelContainer" data-url="<@s.url '/about/whatsNewModal'/>"></div> </#if> </#macro> - -<#macro migrationModal loadedPage> - <#if migrationService.needToShowMigrationDialog(loadedPage)> - <div id="modalMigration" class="modal background-color"> - <div class="modal-content"> - <h4>${locale.getString("info.title.migration")}</h4> - <p>${locale.getString("info.text.migration")}</p> - </div> - <div class="modal-footer background-color"> - <@header.buttonLink url='/migration/cancel' icon='clear' localizationKey='cancel' color='red' id='buttonCloseMigration' classes='modal-action modal-close text-white'/> - <@header.buttonLink url='/migration' icon='merge' localizationKey='info.button.migration' color='green' id='buttonStartMigration' classes='modal-action modal-close text-white'/> - </div> - </div> - </#if> -</#macro> \ No newline at end of file diff --git a/BudgetMasterServer/src/main/resources/templates/migration/migration.ftl b/BudgetMasterServer/src/main/resources/templates/migration/migration.ftl deleted file mode 100644 index 79bf0559edf3b27dd0a12f077fa9622559c4b9f6..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/resources/templates/migration/migration.ftl +++ /dev/null @@ -1,143 +0,0 @@ -<html> - <head> - <#import "../helpers/header.ftl" as header> - <@header.globals/> - <@header.header "BudgetMaster - ${locale.getString('title.migration')}"/> - <#import "/spring.ftl" as s> - </head> - <@header.body> - <#import "../helpers/navbar.ftl" as navbar> - <@navbar.navbar "migration" settings/> - <#import "../helpers/validation.ftl" as validation> - - <main> - <div class="card main-card background-color"> - <div class="container"> - <div class="section center-align"> - <div class="headline">${locale.getString("title.migration")}</div> - </div> - </div> - - <@header.content> - <div class="container"> - <form name="MigrationSettings" action="<@s.url '/migration'/>" method="post"> - <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> - - <div class="row"> - <div class="col s12 m12 l8 offset-l2"> - ${locale.getString("migration.settings.description")} - </div> - </div> - - <div class="row notification-row"> - <div class="col s12 center-align"> - <div class="notification-wrapper"> - <div class="notification background-yellow text-black"> - <i class="fas fa-exclamation-triangle notification-item"></i> - <span class="notification-item left-align">${locale.getString("migration.settings.description.warning")}</span> - </div> - </div> - </div> - </div> - - <div class="row notification-row"> - <div class="col s12 center-align"> - <div class="notification-wrapper"> - <div class="notification background-grey text-black"> - <i class="fas fa-info notification-item"></i> - <span class="notification-item left-align">${locale.getString("migration.settings.description.info")}</span> - </div> - </div> - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">widgets</i> - <select id="migration-database-type" name="databaseTypeName"> - <#list databaseTypes as databaseType> - <#if migrationSettings.databaseType() == databaseType> - <option selected value="${databaseType.getName()}">${databaseType.getName()}</option> - <#else> - <option value="${databaseType.getName()}">${databaseType.getName()}</option> - </#if> - </#list> - </select> - <label for="migration-database-type">${locale.getString("migration.settings.databaseType")}</label> - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">public</i> - <input id="migration-hostname" type="text" name="hostname" <@validation.validation "hostname"/> value="<#if migrationSettings.hostname()??>${migrationSettings.hostname()}</#if>" placeholder="localhost"> - <label for="migration-hostname">${locale.getString("migration.settings.hostname")}</label> - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">dns</i> - <input id="migration-port" type="number" min="1" max="65535" name="port" <@validation.validation "port"/> value="<#if migrationSettings.port()??>${migrationSettings.port()?c}</#if>" placeholder="5432"> - <label for="migration-port">${locale.getString("migration.settings.port")}</label> - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">inventory</i> - <input id="migration-database-name" type="text" name="databaseName" <@validation.validation "databaseName"/> value="<#if migrationSettings.databaseName()??>${migrationSettings.databaseName()}</#if>"> - <label for="migration-database-name">${locale.getString("migration.settings.databaseName")}</label> - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">person</i> - <input id="migration-username" type="text" name="username" <@validation.validation "username"/> value="<#if migrationSettings.username()??>${migrationSettings.username()}</#if>"> - <label for="migration-username">${locale.getString("migration.settings.username")}</label> - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">vpn_key</i> - <input id="migration-password" type="text" name="password" <@validation.validation "password"/> value="<#if migrationSettings.password()??>${migrationSettings.password()}</#if>"> - <label for="migration-password">${locale.getString("migration.settings.password")}</label> - </div> - </div> - - <div class="row"> - <div class="col s12 m12 l8 offset-l2"> - ${locale.getString("migration.settings.verification.password.description")} - </div> - </div> - - <div class="row"> - <div class="input-field col s12 m12 l8 offset-l2"> - <i class="material-icons prefix">lock_open</i> - <input id="migration-verification-password" type="password" name="verificationPassword" <@validation.validation "verificationPassword"/> value=""> - <label for="migration-verification-password">${locale.getString("migration.settings.verification.password")}</label> - </div> - </div> - - <div class="row"> - <div class="col m6 l4 offset-l2 right-align"> - <@header.buttonLink url='/' icon='clear' localizationKey='cancel' color='red'/> - </div> - - <div class="col m6 l4 left-align"> - <@header.buttonSubmit name='action' icon='merge' localizationKey='info.button.migration.start' id='buttonMigrate' color='green'/> - </div> - </div> - </form> - </div> - </@header.content> - </div> - </main> - - <!-- Scripts--> - <#import "../helpers/scripts.ftl" as scripts> - <@scripts.scripts/> - </@header.body> -</html> \ No newline at end of file diff --git a/BudgetMasterServer/src/main/resources/templates/migration/status.ftl b/BudgetMasterServer/src/main/resources/templates/migration/status.ftl deleted file mode 100644 index 20dbff6860353785f56e2876d47de7ab79e5827c..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/resources/templates/migration/status.ftl +++ /dev/null @@ -1,37 +0,0 @@ -<html> - <head> - <#import "../helpers/header.ftl" as header> - <@header.globals/> - <@header.header "BudgetMaster - ${locale.getString('title.migration')}"/> - <#import "/spring.ftl" as s> - <@header.style "collapsible"/> - </head> - <@header.body> - <#import "../helpers/navbar.ftl" as navbar> - <@navbar.navbar "migration" settings/> - <#import "../helpers/validation.ftl" as validation> - - <main> - <div class="card main-card background-color"> - <div class="container"> - <div class="section center-align"> - <div class="headline">${locale.getString("title.migration")}</div> - </div> - </div> - - <div class="container center-align"> - <div id="migration-status" data-url="<@s.url '/migration/getStatus'/>"></div> - </div> - </div> - </main> - - <script> - migrationStatus = "${status.name()}"; - </script> - - <!-- Scripts--> - <#import "../helpers/scripts.ftl" as scripts> - <@scripts.scripts/> - <script src="<@s.url '/js/migration.js'/>"></script> - </@header.body> -</html> \ No newline at end of file diff --git a/BudgetMasterServer/src/main/resources/templates/migration/statusFragment.ftl b/BudgetMasterServer/src/main/resources/templates/migration/statusFragment.ftl deleted file mode 100644 index 0893d2e0fde2a03ba65f433e4b2484a23189b524..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/main/resources/templates/migration/statusFragment.ftl +++ /dev/null @@ -1,85 +0,0 @@ -<#global locale = static["de.thecodelabs.utils.util.Localization"]> -<#import "/spring.ftl" as s> -<#import "../helpers/header.ftl" as header> - -<div class="row"> - <div class="col s12 m12 l8 offset-l2"> - <div class="headline-small migration-status"><i class="${status.getIcon()} ${status.getTextColor()} migration-status-icon"></i> ${locale.getString(status.getLocalizationKey())}</div> - </div> -</div> - -<#if status.name() == "RUNNING"> - <div class="row"> - <div class="col s12 m12 l8 offset-l2"> - <div class="preloader-wrapper small active" id="progress-spinner"> - <div class="spinner-layer spinner-blue-only"> - <div class="circle-clipper left"> - <div class="circle"></div> - </div> - <div class="gap-patch"> - <div class="circle"></div> - </div> - <div class="circle-clipper right"> - <div class="circle"></div> - </div> - </div> - </div> - </div> - </div> -</#if> - -<#if status.name() == "SUCCESS"> - <div class="row"> - <div class="col s12"> - <ul class="collapsible"> - <li> - <div class="collapsible-header bold"> - <i class="fas fa-info"></i> - ${locale.getString("migration.status.summary")} - </div> - <div class="collapsible-body"> - <table class="bordered"> - <#list summary as summaryLine> - <tr> - <td>${summaryLine}</td> - </tr> - </#list> - </table> - </div> - </li> - </ul> - </div> - </div> - - <div class="row" id="button-migration-home"> - <div class="col s12 m12 l8 offset-l2"> - <@header.buttonLink url='/' icon='home' localizationKey='menu.home'/> - </div> - </div> -</#if> - -<#if status.name() == "ERROR"> - <div class="row"> - <div class="col s12"> - <ul class="collapsible"> - <li> - <div class="collapsible-header bold"> - <i class="${status.getIcon()} ${status.getTextColor()}"></i> - ${locale.getString("migration.status.summary")} - </div> - <div class="collapsible-body"> - <p class="left-align"> - <#list summary as summaryLine> - ${summaryLine}<br> - </#list> - </p> - </div> - </li> - </ul> - </div> - </div> -</#if> - -<script> - migrationStatus = "${status.name()}"; -</script> \ No newline at end of file diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/helpers/IntegrationTestHelper.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/helpers/IntegrationTestHelper.java index 608e4176f032d810095e6e34720e0787f0eda263..5e41b756916fbfe40abbefa252ff5c16ef308c54 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/helpers/IntegrationTestHelper.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/helpers/IntegrationTestHelper.java @@ -88,18 +88,6 @@ public class IntegrationTestHelper } } - public void hideMigrationDialog() - { - try - { - WebElement buttonCloseReminder = driver.findElement(By.cssSelector("#modalMigration #buttonCloseMigration")); - buttonCloseReminder.click(); - } - catch(NoSuchElementException ignored) - { - } - } - public void uploadDatabase(String path) { if(path.startsWith("\\")) diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountSelectTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountSelectTest.java index 95263f4487b36ccf66e6c2fe47d6dcc59bd9dc14..363a252d83ee9dd46bc0438c87f28cd26d39d187 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountSelectTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountSelectTest.java @@ -28,7 +28,6 @@ class AccountSelectTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = Account.class.getClassLoader().getResource("AccountDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountTest.java index 1066cf323bf14196949eae74f26656f281abc7a0..1c0afe926de1efec966b3bebfb0140af58909463 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/AccountTest.java @@ -34,7 +34,6 @@ class AccountTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = Account.class.getClassLoader().getResource("AccountDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CategorySelectTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CategorySelectTest.java index 061a269cf173f5b74e31eaee890b432b75df5e26..6fb640e0b18e8ab2fc7a4c48bd20b7a7ccf9bad7 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CategorySelectTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/CategorySelectTest.java @@ -32,7 +32,6 @@ class CategorySelectTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChangeTransactionTypeTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChangeTransactionTypeTest.java index 9d51ff6ed8b54439af7907f16049562f0510efe5..08a3e22635641a43f1c8051a3ed9ef83382cdea8 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChangeTransactionTypeTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChangeTransactionTypeTest.java @@ -56,7 +56,6 @@ class ChangeTransactionTypeTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChartTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChartTest.java index 8de7c7935119cbf98521e90c54529b5b7ddda693..171a3c38be6ddd85f5c7a6d67080e94a24148452 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChartTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/ChartTest.java @@ -35,7 +35,6 @@ class ChartTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/DeleteDatabaseTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/DeleteDatabaseTest.java index 95d7447e724d36f39a8753cbc0c10e73f4b4eff0..e2aa65b1d1e0731d698a5e6bfdb1f0fa93ea0323 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/DeleteDatabaseTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/DeleteDatabaseTest.java @@ -31,7 +31,6 @@ class DeleteDatabaseTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("DatabaseDeleteTest.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/FirstUseTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/FirstUseTest.java index 93ae4b5ee92de9049cd019073a203eb4e1f77794..cb7ea85af95638700697294fca4b1d506aa252b8 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/FirstUseTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/FirstUseTest.java @@ -25,7 +25,6 @@ class FirstUseTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } @Test diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/HotkeyTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/HotkeyTest.java index 777b20cc6861540bf6e7412f5dbfb6be056ceb94..9782fdb6f55736b63ad4d82b72b6261ae4751c0f 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/HotkeyTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/HotkeyTest.java @@ -33,7 +33,6 @@ class HotkeyTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/LoginControllerTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/LoginControllerTest.java index a884d3928e0dad9d6f27775ad2dfd5702c188dd5..ce1bbb232bd1c5ec53196d3a32d2b974be6ff0a7 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/LoginControllerTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/LoginControllerTest.java @@ -58,7 +58,6 @@ class LoginControllerTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); WebElement label = driver.findElement(By.id("logo-home")); String expected = helper.getUrl() + "/images/Logo_with_white_text_medium_res.png"; @@ -73,7 +72,6 @@ class LoginControllerTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("logo-home"))); @@ -91,7 +89,6 @@ class LoginControllerTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); logout(); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/MediaTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/MediaTest.java index a8bf25dac677bede8b8c559d83335bba77f24ba4..1758ffcae61bf89d8ecc94aeff9069a9ddb4fb50 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/MediaTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/MediaTest.java @@ -29,7 +29,6 @@ class MediaTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("OnlyAccountsWithDifferentImages.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromExistingOneTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromExistingOneTest.java index f9b170a041a86497978a7bce465d718e2a7ff4b7..92882dd60d842fe578d87f705f4afeb1c4ddd662 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromExistingOneTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromExistingOneTest.java @@ -28,7 +28,6 @@ class NewTransactionFromExistingOneTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("NewTransactionFromExistingOneTest.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromTemplateTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromTemplateTest.java index ea97d4881765abe71f15584c1ec94ce5318a79a8..5b7eefe36151a28a5e33f464f561a682a1901ddd 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromTemplateTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionFromTemplateTest.java @@ -29,7 +29,6 @@ class NewTransactionFromTemplateTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionNormalTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionNormalTest.java index 6c5ecb9868060bca27f4798cf2d410532401681b..dca149d9a59cf8d6f3aef12aaf60b62487542ecf 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionNormalTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionNormalTest.java @@ -32,7 +32,6 @@ class NewTransactionNormalTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionRecurringTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionRecurringTest.java index 1d450648e657abbdcbc0b17190d5ca98568d2e8a..2103b80e37839f7eb5161009a945db15addb86a0 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionRecurringTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionRecurringTest.java @@ -35,7 +35,6 @@ class NewTransactionRecurringTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionTransferTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionTransferTest.java index a4f45e162003987b06e4adcca78c8b5cdfdc53c9..c38e7d4a799264b88e3817dd385075fd1c110e65 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionTransferTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/NewTransactionTransferTest.java @@ -31,7 +31,6 @@ class NewTransactionTransferTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/SearchTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/SearchTest.java index 1504df20f4cc7c786049f2dcca202d5169a99f58..1aec846f90bc3dd2a48ab2ddfa7041b93198d532 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/SearchTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/SearchTest.java @@ -26,7 +26,6 @@ class SearchTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("SearchDatabase.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/TagTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/TagTest.java index 5019f18a7f63583ba9de60b80a81ed2a2ae8ee96..fa44ee751923f50f4df94f2985968577c4d3427f 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/TagTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/TagTest.java @@ -25,7 +25,6 @@ class TagTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); String path = getClass().getClassLoader().getResource("TagWithSingleQuoteTest.json").getFile().replace("/", File.separator); helper.uploadDatabase(path); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/BackupSettingsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/BackupSettingsTest.java index bcb5ffc160f92f386b599dc95ef2fcb88a0c3344..d84a4e73c7b261cb18ca5882680059f339acf1a4 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/BackupSettingsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/BackupSettingsTest.java @@ -25,7 +25,6 @@ class BackupSettingsTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } @Test diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/MiscSettingsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/MiscSettingsTest.java index a543ac46f1a219bde8efe7c7ff6d4dc3349d84b9..c07b8e9eb5c53c87ab8ae34bbd4df7ded0e05695 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/MiscSettingsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/MiscSettingsTest.java @@ -25,7 +25,6 @@ class MiscSettingsTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/PersonalizationSettingsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/PersonalizationSettingsTest.java index 78d48efc628f30cf5f4c69c53c886788da220fdf..00549627a860624f6a9b0a61d673c3f5096a4185 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/PersonalizationSettingsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/PersonalizationSettingsTest.java @@ -26,7 +26,6 @@ class PersonalizationSettingsTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } @Test diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/SecuritySettingsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/SecuritySettingsTest.java index d85f24e706801f653e3a19a55a324fc76c5005fa..4bf0f96912af7eeb56d5cbb3968e63a2acae7feb 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/SecuritySettingsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/SecuritySettingsTest.java @@ -25,7 +25,6 @@ class SecuritySettingsTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } @Test diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/TransactionSettingsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/TransactionSettingsTest.java index f0fd89ddcf34638577b15343951fee3493a6058f..99d5c1ea6b58249b1c898867ea3a2c5539aeb1d3 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/TransactionSettingsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/TransactionSettingsTest.java @@ -28,7 +28,6 @@ class TransactionSettingsTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } @Test diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/UpdatesSettingsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/UpdatesSettingsTest.java index d2955dddb81bac30149d20d390d4a9f1fb958513..0848eec07b9826c44b007f1bcab39f59a1ea95de 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/UpdatesSettingsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/selenium/settings/UpdatesSettingsTest.java @@ -25,7 +25,6 @@ class UpdatesSettingsTest extends SeleniumTestBase helper.login(UserService.DEFAULT_PASSWORD); helper.hideBackupReminder(); helper.hideWhatsNewDialog(); - helper.hideMigrationDialog(); } @Test diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/MigrationServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/MigrationServiceTest.java deleted file mode 100644 index 430c4b89d186ff3ae18274e3988064710d7c0152..0000000000000000000000000000000000000000 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/MigrationServiceTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package de.deadlocker8.budgetmaster.unit; - -import de.deadlocker8.budgetmaster.accounts.AccountRepository; -import de.deadlocker8.budgetmaster.categories.Category; -import de.deadlocker8.budgetmaster.categories.CategoryRepository; -import de.deadlocker8.budgetmaster.categories.CategoryType; -import de.deadlocker8.budgetmaster.migration.MigrationService; -import de.deadlocker8.budgetmaster.settings.Settings; -import de.deadlocker8.budgetmaster.settings.SettingsService; -import de.deadlocker8.budgetmaster.templates.TemplateRepository; -import de.deadlocker8.budgetmaster.transactions.TransactionRepository; -import de.deadlocker8.budgetmaster.unit.helpers.LocalizedTest; -import de.deadlocker8.budgetmaster.utils.DatabaseConfigurationProperties; -import de.deadlocker8.budgetmaster.utils.Mappings; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.io.TempDir; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -@ExtendWith(SpringExtension.class) -@LocalizedTest -class MigrationServiceTest -{ - @Mock - private SettingsService settingsService; - - @Mock - private AccountRepository accountRepository; - - @Mock - private CategoryRepository categoryRepository; - - @Mock - private TransactionRepository transactionRepository; - - @Mock - private TemplateRepository templateRepository; - - @Mock - private DatabaseConfigurationProperties databaseConfig; - - @Mock - private TaskScheduler scheduler; - - @TempDir - public Path tempFolder; - - @Test - void test_needToShowMigrationDialog_migrationPageOpened_returnFalse() throws IOException - { - final Settings settings = Settings.getDefault(); - - final Path previousDatabase = tempFolder.resolve(MigrationService.PREVIOUS_DATABASE_FILE_NAME); - Files.createFile(previousDatabase); - - Mockito.when(settingsService.getSettings()).thenReturn(settings); - - final MigrationService migrationService = new MigrationService(settingsService, tempFolder, accountRepository, categoryRepository, transactionRepository, templateRepository, databaseConfig, scheduler); - assertThat(migrationService.needToShowMigrationDialog("migration")).isFalse(); - } - - @Test - void test_needToShowMigrationDialog_migrationDeclined_returnFalse() throws IOException - { - final Settings settings = Settings.getDefault(); - settings.setMigrationDeclined(true); - - final Path previousDatabase = tempFolder.resolve(MigrationService.PREVIOUS_DATABASE_FILE_NAME); - Files.createFile(previousDatabase); - - Mockito.when(settingsService.getSettings()).thenReturn(settings); - - final MigrationService migrationService = new MigrationService(settingsService, tempFolder, accountRepository, categoryRepository, transactionRepository, templateRepository, databaseConfig, scheduler); - assertThat(migrationService.needToShowMigrationDialog(Mappings.TRANSACTIONS)).isFalse(); - } - - @Test - void test_needToShowMigrationDialog_newDatabaseNotEmpty_returnFalse() throws IOException - { - final Settings settings = Settings.getDefault(); - - final Path previousDatabase = tempFolder.resolve(MigrationService.PREVIOUS_DATABASE_FILE_NAME); - Files.createFile(previousDatabase); - - Mockito.when(settingsService.getSettings()).thenReturn(settings); - Mockito.when(categoryRepository.findAllByTypeOrderByNameAsc(CategoryType.CUSTOM)).thenReturn(List.of(new Category("custom category", "ff0000", CategoryType.CUSTOM))); - - final MigrationService migrationService = new MigrationService(settingsService, tempFolder, accountRepository, categoryRepository, transactionRepository, templateRepository, databaseConfig, scheduler); - assertThat(migrationService.needToShowMigrationDialog(Mappings.TRANSACTIONS)).isFalse(); - } - - @Test - void test_needToShowMigrationDialog_noPreviousDatabaseExisting_returnFalse() - { - final Settings settings = Settings.getDefault(); - - Mockito.when(settingsService.getSettings()).thenReturn(settings); - - final MigrationService migrationService = new MigrationService(settingsService, tempFolder, accountRepository, categoryRepository, transactionRepository, templateRepository, databaseConfig, scheduler); - assertThat(migrationService.needToShowMigrationDialog(Mappings.TRANSACTIONS)).isFalse(); - } - - @Test - void test_needToShowMigrationDialog_migrationPageNotOpenend_emptyDestinationDatabase_existingPreviousDatabase_notDeclined_returnTrue() throws IOException - { - final Settings settings = Settings.getDefault(); - - final Path previousDatabase = tempFolder.resolve(MigrationService.PREVIOUS_DATABASE_FILE_NAME); - Files.createFile(previousDatabase); - - Mockito.when(settingsService.getSettings()).thenReturn(settings); - - final MigrationService migrationService = new MigrationService(settingsService, tempFolder, accountRepository, categoryRepository, transactionRepository, templateRepository, databaseConfig, scheduler); - assertThat(migrationService.needToShowMigrationDialog(Mappings.TRANSACTIONS)).isTrue(); - } -}