Pull request #155: RED-4601: Sonar issues: gateway, redaction-report
Merge in RED/redaction-report-service from RED-4601-rrs2 to master * commit 'c87fa028e549caf50e989e7b26d7f44c321cf190': RED-4601: Sonar issues: gateway, redaction-report
This commit is contained in:
commit
407e567d3d
@ -1,12 +1,12 @@
|
||||
package buildjob;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalTime;
|
||||
|
||||
import static com.atlassian.bamboo.specs.builders.task.TestParserTask.createJUnitParserTask;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
||||
import com.atlassian.bamboo.specs.api.BambooSpec;
|
||||
import com.atlassian.bamboo.specs.api.builders.BambooKey;
|
||||
import com.atlassian.bamboo.specs.api.builders.Variable;
|
||||
import com.atlassian.bamboo.specs.api.builders.docker.DockerConfiguration;
|
||||
import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
|
||||
import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
|
||||
@ -18,19 +18,16 @@ import com.atlassian.bamboo.specs.api.builders.plan.Stage;
|
||||
import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
|
||||
import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
|
||||
import com.atlassian.bamboo.specs.api.builders.project.Project;
|
||||
import com.atlassian.bamboo.specs.api.builders.Variable;
|
||||
import com.atlassian.bamboo.specs.builders.task.CheckoutItem;
|
||||
import com.atlassian.bamboo.specs.builders.task.InjectVariablesTask;
|
||||
import com.atlassian.bamboo.specs.builders.task.ScriptTask;
|
||||
import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask;
|
||||
import com.atlassian.bamboo.specs.builders.task.VcsTagTask;
|
||||
import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger;
|
||||
import com.atlassian.bamboo.specs.builders.trigger.RepositoryPollingTrigger;
|
||||
import com.atlassian.bamboo.specs.builders.trigger.ScheduledTrigger;
|
||||
import com.atlassian.bamboo.specs.model.task.InjectVariablesScope;
|
||||
import com.atlassian.bamboo.specs.util.BambooServer;
|
||||
import com.atlassian.bamboo.specs.builders.task.ScriptTask;
|
||||
import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties.Location;
|
||||
import com.atlassian.bamboo.specs.util.BambooServer;
|
||||
|
||||
/**
|
||||
* Plan configuration for Bamboo.
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
|
||||
@ -5,9 +5,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
|
||||
@ -80,8 +80,8 @@ public class ExcelReportGenerationService {
|
||||
|
||||
if (!excelModel.isRowsBeforeRedactionEntryRowsAdded()) {
|
||||
|
||||
for (Map.Entry<Integer, Integer> colummWidthEntry : excelModel.getCellWidths().entrySet()) {
|
||||
sheet.setColumnWidth(colummWidthEntry.getKey(), colummWidthEntry.getValue());
|
||||
for (Map.Entry<Integer, Integer> columnWidthEntry : excelModel.getCellWidths().entrySet()) {
|
||||
sheet.setColumnWidth(columnWidthEntry.getKey(), columnWidthEntry.getValue());
|
||||
}
|
||||
|
||||
addRows(workbook, sheet, excelModel.getCellsToCopyBeforeRedactionPlaceholderRow(), 0, placeholderModel, dossierName, fileModel.getFilename());
|
||||
|
||||
@ -11,7 +11,6 @@ import static com.iqser.red.service.redaction.report.v1.server.service.Placehold
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -64,8 +63,7 @@ public class GeneratePlaceholderService {
|
||||
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder()
|
||||
.decode(dossierAttribute.getValue().split(",")[1])));
|
||||
} else {
|
||||
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder()
|
||||
.decode(dossierAttribute.getValue())));
|
||||
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder().decode(dossierAttribute.getValue())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -93,12 +91,7 @@ public class GeneratePlaceholderService {
|
||||
|
||||
Map<String, String> fileAttributeValueByPlaceholder = new HashMap<>();
|
||||
for (Map.Entry<String, String> idEntry : placeholderModel.getFileAttributeIdByPlaceholder().entrySet()) {
|
||||
if (fileModel.getFileAttributes().containsKey(idEntry.getValue())) {
|
||||
fileAttributeValueByPlaceholder.put(idEntry.getKey(), fileModel.getFileAttributes()
|
||||
.get(idEntry.getValue()));
|
||||
} else {
|
||||
fileAttributeValueByPlaceholder.put(idEntry.getKey(), "");
|
||||
}
|
||||
fileAttributeValueByPlaceholder.put(idEntry.getKey(), fileModel.getFileAttributes().getOrDefault(idEntry.getValue(), ""));
|
||||
}
|
||||
placeholderModel.setFileAttributeValueByPlaceholder(fileAttributeValueByPlaceholder);
|
||||
}
|
||||
@ -106,9 +99,7 @@ public class GeneratePlaceholderService {
|
||||
|
||||
public Set<String> getDefaultPlaceholders() {
|
||||
|
||||
Set<String> defPlaceholders = new HashSet<>();
|
||||
defPlaceholders.addAll(Set.of(FILE_NAME_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
return defPlaceholders;
|
||||
return new HashSet<>(Set.of(FILE_NAME_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
}
|
||||
|
||||
|
||||
@ -117,9 +108,7 @@ public class GeneratePlaceholderService {
|
||||
Map<String, String> fileAttributePlaceholders = new HashMap<>();
|
||||
|
||||
var fileAttributesConfig = fileAttributesClient.getFileAttributeConfigs(dossierTemplateId);
|
||||
fileAttributesConfig.forEach(fileAttributeConfig -> {
|
||||
fileAttributePlaceholders.put(fileAttributeConfig.getPlaceholder(), fileAttributeConfig.getId());
|
||||
});
|
||||
fileAttributesConfig.forEach(fileAttributeConfig -> fileAttributePlaceholders.put(fileAttributeConfig.getPlaceholder(), fileAttributeConfig.getId()));
|
||||
return fileAttributePlaceholders;
|
||||
}
|
||||
|
||||
|
||||
@ -20,10 +20,8 @@ public class IuclidFunctionService {
|
||||
public String computeIuclidFunction(List<ReportRedactionEntry> reportRedactionEntries, String filename) {
|
||||
|
||||
Map<String, List<ReportRedactionEntry>> entriesPerJustification = new HashMap<>();
|
||||
reportRedactionEntries.forEach(reportRedactionEntry -> {
|
||||
entriesPerJustification.computeIfAbsent(reportRedactionEntry.getJustification(), (x) -> new ArrayList<>())
|
||||
.add(reportRedactionEntry);
|
||||
});
|
||||
reportRedactionEntries.forEach(reportRedactionEntry -> entriesPerJustification.computeIfAbsent(reportRedactionEntry.getJustification(), (x) -> new ArrayList<>())
|
||||
.add(reportRedactionEntry));
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(removeExtension(filename));
|
||||
@ -37,7 +35,7 @@ public class IuclidFunctionService {
|
||||
while (iterator.hasNext()) {
|
||||
ReportRedactionEntry entry = iterator.next();
|
||||
s.append("P").append(entry.getPage()).append(" ");
|
||||
if(StringUtils.isBlank(entry.getValue()) || entry.getValue().equalsIgnoreCase("Rectangle")) {
|
||||
if (StringUtils.isBlank(entry.getValue()) || entry.getValue().equalsIgnoreCase("Rectangle")) {
|
||||
s.append("non-readable content");
|
||||
} else {
|
||||
s.append(entry.getValue().replaceAll("\n", " ").replaceAll(" ", " "));
|
||||
|
||||
@ -201,13 +201,9 @@ public class PlaceholderService {
|
||||
|
||||
Set<String> allPlaceholders = new HashSet<>(getGeneralPlaceholders());
|
||||
|
||||
dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId).forEach(dossierAttributeConfig -> {
|
||||
allPlaceholders.add(dossierAttributeConfig.getPlaceholder());
|
||||
});
|
||||
dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId).forEach(dossierAttributeConfig -> allPlaceholders.add(dossierAttributeConfig.getPlaceholder()));
|
||||
|
||||
fileAttributesClient.getFileAttributeConfigs(dossierTemplateId).forEach(fileAttributeConfig -> {
|
||||
allPlaceholders.add(fileAttributeConfig.getPlaceholder());
|
||||
});
|
||||
fileAttributesClient.getFileAttributeConfigs(dossierTemplateId).forEach(fileAttributeConfig -> allPlaceholders.add(fileAttributeConfig.getPlaceholder()));
|
||||
|
||||
return allPlaceholders;
|
||||
}
|
||||
|
||||
@ -108,12 +108,12 @@ public class RedactionLogConverterService {
|
||||
str = str.replaceAll("_+?", " ");
|
||||
str = str.replaceAll(" +", " ");
|
||||
|
||||
StringBuilder strbf = new StringBuilder();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Matcher match = Pattern.compile("([a-z])([a-z]*)", Pattern.CASE_INSENSITIVE).matcher(str);
|
||||
while (match.find()) {
|
||||
match.appendReplacement(strbf, match.group(1).toUpperCase() + match.group(2));
|
||||
match.appendReplacement(stringBuilder, match.group(1).toUpperCase() + match.group(2));
|
||||
}
|
||||
return match.appendTail(strbf).toString();
|
||||
return match.appendTail(stringBuilder).toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -153,9 +154,7 @@ public class ReportGenerationService {
|
||||
storedFileInformation.add(new StoredFileInformation(null, storageId, ReportType.WORD_TEMPLATE_MULTI_FILE, multiFileDocument.getTemplateId()));
|
||||
}
|
||||
|
||||
String reportFileInformationStorageId = reportStorageService.storeReportInformation(reportMessage.getDownloadId(), storedFileInformation);
|
||||
|
||||
return reportFileInformationStorageId;
|
||||
return reportStorageService.storeReportInformation(reportMessage.getDownloadId(), storedFileInformation);
|
||||
}
|
||||
|
||||
|
||||
@ -201,7 +200,7 @@ public class ReportGenerationService {
|
||||
}
|
||||
|
||||
RedactionLog redactionLog;
|
||||
Map<String, String> mapOfEntityDisplayName = new HashMap<>();
|
||||
Map<String, String> mapOfEntityDisplayName;
|
||||
try {
|
||||
redactionLog = redactionLogClient.getRedactionLog(dossierId, fileId, new ArrayList<>(), true, false);
|
||||
mapOfEntityDisplayName = fillMapOfTypeAndEntityDisplayName(dossierId);
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportResultMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration.REPORT_QUEUE;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration.REPORT_RESULT_QUEUE;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportResultMessage;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration.REPORT_QUEUE;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration.REPORT_RESULT_QUEUE;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -44,8 +43,7 @@ public class ReportMessageReceiver {
|
||||
}
|
||||
|
||||
|
||||
private void addToReportResultQueue(String userId, String downloadId,
|
||||
String reportFileInformationStorageId, int priority) {
|
||||
private void addToReportResultQueue(String userId, String downloadId, String reportFileInformationStorageId, int priority) {
|
||||
|
||||
try {
|
||||
rabbitTemplate.convertAndSend(REPORT_RESULT_QUEUE, objectMapper.writeValueAsString(new ReportResultMessage(userId, downloadId, reportFileInformationStorageId)), message -> {
|
||||
|
||||
@ -1,22 +1,28 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FORMAT_DATE_ISO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileAttributeConfig;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FORMAT_DATE_ISO;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -28,7 +34,6 @@ public class StatusReportGenerationService {
|
||||
|
||||
public byte[] generateReport(Dossier dossier) {
|
||||
|
||||
|
||||
var fileStatuses = fileStatusClient.getDossierStatus(dossier.getId());
|
||||
|
||||
List<FileAttributeConfig> fileAttributeConfigs = fileAttributesClient.getFileAttributeConfigs(dossier.getDossierTemplateId());
|
||||
@ -64,7 +69,6 @@ public class StatusReportGenerationService {
|
||||
int pages = fileStatus.getNumberOfPages();
|
||||
var fileAttributes = fileStatus.getFileAttributes();
|
||||
|
||||
|
||||
XSSFRow row = sheet.createRow(i + 1);
|
||||
|
||||
XSSFCell cellName = row.createCell(0);
|
||||
@ -84,9 +88,7 @@ public class StatusReportGenerationService {
|
||||
sheet.autoSizeColumn(3);
|
||||
sheet.autoSizeColumn(4);
|
||||
|
||||
Iterator<Map.Entry<String, String>> iterator = fileAttributes.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
var nextElement = iterator.next();
|
||||
for (Map.Entry<String, String> nextElement : fileAttributes.entrySet()) {
|
||||
if (attributesAssignment.get(nextElement.getKey()) != null) {
|
||||
XSSFCell cell = row.createCell(attributesAssignment.get(nextElement.getKey()));
|
||||
cell.setCellValue(nextElement.getValue());
|
||||
|
||||
@ -79,8 +79,8 @@ public class WordReportGenerationService {
|
||||
|
||||
|
||||
@Timed("redactmanager_generateWordReport")
|
||||
public XWPFDocument generateWordReport(List<ReportRedactionEntry> reportEntries, PlaceholderModel placeholderModel, String reportTemplateName, XWPFDocument doc,
|
||||
FileModel fileModel, Dossier dossier, boolean isLastFile) {
|
||||
public void generateWordReport(List<ReportRedactionEntry> reportEntries, PlaceholderModel placeholderModel, String reportTemplateName, XWPFDocument doc, FileModel fileModel,
|
||||
Dossier dossier, boolean isLastFile) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@ -104,7 +104,6 @@ public class WordReportGenerationService {
|
||||
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}", System.currentTimeMillis() - start, fileModel.getId(), fileModel.getNumberOfPages(), reportEntries.size(), reportTemplateName, getClass().getSimpleName());
|
||||
|
||||
return doc;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage() + " in file: " + fileModel.getFilename());
|
||||
throw new RuntimeException(e);
|
||||
@ -419,7 +418,7 @@ public class WordReportGenerationService {
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
SortedSet<Integer> numbers = new TreeSet<Integer>(pages);
|
||||
SortedSet<Integer> numbers = new TreeSet<>(pages);
|
||||
|
||||
Integer start = null;
|
||||
Integer end = null;
|
||||
@ -440,7 +439,7 @@ public class WordReportGenerationService {
|
||||
if (start.equals(end)) {
|
||||
result.append(start).append(",");
|
||||
}
|
||||
//range lenth 2 and more
|
||||
//range length 2 and more
|
||||
else {
|
||||
result.append(start).append("-").append(end).append(",");
|
||||
}
|
||||
@ -449,7 +448,7 @@ public class WordReportGenerationService {
|
||||
end = num;
|
||||
}
|
||||
}
|
||||
if (start.equals(end)) {
|
||||
if (start != null && start.equals(end)) {
|
||||
result.append(start);
|
||||
} else {
|
||||
result.append(start).append("-").append(end);
|
||||
@ -458,10 +457,10 @@ public class WordReportGenerationService {
|
||||
}
|
||||
|
||||
|
||||
private Dimension2DDouble getImageDimension(ByteArrayInputStream bais) throws IOException {
|
||||
private Dimension2DDouble getImageDimension(ByteArrayInputStream byteArrayInputStream) throws IOException {
|
||||
|
||||
BufferedImage bufImg = ImageIO.read(bais);
|
||||
bais.reset();
|
||||
BufferedImage bufImg = ImageIO.read(byteArrayInputStream);
|
||||
byteArrayInputStream.reset();
|
||||
|
||||
double width = bufImg.getWidth();
|
||||
double height = bufImg.getHeight();
|
||||
|
||||
@ -388,7 +388,7 @@ public class RedactionReportIntegrationTest {
|
||||
|
||||
private PlaceholderModel buildPlaceHolderModel(Map<String, String> dossierAttributes, Map<String, String> fileAttributes, List<ImagePlaceholder> imagePlaceholders) {
|
||||
|
||||
var defaultPlaceHolder = new HashSet(Set.of(FILE_NAME_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
var defaultPlaceHolder = new HashSet<>(Set.of(FILE_NAME_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
defaultPlaceHolder.addAll(dossierAttributes.keySet());
|
||||
defaultPlaceHolder.addAll(fileAttributes.keySet());
|
||||
return new PlaceholderModel(defaultPlaceHolder, imagePlaceholders, dossierAttributes, null, fileAttributes);
|
||||
|
||||
@ -23,8 +23,6 @@ import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
|
||||
import io.undertow.util.BadRequestException;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class StatusReportGenerationServiceTest {
|
||||
|
||||
@ -42,12 +40,12 @@ public class StatusReportGenerationServiceTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenerateReport() throws IOException, BadRequestException {
|
||||
public void testGenerateReport() throws IOException {
|
||||
|
||||
String dossierId = "dossierId";
|
||||
|
||||
Dossier dossier = Dossier.builder().dossierName("dossierName").id(dossierId).build();
|
||||
when(dossierClient.getDossierById(dossierId, true,false)).thenReturn(dossier);
|
||||
when(dossierClient.getDossierById(dossierId, true, false)).thenReturn(dossier);
|
||||
|
||||
FileModel fileStatus1 = FileModel.builder()
|
||||
.dossierId(dossierId)
|
||||
@ -56,10 +54,9 @@ public class StatusReportGenerationServiceTest {
|
||||
.assignee("me")
|
||||
.workflowStatus(WorkflowStatus.APPROVED)
|
||||
.numberOfPages(3)
|
||||
.fileAttributes(Map.of("a", "A","config2","B2" ))
|
||||
.fileAttributes(Map.of("a", "A", "config2", "B2"))
|
||||
.build();
|
||||
|
||||
|
||||
FileModel fileStatus2 = FileModel.builder()
|
||||
.dossierId(dossierId)
|
||||
.filename("file2desJahrtausendsGibtsJaNicht")
|
||||
@ -67,7 +64,7 @@ public class StatusReportGenerationServiceTest {
|
||||
.assignee("you")
|
||||
.workflowStatus(WorkflowStatus.APPROVED)
|
||||
.numberOfPages(21)
|
||||
.fileAttributes(Map.of("config1","X1","y", "Y"))
|
||||
.fileAttributes(Map.of("config1", "X1", "y", "Y"))
|
||||
.build();
|
||||
|
||||
when(fileStatusClient.getDossierStatus(dossierId)).thenReturn(List.of(fileStatus1, fileStatus2));
|
||||
@ -79,7 +76,7 @@ public class StatusReportGenerationServiceTest {
|
||||
|
||||
byte[] report = statusReportGenerationService.generateReport(dossier);
|
||||
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/status_report.xlsx")) {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/status_report.xlsx")) {
|
||||
fileOutputStream.write(report);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user