use of easytests.core.models.SubjectModelInterface 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);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testFindByUserAbsentList.
@Test
public void testFindByUserAbsentList() throws Exception {
final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
when(this.subjectsMapper.findByUserId(userModel.getId())).thenReturn(new ArrayList<>(0));
final List<SubjectModelInterface> subjectsFoundedModels = this.subjectsService.findByUser(userModel);
Assert.assertEquals(0, subjectsFoundedModels.size());
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final Integer id = 5;
final SubjectModelInterface subjectModel = this.subjectsSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final SubjectEntity subjectEntity = (SubjectEntity) invocation.getArguments()[0];
subjectEntity.setId(id);
return null;
}).when(this.subjectsMapper).insert(any());
this.subjectsService.save(subjectModel);
verify(subjectModel, times(1)).setId(id);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsSupport method assertModelsListEquals.
public void assertModelsListEquals(List<SubjectModelInterface> expected, List<SubjectModelInterface> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (SubjectModelInterface subjectModel : expected) {
this.assertEquals(subjectModel, actual.get(i));
i++;
}
}
use of easytests.core.models.SubjectModelInterface 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;
}
Aggregations