use of easytests.core.models.IssueStandardTopicPriorityModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPrioritiesServiceTest method testSaveInsertsModel.
@Test
public void testSaveInsertsModel() throws Exception {
final Integer id = this.topicPrioritiesService.findAll().size() + 1;
final IssueStandardTopicPriorityModelInterface topicPriorityModel = Models.createTopicPriorityModel(null, 4, true, 4);
this.topicPrioritiesService.save(topicPriorityModel);
final IssueStandardTopicPriorityModelInterface foundedTopicPriorityModel = this.topicPrioritiesService.find(id);
Assert.assertEquals(topicPriorityModel, foundedTopicPriorityModel);
}
use of easytests.core.models.IssueStandardTopicPriorityModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPrioritiesServiceTest method testSaveUpdatesModel.
@Test
public void testSaveUpdatesModel() throws Exception {
final Integer id = 1;
final IssueStandardTopicPriorityModelInterface topicPriorityModel = Models.createTopicPriorityModel(id, 1, false, 1);
Assert.assertNotEquals(topicPriorityModel, this.topicPrioritiesService.find(id));
this.topicPrioritiesService.save(topicPriorityModel);
Assert.assertEquals(topicPriorityModel, this.topicPrioritiesService.find(id));
}
use of easytests.core.models.IssueStandardTopicPriorityModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPrioritiesServiceTest method testFindAbsentModel.
@Test
public void testFindAbsentModel() throws Exception {
final Integer id = 10;
final IssueStandardTopicPriorityModelInterface foundedIopicPriorityModel = this.topicPrioritiesService.find(id);
Assert.assertNull(foundedIopicPriorityModel);
}
use of easytests.core.models.IssueStandardTopicPriorityModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPriorityEntityTest method testMap.
@Test
public void testMap() {
final Integer id = 5;
final Integer topicId = 2;
final Boolean isPreferable = true;
final Integer issueStandardId = 1;
final IssueStandardTopicPriorityModelInterface topicPriorityModel = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
Mockito.when(topicPriorityModel.getId()).thenReturn(id);
Mockito.when(topicPriorityModel.getTopic()).thenReturn(new TopicModelEmpty(topicId));
Mockito.when(topicPriorityModel.getIsPreferable()).thenReturn(isPreferable);
Mockito.when(topicPriorityModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardId));
final IssueStandardTopicPriorityEntity topicPriorityEntity = new IssueStandardTopicPriorityEntity();
topicPriorityEntity.map(topicPriorityModel);
Assert.assertEquals(id, topicPriorityEntity.getId());
Assert.assertEquals(topicId, topicPriorityEntity.getTopicId());
Assert.assertEquals(isPreferable, topicPriorityEntity.getIsPreferable());
Assert.assertEquals(issueStandardId, topicPriorityEntity.getIssueStandardId());
}
use of easytests.core.models.IssueStandardTopicPriorityModelInterface 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