use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testSaveModelsListWithOptions.
@Test
public void testSaveModelsListWithOptions() throws Exception {
final ArgumentCaptor<SubjectModelInterface> subjectModelCaptor = ArgumentCaptor.forClass(SubjectModelInterface.class);
final List<SubjectModelInterface> subjectsModels = this.getSubjectsFixturesModels();
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
this.subjectsService.save(subjectsModels, subjectsOptions);
this.assertServicesSet(subjectsOptions, subjectsModels.size());
verify(subjectsOptions, times(subjectsModels.size())).saveWithRelations(subjectModelCaptor.capture());
this.subjectsSupport.assertModelsListEquals(subjectsModels, subjectModelCaptor.getAllValues());
verifyNoMoreInteractions(this.subjectsMapper);
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testDeleteModelsListWithOptions.
@Test
public void testDeleteModelsListWithOptions() throws Exception {
final ArgumentCaptor<SubjectModelInterface> subjectModelCaptor = ArgumentCaptor.forClass(SubjectModelInterface.class);
final List<SubjectModelInterface> subjectsModels = this.getSubjectsFixturesModels();
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
this.subjectsService.delete(subjectsModels, subjectsOptions);
this.assertServicesSet(subjectsOptions, subjectsModels.size());
verify(subjectsOptions, times(subjectsModels.size())).deleteWithRelations(subjectModelCaptor.capture());
this.subjectsSupport.assertModelsListEquals(subjectsModels, subjectModelCaptor.getAllValues());
verifyNoMoreInteractions(this.subjectsMapper);
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testDeleteModelsList.
@Test
public void testDeleteModelsList() throws Exception {
final SubjectModelInterface subjectModelFirst = this.createSubjectModel(2, "test2", "description2", 1, 1);
final SubjectModelInterface subjectModelSecond = this.createSubjectModel(3, "test3", "description3", 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.delete(subjectsModels);
verify(subjectsServiceSpy, times(1)).delete(subjectModelFirst);
verify(subjectsServiceSpy, times(1)).delete(subjectModelSecond);
subjectsServiceSpy.delete(subjectsModels, subjectsOptions);
verify(subjectsServiceSpy, times(1)).delete(subjectModelFirst, subjectsOptions);
verify(subjectsServiceSpy, times(1)).delete(subjectModelSecond, subjectsOptions);
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final Integer userId = 1;
final SubjectEntity subjectEntity = this.createSubjectEntityMock(4, "test3", "description3", userId);
final SubjectModelInterface subjectModel = this.mapSubjectModel(subjectEntity);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
given(this.subjectsMapper.find(id)).willReturn(subjectEntity);
given(subjectsOptions.withRelations(subjectModel)).willReturn(subjectModel);
final SubjectModelInterface foundedSubjectModel = this.subjectsService.find(id, subjectsOptions);
Assert.assertEquals(subjectModel, foundedSubjectModel);
verify(subjectsOptions).withRelations(subjectModel);
}
use of easytests.core.options.SubjectsOptionsInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testSaveWithOptions.
@Test
public void testSaveWithOptions() throws Exception {
final SubjectModelInterface subjectModel = this.createSubjectModel(null, "test", "description", 1, 1);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
this.subjectsService.save(subjectModel, subjectsOptions);
verify(subjectsOptions).saveWithRelations(subjectModel);
}
Aggregations