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;
public enum AuthenticationStatus {
AUTHENTICATED,
NOT_AUTHENTICATED,
ERROR
AUTHENTICATED, NOT_AUTHENTICATED, ERROR
}

View File

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

View File

@ -11,15 +11,15 @@ public class FlowerService {
private List<String> 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;
}
}

View File

@ -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;
}

View File

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

View File

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

View File

@ -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);
}
}

View File

@ -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";
}