| 17 | import java.util.UUID; |
| 18 | |
| 19 | @SpringBootApplication |
| 20 | public class Main { |
| 21 | |
| 22 | public static void main(String[] args) { |
| 23 | SpringApplication.run(Main.class, args); |
| 24 | } |
| 25 | |
| 26 | @Bean |
| 27 | CommandLineRunner runner( |
| 28 | CustomerRepository customerRepository, |
| 29 | PasswordEncoder passwordEncoder) { |
| 30 | return args -> { |
| 31 | createRandomCustomer(customerRepository, passwordEncoder); |
| 32 | // testBucketUploadAndDownload(s3Service, s3Buckets); |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | private static void testBucketUploadAndDownload(S3Service s3Service, |
| 37 | S3Buckets s3Buckets) { |
| 38 | s3Service.putObject( |
| 39 | s3Buckets.getCustomer(), |
| 40 | "foo/bar/jamila", |
| 41 | "Hello World".getBytes() |
| 42 | ); |
| 43 | |
| 44 | byte[] obj = s3Service.getObject( |
| 45 | s3Buckets.getCustomer(), |
| 46 | "foo/bar/jamila" |
| 47 | ); |
| 48 | |
| 49 | System.out.println("Hooray: " + new String(obj)); |
| 50 | } |
| 51 | |
| 52 | private static void createRandomCustomer(CustomerRepository customerRepository, PasswordEncoder passwordEncoder) { |
| 53 | var faker = new Faker(); |
| 54 | Random random = new Random(); |
| 55 | Name name = faker.name(); |
| 56 | String firstName = name.firstName(); |
| 57 | String lastName = name.lastName(); |
| 58 | int age = random.nextInt(16, 99); |
| 59 | Gender gender = age % 2 == 0 ? Gender.MALE : Gender.FEMALE; |
| 60 | String email = firstName.toLowerCase() + "." + lastName.toLowerCase() + "@amigoscode.com"; |
| 61 | Customer customer = new Customer( |
| 62 | firstName + " " + lastName, |
| 63 | email, |
| 64 | passwordEncoder.encode("password"), |
| 65 | age, |
| 66 | gender); |
| 67 | customerRepository.save(customer); |
| 68 | System.out.println(email); |
| 69 | } |
| 70 | |
| 71 | } |
nothing calls this directly
no outgoing calls
no test coverage detected