Class Initializer

java.lang.Object
com.mindstore.backend.security.Initializer
All Implemented Interfaces:
org.springframework.boot.CommandLineRunner

@Component public class Initializer extends Object implements org.springframework.boot.CommandLineRunner
Initializer class that is used to populate the database with texts and a test user.
  • Constructor Details

    • Initializer

      public Initializer(TextIndexService textIndexService, UserRepository userRepository, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
      initializer class
      Parameters:
      textIndexService - service class that holds logic for manipulating textDocuments
      userRepository - repository class for users
      passwordEncoder - used to encode passwords for users
  • Method Details

    • run

      public void run(String... args) throws Exception
      Specified by:
      run in interface org.springframework.boot.CommandLineRunner
      Parameters:
      args - function: initializes the application by adding the textDocuments that are present in the data.json and by adding a test user that can be used in tests note: the first step is deleting all existing entries --> this can be commented out later
      Throws:
      Exception - when the data file is not found or the initialization cannot be done (for whatever reasons)