From 0deef843d1038a9e22cc29d1ddbdb748ac368013 Mon Sep 17 00:00:00 2001 From: Gael Leblan Date: Fri, 31 Jan 2025 09:45:34 +0100 Subject: [PATCH] [backend] Converting return lines to HTML tags when importing rich text fields (#2317) --- .../openbas/service/InjectImportService.java | 101 +----- .../service/utils/InjectImportUtils.java | 150 +++++++++ .../service/InjectImportServiceTest.java | 302 ++++++++++++++++++ .../utils/mockMapper/MockMapperUtils.java | 4 +- 4 files changed, 467 insertions(+), 90 deletions(-) create mode 100644 openbas-api/src/main/java/io/openbas/service/utils/InjectImportUtils.java create mode 100644 openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java diff --git a/openbas-api/src/main/java/io/openbas/service/InjectImportService.java b/openbas-api/src/main/java/io/openbas/service/InjectImportService.java index 83debf33d2..4ddc07e0ab 100644 --- a/openbas-api/src/main/java/io/openbas/service/InjectImportService.java +++ b/openbas-api/src/main/java/io/openbas/service/InjectImportService.java @@ -14,6 +14,7 @@ import io.openbas.rest.scenario.response.ImportMessage; import io.openbas.rest.scenario.response.ImportPostSummary; import io.openbas.rest.scenario.response.ImportTestSummary; +import io.openbas.service.utils.InjectImportUtils; import io.openbas.utils.InjectUtils; import java.io.IOException; import java.io.InputStream; @@ -39,7 +40,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.java.Log; import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.logging.log4j.util.Strings; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellReference; @@ -492,7 +492,9 @@ private ImportRow importRow( Matcher matcher = mapPatternByInjectImport .get(injectImporter.getId()) - .matcher(getValueAsString(row, importMapper.getInjectTypeColumn())); + .matcher( + InjectImportUtils.getValueAsString( + row, importMapper.getInjectTypeColumn())); return matcher.find(); }) .toList(); @@ -565,7 +567,7 @@ private ImportRow importRow( if (triggerTimeRuleAttribute.getColumns() != null) { dateAsString = Arrays.stream(triggerTimeRuleAttribute.getColumns().split("\\+")) - .map(column -> getDateAsStringFromCell(row, column, timePattern)) + .map(column -> InjectImportUtils.getDateAsStringFromCell(row, column, timePattern)) .collect(Collectors.joining()); } if (dateAsString.isBlank()) { @@ -584,7 +586,7 @@ private ImportRow importRow( injectTime.setUnformattedDate(dateAsString); injectTime.setLinkedInject(inject); - Temporal dateTime = getInjectDate(injectTime, timePattern); + Temporal dateTime = InjectImportUtils.getInjectDate(injectTime, timePattern); if (dateTime == null) { injectTime.setRelativeDay(relativeDays); @@ -758,7 +760,7 @@ private void setAttributeValue( if (valueCell == null) { setter.accept(ruleAttribute.getDefaultValue()); } else { - String cellValue = getValueAsString(row, ruleAttribute.getColumns()); + String cellValue = InjectImportUtils.getValueAsString(row, ruleAttribute.getColumns()); setter.accept(cellValue.isBlank() ? ruleAttribute.getDefaultValue() : cellValue); } } @@ -806,9 +808,8 @@ private List addFields( String columnValue = Strings.EMPTY; if (ruleAttribute.getColumns() != null) { columnValue = - Arrays.stream(ruleAttribute.getColumns().split("\\+")) - .map(column -> getValueAsString(row, column)) - .collect(Collectors.joining()); + InjectImportUtils.extractAndConvertStringColumnValue( + row, ruleAttribute, mapFieldByKey); } if (columnValue.isBlank()) { inject.getContent().put(ruleAttribute.getDefaultValue(), columnValue); @@ -830,7 +831,7 @@ private List addFields( columnValues = Arrays.stream( Arrays.stream(ruleAttribute.getColumns().split("\\+")) - .map(column -> getValueAsString(row, column)) + .map(column -> InjectImportUtils.getValueAsString(row, column)) .collect(Collectors.joining(",")) .split(",")) .toList(); @@ -908,7 +909,7 @@ private List addFields( == CellType.NUMERIC)) { Double columnValueExpectation = columns.stream() - .map(column -> getValueAsDouble(row, column)) + .map(column -> InjectImportUtils.getValueAsDouble(row, column)) .reduce(0.0, Double::sum); expectation.get().setExpectedScore(columnValueExpectation.doubleValue()); } else { @@ -939,7 +940,7 @@ private List addFields( if (ruleAttribute.getColumns() != null) { String columnValueExpectation = Arrays.stream(ruleAttribute.getColumns().split("\\+")) - .map(column -> getValueAsString(row, column)) + .map(column -> InjectImportUtils.getValueAsString(row, column)) .collect(Collectors.joining()); expectation .get() @@ -954,7 +955,7 @@ private List addFields( if (ruleAttribute.getColumns() != null) { String columnValueExpectation = Arrays.stream(ruleAttribute.getColumns().split("\\+")) - .map(column -> getValueAsString(row, column)) + .map(column -> InjectImportUtils.getValueAsString(row, column)) .collect(Collectors.joining()); expectation .get() @@ -975,36 +976,6 @@ private List addFields( return emptyList(); } - private Temporal getInjectDate(InjectTime injectTime, String timePattern) { - DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME; - if (timePattern != null && !timePattern.isEmpty()) { - dateTimeFormatter = DateTimeFormatter.ofPattern(timePattern); - try { - return LocalDateTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); - } catch (DateTimeParseException firstException) { - try { - return LocalTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); - } catch (DateTimeParseException exception) { - // This is a "probably" a relative date - } - } - } else { - try { - return LocalDateTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); - } catch (DateTimeParseException firstException) { - // The date is not in ISO_DATE_TIME. Trying just the ISO_TIME - dateTimeFormatter = DateTimeFormatter.ISO_TIME; - try { - return LocalDateTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); - } catch (DateTimeParseException secondException) { - // Neither ISO_DATE_TIME nor ISO_TIME - } - } - } - injectTime.setFormatter(dateTimeFormatter); - return null; - } - private List updateInjectDates(Map mapInstantByRowIndex) { List importMessages = new ArrayList<>(); // First of all, are there any absolute date @@ -1195,50 +1166,4 @@ private void processDateToAbsolute(Map mapInstantByRowIndex - earliestInstant.getEpochSecond()); })); } - - private String getDateAsStringFromCell(Row row, String cellColumn, String timePattern) { - if (cellColumn != null - && !cellColumn.isBlank() - && row.getCell(CellReference.convertColStringToIndex(cellColumn)) != null) { - Cell cell = row.getCell(CellReference.convertColStringToIndex(cellColumn)); - if (cell.getCellType() == CellType.STRING) { - return cell.getStringCellValue(); - } else if (cell.getCellType() == CellType.NUMERIC) { - if (timePattern == null || timePattern.isEmpty()) { - return cell.getDateCellValue().toString(); - } else { - return DateFormatUtils.format(cell.getDateCellValue(), timePattern); - } - } - } - return ""; - } - - private String getValueAsString(Row row, String cellColumn) { - if (cellColumn != null - && !cellColumn.isBlank() - && row.getCell(CellReference.convertColStringToIndex(cellColumn)) != null) { - Cell cell = row.getCell(CellReference.convertColStringToIndex(cellColumn)); - if (cell.getCellType() == CellType.STRING) { - return cell.getStringCellValue(); - } else if (cell.getCellType() == CellType.NUMERIC) { - return Double.valueOf(cell.getNumericCellValue()).toString(); - } - } - return ""; - } - - private Double getValueAsDouble(Row row, String cellColumn) { - if (cellColumn != null - && !cellColumn.isBlank() - && row.getCell(CellReference.convertColStringToIndex(cellColumn)) != null) { - Cell cell = row.getCell(CellReference.convertColStringToIndex(cellColumn)); - if (cell.getCellType() == CellType.STRING) { - return Double.valueOf(cell.getStringCellValue()); - } else if (cell.getCellType() == CellType.NUMERIC) { - return cell.getNumericCellValue(); - } - } - return 0.0; - } } diff --git a/openbas-api/src/main/java/io/openbas/service/utils/InjectImportUtils.java b/openbas-api/src/main/java/io/openbas/service/utils/InjectImportUtils.java new file mode 100644 index 0000000000..0f1819db1d --- /dev/null +++ b/openbas-api/src/main/java/io/openbas/service/utils/InjectImportUtils.java @@ -0,0 +1,150 @@ +package io.openbas.service.utils; + +import com.fasterxml.jackson.databind.JsonNode; +import io.openbas.database.model.RuleAttribute; +import io.openbas.service.InjectTime; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.time.temporal.Temporal; +import java.util.*; +import java.util.stream.Collectors; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellReference; + +public class InjectImportUtils { + + /** + * Returns the date as string from an excel cell + * + * @param row the row + * @param cellColumn the column + * @param timePattern the pattern to use to convert the date + * @return the date as string + */ + public static String getDateAsStringFromCell(Row row, String cellColumn, String timePattern) { + if (cellColumn != null + && !cellColumn.isBlank() + && row.getCell(CellReference.convertColStringToIndex(cellColumn)) != null) { + Cell cell = row.getCell(CellReference.convertColStringToIndex(cellColumn)); + if (cell.getCellType() == CellType.STRING) { + return cell.getStringCellValue(); + } else if (cell.getCellType() == CellType.NUMERIC) { + if (timePattern == null || timePattern.isEmpty()) { + return cell.getDateCellValue().toString(); + } else { + return DateFormatUtils.format(cell.getDateCellValue(), timePattern); + } + } + } + return ""; + } + + /** + * Get the value of a cell as a string + * + * @param row the row + * @param cellColumn the column + * @return the value of the cell as string + */ + public static String getValueAsString(Row row, String cellColumn) { + if (cellColumn != null + && !cellColumn.isBlank() + && row.getCell(CellReference.convertColStringToIndex(cellColumn)) != null) { + Cell cell = row.getCell(CellReference.convertColStringToIndex(cellColumn)); + if (cell.getCellType() == CellType.STRING) { + return cell.getStringCellValue(); + } else if (cell.getCellType() == CellType.NUMERIC) { + return Double.valueOf(cell.getNumericCellValue()).toString(); + } + } + return ""; + } + + /** + * Get the value of a cell as a double + * + * @param row the row + * @param cellColumn the column + * @return the value of the cell as a double + */ + public static Double getValueAsDouble(Row row, String cellColumn) { + if (cellColumn != null + && !cellColumn.isBlank() + && row.getCell(CellReference.convertColStringToIndex(cellColumn)) != null) { + Cell cell = row.getCell(CellReference.convertColStringToIndex(cellColumn)); + if (cell.getCellType() == CellType.STRING) { + return Double.valueOf(cell.getStringCellValue()); + } else if (cell.getCellType() == CellType.NUMERIC) { + return cell.getNumericCellValue(); + } + } + return 0.0; + } + + /** + * Extract the value as string and convert it to HTML if need be + * + * @param row the row + * @param ruleAttribute the rule to use to extract the value + * @param mapFieldByKey the map of the fields organized by the name of the field + * @return the value as string + */ + public static String extractAndConvertStringColumnValue( + Row row, RuleAttribute ruleAttribute, Map mapFieldByKey) { + String columnValue = + Arrays.stream(ruleAttribute.getColumns().split("\\+")) + .map(column -> getValueAsString(row, column)) + .collect(Collectors.joining()); + + // Given that richText fields are editable using CKEditor which expects HTML, + // we're converting return line into
. + // TODO : convert properly the whole cell into HTML including formatting (bold, ...) + if (mapFieldByKey.get(ruleAttribute.getName()).get("richText") != null + && mapFieldByKey.get(ruleAttribute.getName()).get("richText").asBoolean()) { + columnValue = columnValue.replaceAll("\n", "
"); + } + return columnValue; + } + + /** + * Returns a date out of an InjectTime object with a time pattern + * + * @param injectTime the object representing a date in the cells + * @param timePattern a pattern to use to find out what value it is + * @return the date + */ + public static Temporal getInjectDate(InjectTime injectTime, String timePattern) { + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME; + if (timePattern != null && !timePattern.isEmpty()) { + dateTimeFormatter = DateTimeFormatter.ofPattern(timePattern); + try { + return LocalDateTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); + } catch (DateTimeParseException firstException) { + try { + return LocalTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); + } catch (DateTimeParseException exception) { + // This is a "probably" a relative date + } + } + } else { + try { + return LocalDateTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); + } catch (DateTimeParseException firstException) { + // The date is not in ISO_DATE_TIME. Trying just the ISO_TIME + dateTimeFormatter = DateTimeFormatter.ISO_TIME; + try { + return LocalTime.parse(injectTime.getUnformattedDate(), dateTimeFormatter); + } catch (DateTimeParseException secondException) { + // Neither ISO_DATE_TIME nor ISO_TIME + } + } + } + injectTime.setFormatter(dateTimeFormatter); + return null; + } +} diff --git a/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java b/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java new file mode 100644 index 0000000000..49903a899f --- /dev/null +++ b/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java @@ -0,0 +1,302 @@ +package io.openbas.service; + +import static org.junit.jupiter.api.Assertions.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import io.openbas.database.model.RuleAttribute; +import io.openbas.service.utils.InjectImportUtils; +import io.openbas.utils.mockMapper.MockMapperUtils; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.util.Date; +import java.util.Map; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.jupiter.api.*; + +public class InjectImportServiceTest { + private Row row; + private Cell cell; + private ObjectNode json; + private Workbook workbook; + + @BeforeEach + void before() throws Exception { + workbook = new XSSFWorkbook(); + Sheet sheet = workbook.createSheet(); + row = sheet.createRow(0); + cell = row.createCell(0); + + json = + new ObjectMapper() + .readValue( + """ + { + "key":"Test", + "richText":true + } + """, + ObjectNode.class); + } + + @AfterEach + void after() throws Exception { + workbook.close(); + } + + // -- INJECT IMPORT -- + + @DisplayName("Test get a date cell as string") + @Test + void testGetDateAsString() throws Exception { + // -- PREPARE -- + Date date = Date.from(LocalDateTime.of(2025, 1, 1, 12, 0).toInstant(ZoneOffset.UTC)); + cell.setCellValue(date); + // -- EXECUTE -- + String result = InjectImportUtils.getDateAsStringFromCell(row, "A", null); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(date.toString(), result); + } + + @DisplayName("Test get a date cell as string with a specific time pattern") + @Test + void testGetDateAsStringWithTimePattern() throws Exception { + // -- PREPARE -- + Date date = Date.from(LocalDateTime.of(2025, 1, 2, 12, 0).toInstant(ZoneOffset.UTC)); + cell.setCellValue(date); + // -- EXECUTE -- + String result = InjectImportUtils.getDateAsStringFromCell(row, "A", "DD/MM/YY HH:mm:ss"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(new SimpleDateFormat("dd/MM/yy HH:mm:ss").format(date), result); + } + + @DisplayName("Test get a date cell as string when no column specified") + @Test + void testGetDateAsStringWhenNoColumn() throws Exception { + // -- PREPARE -- + cell.setCellValue(Date.from(LocalDateTime.of(2025, 1, 1, 12, 0).toInstant(ZoneOffset.UTC))); + // -- EXECUTE -- + String result = InjectImportUtils.getDateAsStringFromCell(row, "", null); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("", result); + } + + @DisplayName("Test get a date cell as string when it's already plain text") + @Test + void testGetDateAsStringWhenAlreadyString() throws Exception { + // -- PREPARE -- + cell.setCellValue("J+1"); + // -- EXECUTE -- + String result = InjectImportUtils.getDateAsStringFromCell(row, "A", null); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("J+1", result); + } + + @DisplayName("Test get a string cell as string") + @Test + void testGetCellValueAsString() throws Exception { + // -- PREPARE -- + cell.setCellValue("A value"); + // -- EXECUTE -- + String result = InjectImportUtils.getValueAsString(row, "A"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("A value", result); + } + + @DisplayName("Test get a string cell as string when no column specified") + @Test + void testGetCellValueAsStringWhenNoColumn() throws Exception { + // -- PREPARE -- + cell.setCellValue("A value"); + // -- EXECUTE -- + String result = InjectImportUtils.getValueAsString(row, ""); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("", result); + } + + @DisplayName("Test get a numeric cell as string") + @Test + void testGetCellValueAsStringWhenAlreadyString() throws Exception { + // -- PREPARE -- + cell.setCellValue(10.0); + // -- EXECUTE -- + String result = InjectImportUtils.getValueAsString(row, "A"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("10.0", result); + } + + @DisplayName("Test get a double cell as string") + @Test + void testGetCellDoubleAsString() throws Exception { + // -- PREPARE -- + cell.setCellValue("10.0"); + // -- EXECUTE -- + Double result = InjectImportUtils.getValueAsDouble(row, "A"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(10.0, result); + } + + @DisplayName("Test get a double cell as string when no column specified") + @Test + void testGetCellDoubleAsStringWhenNoColumn() throws Exception { + // -- PREPARE -- + cell.setCellValue("A value"); + // -- EXECUTE -- + Double result = InjectImportUtils.getValueAsDouble(row, ""); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(0.0, result); + } + + @DisplayName("Test get a double cell when it's already a double") + @Test + void testGetCellDoubleAsStringWhenAlreadyString() throws Exception { + // -- PREPARE -- + cell.setCellValue(10.0); + // -- EXECUTE -- + Double result = InjectImportUtils.getValueAsDouble(row, "A"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(10.0, result); + } + + @DisplayName("Test get a string cell and convert it to HTML") + @Test + void testExtractAndConvertCellAsHTML() throws Exception { + // -- PREPARE -- + cell.setCellValue("Test\nTest"); + RuleAttribute ruleAttribute = MockMapperUtils.createRuleAttribute(); + ruleAttribute.setColumns("A"); + // -- EXECUTE -- + String result = + InjectImportUtils.extractAndConvertStringColumnValue( + row, ruleAttribute, Map.of("Test", json)); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("Test
Test", result); + } + + @DisplayName("Test get a string cell and keep it as plain text") + @Test + void testExtractWithoutConvertingCellAsHTML() throws Exception { + // -- PREPARE -- + cell.setCellValue("Test\nTest"); + RuleAttribute ruleAttribute = MockMapperUtils.createRuleAttribute(); + ruleAttribute.setColumns("A"); + json.put("richText", false); + // -- EXECUTE -- + String result = + InjectImportUtils.extractAndConvertStringColumnValue( + row, ruleAttribute, Map.of("Test", json)); + + // -- ASSERT -- + assertNotNull(result); + assertEquals("Test\nTest", result); + } + + @DisplayName("Test get inject date without pattern but with an ISO_DATE_TIME format") + @Test + void testGetInjectDateWithoutPattern() throws Exception { + // -- PREPARE -- + InjectTime injectTime = new InjectTime(); + injectTime.setUnformattedDate(LocalDateTime.of(2025, 1, 1, 12, 0, 0).toString()); + // -- EXECUTE -- + Temporal result = InjectImportUtils.getInjectDate(injectTime, null); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(LocalDateTime.of(2025, 1, 1, 12, 0, 0), result); + } + + @DisplayName("Test get inject time without pattern but with an ISO_TIME format") + @Test + void testGetInjectTimeWithoutPattern() throws Exception { + // -- PREPARE -- + InjectTime injectTime = new InjectTime(); + injectTime.setUnformattedDate(LocalTime.of(12, 0, 0).format(DateTimeFormatter.ISO_TIME)); + // -- EXECUTE -- + Temporal result = InjectImportUtils.getInjectDate(injectTime, null); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(LocalTime.of(12, 0, 0), result); + } + + @DisplayName("Test get inject time without pattern and in an unknown format") + @Test + void testGetInjectTimeUndetected() throws Exception { + // -- PREPARE -- + InjectTime injectTime = new InjectTime(); + injectTime.setUnformattedDate("13 heures et demi"); + // -- EXECUTE -- + Temporal result = InjectImportUtils.getInjectDate(injectTime, null); + + // -- ASSERT -- + assertNull(result); + } + + @DisplayName("Test get inject date and time with a specified pattern") + @Test + void testGetInjectDateTimeWithPattern() throws Exception { + // -- PREPARE -- + InjectTime injectTime = new InjectTime(); + injectTime.setUnformattedDate("25/01/20 13h05:52"); + // -- EXECUTE -- + Temporal result = InjectImportUtils.getInjectDate(injectTime, "yy/MM/dd HH'h'mm:ss"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(LocalDateTime.of(2025, 1, 20, 13, 5, 52), result); + } + + @DisplayName("Test get inject time with a specified pattern") + @Test + void testGetInjectTimeWithPattern() throws Exception { + // -- PREPARE -- + InjectTime injectTime = new InjectTime(); + injectTime.setUnformattedDate("13h05:52"); + // -- EXECUTE -- + Temporal result = InjectImportUtils.getInjectDate(injectTime, "HH'h'mm:ss"); + + // -- ASSERT -- + assertNotNull(result); + assertEquals(LocalTime.of(13, 5, 52), result); + } + + @DisplayName("Test get inject time with a specified pattern that does not match") + @Test + void testGetInjectTimeUndetectedWithTimePattern() throws Exception { + // -- PREPARE -- + InjectTime injectTime = new InjectTime(); + injectTime.setUnformattedDate("13 heures et demi"); + // -- EXECUTE -- + Temporal result = InjectImportUtils.getInjectDate(injectTime, "HH'h'mm:ss"); + + // -- ASSERT -- + assertNull(result); + } +} diff --git a/openbas-api/src/test/java/io/openbas/utils/mockMapper/MockMapperUtils.java b/openbas-api/src/test/java/io/openbas/utils/mockMapper/MockMapperUtils.java index f4e214772a..be5f9b7490 100644 --- a/openbas-api/src/test/java/io/openbas/utils/mockMapper/MockMapperUtils.java +++ b/openbas-api/src/test/java/io/openbas/utils/mockMapper/MockMapperUtils.java @@ -24,7 +24,7 @@ public static ImportMapper createImportMapper() { return importMapper; } - private static InjectImporter createInjectImporter() { + public static InjectImporter createInjectImporter() { InjectImporter injectImporter = new InjectImporter(); injectImporter.setId(UUID.randomUUID().toString()); injectImporter.setImportTypeValue("Test"); @@ -37,7 +37,7 @@ private static InjectImporter createInjectImporter() { return injectImporter; } - private static RuleAttribute createRuleAttribute() { + public static RuleAttribute createRuleAttribute() { RuleAttribute ruleAttribute = new RuleAttribute(); ruleAttribute.setColumns("Test"); ruleAttribute.setName("Test");