Search in sources :

Example 6 with UserModelEmpty

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

the class SubjectsSupport method getModelMock.

private SubjectModelInterface getModelMock(Integer id, String name, String description, Integer userId) {
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModel.getId()).thenReturn(id);
    Mockito.when(subjectModel.getName()).thenReturn(name);
    Mockito.when(subjectModel.getDescription()).thenReturn(description);
    Mockito.when(subjectModel.getUser()).thenReturn(new UserModelEmpty(userId));
    Mockito.when(subjectModel.getTopics()).thenReturn(new ModelsListEmpty());
    Mockito.when(subjectModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty());
    Mockito.when(subjectModel.getIssues()).thenReturn(new ModelsListEmpty());
    return subjectModel;
}
Also used : ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) UserModelEmpty(easytests.core.models.empty.UserModelEmpty) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 7 with UserModelEmpty

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

the class SubjectsServiceTest method createSubjectModel.

private SubjectModelInterface createSubjectModel(Integer id, String name, Integer userId) {
    final SubjectModelInterface subjectModel = new SubjectModel();
    subjectModel.setId(id);
    subjectModel.setName(name);
    subjectModel.setTopics(new ModelsListEmpty());
    subjectModel.setIssueStandard(new IssueStandardModelEmpty());
    subjectModel.setUser(new UserModelEmpty(userId));
    subjectModel.setIssues(new ModelsListEmpty());
    return subjectModel;
}
Also used : ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) UserModelEmpty(easytests.core.models.empty.UserModelEmpty) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty)

Example 8 with UserModelEmpty

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

the class SubjectsOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final SubjectModelInterface subjectModelFirst = Mockito.mock(SubjectModelInterface.class);
    subjectModelFirst.setId(1);
    given(subjectModelFirst.getUser()).willReturn(new UserModelEmpty(1));
    final SubjectModelInterface subjectModelSecond = Mockito.mock(SubjectModelInterface.class);
    subjectModelSecond.setId(2);
    given(subjectModelSecond.getUser()).willReturn(new UserModelEmpty(2));
    final List<SubjectModelInterface> subjectsModels = new ArrayList<>(2);
    subjectsModels.add(subjectModelFirst);
    subjectsModels.add(subjectModelSecond);
    final SubjectsOptionsInterface subjectsOptions = new SubjectsOptions();
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    final IssueStandardsServiceInterface issueStandardService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardsOptionsInterface issueStandardOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    final UsersServiceInterface usersService = Mockito.mock(UsersServiceInterface.class);
    final UsersOptionsInterface userOptions = Mockito.mock(UsersOptionsInterface.class);
    subjectsOptions.setTopicsService(topicsService);
    subjectsOptions.setIssueStandardsService(issueStandardService);
    subjectsOptions.setUsersService(usersService);
    subjectsOptions.setIssuesService(issuesService);
    subjectsOptions.withTopics(topicsOptions);
    subjectsOptions.withIssueStandard(issueStandardOptions);
    subjectsOptions.withUser(userOptions);
    subjectsOptions.withIssues(issuesOptions);
    final List<TopicModelInterface> topicsModelsFirst = new ArrayList<>();
    topicsModelsFirst.add(Mockito.mock(TopicModelInterface.class));
    final List<TopicModelInterface> topicsModelsSecond = new ArrayList<>();
    topicsModelsSecond.add(Mockito.mock(TopicModelInterface.class));
    topicsModelsSecond.add(Mockito.mock(TopicModelInterface.class));
    given(topicsService.findBySubject(subjectModelFirst, topicsOptions)).willReturn(topicsModelsFirst);
    given(topicsService.findBySubject(subjectModelSecond, topicsOptions)).willReturn(topicsModelsSecond);
    final List<IssueModelInterface> issuesModelsFirst = new ArrayList<>();
    issuesModelsFirst.add(Mockito.mock(IssueModelInterface.class));
    final List<IssueModelInterface> issuesModelsSecond = new ArrayList<>();
    issuesModelsFirst.add(Mockito.mock(IssueModelInterface.class));
    issuesModelsFirst.add(Mockito.mock(IssueModelInterface.class));
    given(issuesService.findBySubject(subjectModelFirst, issuesOptions)).willReturn(issuesModelsFirst);
    given(issuesService.findBySubject(subjectModelSecond, issuesOptions)).willReturn(issuesModelsSecond);
    final IssueStandardModelInterface issueStandardModelFirst = Mockito.mock(IssueStandardModelInterface.class);
    final IssueStandardModelInterface issueStandardModelSecond = Mockito.mock(IssueStandardModelInterface.class);
    given(issueStandardService.findBySubject(subjectModelFirst, issueStandardOptions)).willReturn(issueStandardModelFirst);
    given(issueStandardService.findBySubject(subjectModelSecond, issueStandardOptions)).willReturn(issueStandardModelSecond);
    final UserModelInterface userModelFirst = Mockito.mock(UserModelInterface.class);
    final UserModelInterface userModelSecond = Mockito.mock(UserModelInterface.class);
    given(usersService.find(1, userOptions)).willReturn(userModelFirst);
    given(usersService.find(2, userOptions)).willReturn(userModelSecond);
    final List<SubjectModelInterface> subjectsModelsWithRelations = subjectsOptions.withRelations(subjectsModels);
    Assert.assertEquals(subjectsModelsWithRelations, subjectsModels);
    verify(issuesService).findBySubject(subjectModelSecond, issuesOptions);
    verify(topicsService).findBySubject(subjectModelFirst, topicsOptions);
    verify(issueStandardService).findBySubject(subjectModelFirst, issueStandardOptions);
    verify(usersService).find(1, userOptions);
    verify(subjectsModels.get(0)).setTopics(topicsModelsFirst);
    verify(subjectsModels.get(0)).setTopics(Mockito.anyList());
    verify(subjectsModels.get(0)).setIssues(issuesModelsFirst);
    verify(subjectsModels.get(0)).setIssues(Mockito.anyList());
    verify(subjectsModels.get(0)).setIssueStandard(issueStandardModelFirst);
    verify(subjectsModels.get(0)).setUser(userModelFirst);
    verify(issuesService).findBySubject(subjectModelSecond, issuesOptions);
    verify(topicsService).findBySubject(subjectModelSecond, topicsOptions);
    verify(issueStandardService).findBySubject(subjectModelSecond, issueStandardOptions);
    verify(usersService).find(2, userOptions);
    verify(subjectsModels.get(1)).setTopics(topicsModelsSecond);
    verify(subjectsModels.get(1)).setTopics(Mockito.anyList());
    verify(subjectsModels.get(1)).setIssues(issuesModelsSecond);
    verify(subjectsModels.get(1)).setIssues(Mockito.anyList());
    verify(subjectsModels.get(1)).setIssueStandard(issueStandardModelSecond);
    verify(subjectsModels.get(1)).setUser(userModelSecond);
}
Also used : ArrayList(java.util.ArrayList) UserModelEmpty(easytests.core.models.empty.UserModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with UserModelEmpty

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

the class SubjectsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    subjectModel.setId(1);
    given(subjectModel.getUser()).willReturn(new UserModelEmpty(1));
    final SubjectsOptionsInterface subjectsOptions = new SubjectsOptions();
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final IssueStandardsServiceInterface issueStandardService = Mockito.mock(IssueStandardsServiceInterface.class);
    final UsersServiceInterface usersService = Mockito.mock(UsersServiceInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    final IssueStandardsOptionsInterface issueStandardOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    subjectsOptions.setTopicsService(topicsService);
    subjectsOptions.setIssueStandardsService(issueStandardService);
    subjectsOptions.setUsersService(usersService);
    subjectsOptions.setIssuesService(issuesService);
    subjectsOptions.withTopics(topicsOptions);
    subjectsOptions.withIssueStandard(issueStandardOptions);
    subjectsOptions.withUser(usersOptions);
    subjectsOptions.withIssues(issuesOptions);
    final List<TopicModelInterface> topicsModels = new ArrayList<>();
    topicsModels.add(Mockito.mock(TopicModelInterface.class));
    final List<IssueModelInterface> issuesModels = new ArrayList<>();
    issuesModels.add(Mockito.mock(IssueModelInterface.class));
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
    given(topicsService.findBySubject(subjectModel, topicsOptions)).willReturn(topicsModels);
    given(issueStandardService.findBySubject(subjectModel, issueStandardOptions)).willReturn(issueStandardModel);
    given(usersService.find(subjectModel.getUser().getId(), usersOptions)).willReturn(userModel);
    given(issuesService.findBySubject(subjectModel, issuesOptions)).willReturn(issuesModels);
    final SubjectModelInterface subjectModelWithRelations = subjectsOptions.withRelations(subjectModel);
    Assert.assertEquals(subjectModel, subjectModelWithRelations);
    verify(topicsService).findBySubject(subjectModel, topicsOptions);
    verify(issueStandardService).findBySubject(subjectModel, issueStandardOptions);
    verify(usersService).find(1, usersOptions);
    verify(subjectModel).setTopics(topicsModels);
    verify(subjectModel).setIssueStandard(issueStandardModel);
    verify(subjectModel).setUser(userModel);
    verify(subjectModel).setIssues(issuesModels);
}
Also used : ArrayList(java.util.ArrayList) UserModelEmpty(easytests.core.models.empty.UserModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

UserModelEmpty (easytests.core.models.empty.UserModelEmpty)9 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)7 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)7 Test (org.junit.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 ArrayList (java.util.ArrayList)2 SubjectEntity (easytests.core.entities.SubjectEntity)1