Browse Source

Fix dao tests init

pull/13285/head
ViacheslavKlimov 1 year ago
parent
commit
56bbb5807f
  1. 5
      application/src/main/java/org/thingsboard/server/controller/JobController.java
  2. 2
      dao/src/main/java/org/thingsboard/server/dao/config/JpaDaoConfig.java
  3. 6
      dao/src/main/java/org/thingsboard/server/dao/entity/BaseEntityService.java

5
application/src/main/java/org/thingsboard/server/controller/JobController.java

@ -59,7 +59,6 @@ public class JobController extends BaseController {
@GetMapping("/job/{id}") @GetMapping("/job/{id}")
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
public Job getJobById(@PathVariable UUID id) throws ThingsboardException { public Job getJobById(@PathVariable UUID id) throws ThingsboardException {
// todo check permissions
return jobService.findJobById(getTenantId(), new JobId(id)); return jobService.findJobById(getTenantId(), new JobId(id));
} }
@ -80,7 +79,6 @@ public class JobController extends BaseController {
@RequestParam(required = false) List<UUID> entities, @RequestParam(required = false) List<UUID> entities,
@RequestParam(required = false) Long startTime, @RequestParam(required = false) Long startTime,
@RequestParam(required = false) Long endTime) throws ThingsboardException { @RequestParam(required = false) Long endTime) throws ThingsboardException {
// todo check permissions
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
JobFilter filter = JobFilter.builder() JobFilter filter = JobFilter.builder()
.types(types) .types(types)
@ -95,21 +93,18 @@ public class JobController extends BaseController {
@PostMapping("/job/{id}/cancel") @PostMapping("/job/{id}/cancel")
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
public void cancelJob(@PathVariable UUID id) throws ThingsboardException { public void cancelJob(@PathVariable UUID id) throws ThingsboardException {
// todo check permissions
jobManager.cancelJob(getTenantId(), new JobId(id)); jobManager.cancelJob(getTenantId(), new JobId(id));
} }
@PostMapping("/job/{id}/reprocess") @PostMapping("/job/{id}/reprocess")
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
public void reprocessJob(@PathVariable UUID id) throws ThingsboardException { public void reprocessJob(@PathVariable UUID id) throws ThingsboardException {
// todo check permissions
jobManager.reprocessJob(getTenantId(), new JobId(id)); jobManager.reprocessJob(getTenantId(), new JobId(id));
} }
@DeleteMapping("/job/{id}") @DeleteMapping("/job/{id}")
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
public void deleteJob(@PathVariable UUID id) throws ThingsboardException { public void deleteJob(@PathVariable UUID id) throws ThingsboardException {
// todo check permissions
jobService.deleteJob(getTenantId(), new JobId(id)); jobService.deleteJob(getTenantId(), new JobId(id));
} }

2
dao/src/main/java/org/thingsboard/server/dao/config/JpaDaoConfig.java

@ -45,7 +45,7 @@ import java.util.Objects;
@Configuration @Configuration
@TbAutoConfiguration @TbAutoConfiguration
@ComponentScan({"org.thingsboard.server.dao.sql", "org.thingsboard.server.dao.attributes", "org.thingsboard.server.dao.sqlts.dictionary", "org.thingsboard.server.dao.cache", "org.thingsboard.server.cache"}) @ComponentScan({"org.thingsboard.server.dao.sql", "org.thingsboard.server.dao.attributes", "org.thingsboard.server.dao.sqlts.dictionary", "org.thingsboard.server.dao.cache", "org.thingsboard.server.cache", "org.thingsboard.server.dao.entity"})
@EnableJpaRepositories(value = {"org.thingsboard.server.dao.sql", "org.thingsboard.server.dao.sqlts.dictionary"}, @EnableJpaRepositories(value = {"org.thingsboard.server.dao.sql", "org.thingsboard.server.dao.sqlts.dictionary"},
excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {EventRepository.class, AuditLogRepository.class}), excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {EventRepository.class, AuditLogRepository.class}),
bootstrapMode = BootstrapMode.LAZY) bootstrapMode = BootstrapMode.LAZY)

6
dao/src/main/java/org/thingsboard/server/dao/entity/BaseEntityService.java

@ -103,7 +103,7 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
private EdqsApiService edqsApiService; private EdqsApiService edqsApiService;
@Autowired @Autowired
private EdqsStatsService edqsStatsService; private Optional<EdqsStatsService> edqsStatsService;
@Override @Override
public long countEntitiesByQuery(TenantId tenantId, CustomerId customerId, EntityCountQuery query) { public long countEntitiesByQuery(TenantId tenantId, CustomerId customerId, EntityCountQuery query) {
@ -123,7 +123,7 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
} else { } else {
result = entityQueryDao.countEntitiesByQuery(tenantId, customerId, query); result = entityQueryDao.countEntitiesByQuery(tenantId, customerId, query);
} }
edqsStatsService.reportEntityCountQuery(tenantId, query, System.nanoTime() - startNs); edqsStatsService.ifPresent(statsService -> statsService.reportEntityCountQuery(tenantId, query, System.nanoTime() - startNs));
return result; return result;
} }
@ -157,7 +157,7 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
} }
} }
} }
edqsStatsService.reportEntityDataQuery(tenantId, query, System.nanoTime() - startNs); edqsStatsService.ifPresent(statsService -> statsService.reportEntityDataQuery(tenantId, query, System.nanoTime() - startNs));
return result; return result;
} }

Loading…
Cancel
Save