Search in sources :

Example 11 with UserEntity

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

the class UsersMapperTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    final Integer id = 1;
    final String firstName = "NewFirstName";
    final String lastName = "NewLastName";
    final String surname = "NewSurname";
    final String email = "new.email@gmail.com";
    final String password = "new.hash";
    final Boolean isAdmin = false;
    final Integer state = 2;
    UserEntity userEntity = this.usersMapper.find(id);
    Assert.assertNotNull(userEntity);
    Assert.assertEquals(id, userEntity.getId());
    Assert.assertNotEquals(firstName, userEntity.getFirstName());
    Assert.assertNotEquals(lastName, userEntity.getLastName());
    Assert.assertNotEquals(surname, userEntity.getSurname());
    Assert.assertNotEquals(email, userEntity.getEmail());
    Assert.assertNotEquals(password, userEntity.getPassword());
    Assert.assertNotEquals(isAdmin, userEntity.getIsAdmin());
    Assert.assertNotEquals(state, userEntity.getState());
    userEntity = Mockito.mock(UserEntity.class);
    Mockito.when(userEntity.getId()).thenReturn(id);
    Mockito.when(userEntity.getFirstName()).thenReturn(firstName);
    Mockito.when(userEntity.getLastName()).thenReturn(lastName);
    Mockito.when(userEntity.getSurname()).thenReturn(surname);
    Mockito.when(userEntity.getEmail()).thenReturn(email);
    Mockito.when(userEntity.getPassword()).thenReturn(password);
    Mockito.when(userEntity.getIsAdmin()).thenReturn(isAdmin);
    Mockito.when(userEntity.getState()).thenReturn(state);
    this.usersMapper.update(userEntity);
    userEntity = this.usersMapper.find(id);
    Assert.assertEquals(id, userEntity.getId());
    Assert.assertEquals(firstName, userEntity.getFirstName());
    Assert.assertEquals(lastName, userEntity.getLastName());
    Assert.assertEquals(surname, userEntity.getSurname());
    Assert.assertEquals(email, userEntity.getEmail());
    Assert.assertEquals(password, userEntity.getPassword());
    Assert.assertEquals(isAdmin, userEntity.getIsAdmin());
    Assert.assertEquals(state, userEntity.getState());
}
Also used : UserEntity(easytests.core.entities.UserEntity) Test(org.junit.Test)

Example 12 with UserEntity

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

the class UsersMapperTest method testFind.

@Test
public void testFind() throws Exception {
    final UserEntity userEntity = this.usersMapper.find(1);
    Assert.assertEquals((Integer) 1, userEntity.getId());
    Assert.assertEquals("FirstName1", userEntity.getFirstName());
    Assert.assertEquals("LastName1", userEntity.getLastName());
    Assert.assertEquals("Surname1", userEntity.getSurname());
    Assert.assertEquals("email1@gmail.com", userEntity.getEmail());
    Assert.assertEquals("hash1", userEntity.getPassword());
    Assert.assertEquals(true, userEntity.getIsAdmin());
    Assert.assertEquals((Integer) 1, userEntity.getState());
}
Also used : UserEntity(easytests.core.entities.UserEntity) Test(org.junit.Test)

Example 13 with UserEntity

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

the class UsersSupport method getEntityMock.

private UserEntity getEntityMock(Integer id, String firstName, String lastName, String surname, String email, String password, Boolean isAdmin, Integer state) {
    final UserEntity userEntity = Mockito.mock(UserEntity.class);
    Mockito.when(userEntity.getId()).thenReturn(id);
    Mockito.when(userEntity.getFirstName()).thenReturn(firstName);
    Mockito.when(userEntity.getLastName()).thenReturn(lastName);
    Mockito.when(userEntity.getSurname()).thenReturn(surname);
    Mockito.when(userEntity.getEmail()).thenReturn(email);
    Mockito.when(userEntity.getPassword()).thenReturn(password);
    Mockito.when(userEntity.getIsAdmin()).thenReturn(isAdmin);
    Mockito.when(userEntity.getState()).thenReturn(state);
    return userEntity;
}
Also used : UserEntity(easytests.core.entities.UserEntity)

Example 14 with UserEntity

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

the class UsersMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<UserEntity> usersFoundedEntities = this.usersMapper.findAll();
    Assert.assertEquals(3, usersFoundedEntities.size());
    Integer index = 0;
    for (UserEntity userEntity : usersFoundedEntities) {
        final UserEntity userFixtureEntity = this.usersSupport.getEntityFixtureMock(index);
        this.usersSupport.assertEquals(userFixtureEntity, userEntity);
        index++;
    }
}
Also used : UserEntity(easytests.core.entities.UserEntity) Test(org.junit.Test)

Example 15 with UserEntity

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

the class UsersService method map.

private UserEntity map(UserModelInterface userModel) {
    final UserEntity userEntity = new UserEntity();
    userEntity.map(userModel);
    return userEntity;
}
Also used : 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