Search in sources :

Example 16 with UserModelInterface

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

the class UsersServiceTest method testDeleteIdentifiedModel.

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

Example 17 with UserModelInterface

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

the class SubjectsServiceTest method createSubjectModel.

private SubjectModelInterface createSubjectModel(Integer id, String name, String description, Integer userId, Integer issueStandardId) {
    final SubjectModelInterface subjectModel = new SubjectModel();
    subjectModel.setId(id);
    subjectModel.setName(name);
    subjectModel.setDescription(description);
    final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
    Mockito.when(userModel.getId()).thenReturn(userId);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    subjectModel.setUser(userModel);
    subjectModel.setIssueStandard(issueStandardModel);
    return subjectModel;
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) UserModelInterface(easytests.core.models.UserModelInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 18 with UserModelInterface

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

the class SubjectsServiceTest method testFindByUserWithOptions.

@Test
public void testFindByUserWithOptions() 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);
    given(userModel.getId()).willReturn(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 SubjectsOptionsInterface subjectOptions = Mockito.mock(SubjectsOptionsInterface.class);
    given(subjectOptions.withRelations(subjectsModels)).willReturn(subjectsModels);
    final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findByUser(userModel, subjectOptions);
    verify(this.subjectsMapper).findByUserId(userId);
    verify(subjectOptions).withRelations(subjectsModels);
    Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectEntity(easytests.core.entities.SubjectEntity) ArrayList(java.util.ArrayList) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 19 with UserModelInterface

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

the class UsersServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final UserModelInterface userModel = Models.createUserModel(null, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.usersService.delete(userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 20 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 UserModelInterface userModel = Models.createUserModel(id, "FirstName1", "LastName1", "Surname1", "email1@gmail.com", "hash1", true, 1);
    final UserModelInterface foundedUserModel = this.usersService.find(id);
    Assert.assertEquals(userModel, foundedUserModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

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