Search in sources :

Example 6 with SubjectsOptionsInterface

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

Example 7 with SubjectsOptionsInterface

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);
}
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 8 with SubjectsOptionsInterface

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

Example 9 with SubjectsOptionsInterface

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";
}
Also used : SubjectDto(easytests.personal.dto.SubjectDto) SubjectsOptions(easytests.core.options.SubjectsOptions) IssueStandardsOptions(easytests.core.options.IssueStandardsOptions) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 10 with SubjectsOptionsInterface

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);
}
Also used : SubjectsOptions(easytests.core.options.SubjectsOptions) UsersOptions(easytests.core.options.UsersOptions) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

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