Search in sources :

Example 1 with SubjectModel

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

the class SubjectsServiceTest method createSubjectModel.

private SubjectModelInterface createSubjectModel(Integer id, String name, String description, Integer userId, Integer issueStandardId) {
    final SubjectModelInterface subjectModel = new SubjectModel();
    subjectModel.setId(id);
    subjectModel.setName(name);
    subjectModel.setDescription(description);
    final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
    Mockito.when(userModel.getId()).thenReturn(userId);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    subjectModel.setUser(userModel);
    subjectModel.setIssueStandard(issueStandardModel);
    return subjectModel;
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) UserModelInterface(easytests.core.models.UserModelInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 2 with SubjectModel

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

the class TopicsOptionsTest method testDeleteWithRelationsSubject.

@Test
public void testDeleteWithRelationsSubject() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
    given(topicModel.getSubject()).willReturn(subjectModelId);
    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 = new SubjectModel();
    topicModel.setSubject(subjectModel);
    final InOrder inOrder = Mockito.inOrder(topicsService, subjectsService);
    topicsOptions.deleteWithRelations(topicModel);
    inOrder.verify(topicsService).delete(topicModel);
    inOrder.verify(subjectsService).save(topicModel.getSubject(), subjectsOptions);
}
Also used : InOrder(org.mockito.InOrder) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with SubjectModel

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

the class TopicsOptionsTest method testSaveDeleteWithRelationsSubject.

@Test
public void testSaveDeleteWithRelationsSubject() {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
    given(topicModel.getSubject()).willReturn(subjectModelId);
    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 = new SubjectModel();
    topicModel.setSubject(subjectModel);
    topicsOptions.saveWithRelations(topicModel);
    verify(topicsService).save(topicModel);
    topicsOptions.deleteWithRelations(topicModel);
    verify(topicsService).delete(topicModel);
    verify(subjectsService, times(2)).save(topicModel.getSubject(), subjectsOptions);
}
Also used : SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SubjectModel

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

the class TopicsOptionsTest method testSaveWithRelationsSubject.

@Test
public void testSaveWithRelationsSubject() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
    given(topicModel.getSubject()).willReturn(subjectModelId);
    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 = new SubjectModel();
    topicModel.setSubject(subjectModel);
    final InOrder inOrder = Mockito.inOrder(subjectsService, topicsService);
    topicsOptions.saveWithRelations(topicModel);
    inOrder.verify(subjectsService).save(topicModel.getSubject(), subjectsOptions);
    inOrder.verify(topicsService).save(topicModel);
}
Also used : InOrder(org.mockito.InOrder) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with SubjectModel

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

the class SubjectsService method map.

private SubjectModel map(SubjectEntity subjectEntity) {
    final SubjectModel subjectModel = new SubjectModel();
    subjectModel.map(subjectEntity);
    return subjectModel;
}
Also used : SubjectModel(easytests.core.models.SubjectModel)

Aggregations

SubjectModel (easytests.core.models.SubjectModel)7 SubjectModelInterface (easytests.core.models.SubjectModelInterface)6 TopicModelInterface (easytests.core.models.TopicModelInterface)3 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)3 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)2 InOrder (org.mockito.InOrder)2 IssueStandardModel (easytests.core.models.IssueStandardModel)1 UserModelInterface (easytests.core.models.UserModelInterface)1 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)1