mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2026-05-15 14:20:30 +09:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0011913c2 | ||
|
|
a59b6a6c96 | ||
|
|
68aaab6ac4 | ||
|
|
a1d8b12e98 | ||
|
|
45d6a4c59a | ||
|
|
e6f6fb5f06 | ||
|
|
13c438d097 | ||
|
|
75d630aad0 | ||
|
|
9eddc0b1fd | ||
|
|
fa4ede5179 | ||
|
|
3aa672031a | ||
|
|
82ca186bff | ||
|
|
527ee1200a | ||
|
|
82a60eb651 | ||
|
|
7fd174b313 | ||
|
|
7c910196e1 |
14
.github/workflows/sonar-java.yml
vendored
14
.github/workflows/sonar-java.yml
vendored
@@ -7,27 +7,27 @@ on:
|
||||
# paths: [ 'quartz-manager-parent/**' ]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and analyze
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 17
|
||||
distribution: 'zulu' # Alternative distribution options are available.
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
/.project
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
||||
## **v4.0.9**
|
||||
Fixed a bug which prevented to run the liquibase migration scripts in case of usage of quartz-manager-starter-persistence
|
||||
|
||||
## **v4.0.8**
|
||||
Upgraded the frontend to angular v14
|
||||
|
||||
## **v4.0.6**
|
||||
Minor bug fixes
|
||||
|
||||
## **v4.0.5**
|
||||
Fixed potential security issues
|
||||
|
||||
## **v4.0.4**
|
||||
* Conformed the trigger configuration to the Simple Trigger of Quartz
|
||||
* **BREAKING CHANGE** Changed accordingly the API and the UI
|
||||
* Made Quartz Manager embeddable in projects with existing quartz instance, security layer, swagger ui.
|
||||
|
||||
## **v3.1.0**
|
||||
* Added a new persistence module to persist the quartz triggers in a postgresql database
|
||||
|
||||
## **v3.0.1**
|
||||
|
||||
Quartz-Manager is now publicly available into the maven central repo into 3 different packages.
|
||||
|
||||
16
README.md
16
README.md
@@ -80,12 +80,12 @@ Add the dependency, make eligible for Quart Manager the job classes and set the
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-api</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<version>4.0.8</version>
|
||||
</dependency>
|
||||
```
|
||||
#### Gradle
|
||||
```
|
||||
implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-api', version: '4.0.5'
|
||||
implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-api', version: '4.0.8'
|
||||
```
|
||||
|
||||
### Step 2. Quartz Manager Job Classes
|
||||
@@ -168,12 +168,12 @@ You can optionally import the following dependency to have the UI Dashboard to i
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-ui</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<version>4.0.8</version>
|
||||
</dependency>
|
||||
```
|
||||
#### Gradle
|
||||
```
|
||||
implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-ui', version: '4.0.5'
|
||||
implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-ui', version: '4.0.8'
|
||||
```
|
||||
|
||||
### Reach out the UI Console at URL
|
||||
@@ -203,14 +203,14 @@ Future development: the Quart Manager Security OAuth2 client.
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-security</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<version>4.0.8</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
#### Gradle
|
||||
|
||||
```
|
||||
compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-security', version: '4.0.5'
|
||||
compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-security', version: '4.0.8'
|
||||
```
|
||||
|
||||
|
||||
@@ -240,14 +240,14 @@ The pre-requesite is the availability of Postgresql database where Quartz Manage
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-persistence</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<version>4.0.8</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
#### Gradle
|
||||
|
||||
```
|
||||
compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-persistence', version: '4.0.5'
|
||||
compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-persistence', version: '4.0.8'
|
||||
```
|
||||
|
||||
### Quartz Manager Persistence Lib - App Props
|
||||
|
||||
1
quartz-manager-parent/.gitignore
vendored
1
quartz-manager-parent/.gitignore
vendored
@@ -4,3 +4,4 @@
|
||||
.classpath
|
||||
.project
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
@@ -58,13 +58,13 @@ Replace the dummy job (class: `it.fabioformosa.quartzmanager.jobs.SampleJob`) wi
|
||||
|
||||
**Backend Stack** Java 9, Spring Boot 2.5.6 (Spring MVC 5.3.12, Spring Security 5.5.3), Quartz Scheduler 2.3.2
|
||||
|
||||
**Frontend** Angular 9.1.4, Web-Socket (stompjs 2.3.3)
|
||||
**Frontend** Angular 14.2.12, Web-Socket (stompjs 2.3.3)
|
||||
|
||||
**Style** Angular Material 9, FontAwesome 5
|
||||
**Style** Angular Material 14, FontAwesome 5
|
||||
|
||||
Starting from Quartz Manager v2.x.x, the new structure of project is:
|
||||
* Multi-module maven project: REST API backend
|
||||
* Angular 9: Single Page Application frontend
|
||||
* Angular 14: Single Page Application frontend
|
||||
|
||||
(The first version of quartz manager was a monolithic backend that provided also frontend developed with angularjs 1.6.x. You can find it at the branch 1.x.x)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -78,27 +78,27 @@
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-common</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-api</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-security</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-persistence</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-starter-ui</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</parent>
|
||||
<artifactId>quartz-manager-common</artifactId>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quartz-manager-starter-api</artifactId>
|
||||
|
||||
@@ -55,7 +55,8 @@ public class SchedulerConfig {
|
||||
if (quartzProperties != null && quartzProperties.size() > 0)
|
||||
mergedProperties.putAll(quartzProperties);
|
||||
factory.setQuartzProperties(mergedProperties);
|
||||
factory.setAutoStartup(false);
|
||||
boolean isAutoStartup = mergedProperties.getProperty("org.quartz.scheduler.isAutoStartup") != null && mergedProperties.getProperty("org.quartz.scheduler.isAutoStartup").equals("true");
|
||||
factory.setAutoStartup(isAutoStartup);
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.fabioformosa.quartzmanager.api.configuration;
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.common.config.QuartzManagerPaths;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
@@ -14,14 +15,16 @@ public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry config) {
|
||||
config.enableSimpleBroker("/topic");
|
||||
config.setApplicationDestinationPrefixes("/job");
|
||||
config.enableSimpleBroker("/topic"); //enable a simple memory-based message broker
|
||||
// on destinations prefixed with /topic
|
||||
config.setApplicationDestinationPrefixes("/job"); // it designates the prefix for messages
|
||||
// that are bound for methods annotated with @MessageMapping
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/quartz-manager/logs").setAllowedOrigins("/**").withSockJS();
|
||||
registry.addEndpoint("/quartz-manager/progress").setAllowedOrigins("/**").withSockJS();
|
||||
registry.addEndpoint(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs").setAllowedOrigins("/**").withSockJS();
|
||||
registry.addEndpoint(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress").setAllowedOrigins("/**").withSockJS();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ import org.springframework.stereotype.Controller;
|
||||
@Controller
|
||||
public class WebsocketController {
|
||||
|
||||
@MessageMapping({ QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs", QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress" })
|
||||
@MessageMapping({
|
||||
QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs",
|
||||
QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress"
|
||||
})
|
||||
@SendTo("/topic/logs")
|
||||
public String subscribe() {
|
||||
return "subscribed";
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.fabioformosa.quartzmanager.api.converters;
|
||||
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerCommandDTO;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.SimpleScheduleBuilder;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
@@ -19,6 +20,8 @@ public class SimpleTriggerCommandDTOToSimpleTrigger implements Converter<SimpleT
|
||||
if (triggerCommandDTO.getSimpleTriggerInputDTO().getEndDate() != null)
|
||||
triggerTriggerBuilder.endAt(triggerCommandDTO.getSimpleTriggerInputDTO().getEndDate());
|
||||
|
||||
if (triggerCommandDTO.getSimpleTriggerInputDTO().getJobDataMap() != null)
|
||||
triggerTriggerBuilder.usingJobData(new JobDataMap(triggerCommandDTO.getSimpleTriggerInputDTO().getJobDataMap()));
|
||||
|
||||
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
|
||||
if (triggerCommandDTO.getSimpleTriggerInputDTO().getRepeatInterval() != null)
|
||||
|
||||
@@ -14,6 +14,7 @@ public class SimpleTriggerToSimpleTriggerDTO extends TriggerToTriggerDTO<SimpleT
|
||||
target.setRepeatCount(source.getRepeatCount());
|
||||
target.setRepeatInterval(source.getRepeatInterval());
|
||||
target.setMisfireInstruction(source.getMisfireInstruction());
|
||||
target.setJobDataMap(source.getJobDataMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,8 +3,9 @@ package it.fabioformosa.quartzmanager.api.dto;
|
||||
import it.fabioformosa.quartzmanager.api.validators.ValidTriggerRepetition;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.validation.constraints.Positive;
|
||||
import java.util.Map;
|
||||
|
||||
@ValidTriggerRepetition
|
||||
@SuperBuilder
|
||||
@@ -18,4 +19,7 @@ public class SimpleTriggerInputDTO extends TriggerCommandDTO implements TriggerR
|
||||
|
||||
@Positive
|
||||
private Long repeatInterval;
|
||||
|
||||
@Nullable
|
||||
private Map<String, ?> jobDataMap;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.quartz.JobDataMap;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -23,4 +24,5 @@ public class TriggerDTO {
|
||||
private JobKeyDTO jobKeyDTO;
|
||||
private JobDetailDTO jobDetailDTO;
|
||||
private boolean mayFireAgain;
|
||||
private JobDataMap jobDataMap;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class WebSocketLogsNotifier implements WebhookSender<LogRecord> {
|
||||
private SimpMessageSendingOperations messagingTemplate;
|
||||
|
||||
@Override
|
||||
public void send(LogRecord logRecord) {
|
||||
public void send(LogRecord logRecord) {
|
||||
messagingTemplate.convertAndSend(TOPIC_LOGS, logRecord);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.Map;
|
||||
import static java.util.Map.entry;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
@@ -68,6 +69,10 @@ class SimpleTriggerControllerTest {
|
||||
}
|
||||
|
||||
private SimpleTriggerInputDTO buildACompleteSimpleTriggerCommandDTO() {
|
||||
Map<String, ?> triggerJobDataMap = Map.ofEntries(
|
||||
entry("customTriggerData1", "value1"),
|
||||
entry("customTriggerData2", "value2")
|
||||
);
|
||||
return SimpleTriggerInputDTO.builder()
|
||||
.jobClass("it.fabioformosa.quartzmanager.api.jobs.SampleJob")
|
||||
.startDate(new Date())
|
||||
@@ -75,6 +80,7 @@ class SimpleTriggerControllerTest {
|
||||
.misfireInstruction(MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW)
|
||||
.repeatCount(5)
|
||||
.repeatInterval(1000L * 60 * 60)
|
||||
.jobDataMap(triggerJobDataMap)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,23 @@ package it.fabioformosa.quartzmanager.api.controllers.utils;
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.common.utils.DateUtils;
|
||||
import it.fabioformosa.quartzmanager.api.dto.*;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.SimpleScheduleBuilder;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class TriggerUtils {
|
||||
|
||||
static public TriggerDTO getTriggerInstance(String triggerName){
|
||||
static public TriggerDTO getTriggerInstance(String triggerName) {
|
||||
return TriggerDTO.builder()
|
||||
.description("sample trigger")
|
||||
.endTime(DateUtils.addHoursToNow(2L))
|
||||
@@ -28,7 +39,7 @@ public class TriggerUtils {
|
||||
.build();
|
||||
}
|
||||
|
||||
static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName, SimpleTriggerInputDTO simpleTriggerInputDTO){
|
||||
static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName, SimpleTriggerInputDTO simpleTriggerInputDTO) {
|
||||
return SimpleTriggerDTO.builder()
|
||||
.description("simple trigger")
|
||||
.repeatCount(simpleTriggerInputDTO.getRepeatCount())
|
||||
@@ -48,10 +59,11 @@ public class TriggerUtils {
|
||||
.nextFireTime(DateUtils.addHoursToNow(1L))
|
||||
.priority(1)
|
||||
.startTime(DateUtils.fromLocalDateTimeToDate(LocalDateTime.now()))
|
||||
.jobDataMap(new JobDataMap(simpleTriggerInputDTO.getJobDataMap()))
|
||||
.build();
|
||||
}
|
||||
|
||||
static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName){
|
||||
static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName) {
|
||||
return SimpleTriggerDTO.builder()
|
||||
.description("simple trigger")
|
||||
.repeatCount(2)
|
||||
@@ -71,6 +83,44 @@ public class TriggerUtils {
|
||||
.nextFireTime(DateUtils.addHoursToNow(1L))
|
||||
.priority(1)
|
||||
.startTime(DateUtils.fromLocalDateTimeToDate(LocalDateTime.now()))
|
||||
.jobDataMap(new JobDataMap(Map.ofEntries(entry("customTriggerData1", "value1"))))
|
||||
.build();
|
||||
}
|
||||
|
||||
static public SimpleTrigger buildSimpleTrigger() {
|
||||
TriggerBuilder<Trigger> triggerTriggerBuilder = TriggerBuilder.newTrigger();
|
||||
triggerTriggerBuilder.startAt(new Date());
|
||||
triggerTriggerBuilder.endAt(DateUtils.addHoursToNow(1));
|
||||
triggerTriggerBuilder.usingJobData(new JobDataMap(Map.ofEntries(entry("data", "value"))));
|
||||
|
||||
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
|
||||
scheduleBuilder.withIntervalInMilliseconds(1000);
|
||||
scheduleBuilder.withRepeatCount(1);
|
||||
scheduleBuilder.withMisfireHandlingInstructionFireNow();
|
||||
|
||||
return triggerTriggerBuilder.withSchedule(
|
||||
scheduleBuilder
|
||||
)
|
||||
.withIdentity("simpleTrigger").build();
|
||||
}
|
||||
|
||||
static public SimpleTriggerCommandDTO buildSimpleTriggerCommandDTO(String triggerName) throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date startDate = dateFormat.parse("2024-02-02");
|
||||
Date endDate = dateFormat.parse("2024-03-02");
|
||||
|
||||
SimpleTriggerInputDTO triggerInputDTO = SimpleTriggerInputDTO.builder()
|
||||
.misfireInstruction(MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW)
|
||||
.jobClass("sample.jobClass")
|
||||
.repeatCount(1)
|
||||
.repeatInterval(1000L)
|
||||
.startDate(startDate)
|
||||
.endDate(endDate)
|
||||
.jobDataMap(Map.ofEntries(entry("data", "value")))
|
||||
.build();
|
||||
return SimpleTriggerCommandDTO.builder()
|
||||
.triggerName(triggerName)
|
||||
.simpleTriggerInputDTO(triggerInputDTO)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package it.fabioformosa.quartzmanager.api.converters;
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.controllers.utils.TriggerUtils;
|
||||
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerCommandDTO;
|
||||
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.SimpleTrigger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@SpringBootTest
|
||||
class SimpleTriggerCommandDTOToSimpleTriggerTest {
|
||||
|
||||
@Autowired
|
||||
private ConversionService conversionService;
|
||||
|
||||
@Order(1)
|
||||
@Test
|
||||
void givenSimpleTriggerCommandDTO_whenItIsConverted_thenASimpleTriggerIsReturned() throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date startDate = dateFormat.parse("2024-02-02");
|
||||
Date endDate = dateFormat.parse("2024-03-02");
|
||||
SimpleTriggerCommandDTO simpleTriggerCommandDTO = TriggerUtils.buildSimpleTriggerCommandDTO("mytrigger");
|
||||
SimpleTrigger simpleTrigger = conversionService.convert(simpleTriggerCommandDTO, SimpleTrigger.class);
|
||||
Assertions.assertThat(simpleTrigger).isNotNull();
|
||||
Assertions.assertThat(simpleTrigger.getRepeatCount()).isEqualTo(simpleTriggerCommandDTO.getSimpleTriggerInputDTO().getRepeatCount());
|
||||
Assertions.assertThat(simpleTrigger.getRepeatInterval()).isEqualTo(simpleTriggerCommandDTO.getSimpleTriggerInputDTO().getRepeatInterval());
|
||||
Assertions.assertThat(simpleTrigger.getJobDataMap()).containsEntry("data", "value");
|
||||
Assertions.assertThat(simpleTrigger.getStartTime()).isEqualTo(startDate);
|
||||
Assertions.assertThat(simpleTrigger.getEndTime()).isEqualTo(endDate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package it.fabioformosa.quartzmanager.api.converters;
|
||||
|
||||
import it.fabioformosa.quartzmanager.api.controllers.utils.TriggerUtils;
|
||||
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerDTO;
|
||||
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.SimpleTrigger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
|
||||
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@SpringBootTest
|
||||
class SimpleTriggerToSimpleTriggerDTOTest {
|
||||
|
||||
@Autowired
|
||||
private ConversionService conversionService;
|
||||
|
||||
@Order(1)
|
||||
@Test
|
||||
void givenSimpleTrigger_whenItIsConverted_thenADtoIsReturned() {
|
||||
SimpleTrigger simpleTrigger = TriggerUtils.buildSimpleTrigger();
|
||||
SimpleTriggerDTO simpleTriggerDTO = conversionService.convert(simpleTrigger, SimpleTriggerDTO.class);
|
||||
Assertions.assertThat(simpleTriggerDTO).isNotNull();
|
||||
Assertions.assertThat(simpleTriggerDTO.getRepeatCount()).isEqualTo(simpleTrigger.getRepeatCount());
|
||||
Assertions.assertThat(simpleTriggerDTO.getRepeatInterval()).isEqualTo(simpleTrigger.getRepeatInterval());
|
||||
Assertions.assertThat(simpleTriggerDTO.getJobDataMap()).containsEntry("data", "value");
|
||||
Assertions.assertThat(simpleTriggerDTO.getStartTime()).isEqualTo(simpleTrigger.getStartTime());
|
||||
Assertions.assertThat(simpleTriggerDTO.getEndTime()).isEqualTo(simpleTrigger.getEndTime());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quartz-manager-starter-persistence</artifactId>
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.springframework.context.annotation.*;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:quartz-persistence.properties")
|
||||
public class PersistenceConfig {
|
||||
|
||||
@Value("${quartz-manager.persistence.quartz.datasource.url}")
|
||||
@@ -57,7 +56,7 @@ public class PersistenceConfig {
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public DataSource quartzManagerDatasource(PersistenceDatasourceProps persistenceDatasourceProps) {
|
||||
public DataSource quartzManagerDatasource() {
|
||||
return DataSourceBuilder.create()
|
||||
.url(quartzDatasourceUrl)
|
||||
.driverClassName("org.postgresql.Driver")
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||
|
||||
<includeAll path="./migrations" relativeToChangelogFile="true"/>
|
||||
<includeAll path="classpath:db/quartz-scheduler/migrations" relativeToChangelogFile="false" errorIfMissingOrEmpty="true"/>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quartz-manager-starter-security</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quartz-manager-starter-ui</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>it.fabioformosa.quartz-manager</groupId>
|
||||
<artifactId>quartz-manager-parent</artifactId>
|
||||
<version>4.0.8</version>
|
||||
<version>4.0.9</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quartz-manager-web-showcase</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user