use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<SubjectEntity> subjectsEntities = this.getSubjectsEntities();
final List<SubjectModelInterface> subjectsModels = this.getUsersModels();
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
given(this.subjectsMapper.findAll()).willReturn(subjectsEntities);
given(subjectsOptions.withRelations(Mockito.anyList())).willReturn(subjectsModels);
final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findAll(subjectsOptions);
verify(subjectsOptions).withRelations(foundedSubjectsModels);
Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
use of easytests.core.options.SubjectsOptionsInterface 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);
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testSaveEntitiesList.
@Test
public void testSaveEntitiesList() throws Exception {
final SubjectModelInterface subjectModelFirst = this.createSubjectModel(null, "test1", "description1", 1, 1);
final SubjectModelInterface subjectModelSecond = this.createSubjectModel(null, "test2", "description2", 2, 2);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
final List<SubjectModelInterface> subjectsModels = new ArrayList<>();
subjectsModels.add(subjectModelFirst);
subjectsModels.add(subjectModelSecond);
final SubjectsServiceInterface subjectsServiceSpy = Mockito.spy(subjectsService);
subjectsServiceSpy.save(subjectsModels);
verify(subjectsServiceSpy, times(1)).save(subjectModelFirst);
verify(subjectsServiceSpy, times(1)).save(subjectModelSecond);
subjectsServiceSpy.save(subjectsModels, subjectsOptions);
verify(subjectsServiceSpy, times(1)).save(subjectModelFirst, subjectsOptions);
verify(subjectsServiceSpy, times(1)).save(subjectModelSecond, subjectsOptions);
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsController method read.
@GetMapping("{id}")
public String read(@PathVariable("id") Integer id, Model model) {
final SubjectsOptionsInterface subjectsOptions = new SubjectsOptions().withIssueStandard(new IssueStandardsOptions());
final SubjectModelInterface subjectModel = getSubjectModel(id, subjectsOptions);
final SubjectDto subject = new SubjectDto();
subject.map(subjectModel);
model.addAttribute("subject", subject);
model.addAttribute("issueStandardId", subjectModel.getIssueStandard().getId());
return "subjects/view";
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class UsersOptionsBuilderTest method testForDelete.
@Test
public void testForDelete() throws Exception {
final SubjectsOptionsInterface subjectsOptions = new SubjectsOptions();
given(this.subjectsOptionsBuilder.forDelete()).willReturn(subjectsOptions);
final UsersOptionsInterface usersOptions = this.usersOptionsBuilder.forDelete();
Assert.assertEquals(new UsersOptions().withSubjects(subjectsOptions), usersOptions);
}
Aggregations