diff --git a/quartz-manager-parent/pom.xml b/quartz-manager-parent/pom.xml index 6e8cf80..db206be 100644 --- a/quartz-manager-parent/pom.xml +++ b/quartz-manager-parent/pom.xml @@ -10,7 +10,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT pom @@ -69,27 +69,27 @@ it.fabioformosa.quartz-manager quartz-manager-common - 4.0.5 + 4.0.6-SNAPSHOT it.fabioformosa.quartz-manager quartz-manager-starter-api - 4.0.5 + 4.0.6-SNAPSHOT it.fabioformosa.quartz-manager quartz-manager-starter-security - 4.0.5 + 4.0.6-SNAPSHOT it.fabioformosa.quartz-manager quartz-manager-starter-persistence - 4.0.5 + 4.0.6-SNAPSHOT it.fabioformosa.quartz-manager quartz-manager-starter-ui - 4.0.5 + 4.0.6-SNAPSHOT @@ -128,6 +128,19 @@ org.jacoco jacoco-maven-plugin ${jacoco-maven-plugin.version} + + + **/OpenApiConfig.class + **/SecurityOpenApiConfig.class + **/QuartzModuleProperties.class + **/QuartManagerDemoApplication.class + **/ServletInitializer.class + **/SessionController.class + **/HealthCheckController.class + **/WebShowcaseOpenApiConfig.class + **/MisfireTestJob.class + + diff --git a/quartz-manager-parent/quartz-manager-common/pom.xml b/quartz-manager-parent/quartz-manager-common/pom.xml index 964df3c..d2c1637 100644 --- a/quartz-manager-parent/quartz-manager-common/pom.xml +++ b/quartz-manager-parent/quartz-manager-common/pom.xml @@ -3,7 +3,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT quartz-manager-common diff --git a/quartz-manager-parent/quartz-manager-common/src/main/java/it/fabioformosa/quartzmanager/api/common/utils/Try.java b/quartz-manager-parent/quartz-manager-common/src/main/java/it/fabioformosa/quartzmanager/api/common/utils/Try.java index 285dad3..4fd255e 100644 --- a/quartz-manager-parent/quartz-manager-common/src/main/java/it/fabioformosa/quartzmanager/api/common/utils/Try.java +++ b/quartz-manager-parent/quartz-manager-common/src/main/java/it/fabioformosa/quartzmanager/api/common/utils/Try.java @@ -1,13 +1,20 @@ package it.fabioformosa.quartzmanager.api.common.utils; +import lombok.Getter; + import java.util.function.Function; +/** + * + * @param success type + */ +@Getter public class Try { private final Throwable failure; private final R success; - public Try(Throwable failure, R success) { + private Try(Throwable failure, R success) { this.failure = failure; this.success = success; } @@ -16,11 +23,11 @@ public class Try { return success; } - public static Try success(R r){ + private static Try success(R r){ return new Try<>(null, r); } - public static Try failure(Throwable e){ + private static Try failure(Throwable e){ return new Try<>(e, null); } @@ -38,14 +45,6 @@ public class Try { return t -> Try.with(checkedFunction).apply(t).getSuccess(); } - public boolean isSuccess(){ - return this.failure == null; - } - - public boolean isFailure(){ - return this.failure != null; - } - @FunctionalInterface public static interface CheckedFunction { R apply(T t) throws java.lang.Exception; diff --git a/quartz-manager-parent/quartz-manager-common/src/test/java/it/fabioformosa/quartzmanager/api/common/utils/TryTest.java b/quartz-manager-parent/quartz-manager-common/src/test/java/it/fabioformosa/quartzmanager/api/common/utils/TryTest.java new file mode 100644 index 0000000..be555a9 --- /dev/null +++ b/quartz-manager-parent/quartz-manager-common/src/test/java/it/fabioformosa/quartzmanager/api/common/utils/TryTest.java @@ -0,0 +1,42 @@ +package it.fabioformosa.quartzmanager.api.common.utils; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +class TryTest { + + String raiseExceptionIfHello(String greetings) throws Exception { + if("hello".equals(greetings)) + throw new Exception("hello"); + return greetings; + } + + @Test + void givenAFunctionWhichRaisesAnException_whenSneakyThrowIsCalled_thenItReturnsNull(){ + String hello = Optional.of("hello").map(Try.sneakyThrow(this::raiseExceptionIfHello)).orElse(null); + Assertions.assertThat(hello).isNull(); + } + + @Test + void givenAFunctionWhichDoesntRaiseAnException_whenSneakyThrowIsCalled_thenItReturnsTheValue(){ + String hello = Optional.of("not hello").map(Try.sneakyThrow(this::raiseExceptionIfHello)).orElse(null); + Assertions.assertThat(hello).isEqualTo("not hello"); + } + + @Test + void givenAFunctionWhichRaisesAnException_whenTryWithIsCalled_thenItReturnsAFailureObj(){ + Try aTry = Optional.of("hello").map(greet -> Try.with(this::raiseExceptionIfHello).apply(greet)).get(); + Assertions.assertThat(aTry.getFailure()).isNotNull(); + Assertions.assertThat(aTry.getFailure().getMessage()).isEqualTo("hello"); + } + + @Test + void givenAFunctionWhichDoesntRaiseAnException_whenTryWithIsCalled_thenItReturnsTheValue(){ + Try aTry = Optional.of("not hello").map(greet -> Try.with(this::raiseExceptionIfHello).apply(greet)).get(); + Assertions.assertThat(aTry.getFailure()).isNull(); + Assertions.assertThat(aTry.getSuccess()).isEqualTo("not hello"); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/pom.xml b/quartz-manager-parent/quartz-manager-starter-api/pom.xml index a1d32d9..58dc0b0 100644 --- a/quartz-manager-parent/quartz-manager-starter-api/pom.xml +++ b/quartz-manager-parent/quartz-manager-starter-api/pom.xml @@ -5,7 +5,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT quartz-manager-starter-api @@ -20,7 +20,7 @@ UTF-8 1.5.12 9 - **/QuartManagerApplicationTests.java + **/QuartManagerApplicationTests.java, **/OpenApiConfig.java diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/controllers/JobController.java b/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/controllers/JobController.java index ff63601..ad47df2 100644 --- a/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/controllers/JobController.java +++ b/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/controllers/JobController.java @@ -16,10 +16,11 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.stream.Collectors; -@RequestMapping(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/jobs") +@RequestMapping(JobController.JOB_CONTROLLER_BASE_URL) @SecurityRequirement(name = OpenAPIConfigConsts.QUARTZ_MANAGER_SEC_OAS_SCHEMA) @RestController public class JobController { + public static final String JOB_CONTROLLER_BASE_URL = QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/jobs"; private final JobService jobService; public JobController(JobService jobService) { diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTO.java b/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTO.java index 6561c95..1a0ca26 100644 --- a/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTO.java +++ b/quartz-manager-parent/quartz-manager-starter-api/src/main/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTO.java @@ -17,7 +17,8 @@ public class SchedulerToSchedulerDTO extends AbstractBaseConverterToDTO quartzModulePropertiesList = new ArrayList<>(); - quartzModulePropertiesList.add(quartzModuleProperties); + void givenASchedulerName_whenTheSchedulerIsInstantiated_thenTheSchedulerHasThatName() throws Exception { + List quartzModulePropertiesList = getQuartzModulePropertiesWithASchedulerName(TEST_SCHEDULER_NAME); SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModulePropertiesList); GenericApplicationContext applicationContext = new GenericApplicationContext(); applicationContext.refresh(); @@ -31,8 +30,16 @@ class SchedulerConfigTest { Assertions.assertThat(scheduler.getSchedulerName()).isEqualTo(TEST_SCHEDULER_NAME); } + private static List getQuartzModulePropertiesWithASchedulerName(String schedulerName) { + QuartzModuleProperties quartzModuleProperties = new QuartzModuleProperties(); + quartzModuleProperties.getProperties().put("org.quartz.scheduler.instanceName", schedulerName); + List quartzModulePropertiesList = new ArrayList<>(); + quartzModulePropertiesList.add(quartzModuleProperties); + return quartzModulePropertiesList; + } + @Test - void givenNoSchedulerName_whenTheSchedulerIsInstatiated_thenTheSchedulerHasTheDefaultName() throws Exception { + void givenNoSchedulerName_whenTheSchedulerIsInstantiated_thenTheSchedulerHasTheDefaultName() throws Exception { QuartzModuleProperties quartzModuleProperties = new QuartzModuleProperties(); List quartzModulePropertiesList = new ArrayList<>(); quartzModulePropertiesList.add(quartzModuleProperties); @@ -46,4 +53,32 @@ class SchedulerConfigTest { Assertions.assertThat(scheduler.getSchedulerName()).isEqualTo(QUARTZ_SCHEDULER_DEFAULT_NAME); } + @Test + void givenAManagedProperties_whenTheSchedulerIsInstantiated_thenTheManagedPropsHavePriority() throws Exception { + List quartzModulePropertiesList = getQuartzModulePropertiesWithASchedulerName(TEST_SCHEDULER_NAME); + SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModulePropertiesList); + GenericApplicationContext applicationContext = new GenericApplicationContext(); + applicationContext.refresh(); + + Properties managedProps = new Properties(); + String overridden_scheduler_name = "OVERRIDDEN_SCHEDULER_NAME"; + managedProps.put("org.quartz.scheduler.instanceName", overridden_scheduler_name); + SchedulerFactoryBean schedulerFactoryBean = schedulerConfig.schedulerFactoryBean(schedulerConfig.jobFactory(applicationContext), managedProps); + + schedulerFactoryBean.afterPropertiesSet(); + Scheduler scheduler = schedulerFactoryBean.getScheduler(); + Assertions.assertThat(scheduler.getSchedulerName()).isEqualTo(overridden_scheduler_name); + } + + @Test + void givenAnEmptyManagedPropFile_whenSchedulerConfigRuns_thenItReturnsAnEmptyPropList() throws IOException { + List quartzModulePropertiesList = getQuartzModulePropertiesWithASchedulerName(TEST_SCHEDULER_NAME); + SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModulePropertiesList); + GenericApplicationContext applicationContext = new GenericApplicationContext(); + applicationContext.refresh(); + + Properties properties = schedulerConfig.quartzProperties(); + Assertions.assertThat(properties).isEmpty(); + } + } diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/JobControllerTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/JobControllerTest.java new file mode 100644 index 0000000..49838de --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/JobControllerTest.java @@ -0,0 +1,46 @@ +package it.fabioformosa.quartzmanager.api.controllers; + +import it.fabioformosa.quartzmanager.api.QuartManagerApplicationTests; +import it.fabioformosa.quartzmanager.api.controllers.utils.TestUtils; +import it.fabioformosa.quartzmanager.api.jobs.SampleJob; +import it.fabioformosa.quartzmanager.api.services.JobService; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; + +@ContextConfiguration(classes = {QuartManagerApplicationTests.class}) +@WebMvcTest(controllers = SimpleTriggerController.class, properties = { + "quartz-manager.jobClassPackages=it.fabioformosa.quartzmanager.jobs" +}) +class JobControllerTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private JobService jobService; + + @Test + void whenGetListIsCalled_thenTheSimpleJobIsReturned() throws Exception { + Mockito.when(jobService.getJobClasses()).thenReturn(List.of(SampleJob.class)); + + List expectedJobs = List.of(SampleJob.class.getName()); + mockMvc.perform(get(JobController.JOB_CONTROLLER_BASE_URL) + .contentType(MediaType.APPLICATION_JSON)).andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().json(TestUtils.toJson(expectedJobs))); + + Mockito.verify(jobService, Mockito.times(1)).getJobClasses(); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/ResourceConflictControllerTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/ResourceConflictControllerTest.java new file mode 100644 index 0000000..7df7b44 --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/ResourceConflictControllerTest.java @@ -0,0 +1,28 @@ +package it.fabioformosa.quartzmanager.api.controllers; + +import it.fabioformosa.quartzmanager.api.QuartManagerApplicationTests; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@ContextConfiguration(classes = {QuartManagerApplicationTests.class}) +@WebMvcTest(controllers = SimpleTriggerController.class, properties = { + "quartz-manager.jobClassPackages=it.fabioformosa.quartzmanager.jobs" +}) +class ResourceConflictControllerTest { + + @Autowired + private MockMvc mockMvc; + + @Test + void whenAResourceConflictExceptionIsRaised_thenTheExceptionHandlerReturns409() throws Exception { + mockMvc.perform( + MockMvcRequestBuilders.post(TestController.TEST_CONTROLLER_BASE_URL + "/test-conflict") + .contentType(MediaType.APPLICATION_JSON)).andExpect(MockMvcResultMatchers.status().isConflict()); + } +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/SchedulerControllerTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/SchedulerControllerTest.java new file mode 100644 index 0000000..3e5ff80 --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/SchedulerControllerTest.java @@ -0,0 +1,89 @@ +package it.fabioformosa.quartzmanager.api.controllers; + +import it.fabioformosa.quartzmanager.api.QuartManagerApplicationTests; +import it.fabioformosa.quartzmanager.api.controllers.utils.TestUtils; +import it.fabioformosa.quartzmanager.api.dto.SchedulerDTO; +import it.fabioformosa.quartzmanager.api.enums.SchedulerStatus; +import it.fabioformosa.quartzmanager.api.services.SchedulerService; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; + +@ContextConfiguration(classes = {QuartManagerApplicationTests.class}) +@WebMvcTest(controllers = SimpleTriggerController.class, properties = { + "quartz-manager.jobClassPackages=it.fabioformosa.quartzmanager.jobs" +}) +class SchedulerControllerTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private SchedulerService schedulerService; + + @Test + void whenTheGetIsCalled_thenTheSchedulerServiceIsReturned() throws Exception { + SchedulerDTO schedulerDTO = SchedulerDTO.builder() + .name("TEST_SCHEDULER") + .instanceId("testSchedulerId") + .status(SchedulerStatus.STOPPED) + .build(); + Mockito.when(schedulerService.getScheduler()).thenReturn(schedulerDTO); + + mockMvc.perform(get(SchedulerController.SCHEDULER_CONTROLLER_BASE_URL) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().json(TestUtils.toJson(schedulerDTO))); + + Mockito.verify(schedulerService).getScheduler(); + } + + @Test + void givenAScheduler_whenTheGetPausedIsCalled_then2xxReturned() throws Exception { + mockMvc.perform(get(SchedulerController.SCHEDULER_CONTROLLER_BASE_URL + "/pause") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andExpect(MockMvcResultMatchers.content().string("")); + + Mockito.verify(schedulerService).standby(); + } + + @Test + void givenAScheduler_whenTheGetResumedIsCalled_then2xxReturned() throws Exception { + mockMvc.perform(get(SchedulerController.SCHEDULER_CONTROLLER_BASE_URL + "/resume") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andExpect(MockMvcResultMatchers.content().string("")); + + Mockito.verify(schedulerService).start(); + } + + @Test + void givenAScheduler_whenTheGetRunIsCalled_then2xxReturned() throws Exception { + mockMvc.perform(get(SchedulerController.SCHEDULER_CONTROLLER_BASE_URL + "/run") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andExpect(MockMvcResultMatchers.content().string("")); + + Mockito.verify(schedulerService).start(); + } + + @Test + void givenAScheduler_whenTheGetStoppedIsCalled_then2xxReturned() throws Exception { + mockMvc.perform(get(SchedulerController.SCHEDULER_CONTROLLER_BASE_URL + "/stop") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andExpect(MockMvcResultMatchers.content().string("")); + + Mockito.verify(schedulerService).shutdown(); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/TestController.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/TestController.java new file mode 100644 index 0000000..88a0b11 --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/controllers/TestController.java @@ -0,0 +1,19 @@ +package it.fabioformosa.quartzmanager.api.controllers; + +import it.fabioformosa.quartzmanager.api.exceptions.ResourceConflictException; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequestMapping(TestController.TEST_CONTROLLER_BASE_URL) +@RestController +public class TestController { + + public static final String TEST_CONTROLLER_BASE_URL = "/test-controller"; + + @PostMapping("/test-conflict") + public void raiseConflictException(){ + throw new ResourceConflictException(1000L, "another entity has found with the same ID"); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTOTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTOTest.java new file mode 100644 index 0000000..8729348 --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/converters/SchedulerToSchedulerDTOTest.java @@ -0,0 +1,71 @@ +package it.fabioformosa.quartzmanager.api.converters; + +import it.fabioformosa.quartzmanager.api.dto.SchedulerDTO; +import it.fabioformosa.quartzmanager.api.enums.SchedulerStatus; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.convert.ConversionService; +import org.springframework.test.annotation.DirtiesContext; + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@SpringBootTest +class SchedulerToSchedulerDTOTest { + + @Autowired + private Scheduler scheduler; + + @Autowired + private ConversionService conversionService; + + + + @Order(1) + @Test + void givenAnActiveScheduler_whenItIsConverted_thenADtoIsReturned () throws SchedulerException { + Assertions.assertThat(scheduler.isShutdown()).isFalse(); + SchedulerDTO schedulerDTO = conversionService.convert(scheduler, SchedulerDTO.class); + Assertions.assertThat(schedulerDTO).isNotNull(); + Assertions.assertThat(schedulerDTO.getName()).isEqualTo(scheduler.getSchedulerName()); + Assertions.assertThat(schedulerDTO.getInstanceId()).isEqualTo(scheduler.getSchedulerInstanceId()); + } + + @Order(2) + @Test + void givenAnActiveScheduler_whenItIsConverted_thenADtoHasAStatus () throws SchedulerException { + scheduler.start(); + Assertions.assertThat(scheduler.isStarted()).isTrue(); + SchedulerDTO schedulerDTO = conversionService.convert(scheduler, SchedulerDTO.class); + Assertions.assertThat(schedulerDTO.getStatus()).isEqualTo(SchedulerStatus.RUNNING); + + scheduler.standby(); + Assertions.assertThat(scheduler.isInStandbyMode()).isTrue(); + schedulerDTO = conversionService.convert(scheduler, SchedulerDTO.class); + Assertions.assertThat(schedulerDTO.getStatus()).isEqualTo(SchedulerStatus.PAUSED); + + } + + @DirtiesContext + @Order(3) + @Test + void givenASchedulerInShutdown_whenItIsConverted_thenADtoIsReturnedWithNoTriggers () throws SchedulerException { + Assertions.assertThat(scheduler.isShutdown()).isFalse(); + scheduler.shutdown(false); + Assertions.assertThat(scheduler.isShutdown()).isTrue(); + + SchedulerDTO schedulerDTO = conversionService.convert(scheduler, SchedulerDTO.class); + Assertions.assertThat(schedulerDTO).isNotNull(); + Assertions.assertThat(schedulerDTO.getName()).isEqualTo(scheduler.getSchedulerName()); + Assertions.assertThat(schedulerDTO.getInstanceId()).isEqualTo(scheduler.getSchedulerInstanceId()); + Assertions.assertThat(schedulerDTO.getTriggerKeys()).isNull(); + Assertions.assertThat(schedulerDTO.getStatus()).isEqualTo(SchedulerStatus.STOPPED); + } + + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/dto/TriggerFiredBundleDTOTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/dto/TriggerFiredBundleDTOTest.java new file mode 100644 index 0000000..a301569 --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/dto/TriggerFiredBundleDTOTest.java @@ -0,0 +1,33 @@ +package it.fabioformosa.quartzmanager.api.dto; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import static org.junit.jupiter.api.Assertions.*; + +class TriggerFiredBundleDTOTest { + + @CsvSource({ + "10, 100, 10", + "23, 1000, 2", + "26, 1000, 3" + }) + @ParameterizedTest + void givenARepeatCount_whenTheTriggerHasFiredXTimes_thenThePercentageIsCalculatedAccordingly(int timesTriggered, int repeatCount, int expectedPercentage){ + TriggerFiredBundleDTO triggerFiredBundleDTO = TriggerFiredBundleDTO.builder().build(); + triggerFiredBundleDTO.setTimesTriggered(timesTriggered); + triggerFiredBundleDTO.setRepeatCount(repeatCount); + Assertions.assertThat(triggerFiredBundleDTO.getPercentage()).isEqualTo(expectedPercentage); + } + + @Test + void givenAnInfiniteRecursion_whenTheTriggerHasFired10_thenThePercentageIsMinus1(){ + TriggerFiredBundleDTO triggerFiredBundleDTO = TriggerFiredBundleDTO.builder().build(); + triggerFiredBundleDTO.setTimesTriggered(10); + triggerFiredBundleDTO.setRepeatCount(-1); + Assertions.assertThat(triggerFiredBundleDTO.getPercentage()).isEqualTo(-1); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/jobs/SampleJobTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/jobs/SampleJobTest.java new file mode 100644 index 0000000..f56bd0d --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/jobs/SampleJobTest.java @@ -0,0 +1,79 @@ +package it.fabioformosa.quartzmanager.api.jobs; + +import it.fabioformosa.quartzmanager.api.dto.TriggerFiredBundleDTO; +import it.fabioformosa.quartzmanager.api.jobs.entities.LogRecord; +import it.fabioformosa.quartzmanager.api.websockets.WebhookSender; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.quartz.*; + +import static org.mockito.ArgumentMatchers.argThat; + +class SampleJobTest { + + @InjectMocks + private SampleJob sampleJob; + + @Mock + private WebhookSender webSocketProgressNotifier; + @Mock + private WebhookSender webSocketLogsNotifier; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + @Test + void givenASampleJob_whenTheJobIsExecuted_thenTheWebhookSendersAreCalled() { + JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class); + + ScheduleBuilder schedulerBuilder = SimpleScheduleBuilder.simpleSchedule() + .withRepeatCount(5) + .withIntervalInMilliseconds(1000L); + JobDetail jobDetail = JobBuilder + .newJob(SampleJob.class).withIdentity(JobKey.jobKey("test-job")) + .build(); + Trigger trigger = TriggerBuilder.newTrigger() + .forJob(jobDetail) + .withSchedule(schedulerBuilder) + .build(); + Mockito.when(jobExecutionContext.getTrigger()).thenReturn(trigger); + Mockito.when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); + + sampleJob.execute(jobExecutionContext); + Mockito.verify(webSocketLogsNotifier).send(argThat(actualLogRecord -> { + Assertions.assertThat(actualLogRecord.getMessage()).isEqualTo("Hello!"); + Assertions.assertThat(actualLogRecord.getType()).isEqualTo(LogRecord.LogType.INFO); + Assertions.assertThat(actualLogRecord.getDate()).isNotNull(); + Assertions.assertThat(actualLogRecord.getThreadName()).isNotNull(); + return true; + })); + Mockito.verify(webSocketProgressNotifier).send(argThat(triggerFiredBundleDTO -> { + Assertions.assertThat(triggerFiredBundleDTO.getJobKey()).isEqualTo("test-job"); + Assertions.assertThat(triggerFiredBundleDTO.getRepeatCount()).isEqualTo(6); + Assertions.assertThat(triggerFiredBundleDTO.getJobClass()).isEqualTo(SampleJob.class.getName()); + Assertions.assertThat(triggerFiredBundleDTO.getTimesTriggered()).isZero(); + Assertions.assertThat(triggerFiredBundleDTO.getNextFireTime()).isNull(); + Assertions.assertThat(triggerFiredBundleDTO.getPercentage()).isZero(); + Assertions.assertThat(triggerFiredBundleDTO.getFinalFireTime()).isNotNull(); + Assertions.assertThat(triggerFiredBundleDTO.getPreviousFireTime()).isNull(); + return true; + })); + } + + @Test + void givenASampleJob_whenTheDoItMethodIsCalled_thenALogRecordIsReturned() { + JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class); + LogRecord logRecord = sampleJob.doIt(jobExecutionContext); + Assertions.assertThat(logRecord.getMessage()).isEqualTo("Hello!"); + Assertions.assertThat(logRecord.getType()).isEqualTo(LogRecord.LogType.INFO); + Assertions.assertThat(logRecord.getDate()).isNotNull(); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SchedulerServiceIntegrationTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SchedulerServiceIntegrationTest.java new file mode 100644 index 0000000..1f54ccc --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SchedulerServiceIntegrationTest.java @@ -0,0 +1,57 @@ +package it.fabioformosa.quartzmanager.api.services; + +import it.fabioformosa.quartzmanager.api.dto.SchedulerDTO; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@SpringBootTest +class SchedulerServiceIntegrationTest { + + @Autowired + private SchedulerService schedulerService; + + @Autowired + private Scheduler scheduler; + + @Test + void givenASchedulerService_whenGetSchedulerIsCalled_thenReturnIt() throws SchedulerException { + SchedulerDTO schedulerDTO = schedulerService.getScheduler(); + Assertions.assertThat(schedulerDTO).isNotNull(); + Assertions.assertThat(schedulerDTO.getName()).isEqualTo(scheduler.getSchedulerName()); + } + + @Order(1) + @Test + void givenASchedulerService_whenTheStatusIsChange_thenTheSchedulerReflectsTheSame() throws SchedulerException { + Assertions.assertThat(scheduler.isStarted()).isFalse(); + schedulerService.start(); + Assertions.assertThat(scheduler.isStarted()).isTrue(); + } + @Order(2) + @Test + void givenASchedulerService_whenStandByIsCalled_thenTheStandByIsPropagated() throws SchedulerException { + Assertions.assertThat(scheduler.isInStandbyMode()).isFalse(); + schedulerService.standby(); + Assertions.assertThat(scheduler.isInStandbyMode()).isTrue(); + } + + @Order(3) + @DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD) + @Test + void givenASchedulerService_whenShutdownIsCalled_thenTheShutdownIsPropagated() throws SchedulerException { + Assertions.assertThat(scheduler.isShutdown()).isFalse(); + schedulerService.start(); + schedulerService.shutdown(); + Assertions.assertThat(scheduler.isShutdown()).isTrue(); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SchedulerServiceTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SchedulerServiceTest.java new file mode 100644 index 0000000..b9d11bb --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SchedulerServiceTest.java @@ -0,0 +1,63 @@ +package it.fabioformosa.quartzmanager.api.services; + +import it.fabioformosa.quartzmanager.api.dto.SchedulerDTO; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.core.convert.ConversionService; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.MockitoAnnotations.openMocks; + +class SchedulerServiceTest { + + @InjectMocks + private SchedulerService schedulerService; + + @Mock + private Scheduler scheduler; + + @Mock + private ConversionService conversionService; + + @BeforeEach + void setUp() { + openMocks(this); + } + + @Test + void givenASchedulerService_whenGetSchedulerIsCalled_thenReturnIt(){ + Mockito.when(conversionService.convert(any(Scheduler.class), eq(SchedulerDTO.class))).thenReturn(SchedulerDTO.builder() + .name("testScheduler") + .build()); + + SchedulerDTO schedulerDTO = schedulerService.getScheduler(); + Assertions.assertThat(schedulerDTO).isNotNull(); + Assertions.assertThat(schedulerDTO.getName()).isEqualTo("testScheduler"); + } + + @Test + void givenASchedulerService_whenStandByIsCalled_thenTheStandByIsPropagated() throws SchedulerException { + schedulerService.standby(); + Mockito.verify(scheduler).standby(); + } + + @Test + void givenASchedulerService_whenShutdownIsCalled_thenTheShutdownIsPropagated() throws SchedulerException { + schedulerService.shutdown(); + Mockito.verify(scheduler).shutdown(true); + } + + @Test + void givenASchedulerService_whenStarted_thenTheSchedulerIsStarted() throws SchedulerException { + schedulerService.start(); + Mockito.verify(scheduler).start(); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SimpleTriggerServiceTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SimpleTriggerServiceTest.java index dea7667..e396c97 100644 --- a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SimpleTriggerServiceTest.java +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/SimpleTriggerServiceTest.java @@ -9,9 +9,7 @@ import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.SimpleTrigger; +import org.quartz.*; import org.springframework.core.convert.ConversionService; import java.util.Date; @@ -45,6 +43,21 @@ class SimpleTriggerServiceTest { Assertions.assertThat(throwable).isInstanceOf(TriggerNotFoundException.class); } + @Test + void givenAnExistingTrigger_whenGetSimplerTriggerByNameIsCalled_thenTheDtoIsReturned() throws SchedulerException, TriggerNotFoundException { + String existing_trigger = "existing_trigger"; + Mockito.when(scheduler.getTrigger(any(TriggerKey.class))) + .thenReturn(TriggerBuilder.newTrigger().withIdentity(existing_trigger).build()); + Mockito.when(conversionService.convert(any(SimpleTrigger.class), eq(SimpleTriggerDTO.class))) + .thenReturn(SimpleTriggerDTO.builder() + .triggerKeyDTO(TriggerKeyDTO.builder().name(existing_trigger).build()) + .build()); + + + SimpleTriggerDTO simpleTriggerByName = simpleSchedulerService.getSimpleTriggerByName(existing_trigger); + Assertions.assertThat(simpleTriggerByName.getTriggerKeyDTO().getName()).isEqualTo(existing_trigger); + } + @Test void givenASimpleTriggerCommandDTO_whenASimpleTriggerIsScheduled_thenATriggerDTOIsReturned() throws SchedulerException, ClassNotFoundException { SimpleTriggerInputDTO triggerInputDTO = SimpleTriggerInputDTO.builder() @@ -79,4 +92,41 @@ class SimpleTriggerServiceTest { Assertions.assertThat(simpleTrigger).isEqualTo(expectedTriggerDTO); } + @Test + void givenASimpleTriggerCommandDTO_whenASimpleTriggerIsRecheduled_thenATriggerDTOIsReturned() throws SchedulerException, ClassNotFoundException { + SimpleTriggerInputDTO triggerInputDTO = SimpleTriggerInputDTO.builder() + .jobClass("it.fabioformosa.quartzmanager.api.jobs.SampleJob") + .startDate(new Date()) + .repeatInterval(5000L).repeatCount(5) + .endDate(DateUtils.addHoursToNow(1)) + .build(); + + String simpleTriggerName = "simpleTrigger"; + + SimpleTriggerDTO expectedTriggerDTO = SimpleTriggerDTO.builder() + .startTime(triggerInputDTO.getStartDate()) + .repeatInterval(1000) + .repeatCount(10) + .mayFireAgain(true) + .finalFireTime(triggerInputDTO.getEndDate()) + .jobKeyDTO(JobKeyDTO.builder().name("MyJob").build()) + .misfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW) + .triggerKeyDTO(TriggerKeyDTO.builder().name(simpleTriggerName).build()) + .build(); + + Mockito.when(scheduler.rescheduleJob(any(), any())).thenReturn(new Date()); + Mockito.when(conversionService.convert(any(), eq(SimpleTriggerDTO.class))).thenReturn(expectedTriggerDTO); + + SimpleTriggerCommandDTO simpleTriggerCommandDTO = SimpleTriggerCommandDTO.builder() + .triggerName(simpleTriggerName) + .simpleTriggerInputDTO(triggerInputDTO) + .build(); + SimpleTriggerDTO simpleTrigger = simpleSchedulerService.rescheduleSimpleTrigger(simpleTriggerCommandDTO); + + Assertions.assertThat(simpleTrigger).isEqualTo(expectedTriggerDTO); + + Mockito.verify(scheduler).rescheduleJob(any(), any()); + Mockito.verify(conversionService).convert(any(), eq(SimpleTriggerDTO.class)); + } + } diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/TriggerServiceTest.java b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/TriggerServiceTest.java new file mode 100644 index 0000000..0d7979d --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/java/it/fabioformosa/quartzmanager/api/services/TriggerServiceTest.java @@ -0,0 +1,50 @@ +package it.fabioformosa.quartzmanager.api.services; + +import it.fabioformosa.quartzmanager.api.dto.TriggerKeyDTO; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.TriggerKey; +import org.springframework.core.convert.ConversionService; +import org.springframework.core.convert.TypeDescriptor; + +import java.util.List; +import java.util.Set; + +import static org.mockito.ArgumentMatchers.any; + +class TriggerServiceTest { + + @InjectMocks + private TriggerService triggerService; + + @Mock + private Scheduler scheduler; + + @Mock + private ConversionService conversionService; + + @BeforeEach + void setUp(){ + MockitoAnnotations.openMocks(this); + } + + @Test + void givenATrigger_whenTheyAreFecthed_TheServiceReturnsTheDtos() throws SchedulerException { + String triggerTestName = "triggerTest"; + Mockito.when(scheduler.getTriggerKeys(any())).thenReturn(Set.of(TriggerKey.triggerKey(triggerTestName))); + Mockito.when(conversionService.convert(any(Set.class), any(TypeDescriptor.class), any(TypeDescriptor.class))) + .thenReturn(List.of(TriggerKeyDTO.builder().name(triggerTestName).build())); + + List triggerKeyDTOs = triggerService.fetchTriggers(); + Assertions.assertThat(triggerKeyDTOs).hasSize(1); + Assertions.assertThat(triggerKeyDTOs.get(0).getName()).isEqualTo(triggerTestName); + } + +} diff --git a/quartz-manager-parent/quartz-manager-starter-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/quartz-manager-parent/quartz-manager-starter-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 0000000..1f0955d --- /dev/null +++ b/quartz-manager-parent/quartz-manager-starter-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline diff --git a/quartz-manager-parent/quartz-manager-starter-persistence/pom.xml b/quartz-manager-parent/quartz-manager-starter-persistence/pom.xml index f38265c..29ec8e3 100644 --- a/quartz-manager-parent/quartz-manager-starter-persistence/pom.xml +++ b/quartz-manager-parent/quartz-manager-starter-persistence/pom.xml @@ -3,7 +3,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT quartz-manager-starter-persistence diff --git a/quartz-manager-parent/quartz-manager-starter-security/pom.xml b/quartz-manager-parent/quartz-manager-starter-security/pom.xml index 107a90c..eef8e7b 100644 --- a/quartz-manager-parent/quartz-manager-starter-security/pom.xml +++ b/quartz-manager-parent/quartz-manager-starter-security/pom.xml @@ -4,7 +4,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT quartz-manager-starter-security diff --git a/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AjaxAuthenticationFilter.java b/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AjaxAuthenticationFilter.java deleted file mode 100644 index 9511abb..0000000 --- a/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AjaxAuthenticationFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -package it.fabioformosa.quartzmanager.api.security.helpers.impl; - -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.WebAttributes; -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; -import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -public class AjaxAuthenticationFilter extends UsernamePasswordAuthenticationFilter { - - public class AjaxLoginAuthSuccessHandler extends SimpleUrlAuthenticationSuccessHandler - implements AuthenticationSuccessHandler { - - @Override - public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, - Authentication authentication) { - response.setStatus(HttpServletResponse.SC_OK); - super.clearAuthenticationAttributes(request); - } - - } - - public AjaxAuthenticationFilter(AuthenticationManager authenticationManager) { - setAuthenticationManager(authenticationManager); - setUsernameParameter("ajaxUsername"); - setPasswordParameter("ajaxPassword"); - setPostOnly(true); - setFilterProcessesUrl("/ajaxLogin"); - - setAuthenticationSuccessHandler(new AjaxLoginAuthSuccessHandler()); - } - - /** - * Removes temporary authentication-related data which may have been stored - * in the session during the authentication process. - */ - protected final void clearAuthenticationAttributes(HttpServletRequest request) { - HttpSession session = request.getSession(false); - - if (session == null) - return; - - session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); - } - -} diff --git a/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AnonAuthentication.java b/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AnonAuthentication.java index 2651a6c..2ea1410 100644 --- a/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AnonAuthentication.java +++ b/quartz-manager-parent/quartz-manager-starter-security/src/main/java/it/fabioformosa/quartzmanager/api/security/helpers/impl/AnonAuthentication.java @@ -1,7 +1,9 @@ package it.fabioformosa.quartzmanager.api.security.helpers.impl; +import lombok.EqualsAndHashCode; import org.springframework.security.authentication.AbstractAuthenticationToken; +@EqualsAndHashCode public class AnonAuthentication extends AbstractAuthenticationToken { private static final long serialVersionUID = 1L; @@ -9,15 +11,6 @@ public class AnonAuthentication extends AbstractAuthenticationToken { super( null ); } - @Override - public boolean equals( Object obj ) { - if ( this == obj ) - return true; - if ( obj == null ) - return false; - return getClass() == obj.getClass(); - } - @Override public Object getCredentials() { return null; @@ -28,11 +21,6 @@ public class AnonAuthentication extends AbstractAuthenticationToken { return null; } - @Override - public int hashCode() { - return 7; - } - @Override public boolean isAuthenticated() { return true; diff --git a/quartz-manager-parent/quartz-manager-starter-ui/pom.xml b/quartz-manager-parent/quartz-manager-starter-ui/pom.xml index 057d1c8..0e2079a 100644 --- a/quartz-manager-parent/quartz-manager-starter-ui/pom.xml +++ b/quartz-manager-parent/quartz-manager-starter-ui/pom.xml @@ -4,7 +4,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT quartz-manager-starter-ui diff --git a/quartz-manager-parent/quartz-manager-web-showcase/pom.xml b/quartz-manager-parent/quartz-manager-web-showcase/pom.xml index 56ee643..d49c492 100644 --- a/quartz-manager-parent/quartz-manager-web-showcase/pom.xml +++ b/quartz-manager-parent/quartz-manager-web-showcase/pom.xml @@ -5,7 +5,7 @@ it.fabioformosa.quartz-manager quartz-manager-parent - 4.0.5 + 4.0.6-SNAPSHOT quartz-manager-web-showcase