JAVA-13721 Further formatting of files

This commit is contained in:
Dhawal Kapil 2023-05-16 23:06:58 +05:30
parent 7b8fad5dc9
commit 585d1e1575
8 changed files with 27 additions and 24 deletions

View File

@ -1,7 +1,5 @@
package com.baeldung.mockito.argumentcaptor; package com.baeldung.mockito.argumentcaptor;
public enum AuthenticationStatus { public enum AuthenticationStatus {
AUTHENTICATED, AUTHENTICATED, NOT_AUTHENTICATED, ERROR
NOT_AUTHENTICATED,
ERROR
} }

View File

@ -1,7 +1,5 @@
package com.baeldung.mockito.argumentcaptor; package com.baeldung.mockito.argumentcaptor;
public enum ServiceStatus { public enum ServiceStatus {
UP, UP, DOWN, AUTHENTICATED
DOWN,
AUTHENTICATED
} }

View File

@ -11,15 +11,15 @@ public class FlowerService {
private List<String> flowers = Arrays.asList("Poppy", "Ageratum", "Carnation", "Diascia", "Lantana"); private List<String> flowers = Arrays.asList("Poppy", "Ageratum", "Carnation", "Diascia", "Lantana");
public String analyze(String name) { public String analyze(String name) {
if(flowers.contains(name)) { if (flowers.contains(name)) {
return "flower"; return "flower";
} }
return null; return null;
} }
public boolean isABigFlower(String name, int petals) { public boolean isABigFlower(String name, int petals) {
if(flowers.contains(name)) { if (flowers.contains(name)) {
if(petals > 10) { if (petals > 10) {
return true; return true;
} }
} }

View File

@ -1,34 +1,39 @@
package com.baeldung.mockito.junit5; package com.baeldung.mockito.junit5;
public class User { public class User {
private Integer id; private Integer id;
private String name; private String name;
private int age; private int age;
public User() { public User() {
} }
public User(String name, int age) { public User(String name, int age) {
this.name = name; this.name = name;
this.age = age; this.age = age;
} }
public Integer getId() { public Integer getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public int getAge() { public int getAge() {
return age; return age;
} }
public void setAge(int age) { public void setAge(int age) {
this.age = age; this.age = age;
} }

View File

@ -1,7 +1,7 @@
package com.baeldung.mockito.junit5.repository; package com.baeldung.mockito.junit5.repository;
public interface SettingRepository { public interface SettingRepository {
int getUserMinAge(); int getUserMinAge();
int getUserNameMinLength(); int getUserNameMinLength();

View File

@ -5,6 +5,7 @@ import com.baeldung.mockito.junit5.User;
public interface UserRepository { public interface UserRepository {
User insert(User user); User insert(User user);
boolean isUsernameAlreadyExists(String userName); boolean isUsernameAlreadyExists(String userName);
} }

View File

@ -6,11 +6,11 @@ import com.baeldung.mockito.junit5.repository.SettingRepository;
import com.baeldung.mockito.junit5.repository.UserRepository; import com.baeldung.mockito.junit5.repository.UserRepository;
public class DefaultUserService implements UserService { public class DefaultUserService implements UserService {
private UserRepository userRepository; private UserRepository userRepository;
private SettingRepository settingRepository; private SettingRepository settingRepository;
private MailClient mailClient; private MailClient mailClient;
public DefaultUserService(UserRepository userRepository, SettingRepository settingRepository, MailClient mailClient) { public DefaultUserService(UserRepository userRepository, SettingRepository settingRepository, MailClient mailClient) {
this.userRepository = userRepository; this.userRepository = userRepository;
this.settingRepository = settingRepository; this.settingRepository = settingRepository;
@ -26,19 +26,20 @@ public class DefaultUserService implements UserService {
} }
private void validate(User user) { private void validate(User user) {
if(user.getName() == null) { if (user.getName() == null) {
throw new RuntimeException(Errors.USER_NAME_REQUIRED); 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); throw new RuntimeException(Errors.USER_NAME_SHORT);
} }
if(user.getAge() < settingRepository.getUserMinAge()) { if (user.getAge() < settingRepository.getUserMinAge()) {
throw new RuntimeException(Errors.USER_AGE_YOUNG); throw new RuntimeException(Errors.USER_AGE_YOUNG);
} }
if(userRepository.isUsernameAlreadyExists(user.getName())) { if (userRepository.isUsernameAlreadyExists(user.getName())) {
throw new RuntimeException(Errors.USER_NAME_DUPLICATE); throw new RuntimeException(Errors.USER_NAME_DUPLICATE);
} }
} }

View File

@ -6,5 +6,5 @@ public class Errors {
public static final String USER_NAME_SHORT = "user.name.short"; 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_AGE_YOUNG = "user.age.young";
public static final String USER_NAME_DUPLICATE = "user.name.duplicate"; public static final String USER_NAME_DUPLICATE = "user.name.duplicate";
} }