mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:25:49 +00:00
add CredentialServiceTest
This commit is contained in:
parent
f37360e8ab
commit
37f8f05c01
19 changed files with 262 additions and 45 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.samples.petclinic.configuration;
|
||||
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.configuration.MutableConfiguration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
|
||||
|
@ -34,7 +35,11 @@ class CacheConfiguration {
|
|||
|
||||
@Bean
|
||||
public JCacheManagerCustomizer petclinicCacheConfigurationCustomizer() {
|
||||
return cm -> cm.createCache("vets", cacheConfiguration());
|
||||
return (cm) -> {
|
||||
if (cm.getCache("vets") == null) {
|
||||
cm.createCache("vets", cacheConfiguration());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,4 +55,13 @@ class CacheConfiguration {
|
|||
return new MutableConfiguration<>().setStatisticsEnabled(true);
|
||||
}
|
||||
|
||||
class MyCashe implements JCacheManagerCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(CacheManager cacheManager) {
|
||||
if (cacheManager.getCache("vets") == null) {
|
||||
cacheManager.createCache("vets", cacheConfiguration());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.samples.petclinic.common.*;
|
||||
import org.springframework.samples.petclinic.controller.common.WebSocketSender;
|
||||
import org.springframework.samples.petclinic.dto.common.CredentialDTO;
|
||||
import org.springframework.samples.petclinic.dto.common.MessageDTO;
|
||||
import org.springframework.samples.petclinic.dto.common.UserDTO;
|
||||
|
@ -38,6 +37,9 @@ import java.util.Map;
|
|||
@Controller
|
||||
public class UserController extends WebSocketSender {
|
||||
|
||||
// set true if you whant confirmation email for first provider connection
|
||||
private static final boolean ASK_OAUTH2_CONFIRMATION = false;
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final CredentialService credentialService;
|
||||
|
@ -179,15 +181,23 @@ public class UserController extends WebSocketSender {
|
|||
user = userService.save(user);
|
||||
}
|
||||
|
||||
// send confirmation mail
|
||||
MessageDTO message = new MessageDTO(firstName, lastName, "admin@petclinic.com", credential.getEmail(),
|
||||
if (ASK_OAUTH2_CONFIRMATION) {
|
||||
// prepare message
|
||||
MessageDTO message = new MessageDTO(firstName, lastName, "admin@petclinic.com", email,
|
||||
"New connexion from " + credential.getProvider(),
|
||||
"Your attempt to connect from " + credential.getProvider()
|
||||
+ " To confirm this connection, please click the link below : ",
|
||||
"http://localhost:8080/confirm-account?token=" + credential.getToken());
|
||||
|
||||
log.info(message.toString());
|
||||
// send confirmation mail
|
||||
emailService.sendMailAsynch(message, Locale.getDefault());
|
||||
}
|
||||
else {
|
||||
credential.setExpiration(null);
|
||||
credential.setToken("");
|
||||
credential.setVerified(true);
|
||||
credentialService.save(credential);
|
||||
}
|
||||
|
||||
// disconnect
|
||||
authentication.eraseCredentials();
|
||||
|
|
|
@ -57,9 +57,15 @@ public class CredentialDTO extends BaseDTO {
|
|||
this.setExpiration();
|
||||
}
|
||||
|
||||
public CredentialDTO(@NotNull String provider, @NotNull @Size(min = CommonParameter.EMAIL_MIN, max = CommonParameter.EMAIL_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.EMAIL_MIN + " AND " + CommonParameter.EMAIL_MAX + " !") @Pattern(regexp = CommonParameter.EMAIL_REGEXP, message = CommonError.EMAIL_FORMAT) String email, @NotNull @Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !") String password, @NotNull Boolean verified) {
|
||||
public CredentialDTO(@NotNull String provider,
|
||||
@NotNull @Size(min = CommonParameter.EMAIL_MIN, max = CommonParameter.EMAIL_MAX,
|
||||
message = CommonError.FORMAT_BETWEEN + CommonParameter.EMAIL_MIN + " AND "
|
||||
+ CommonParameter.EMAIL_MAX + " !") @Pattern(regexp = CommonParameter.EMAIL_REGEXP,
|
||||
message = CommonError.EMAIL_FORMAT) String email,
|
||||
@NotNull @Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX,
|
||||
message = CommonError.FORMAT_BETWEEN + CommonParameter.PASSWORD_MIN + " AND "
|
||||
+ CommonParameter.PASSWORD_MAX + " !") String password,
|
||||
@NotNull Boolean verified) {
|
||||
this.provider = provider;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
|
|
|
@ -23,4 +23,5 @@ public class AuthProvider extends NamedEntity {
|
|||
this.setId(id);
|
||||
this.setName(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,9 +58,19 @@ public class Credential extends BaseEntity {
|
|||
@Column(name = "expiration")
|
||||
private Date expiration;
|
||||
|
||||
public Credential(@NotNull Integer providerId, @NotNull @Size(min = CommonParameter.EMAIL_MIN, max = CommonParameter.EMAIL_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.EMAIL_MIN + " AND " + CommonParameter.EMAIL_MAX + " !") @Pattern(regexp = CommonParameter.EMAIL_REGEXP, message = CommonError.EMAIL_FORMAT) String email, @NotNull @Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX, message = CommonError.FORMAT_BETWEEN
|
||||
+ CommonParameter.PASSWORD_MIN + " AND " + CommonParameter.PASSWORD_MAX + " !") String password, @NotNull Boolean verified) {
|
||||
public int getTokenExpiration() {
|
||||
return TOKEN_EXPIRATION;
|
||||
}
|
||||
|
||||
public Credential(@NotNull Integer providerId,
|
||||
@NotNull @Size(min = CommonParameter.EMAIL_MIN, max = CommonParameter.EMAIL_MAX,
|
||||
message = CommonError.FORMAT_BETWEEN + CommonParameter.EMAIL_MIN + " AND "
|
||||
+ CommonParameter.EMAIL_MAX + " !") @Pattern(regexp = CommonParameter.EMAIL_REGEXP,
|
||||
message = CommonError.EMAIL_FORMAT) String email,
|
||||
@NotNull @Size(min = CommonParameter.PASSWORD_MIN, max = CommonParameter.PASSWORD_MAX,
|
||||
message = CommonError.FORMAT_BETWEEN + CommonParameter.PASSWORD_MIN + " AND "
|
||||
+ CommonParameter.PASSWORD_MAX + " !") String password,
|
||||
@NotNull Boolean verified) {
|
||||
this.providerId = providerId;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.samples.petclinic.model.common.Credential;
|
||||
import org.springframework.samples.petclinic.model.common.User;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -43,9 +44,17 @@ public interface CredentialRepository extends Repository<Credential, Integer> {
|
|||
List<Credential> findAll();
|
||||
|
||||
/**
|
||||
* Save a {@link Credential} to the data store, either inserting or updating it.
|
||||
* Save an {@link Credential} to the data store, either inserting or updating it.
|
||||
* @param credential the {@link Credential} to save
|
||||
* @return the deleted {@link Credential}
|
||||
*/
|
||||
Credential save(Credential credential);
|
||||
|
||||
/**
|
||||
* Delete an {@link Credential} to the data store.
|
||||
* @param credential the {@link Credential} to delete
|
||||
* @return the deleted {@link Credential}
|
||||
*/
|
||||
Credential delete(Credential credential);
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface UserRepository extends Repository<User, Integer> {
|
|||
|
||||
/**
|
||||
* Save an {@link User} to the data store, either inserting or updating it.
|
||||
* @param user the {@link User} to delete
|
||||
* @param user the {@link User} to save
|
||||
* @return the deleted {@link User}
|
||||
*/
|
||||
User save(User user);
|
||||
|
|
|
@ -126,4 +126,10 @@ public class CredentialService {
|
|||
return entityToDTO(credential);
|
||||
}
|
||||
|
||||
public CredentialDTO delete(CredentialDTO dto) {
|
||||
Credential credential = dtoToEntity(dto);
|
||||
credential = credentialRepository.delete(credential);
|
||||
return entityToDTO(credential);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.springframework.samples.petclinic.service.common;
|
|||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.common.UserDTO;
|
||||
import org.springframework.samples.petclinic.model.common.Role;
|
||||
import org.springframework.samples.petclinic.model.common.User;
|
||||
import org.springframework.samples.petclinic.repository.RoleRepository;
|
||||
import org.springframework.samples.petclinic.repository.UserRepository;
|
||||
|
|
|
@ -128,7 +128,7 @@ CREATE TABLE credentials (
|
|||
password VARCHAR(255) NOT NULL,
|
||||
verified BOOLEAN NOT NULL,
|
||||
token VARCHAR(255) DEFAULT NULL,
|
||||
expiration DATE DEFAULT NULL
|
||||
expiration TIMESTAMP DEFAULT NULL
|
||||
);
|
||||
ALTER TABLE credentials ADD CONSTRAINT fk_credentials_provider_id FOREIGN KEY (provider_id) REFERENCES auth_providers (id);
|
||||
CREATE INDEX credentials_email ON credentials (email);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.samples.petclinic;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
package org.springframework.samples.petclinic.service.common;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.samples.petclinic.dto.common.CredentialDTO;
|
||||
import org.springframework.samples.petclinic.dto.common.UserDTO;
|
||||
import org.springframework.samples.petclinic.model.common.AuthProvider;
|
||||
import org.springframework.samples.petclinic.model.common.Credential;
|
||||
import org.springframework.samples.petclinic.repository.AuthProviderRepository;
|
||||
import org.springframework.samples.petclinic.repository.CredentialRepository;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class CredentialServiceIntegrationTest {
|
||||
|
||||
private static String PROVIDER_TEST_NAME = "Provider Test";
|
||||
|
||||
private static Integer PROVIDER_TEST_ID = 11;
|
||||
|
||||
private static final String EMAIL_TEST = "eduardo.rodriguez@petclinic.com";
|
||||
|
||||
private static final String PASSWORD_TEST = "$2a$10$8KypNYtPopFo8Sk5jbKJ4.lCKeBhdApsrkmFfhwjB8nCls8qpzjZG";
|
||||
|
||||
private static final String TOKEN_TEST = UUID.randomUUID().toString();
|
||||
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
|
||||
@Autowired
|
||||
private AuthProviderRepository authProviderRepository;
|
||||
|
||||
@Autowired
|
||||
private CredentialRepository credentialRepository;
|
||||
|
||||
private CredentialService credentialService;
|
||||
|
||||
private Credential credential;
|
||||
|
||||
private CredentialDTO credentialDTO;
|
||||
|
||||
private AuthProvider authProvider;
|
||||
|
||||
private List<Credential> allCredentials;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
allCredentials = credentialRepository.findAll();
|
||||
|
||||
credentialService = new CredentialService(credentialRepository, bCryptPasswordEncoder, authProviderRepository);
|
||||
authProvider = new AuthProvider(PROVIDER_TEST_ID, PROVIDER_TEST_NAME);
|
||||
credential = new Credential(PROVIDER_TEST_ID, EMAIL_TEST, PASSWORD_TEST, true);
|
||||
credential.setToken(TOKEN_TEST);
|
||||
credentialDTO = new CredentialDTO(PROVIDER_TEST_NAME, EMAIL_TEST, PASSWORD_TEST, true);
|
||||
credentialDTO.setToken(TOKEN_TEST);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Timestamp(cal.getTime().getTime()));
|
||||
cal.add(Calendar.MINUTE, credential.getTokenExpiration());
|
||||
credential.setExpiration(cal.getTime());
|
||||
credentialDTO.setExpiration(cal.getTime());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Tag("findByEmailAndProvider")
|
||||
@DisplayName("Verify that we call right method to get Credential by Email and Provider")
|
||||
void findByEmailAndProvider() {
|
||||
|
||||
for(Credential credential: allCredentials) {
|
||||
String email = credential.getEmail();
|
||||
String provider = authProviderRepository.findById(credential.getProviderId()).getName();
|
||||
CredentialDTO found = credentialService.findByEmailAndProvider(email,provider);
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialService.entityToDTO(credential));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("findByToken")
|
||||
@DisplayName("Verify that we call right method to get Credential by Token")
|
||||
@Disabled
|
||||
void findByToken() {
|
||||
credentialDTO = credentialService.save(credentialDTO);
|
||||
|
||||
CredentialDTO found = credentialService.findByToken(TOKEN_TEST);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabas
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.samples.petclinic.dto.common.CredentialDTO;
|
||||
import org.springframework.samples.petclinic.dto.common.UserDTO;
|
||||
import org.springframework.samples.petclinic.model.common.AuthProvider;
|
||||
import org.springframework.samples.petclinic.model.common.Credential;
|
||||
import org.springframework.samples.petclinic.repository.AuthProviderRepository;
|
||||
|
@ -17,23 +18,28 @@ import org.springframework.samples.petclinic.repository.CredentialRepository;
|
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class CredentialServiceTest {
|
||||
|
||||
private static String PROVIDER_TEST_NAME = "Provider Test";
|
||||
|
||||
private static Integer PROVIDER_TEST_ID = 11;
|
||||
|
||||
private static final String EMAIL_TEST = "eduardo.rodriguez@petclinic.com";
|
||||
|
||||
private static final String PASSWORD_TEST = "$2a$10$8KypNYtPopFo8Sk5jbKJ4.lCKeBhdApsrkmFfhwjB8nCls8qpzjZG";
|
||||
|
||||
private static final String TOKEN_TEST = UUID.randomUUID().toString();
|
||||
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
|
||||
|
@ -54,20 +60,26 @@ class CredentialServiceTest {
|
|||
@BeforeEach
|
||||
void beforeEach() {
|
||||
credentialService = new CredentialService(credentialRepository, bCryptPasswordEncoder, authProviderRepository);
|
||||
authProvider = new AuthProvider(PROVIDER_TEST_ID,PROVIDER_TEST_NAME);
|
||||
credential = new Credential(PROVIDER_TEST_ID, EMAIL_TEST, PASSWORD_TEST,true);
|
||||
credentialDTO = new CredentialDTO(PROVIDER_TEST_NAME, EMAIL_TEST, PASSWORD_TEST,true);
|
||||
|
||||
|
||||
authProvider = new AuthProvider(PROVIDER_TEST_ID, PROVIDER_TEST_NAME);
|
||||
credential = new Credential(PROVIDER_TEST_ID, EMAIL_TEST, PASSWORD_TEST, true);
|
||||
credential.setToken(TOKEN_TEST);
|
||||
credentialDTO = new CredentialDTO(PROVIDER_TEST_NAME, EMAIL_TEST, PASSWORD_TEST, true);
|
||||
credentialDTO.setToken(TOKEN_TEST);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Timestamp(cal.getTime().getTime()));
|
||||
cal.add(Calendar.MINUTE, credential.getTokenExpiration());
|
||||
credential.setExpiration(cal.getTime());
|
||||
credentialDTO.setExpiration(cal.getTime());
|
||||
|
||||
given(authProviderRepository.findByName(anyString())).willReturn(authProvider);
|
||||
given(authProviderRepository.findById(anyInt())).willReturn(authProvider);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("dtoToEntity")
|
||||
@DisplayName("Verify the convertion from DTO to Entity")
|
||||
void dtoToEntity() {
|
||||
given(authProviderRepository.findByName(PROVIDER_TEST_NAME)).willReturn(authProvider);
|
||||
Credential found = credentialService.dtoToEntity(credentialDTO);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credential);
|
||||
|
@ -77,24 +89,67 @@ class CredentialServiceTest {
|
|||
@Tag("entityToDTO")
|
||||
@DisplayName("Verify the convertion from Entity to DTO")
|
||||
void entityToDTO() {
|
||||
given(authProviderRepository.findById(PROVIDER_TEST_ID)).willReturn(authProvider);
|
||||
|
||||
CredentialDTO found = credentialService.entityToDTO(credential);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@Tag("findByEmailAndProvider")
|
||||
@DisplayName("Verify that we call right method to get Credential by Email and Provider")
|
||||
void findByEmailAndProvider() {
|
||||
given(credentialRepository.findByEmailAndProvider(EMAIL_TEST,PROVIDER_TEST_ID)).willReturn(credential);
|
||||
given(authProviderRepository.findByName(PROVIDER_TEST_NAME)).willReturn(authProvider);
|
||||
given(authProviderRepository.findById(PROVIDER_TEST_ID)).willReturn(authProvider);
|
||||
given(credentialRepository.findByEmailAndProvider(EMAIL_TEST, PROVIDER_TEST_ID)).willReturn(credential);
|
||||
|
||||
CredentialDTO found = credentialService.findByEmailAndProvider(EMAIL_TEST,PROVIDER_TEST_NAME);
|
||||
CredentialDTO found = credentialService.findByEmailAndProvider(EMAIL_TEST, PROVIDER_TEST_NAME);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("findByToken")
|
||||
@DisplayName("Verify that we call right method to get Credential by Token")
|
||||
void findByToken() {
|
||||
given(credentialRepository.findByToken(TOKEN_TEST)).willReturn(credential);
|
||||
|
||||
CredentialDTO found = credentialService.findByToken(TOKEN_TEST);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("save")
|
||||
@DisplayName("Verify that we call right method to save Credential")
|
||||
void save() {
|
||||
given(credentialRepository.save(any(Credential.class))).willReturn(credential);
|
||||
|
||||
CredentialDTO found = credentialService.save(credentialDTO);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("saveNew")
|
||||
@DisplayName("Verify that we call right method to save Credential from User")
|
||||
void saveNew() {
|
||||
UserDTO user = new UserDTO();
|
||||
user.setEmail(EMAIL_TEST);
|
||||
user.setPassword(PASSWORD_TEST);
|
||||
user.setMatchingPassword(PASSWORD_TEST);
|
||||
|
||||
given(credentialRepository.save(any(Credential.class))).willReturn(credential);
|
||||
|
||||
CredentialDTO found = credentialService.saveNew(user);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("delete")
|
||||
@DisplayName("Verify that we call right method to delete Credential")
|
||||
void delete() {
|
||||
given(credentialRepository.delete(any(Credential.class))).willReturn(credential);
|
||||
|
||||
CredentialDTO found = credentialService.delete(credentialDTO);
|
||||
|
||||
assertThat(found).isEqualToComparingFieldByField(credentialDTO);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import java.util.List;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class PrivilegeServiceIntegrationTest {
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.List;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class PrivilegeServiceTest {
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.util.*;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class RoleServiceIntegrationTest {
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import java.util.*;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class RoleServiceTest {
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.util.*;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class UserServiceIntegrationTest {
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.util.*;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AutoConfigureTestDatabase
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
@RunWith(SpringRunner.class)
|
||||
class UserServiceTest {
|
||||
|
||||
|
|
Loading…
Reference in a new issue