Commit a5e2f7d7 authored by Jürgen Hannus's avatar Jürgen Hannus
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Jürgen Hannus

See merge request teis/scheduler-service!27
parents 64d7c639 6a299ae9
# Changelog
## [1.13.0] - 2021-01-22
* added integration tests
## [1.12.0] - 2020-10-30
* removed Camunda BPMN dependency
* updated Spring Boot framework to version 2.3.4.RELEASE
* updated teis-gradle-plugin version to latest which contains different Gradle dependency configuration sets (functionalities) and therefore Gradle configuration was stripped down from microservice configuration
* updated teis-gradle-plugin version to latest which contains different Gradle dependency configuration sets (
functionalities) and therefore Gradle configuration was stripped down from microservice configuration
* updated Gradle Wrapper to version 5.6.4
\ No newline at end of file
theGroup=ee.sm.ti.teis
theVersion=1.12.0
commonsVersion=1.14.0
commonApiGatewayVersion=1.14.0
adminApiGatewayVersion=1.7.0
theVersion=1.13.0
commonsVersion=1.18.0
commonApiGatewayVersion=1.18.0
adminApiGatewayVersion=1.8.0
pluginVersion=1.2.0
package ee.sm.ti.teis.scheduler.admin;
import ee.sm.ti.teis.SchedulerAppTestBase;
import ee.sm.ti.teis.admingateway.systemjobs.GetSystemJobDefinitionsRequest;
import ee.sm.ti.teis.admingateway.systemjobs.GetSystemJobDefinitionsResponse;
import ee.sm.ti.teis.admingateway.systemjobs.GetSystemJobsRequest;
import ee.sm.ti.teis.admingateway.systemjobs.GetSystemJobsResponse;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.TI_MANAGE_SYSTEM_JOBS;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.TI_VIEW_SYSTEM_JOBS;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.util.CollectionUtils.isEmpty;
public class AdminJobListenerTest extends SchedulerAppTestBase {
@Autowired
AdminJobListener listener;
RequestMetaDTO requestMetaDTO;
@BeforeEach
void setUp() {
requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(),
List.of(TI_MANAGE_SYSTEM_JOBS.name()));
}
@Test
public void getSystemJobDefinitions_success() {
GetSystemJobDefinitionsRequest request = new GetSystemJobDefinitionsRequest();
requestMetaDTO.setPrivileges(List.of(TI_VIEW_SYSTEM_JOBS.name()));
request.setPayload(null, requestMetaDTO);
GetSystemJobDefinitionsResponse response = listener.getSystemJobDefinitions(request);
// needed because ee.sm.ti.teis.scheduler.processor.SystemJobEventsListenerTest.sendStartedEvent_success is not transactional
if (isEmpty(response.getPayload())) {
assertThat(response.getPayload()).isEmpty();
} else {
assertThat(response.getPayload().get(0).getId()).isEqualTo("scheduler.test");
}
}
@Test
public void getSystemJobExecutions_success() {
GetSystemJobsRequest request = new GetSystemJobsRequest();
request.setPayload("violationacts.createPreceptTasks", requestMetaDTO);
GetSystemJobsResponse response = listener.getSystemJobExecutions(request);
assertThat(response.getPayload()).isEmpty();
}
}
......@@ -8,7 +8,7 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class JobDefinitionServiceTest extends SchedulerAppTestBase {
public class JobDefinitionServiceTest extends SchedulerAppTestBase {
@Autowired
JobDefinitionService jobDefinitionService;
......
......@@ -26,6 +26,7 @@ import static org.testcontainers.shaded.com.google.common.collect.ImmutableList.
public class JobProcessingServiceTest extends SchedulerAppTestBase {
private static final String JOB_ID = "scheduler.pingTestJob";
@Autowired
JobProcessingService jobProcessingService;
......
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="integtest-setup.sql" relativeToChangelogFile="true" />
<include file="classpath:db/changelog/db.changelog-master.xml" />
<include file="integtest-data.sql" relativeToChangelogFile="true" />
<include file="integtest-setup.sql" relativeToChangelogFile="true"/>
<include file="classpath:db/changelog/db.changelog-master.xml"/>
<include file="integtest-data.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>
......@@ -38,11 +38,13 @@ public class AdminBusinessService {
throw new TeisResourceNotFoundException("System job not found with id = " + jobId);
}
List<JobExecutionEntity> jobExecutionEntities = jobExecutionRepository.findAllByJobDefinitionIdOrderByCreatedAtAsc(jobId);
return jobExecutionMapper.toGwDtoList(jobExecutionEntities);
}
public List<JobDefinitionDto> getSystemJobs() {
List<JobDefinitionEntity> definitions = jobDefinitionRepository.findAll();
List<JobDefinitionDto> definitionDtoList = new ArrayList<>();
definitions.forEach(definition -> {
JobExecutionEntity execution = jobExecutionRepository.findFirstByJobDefinitionId(definition.getId());
......@@ -51,9 +53,8 @@ public class AdminBusinessService {
jobDefinitionDto.setLastResponseMessage(execution.getResponseMessage());
definitionDtoList.add(jobDefinitionDto);
}
});
return definitionDtoList;
}
......
......@@ -7,11 +7,7 @@ import ee.sm.ti.teis.types.enums.SystemJobStatus;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
......
......@@ -5,14 +5,10 @@ import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface JobDefinitionMapper {
JobDefinitionDto toGwDto(JobDefinitionEntity jobDefinition);
List<JobDefinitionDto> toGwDtoList(List<JobDefinitionEntity> jobDefinitionList);
}
......@@ -6,5 +6,6 @@ import java.util.List;
public interface JobDefinitionRepository extends CrudRepository<JobDefinitionEntity, String> {
List<JobDefinitionEntity> findAllByDisabled(Boolean disabled);
List<JobDefinitionEntity> findAll();
}
......@@ -5,12 +5,7 @@ import ee.sm.ti.teis.types.enums.SystemJobResponseCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.UUID;
......
......@@ -57,7 +57,7 @@ public class JobProcessingService {
if (jobExecutionOptional.isPresent()) {
jobExecution = jobExecutionOptional.get();
LocalDateTime startTime = systemJob.getStartedAt() == null ? now() : systemJob.getStartedAt();
jobExecution.setStartedAt(startTime );
jobExecution.setStartedAt(startTime);
} else {
jobExecution = jobExecutionMapper.fromDomainToEntity(systemJob);
}
......
......@@ -17,11 +17,11 @@ import java.util.UUID;
@RequiredArgsConstructor
public class SystemJobNotificationService {
private final ApplicationEventPublisher eventPublisher;
@Value("${teis.system.name}")
String systemName;
private final ApplicationEventPublisher eventPublisher;
void notifyExecuteJob(SystemJob payload) {
SystemJobStartExecutionMessageDto requestDTO = new ExecuteSystemJobStartRequest();
requestDTO.setPayload(payload, createRequestMeta());
......
......@@ -49,7 +49,7 @@ public class TriggerInitializerService {
jobSchedulerService.createScheduledJob(job);
job.setInitNeeded(false);
jobDefinitionService.updateJob(job);
log.info ("Job trigger initialized for jobId={}. {}", job.getId(), job.toString());
log.info("Job trigger initialized for jobId={}. {}", job.getId(), job.toString());
}
}
return jobDefinitions;
......@@ -60,7 +60,7 @@ public class TriggerInitializerService {
for (String jobId : jobIds) {
if (jobDefinitions.stream().noneMatch(j -> j.getId().equalsIgnoreCase(jobId))) {
jobSchedulerService.deleteScheduledJob(jobId);
log.info ("Job trigger deleted for jobId={}", jobId);
log.info("Job trigger deleted for jobId={}", jobId);
}
}
}
......
......@@ -13,6 +13,7 @@ public class JobProcessInstanceContext {
private JobProcessInstanceContext() {
throw new IllegalArgumentException("Utility class");
}
public static String getProcessInstanceBusinessKey(SystemJob systemJob) {
return getProcessInstanceBusinessKey(systemJob.getId(), systemJob.getExecutionId().toString());
}
......
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="classpath:common/db/changelog/common-master.xml"/>
<includeAll path="domain" relativeToChangelogFile="true" />
<include file="classpath:common/db/changelog/camunda-7-10.xml" />
<include file="classpath:org/quartz/impl/jdbcjobstore/liquibase.quartz.init.xml" />
<includeAll path="data" relativeToChangelogFile="true" />
<include file="classpath:common/db/changelog/common-master.xml"/>
<includeAll path="domain" relativeToChangelogFile="true"/>
<include file="classpath:common/db/changelog/camunda-7-10.xml"/>
<include file="classpath:org/quartz/impl/jdbcjobstore/liquibase.quartz.init.xml"/>
<includeAll path="data" relativeToChangelogFile="true"/>
</databaseChangeLog>
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=25
org.quartz.threadPool.threadPriority=5
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.misfireThreshold=1000
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties=true
org.quartz.jobStore.tablePrefix=QRTZ_
#============================================================================
# Configure Cluster properties
#============================================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment