TSK-1964: made UserService injectable and adapted/fixed test
This commit is contained in:
parent
88d77ac409
commit
3c71c08684
|
@ -42,6 +42,8 @@ import pro.taskana.testapi.TaskanaEngineProxy;
|
|||
import pro.taskana.testapi.WithServiceProvider;
|
||||
import pro.taskana.testapi.WithServiceProvider.WithServiceProviders;
|
||||
import pro.taskana.testapi.util.ServiceProviderExtractor;
|
||||
import pro.taskana.user.api.UserService;
|
||||
import pro.taskana.user.internal.UserServiceImpl;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.internal.WorkbasketServiceImpl;
|
||||
|
||||
|
@ -112,8 +114,10 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
MonitorService monitorService = taskanaEngine.getMonitorService();
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
ConfigurationService configurationService = taskanaEngine.getConfigurationService();
|
||||
JobService jobService = taskanaEngine.getJobService();
|
||||
CurrentUserContext currentUserContext = taskanaEngine.getCurrentUserContext();
|
||||
UserService userService = taskanaEngine.getUserService();
|
||||
SqlSession sqlSession = taskanaEngineProxy.getSqlSession();
|
||||
return Map.ofEntries(
|
||||
Map.entry(TaskanaEngineConfiguration.class, taskanaEngine.getConfiguration()),
|
||||
|
@ -128,13 +132,15 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
|||
Map.entry(WorkbasketServiceImpl.class, workbasketService),
|
||||
Map.entry(ClassificationService.class, classificationService),
|
||||
Map.entry(ClassificationServiceImpl.class, classificationService),
|
||||
Map.entry(ConfigurationService.class, taskanaEngine.getConfigurationService()),
|
||||
Map.entry(ConfigurationServiceImpl.class, taskanaEngine.getConfigurationService()),
|
||||
Map.entry(ConfigurationService.class, configurationService),
|
||||
Map.entry(ConfigurationServiceImpl.class, configurationService),
|
||||
Map.entry(JobService.class, jobService),
|
||||
Map.entry(JobServiceImpl.class, jobService),
|
||||
Map.entry(CurrentUserContext.class, currentUserContext),
|
||||
Map.entry(CurrentUserContextImpl.class, currentUserContext),
|
||||
Map.entry(WorkingDaysToDaysConverter.class, taskanaEngine.getWorkingDaysToDaysConverter()),
|
||||
Map.entry(ConfigurationMapper.class, sqlSession.getMapper(ConfigurationMapper.class)));
|
||||
Map.entry(ConfigurationMapper.class, sqlSession.getMapper(ConfigurationMapper.class)),
|
||||
Map.entry(UserService.class, userService),
|
||||
Map.entry(UserServiceImpl.class, userService));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import pro.taskana.monitor.api.MonitorService;
|
|||
import pro.taskana.monitor.internal.MonitorServiceImpl;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.internal.TaskServiceImpl;
|
||||
import pro.taskana.user.api.UserService;
|
||||
import pro.taskana.user.internal.UserServiceImpl;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.internal.WorkbasketServiceImpl;
|
||||
|
||||
|
@ -50,6 +52,8 @@ class TaskanaDependencyInjectionExtensionTest {
|
|||
@TaskanaInject CurrentUserContext currentUserContext;
|
||||
@TaskanaInject CurrentUserContextImpl currentUserContextImpl;
|
||||
@TaskanaInject ConfigurationMapper configurationMapper;
|
||||
@TaskanaInject UserService userService;
|
||||
@TaskanaInject UserServiceImpl userServiceImpl;
|
||||
|
||||
@Test
|
||||
void should_NotInjectTaskanaEngineConfiguration_When_FieldIsNotAnnotated() {
|
||||
|
@ -70,13 +74,19 @@ class TaskanaDependencyInjectionExtensionTest {
|
|||
@Test
|
||||
void should_InjectTaskanaEngine_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
TaskanaEngine taskanaEngine) {
|
||||
assertThat(taskanaEngine).isSameAs(this.taskanaEngine).isNotNull();
|
||||
assertThat(taskanaEngine)
|
||||
.isSameAs(this.taskanaEngine)
|
||||
.isSameAs(this.taskanaEngineImpl)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectTaskanaEngineImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
TaskanaEngineImpl taskanaEngineImpl) {
|
||||
assertThat(taskanaEngineImpl).isSameAs(this.taskanaEngineImpl).isNotNull();
|
||||
assertThat(taskanaEngineImpl)
|
||||
.isSameAs(this.taskanaEngineImpl)
|
||||
.isSameAs(this.taskanaEngine)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,72 +98,99 @@ class TaskanaDependencyInjectionExtensionTest {
|
|||
@Test
|
||||
void should_InjectClassificationService_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
ClassificationService classificationService) {
|
||||
assertThat(classificationService).isSameAs(this.classificationService).isNotNull();
|
||||
assertThat(classificationService)
|
||||
.isSameAs(this.classificationService)
|
||||
.isSameAs(this.classificationServiceImpl)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectClassificationServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
ClassificationServiceImpl classificationServiceImpl) {
|
||||
assertThat(classificationServiceImpl).isSameAs(this.classificationServiceImpl).isNotNull();
|
||||
assertThat(classificationServiceImpl)
|
||||
.isSameAs(this.classificationServiceImpl)
|
||||
.isSameAs(this.classificationService)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectWorkbasketService_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
WorkbasketService workbasketService) {
|
||||
assertThat(workbasketService).isSameAs(this.workbasketService).isNotNull();
|
||||
assertThat(workbasketService)
|
||||
.isSameAs(this.workbasketService)
|
||||
.isSameAs(this.workbasketServiceImpl)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectWorkbasketServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
WorkbasketServiceImpl workbasketServiceImpl) {
|
||||
assertThat(workbasketServiceImpl).isSameAs(this.workbasketServiceImpl).isNotNull();
|
||||
assertThat(workbasketServiceImpl)
|
||||
.isSameAs(this.workbasketServiceImpl)
|
||||
.isSameAs(this.workbasketService)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectTaskService_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
TaskService taskService) {
|
||||
assertThat(taskService).isSameAs(this.taskService).isNotNull();
|
||||
assertThat(taskService).isSameAs(this.taskService).isSameAs(this.taskServiceImpl).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectTaskServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
TaskServiceImpl taskServiceImpl) {
|
||||
assertThat(taskServiceImpl).isSameAs(this.taskServiceImpl).isNotNull();
|
||||
assertThat(taskServiceImpl)
|
||||
.isSameAs(this.taskServiceImpl)
|
||||
.isSameAs(this.taskService)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectMonitorService_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
MonitorService monitorService) {
|
||||
assertThat(monitorService).isSameAs(this.monitorService).isNotNull();
|
||||
assertThat(monitorService)
|
||||
.isSameAs(this.monitorService)
|
||||
.isSameAs(this.monitorServiceImpl)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectMonitorServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
MonitorServiceImpl monitorServiceImpl) {
|
||||
assertThat(monitorServiceImpl).isSameAs(this.monitorServiceImpl).isNotNull();
|
||||
assertThat(monitorServiceImpl)
|
||||
.isSameAs(this.monitorServiceImpl)
|
||||
.isSameAs(this.monitorService)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectJobService_When_FieldIsAnnotatedOrDeclaredAsParameter(JobService jobService) {
|
||||
assertThat(jobService).isSameAs(this.jobService).isNotNull();
|
||||
assertThat(jobService).isSameAs(this.jobService).isSameAs(jobServiceImpl).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectJobServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
JobServiceImpl jobServiceImpl) {
|
||||
assertThat(jobServiceImpl).isSameAs(this.jobServiceImpl).isNotNull();
|
||||
assertThat(jobServiceImpl).isSameAs(this.jobServiceImpl).isSameAs(this.jobService).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectConfigurationService_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
ConfigurationService configurationService) {
|
||||
assertThat(configurationService).isSameAs(this.configurationService).isNotNull();
|
||||
assertThat(configurationService)
|
||||
.isSameAs(this.configurationService)
|
||||
.isSameAs(this.configurationServiceImpl)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectConfigurationServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
ConfigurationServiceImpl configurationServiceImpl) {
|
||||
assertThat(configurationServiceImpl).isSameAs(this.configurationServiceImpl).isNotNull();
|
||||
assertThat(configurationServiceImpl)
|
||||
.isSameAs(this.configurationServiceImpl)
|
||||
.isSameAs(this.configurationService)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -165,13 +202,19 @@ class TaskanaDependencyInjectionExtensionTest {
|
|||
@Test
|
||||
void should_InjectCurrentUserContext_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
CurrentUserContext currentUserContext) {
|
||||
assertThat(currentUserContext).isSameAs(this.currentUserContext).isNotNull();
|
||||
assertThat(currentUserContext)
|
||||
.isSameAs(this.currentUserContext)
|
||||
.isSameAs(this.currentUserContextImpl)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectCurrentUserContextImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
CurrentUserContextImpl currentUserContextImpl) {
|
||||
assertThat(currentUserContextImpl).isSameAs(this.currentUserContextImpl).isNotNull();
|
||||
assertThat(currentUserContextImpl)
|
||||
.isSameAs(this.currentUserContextImpl)
|
||||
.isSameAs(this.currentUserContext)
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -179,4 +222,19 @@ class TaskanaDependencyInjectionExtensionTest {
|
|||
ConfigurationMapper configurationMapper) {
|
||||
assertThat(configurationMapper).isSameAs(this.configurationMapper).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectUserService_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
UserService userService) {
|
||||
assertThat(userService).isSameAs(this.userService).isSameAs(this.userServiceImpl).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_InjectUserServiceImpl_When_FieldIsAnnotatedOrDeclaredAsParameter(
|
||||
UserServiceImpl userServiceImpl) {
|
||||
assertThat(userServiceImpl)
|
||||
.isSameAs(this.userServiceImpl)
|
||||
.isSameAs(this.userService)
|
||||
.isNotNull();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue