Search in sources :

Example 31 with UserModelInterface

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

the class UsersServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<UserEntity> usersEntities = this.getUsersEntities();
    final List<UserModelInterface> usersModels = this.getUsersModels();
    final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
    given(this.usersMapper.findAll()).willReturn(usersEntities);
    given(usersOptions.withRelations(Mockito.anyList())).willReturn(usersModels);
    final List<UserModelInterface> foundedUsersModels = this.usersService.findAll(usersOptions);
    verify(usersOptions).withRelations(usersModels);
    Assert.assertEquals(usersModels, foundedUsersModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface) UserEntity(easytests.core.entities.UserEntity)

Example 32 with UserModelInterface

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

the class UsersServiceTest method testSaveWithOptions.

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

Example 33 with UserModelInterface

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

the class UsersServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    given(this.usersMapper.find(id)).willReturn(null);
    final UserModelInterface userModel = this.usersService.find(id);
    Assert.assertEquals(null, userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 34 with UserModelInterface

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

the class UsersServiceTest method mapUserModel.

private UserModelInterface mapUserModel(UserEntity userEntity) {
    final UserModelInterface userModel = new UserModel();
    userModel.map(userEntity);
    return userModel;
}
Also used : UserModel(easytests.core.models.UserModel) UserModelInterface(easytests.core.models.UserModelInterface)

Example 35 with UserModelInterface

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

the class SubjectsServiceTest method testFindByUser.

@Test
public void testFindByUser() throws Exception {
    final Integer userId = 7;
    final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
    final SubjectEntity subjectEntityFirst = this.createSubjectEntityMock(3, "test3", "description3", userId);
    final SubjectEntity subjectEntitySecond = this.createSubjectEntityMock(12, "test12", "description12", userId);
    final List<SubjectEntity> subjectsEntities = new ArrayList<>();
    subjectsEntities.add(subjectEntityFirst);
    subjectsEntities.add(subjectEntitySecond);
    Mockito.when(userModel.getId()).thenReturn(userId);
    given(this.subjectsMapper.findByUserId(userId)).willReturn(subjectsEntities);
    final List<SubjectModelInterface> subjectsModels = new ArrayList<>();
    subjectsModels.add(this.mapSubjectModel(subjectEntityFirst));
    subjectsModels.add(this.mapSubjectModel(subjectEntitySecond));
    final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findByUser(userModel);
    verify(this.subjectsMapper).findByUserId(userId);
    Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectEntity(easytests.core.entities.SubjectEntity) ArrayList(java.util.ArrayList) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

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