Search in sources :

Example 1 with UserEntity

use of easytests.core.entities.UserEntity in project easy-tests by malinink.

the class UsersServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final UserModelInterface userAdditionalModel = this.usersSupport.getModelAdditionalMock(0);
    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(userAdditionalModel);
    verify(userAdditionalModel, times(1)).setId(5);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UserEntity(easytests.core.entities.UserEntity)

Example 2 with UserEntity

use of easytests.core.entities.UserEntity in project easy-tests by malinink.

the class UsersSupport method assertEntitiesListEquals.

public void assertEntitiesListEquals(List<UserEntity> expected, List<UserEntity> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (UserEntity userEntity : expected) {
        this.assertEquals(userEntity, actual.get(i));
        i++;
    }
}
Also used : UserEntity(easytests.core.entities.UserEntity)

Example 3 with UserEntity

use of easytests.core.entities.UserEntity in project easy-tests by malinink.

the class UsersServiceTest method testFindByEmailWithOptions.

@Test
public void testFindByEmailWithOptions() throws Exception {
    final String email = "new.email@gmail.com";
    final UserEntity userEntity = Entities.createUserEntityMock(1, "NewFirstName", "NewLastName1", "NewSurname1", email, "newhash1", false, 3);
    final UserModelInterface userModel = this.mapUserModel(userEntity);
    final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
    given(this.usersMapper.findByEmail(email)).willReturn(userEntity);
    given(usersOptions.withRelations(userModel)).willReturn(userModel);
    final UserModelInterface foundedUserModel = this.usersService.findByEmail(email, usersOptions);
    Assert.assertEquals(userModel, foundedUserModel);
    verify(usersOptions).withRelations(userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface) UserEntity(easytests.core.entities.UserEntity)

Example 4 with UserEntity

use of easytests.core.entities.UserEntity in project easy-tests by malinink.

the class UsersServiceTest method testFindWithOptions.

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

Example 5 with UserEntity

use of easytests.core.entities.UserEntity 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)

Aggregations

UserEntity (easytests.core.entities.UserEntity)21 UserModelInterface (easytests.core.models.UserModelInterface)7 Test (org.junit.Test)7 UsersOptionsInterface (easytests.core.options.UsersOptionsInterface)3 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1 ArrayList (java.util.ArrayList)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1