Move insert person methods to TestUtils

This commit is contained in:
2023-04-27 20:20:17 -05:00
parent 1314ee98b8
commit a40f9afd38
2 changed files with 43 additions and 37 deletions

View File

@ -22,6 +22,7 @@
package com.kingsrook.qqq.api;
import java.time.LocalDate;
import java.util.List;
import com.kingsrook.qqq.api.model.APIVersion;
import com.kingsrook.qqq.api.model.metadata.ApiInstanceMetaData;
@ -30,7 +31,11 @@ import com.kingsrook.qqq.api.model.metadata.fields.ApiFieldMetaData;
import com.kingsrook.qqq.api.model.metadata.fields.ApiFieldMetaDataContainer;
import com.kingsrook.qqq.api.model.metadata.tables.ApiTableMetaData;
import com.kingsrook.qqq.api.model.metadata.tables.ApiTableMetaDataContainer;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterOrderBy;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QAuthenticationType;
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
@ -324,4 +329,40 @@ public class TestUtils
.withOrderBy(new QFilterOrderBy("key"));
}
/*******************************************************************************
**
*******************************************************************************/
public static void insertPersonRecord(Integer id, String firstName, String lastName) throws QException
{
insertPersonRecord(id, firstName, lastName, null);
}
/*******************************************************************************
**
*******************************************************************************/
public static void insertPersonRecord(Integer id, String firstName, String lastName, LocalDate birthDate) throws QException
{
InsertInput insertInput = new InsertInput();
insertInput.setTableName(TestUtils.TABLE_NAME_PERSON);
insertInput.setRecords(List.of(new QRecord().withValue("id", id).withValue("firstName", firstName).withValue("lastName", lastName).withValue("birthDate", birthDate)));
new InsertAction().execute(insertInput);
}
/*******************************************************************************
**
*******************************************************************************/
public static void insertSimpsons() throws QException
{
insertPersonRecord(1, "Homer", "Simpson");
insertPersonRecord(2, "Marge", "Simpson");
insertPersonRecord(3, "Bart", "Simpson");
insertPersonRecord(4, "Lisa", "Simpson");
insertPersonRecord(5, "Maggie", "Simpson");
}
}

View File

@ -61,6 +61,8 @@ import org.json.JSONObject;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static com.kingsrook.qqq.api.TestUtils.insertPersonRecord;
import static com.kingsrook.qqq.api.TestUtils.insertSimpsons;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@ -1240,43 +1242,6 @@ class QJavalinApiHandlerTest extends BaseTest
/*******************************************************************************
**
*******************************************************************************/
private static void insertPersonRecord(Integer id, String firstName, String lastName) throws QException
{
insertPersonRecord(id, firstName, lastName, null);
}
/*******************************************************************************
**
*******************************************************************************/
private static void insertPersonRecord(Integer id, String firstName, String lastName, LocalDate birthDate) throws QException
{
InsertInput insertInput = new InsertInput();
insertInput.setTableName(TestUtils.TABLE_NAME_PERSON);
insertInput.setRecords(List.of(new QRecord().withValue("id", id).withValue("firstName", firstName).withValue("lastName", lastName).withValue("birthDate", birthDate)));
new InsertAction().execute(insertInput);
}
/*******************************************************************************
**
*******************************************************************************/
private static void insertSimpsons() throws QException
{
insertPersonRecord(1, "Homer", "Simpson");
insertPersonRecord(2, "Marge", "Simpson");
insertPersonRecord(3, "Bart", "Simpson");
insertPersonRecord(4, "Lisa", "Simpson");
insertPersonRecord(5, "Maggie", "Simpson");
}
/*******************************************************************************
**
*******************************************************************************/