Search in sources :

Example 1 with SubjectsOptionsInterface

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);
}
Also used : SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 2 with SubjectsOptionsInterface

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);
}
Also used : SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 3 with SubjectsOptionsInterface

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);
}
Also used : ArrayList(java.util.ArrayList) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 4 with SubjectsOptionsInterface

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);
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 5 with SubjectsOptionsInterface

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);
}
Also used : SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Aggregations

SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)12 SubjectModelInterface (easytests.core.models.SubjectModelInterface)11 SubjectEntity (easytests.core.entities.SubjectEntity)3 ArrayList (java.util.ArrayList)3 SubjectsOptions (easytests.core.options.SubjectsOptions)2 TopicModelInterface (easytests.core.models.TopicModelInterface)1 UserModelInterface (easytests.core.models.UserModelInterface)1 IssueStandardsOptions (easytests.core.options.IssueStandardsOptions)1 UsersOptions (easytests.core.options.UsersOptions)1 UsersOptionsInterface (easytests.core.options.UsersOptionsInterface)1 SubjectDto (easytests.personal.dto.SubjectDto)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1