Search in sources :

Example 11 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testSaveUpdatesEntity.

@Test
public void testSaveUpdatesEntity() throws Exception {
    final UserModelInterface userModel = Models.createUserModel(1, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
    this.usersService.save(userModel);
    verify(this.usersMapper, times(1)).update(this.mapUserEntity(userModel));
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 12 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testFindByEmailAbsentModel.

@Test
public void testFindByEmailAbsentModel() throws Exception {
    final String email = "absent.email@gmail.com";
    given(this.usersMapper.findByEmail(email)).willReturn(null);
    final UserModelInterface userModel = this.usersService.findByEmail(email);
    Assert.assertEquals(null, userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 13 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final UserEntity userEntity = Entities.createUserEntityMock(id, "NewFirstName", "NewLastName1", "NewSurname1", "new.email@gmail.com", "newhash1", false, 3);
    given(this.usersMapper.find(id)).willReturn(userEntity);
    final UserModelInterface userModel = this.usersService.find(id);
    Assert.assertEquals(this.mapUserModel(userEntity), userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UserEntity(easytests.core.entities.UserEntity)

Example 14 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final UserModelInterface userModel = Models.createUserModel(null, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
    doAnswer(invocation -> {
        final UserEntity userEntity = (UserEntity) invocation.getArguments()[0];
        userEntity.setId(5);
        return null;
    }).when(this.usersMapper).insert(Mockito.any(UserEntity.class));
    this.usersService.save(userModel);
    verify(this.usersMapper, times(1)).insert(this.mapUserEntity(userModel));
    Assert.assertEquals((Integer) 5, userModel.getId());
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UserEntity(easytests.core.entities.UserEntity)

Example 15 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final UserModelInterface userModel = Models.createUserModel(1, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
    final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
    this.usersService.delete(userModel, usersOptions);
    verify(usersOptions).deleteWithRelations(userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface)

Aggregations

UserModelInterface (easytests.core.models.UserModelInterface)40 Test (org.junit.Test)11 SubjectModelInterface (easytests.core.models.SubjectModelInterface)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 UserEntity (easytests.core.entities.UserEntity)7 UsersOptionsInterface (easytests.core.options.UsersOptionsInterface)7 ArrayList (java.util.ArrayList)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 SubjectEntity (easytests.core.entities.SubjectEntity)3 UserModel (easytests.core.models.UserModel)3 UsersServiceInterface (easytests.core.services.UsersServiceInterface)2 InOrder (org.mockito.InOrder)2 UserModelDto (easytests.admin.dto.UserModelDto)1 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)1 SubjectModel (easytests.core.models.SubjectModel)1 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)1 UsersOptions (easytests.core.options.UsersOptions)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1