Search in sources :

Example 1 with SubjectModelInterface

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

the class TopicsOptionsTest method testWithRelationsSubjectOnSingleModel.

@Test
public void testWithRelationsSubjectOnSingleModel() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setSubjectsService(subjectsService);
    topicsOptions.setTopicsService(topicsService);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    topicsOptions.withSubject(subjectsOptions);
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    final SubjectModelInterface subjectModelWithId = Mockito.mock(SubjectModelInterface.class);
    given(topicModel.getSubject()).willReturn(subjectModelWithId);
    given(subjectsService.find(topicModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
    final TopicModelInterface topicModelWithRelations = topicsOptions.withRelations(topicModel);
    Assert.assertEquals(topicModel, topicModelWithRelations);
    subjectsService.find(1, subjectsOptions);
    verify(topicModel).setSubject(subjectModel);
}
Also used : SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with SubjectModelInterface

use of easytests.core.models.SubjectModelInterface 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 3 with SubjectModelInterface

use of easytests.core.models.SubjectModelInterface 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 4 with SubjectModelInterface

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

the class SubjectsServiceTest method testFindByUserPresentList.

@Test
public void testFindByUserPresentList() throws Exception {
    final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
    final List<SubjectEntity> subjectsEntities = this.getSubjectsFixturesEntities();
    when(this.subjectsMapper.findByUserId(userModel.getId())).thenReturn(subjectsEntities);
    final List<SubjectModelInterface> subjectsFoundedModels = this.subjectsService.findByUser(userModel);
    this.subjectsSupport.assertModelsListEquals(this.getSubjectsFixturesModels(), subjectsFoundedModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectEntity(easytests.core.entities.SubjectEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 5 with SubjectModelInterface

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

the class TopicsServiceTest method testFindBySubjectPresentList.

@Test
public void testFindBySubjectPresentList() throws Exception {
    final SubjectModelInterface subjectModel = this.subjectsSupport.getModelFixtureMock(0);
    final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
    when(this.topicsMapper.findBySubjectId(subjectModel.getId())).thenReturn(topicsEntities);
    final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findBySubject(subjectModel);
    this.topicsSupport.assertModelsListEquals(this.getTopicsFixturesModels(), topicsFoundedModels);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SubjectModelInterface (easytests.core.models.SubjectModelInterface)64 Test (org.junit.Test)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 TopicModelInterface (easytests.core.models.TopicModelInterface)18 ArrayList (java.util.ArrayList)16 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)15 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)11 UserModelInterface (easytests.core.models.UserModelInterface)9 SubjectEntity (easytests.core.entities.SubjectEntity)7 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)7 SubjectModel (easytests.core.models.SubjectModel)6 InOrder (org.mockito.InOrder)6 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)5 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 TopicEntity (easytests.core.entities.TopicEntity)4 IssueModelInterface (easytests.core.models.IssueModelInterface)4 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)4 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)4 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)4