From 585d1e1575b51e50c0103ca65c0fe90ed1f5f9a7 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Tue, 16 May 2023 23:06:58 +0530 Subject: [PATCH] JAVA-13721 Further formatting of files --- .../argumentcaptor/AuthenticationStatus.java | 4 +--- .../mockito/argumentcaptor/ServiceStatus.java | 4 +--- .../argumentmatchers/service/FlowerService.java | 6 +++--- .../java/com/baeldung/mockito/junit5/User.java | 13 +++++++++---- .../junit5/repository/SettingRepository.java | 2 +- .../junit5/repository/UserRepository.java | 3 ++- .../junit5/service/DefaultUserService.java | 17 +++++++++-------- .../baeldung/mockito/junit5/service/Errors.java | 2 +- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/AuthenticationStatus.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/AuthenticationStatus.java index 8307b4323b..0ba8a70021 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/AuthenticationStatus.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/AuthenticationStatus.java @@ -1,7 +1,5 @@ package com.baeldung.mockito.argumentcaptor; public enum AuthenticationStatus { - AUTHENTICATED, - NOT_AUTHENTICATED, - ERROR + AUTHENTICATED, NOT_AUTHENTICATED, ERROR } diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/ServiceStatus.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/ServiceStatus.java index 65def5af64..3951174b30 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/ServiceStatus.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentcaptor/ServiceStatus.java @@ -1,7 +1,5 @@ package com.baeldung.mockito.argumentcaptor; public enum ServiceStatus { - UP, - DOWN, - AUTHENTICATED + UP, DOWN, AUTHENTICATED } diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentmatchers/service/FlowerService.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentmatchers/service/FlowerService.java index 364f2b57d7..f654638fd3 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentmatchers/service/FlowerService.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/argumentmatchers/service/FlowerService.java @@ -11,15 +11,15 @@ public class FlowerService { private List flowers = Arrays.asList("Poppy", "Ageratum", "Carnation", "Diascia", "Lantana"); public String analyze(String name) { - if(flowers.contains(name)) { + if (flowers.contains(name)) { return "flower"; } return null; } public boolean isABigFlower(String name, int petals) { - if(flowers.contains(name)) { - if(petals > 10) { + if (flowers.contains(name)) { + if (petals > 10) { return true; } } diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/User.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/User.java index 0f0b93e30b..4457d59b02 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/User.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/User.java @@ -1,34 +1,39 @@ package com.baeldung.mockito.junit5; public class User { - + private Integer id; private String name; private int age; - + public User() { } - + public User(String name, int age) { this.name = name; this.age = age; } - + public Integer getId() { return id; } + public void setId(Integer id) { this.id = id; } + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public int getAge() { return age; } + public void setAge(int age) { this.age = age; } diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/SettingRepository.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/SettingRepository.java index 78249c9fd9..094be12770 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/SettingRepository.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/SettingRepository.java @@ -1,7 +1,7 @@ package com.baeldung.mockito.junit5.repository; public interface SettingRepository { - + int getUserMinAge(); int getUserNameMinLength(); diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/UserRepository.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/UserRepository.java index 5ce624b73b..9bc1b0d38c 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/UserRepository.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/repository/UserRepository.java @@ -5,6 +5,7 @@ import com.baeldung.mockito.junit5.User; public interface UserRepository { User insert(User user); + boolean isUsernameAlreadyExists(String userName); - + } diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/DefaultUserService.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/DefaultUserService.java index c239bba2b3..bad4e46682 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/DefaultUserService.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/DefaultUserService.java @@ -6,11 +6,11 @@ import com.baeldung.mockito.junit5.repository.SettingRepository; import com.baeldung.mockito.junit5.repository.UserRepository; public class DefaultUserService implements UserService { - + private UserRepository userRepository; private SettingRepository settingRepository; private MailClient mailClient; - + public DefaultUserService(UserRepository userRepository, SettingRepository settingRepository, MailClient mailClient) { this.userRepository = userRepository; this.settingRepository = settingRepository; @@ -26,19 +26,20 @@ public class DefaultUserService implements UserService { } private void validate(User user) { - if(user.getName() == null) { + if (user.getName() == null) { throw new RuntimeException(Errors.USER_NAME_REQUIRED); } - if(user.getName().length() < settingRepository.getUserNameMinLength()) { + if (user.getName() + .length() < settingRepository.getUserNameMinLength()) { throw new RuntimeException(Errors.USER_NAME_SHORT); } - - if(user.getAge() < settingRepository.getUserMinAge()) { + + if (user.getAge() < settingRepository.getUserMinAge()) { throw new RuntimeException(Errors.USER_AGE_YOUNG); } - - if(userRepository.isUsernameAlreadyExists(user.getName())) { + + if (userRepository.isUsernameAlreadyExists(user.getName())) { throw new RuntimeException(Errors.USER_NAME_DUPLICATE); } } diff --git a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/Errors.java b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/Errors.java index c46688f484..8a6882124a 100644 --- a/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/Errors.java +++ b/testing-modules/mockito-simple/src/main/java/com/baeldung/mockito/junit5/service/Errors.java @@ -6,5 +6,5 @@ public class Errors { public static final String USER_NAME_SHORT = "user.name.short"; public static final String USER_AGE_YOUNG = "user.age.young"; public static final String USER_NAME_DUPLICATE = "user.name.duplicate"; - + }