use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testDeleteWithOptions.
@Test
public void testDeleteWithOptions() throws Exception {
final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
this.topicsService.delete(topicModel, topicOptions);
verify(topicOptions, times(1)).deleteWithRelations(topicModel);
this.assertServicesSet(topicOptions);
verifyNoMoreInteractions(this.topicsMapper);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testDeleteModelsListWithOptions.
@Test
public void testDeleteModelsListWithOptions() throws Exception {
final ArgumentCaptor<TopicModelInterface> topicModelCaptor = ArgumentCaptor.forClass(TopicModelInterface.class);
final List<TopicModelInterface> topicsModels = this.getTopicsFixturesModels();
final TopicsOptionsInterface topicsOptions = mock(TopicsOptionsInterface.class);
this.topicsService.delete(topicsModels, topicsOptions);
this.assertServicesSet(topicsOptions, topicsModels.size());
verify(topicsOptions, times(topicsModels.size())).deleteWithRelations(topicModelCaptor.capture());
this.topicsSupport.assertModelsListEquals(topicsModels, topicModelCaptor.getAllValues());
verifyNoMoreInteractions(this.topicsMapper);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testDeleteUnidentifiedModelThrowsException.
@Test
public void testDeleteUnidentifiedModelThrowsException() throws Exception {
final TopicModelInterface topicModel = this.topicsSupport.getModelAdditionalMock(0);
exception.expect(DeleteUnidentifiedModelException.class);
this.topicsService.delete(topicModel);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testSaveWithOptions.
@Test
public void testSaveWithOptions() throws Exception {
final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
this.topicsService.save(topicModel, topicOptions);
verify(topicOptions, times(1)).saveWithRelations(topicModel);
this.assertServicesSet(topicOptions);
verifyNoMoreInteractions(this.topicsMapper);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPrioritiesOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = new IssueStandardTopicPrioritiesOptions();
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
final Integer topicIdFirst = 3;
final Integer topicIdSecond = 5;
final Integer issueStandardIdFirst = 10;
final Integer issueStandardIdSecond = 20;
IssueStandardTopicPriorityModelInterface topicPriorityModelFirst = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
IssueStandardTopicPriorityModelInterface topicPriorityModelSecond = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
Mockito.when(topicPriorityModelFirst.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdFirst));
Mockito.when(topicPriorityModelFirst.getTopic()).thenReturn(new TopicModelEmpty(topicIdFirst));
Mockito.when(topicPriorityModelSecond.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdSecond));
Mockito.when(topicPriorityModelSecond.getTopic()).thenReturn(new TopicModelEmpty(topicIdSecond));
final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = new ArrayList<>(2);
topicPriorityModels.add(topicPriorityModelFirst);
topicPriorityModels.add(topicPriorityModelSecond);
final TopicModelInterface topicModelFirst = Mockito.mock(TopicModelInterface.class);
Mockito.when(topicModelFirst.getId()).thenReturn(topicIdFirst);
given(topicsService.find(topicIdFirst, topicsOptions)).willReturn(topicModelFirst);
final TopicModelInterface topicModelSecond = Mockito.mock(TopicModelInterface.class);
Mockito.when(topicModelSecond.getId()).thenReturn(topicIdSecond);
given(topicsService.find(topicIdSecond, topicsOptions)).willReturn(topicModelSecond);
final IssueStandardModelInterface issueStandardModelFirst = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModelFirst.getId()).thenReturn(issueStandardIdFirst);
given(issueStandardsService.find(issueStandardIdFirst, issueStandardsOptions)).willReturn(issueStandardModelFirst);
final IssueStandardModelInterface issueStandardModelSecond = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModelSecond.getId()).thenReturn(issueStandardIdSecond);
given(issueStandardsService.find(issueStandardIdSecond, issueStandardsOptions)).willReturn(issueStandardModelSecond);
// options не заданы
final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsWithoutRelations = topicPrioritiesOptions.withRelations(topicPriorityModels);
verify(topicsService, times(0)).find(topicIdFirst, topicsOptions);
verify(topicsService, times(0)).find(topicIdSecond, topicsOptions);
verify(issueStandardsService, times(0)).find(issueStandardIdFirst, issueStandardsOptions);
verify(issueStandardsService, times(0)).find(issueStandardIdSecond, issueStandardsOptions);
Assert.assertEquals(topicPriorityModels, topicPriorityModelsWithoutRelations);
Mockito.verify(topicPriorityModelFirst, times(0)).setTopic(topicModelFirst);
Mockito.verify(topicPriorityModelSecond, times(0)).setTopic(topicModelSecond);
Mockito.verify(topicPriorityModelFirst, times(0)).setIssueStandard(issueStandardModelFirst);
Mockito.verify(topicPriorityModelSecond, times(0)).setIssueStandard(issueStandardModelSecond);
topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
topicPrioritiesOptions.setTopicsService(topicsService);
topicPrioritiesOptions.withTopic(topicsOptions).withIssueStandard(issueStandardsOptions);
// теперь options заданы
final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsWithRelations = topicPrioritiesOptions.withRelations(topicPriorityModels);
verify(topicsService, times(1)).find(topicIdFirst, topicsOptions);
verify(topicsService, times(1)).find(topicIdSecond, topicsOptions);
verify(issueStandardsService, times(1)).find(issueStandardIdFirst, issueStandardsOptions);
verify(issueStandardsService, times(1)).find(issueStandardIdSecond, issueStandardsOptions);
Assert.assertEquals(topicPriorityModels, topicPriorityModelsWithRelations);
Mockito.verify(topicPriorityModelFirst, times(1)).setTopic(topicModelFirst);
Mockito.verify(topicPriorityModelSecond, times(1)).setTopic(topicModelSecond);
Mockito.verify(topicPriorityModelFirst, times(1)).setIssueStandard(issueStandardModelFirst);
Mockito.verify(topicPriorityModelSecond, times(1)).setIssueStandard(issueStandardModelSecond);
}
Aggregations