CE-1955 - Test fixes

This commit is contained in:
2024-11-25 11:10:01 -06:00
parent bdbb2d2d00
commit 3c06e0e589
3 changed files with 18 additions and 8 deletions

View File

@ -643,7 +643,7 @@ public class GenerateReportActionTest extends BaseTest
Iterator<Map<String, String>> iterator = list.iterator(); Iterator<Map<String, String>> iterator = list.iterator();
Map<String, String> row = iterator.next(); Map<String, String> row = iterator.next();
assertEquals(5, list.size()); assertEquals(5, list.size());
assertThat(row).containsOnlyKeys("Id", "First Name", "Last Name"); assertThat(row).containsOnlyKeys("Id", "First Name", "Last Name", "Birth Date");
} }
@ -674,7 +674,9 @@ public class GenerateReportActionTest extends BaseTest
.withColumns(List.of( .withColumns(List.of(
new QReportField().withName("id"), new QReportField().withName("id"),
new QReportField().withName("firstName"), new QReportField().withName("firstName"),
new QReportField().withName("lastName"))))); new QReportField().withName("lastName"),
new QReportField().withName("birthDate")
))));
return report; return report;
} }

View File

@ -167,8 +167,12 @@ class BulkInsertV2FullProcessTest extends BaseTest
Serializable bulkLoadProfile = runProcessOutput.getValue("bulkLoadProfile"); Serializable bulkLoadProfile = runProcessOutput.getValue("bulkLoadProfile");
assertThat(bulkLoadProfile).isInstanceOf(BulkLoadProfile.class); assertThat(bulkLoadProfile).isInstanceOf(BulkLoadProfile.class);
assertThat(((BulkLoadProfile) bulkLoadProfile).getFieldList()).hasSizeGreaterThan(5); assertThat(((BulkLoadProfile) bulkLoadProfile).getFieldList()).hasSizeGreaterThan(5);
assertEquals("birthDate", ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(0).getFieldName()); assertEquals("firstName", ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(0).getFieldName());
assertEquals(5, ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(0).getColumnIndex()); assertEquals(3, ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(0).getColumnIndex());
assertEquals("lastName", ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(1).getFieldName());
assertEquals(4, ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(1).getColumnIndex());
assertEquals("birthDate", ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(2).getFieldName());
assertEquals(5, ((BulkLoadProfile) bulkLoadProfile).getFieldList().get(2).getColumnIndex());
assertThat(runProcessOutput.getProcessState().getNextStepName()).isPresent().get().isEqualTo("fileMapping"); assertThat(runProcessOutput.getProcessState().getNextStepName()).isPresent().get().isEqualTo("fileMapping");

View File

@ -24,7 +24,10 @@ package com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.fil
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month; import java.time.Month;
import java.util.Map; import java.util.Map;
import com.kingsrook.qqq.backend.core.BaseTest; import com.kingsrook.qqq.backend.core.BaseTest;
@ -54,7 +57,7 @@ class XlsxFileToRowsTest extends BaseTest
** **
*******************************************************************************/ *******************************************************************************/
@Test @Test
void test() throws QException void test() throws QException, IOException
{ {
byte[] byteArray = writeExcelBytes(); byte[] byteArray = writeExcelBytes();
@ -63,8 +66,8 @@ class XlsxFileToRowsTest extends BaseTest
BulkLoadFileRow headerRow = fileToRowsInterface.next(); BulkLoadFileRow headerRow = fileToRowsInterface.next();
BulkLoadFileRow bodyRow = fileToRowsInterface.next(); BulkLoadFileRow bodyRow = fileToRowsInterface.next();
assertEquals(new BulkLoadFileRow(new String[] {"Id", "First Name", "Last Name"}), headerRow); assertEquals(new BulkLoadFileRow(new String[] {"Id", "First Name", "Last Name", "Birth Date"}), headerRow);
assertEquals(new BulkLoadFileRow(new String[] {"1", "Darin", "Jonson"}), bodyRow); assertEquals(new BulkLoadFileRow(new Serializable[] {1, "Darin", "Jonson", LocalDateTime.of(1980, Month.JANUARY, 31, 0, 0)}), bodyRow);
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
// make sure there's at least a limit (less than 20) to how many more rows there are // // make sure there's at least a limit (less than 20) to how many more rows there are //
@ -83,7 +86,7 @@ class XlsxFileToRowsTest extends BaseTest
/*************************************************************************** /***************************************************************************
** **
***************************************************************************/ ***************************************************************************/
private static byte[] writeExcelBytes() throws QException private static byte[] writeExcelBytes() throws QException, IOException
{ {
ReportFormat format = ReportFormat.XLSX; ReportFormat format = ReportFormat.XLSX;
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -100,6 +103,7 @@ class XlsxFileToRowsTest extends BaseTest
new GenerateReportAction().execute(reportInput); new GenerateReportAction().execute(reportInput);
byte[] byteArray = baos.toByteArray(); byte[] byteArray = baos.toByteArray();
// FileUtils.writeByteArrayToFile(new File("/tmp/xlsx.xlsx"), byteArray);
return byteArray; return byteArray;
} }