Merged feature/checkstyle-updates into dev

This commit is contained in:
2024-08-05 13:35:21 -05:00
50 changed files with 395 additions and 256 deletions

View File

@ -213,18 +213,6 @@
<property name="tokens" value="VARIABLE_DEF"/> <property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/> <property name="allowSamelineMultipleAnnotations" value="true"/>
</module> </module>
<module name="NonEmptyAtclauseDescription"/>
<!-- <module name="JavadocTagContinuationIndentation"/> -->
<!--
<module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
-->
<!-- <module name="JavadocParagraph"/> -->
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="JavadocMethod"> <module name="JavadocMethod">
<property name="allowMissingParamTags" value="true"/> <property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/> <property name="allowMissingReturnTag" value="true"/>
@ -233,23 +221,14 @@
<module name="MissingJavadocMethod"> <module name="MissingJavadocMethod">
<property name="scope" value="private"/> <property name="scope" value="private"/>
</module> </module>
<module name="MissingJavadocType">
<property name="scope" value="private"/>
</module>
<module name="MethodName"> <module name="MethodName">
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern" <message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/> value="Method name ''{0}'' must match pattern ''{1}''."/>
</module> </module>
<module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/>
</module>
<module name="MagicNumber">
<property name="severity" value="info"/>
<property name="tokens" value="NUM_DOUBLE, NUM_FLOAT, NUM_INT"/>
<property name="ignoreNumbers" value="0, 1, 2, 3, 4, 5, 6, 7, 8"/>
<property name="ignoreFieldDeclaration" value="true"/>
<property name="ignoreAnnotation" value="true"/>
</module>
<module name="EmptyCatchBlock"> <module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/> <property name="exceptionVariableName" value="expected"/>
</module> </module>

View File

@ -167,6 +167,7 @@
<violationSeverity>warning</violationSeverity> <violationSeverity>warning</violationSeverity>
<excludes>**/target/generated-sources/*.*</excludes> <excludes>**/target/generated-sources/*.*</excludes>
<!-- <linkXRef>false</linkXRef> --> <!-- <linkXRef>false</linkXRef> -->
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration> </configuration>
<goals> <goals>
<goal>check</goal> <goal>check</goal>

View File

@ -344,6 +344,9 @@ public class RecordAutomationStatusUpdater
/***************************************************************************
**
***************************************************************************/
private record Key(QTableMetaData table, TriggerEvent triggerEvent) {} private record Key(QTableMetaData table, TriggerEvent triggerEvent) {}
} }

View File

@ -55,10 +55,10 @@ public abstract class AbstractPreInsertCustomizer implements TableCustomizerInte
///////////////////////////////////////////////////////////////////////////////// /***************************************************************************
// allow the customizer to specify when it should be executed as part of the // ** allow the customizer to specify when it should be executed as part of the
// insert action. default (per method in this class) is AFTER_ALL_VALIDATIONS // ** insert action. default (per method in this class) is AFTER_ALL_VALIDATIONS
///////////////////////////////////////////////////////////////////////////////// ***************************************************************************/
public enum WhenToRun public enum WhenToRun
{ {
BEFORE_ALL_VALIDATIONS, BEFORE_ALL_VALIDATIONS,

View File

@ -50,6 +50,9 @@ import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
*******************************************************************************/ *******************************************************************************/
public abstract class ChildInserterPostInsertCustomizer extends AbstractPostInsertCustomizer public abstract class ChildInserterPostInsertCustomizer extends AbstractPostInsertCustomizer
{ {
/***************************************************************************
**
***************************************************************************/
public enum RelationshipType public enum RelationshipType
{ {
PARENT_POINTS_AT_CHILD, PARENT_POINTS_AT_CHILD,

View File

@ -152,5 +152,8 @@ public class AuditDetailAccumulator implements Serializable
} }
/***************************************************************************
**
***************************************************************************/
private record TableNameAndPrimaryKey(String tableName, Serializable primaryKey) {} private record TableNameAndPrimaryKey(String tableName, Serializable primaryKey) {}
} }

View File

@ -42,6 +42,9 @@ public class NowWithOffset extends AbstractFilterExpression<Instant>
/***************************************************************************
**
***************************************************************************/
public enum Operator public enum Operator
{PLUS, MINUS} {PLUS, MINUS}

View File

@ -43,6 +43,9 @@ public class ThisOrLastPeriod extends AbstractFilterExpression<Instant>
/***************************************************************************
**
***************************************************************************/
public enum Operator public enum Operator
{THIS, LAST} {THIS, LAST}

View File

@ -28,6 +28,9 @@ package com.kingsrook.qqq.backend.core.model.dashboard.widgets;
*******************************************************************************/ *******************************************************************************/
public class AlertData extends QWidgetData public class AlertData extends QWidgetData
{ {
/***************************************************************************
**
***************************************************************************/
public enum AlertType public enum AlertType
{ {
ERROR, ERROR,

View File

@ -33,6 +33,9 @@ public class BlockTooltip
/***************************************************************************
**
***************************************************************************/
public enum Placement public enum Placement
{BOTTOM, LEFT, RIGHT, TOP} {BOTTOM, LEFT, RIGHT, TOP}

View File

@ -39,6 +39,9 @@ public class ParentWidgetMetaData extends QWidgetMetaData
/***************************************************************************
**
***************************************************************************/
public enum LayoutType public enum LayoutType
{ {
GRID, GRID,

View File

@ -32,6 +32,9 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.UniqueKey;
*******************************************************************************/ *******************************************************************************/
public class CacheUseCase public class CacheUseCase
{ {
/***************************************************************************
**
***************************************************************************/
public enum Type public enum Type
{ {
PRIMARY_KEY_TO_PRIMARY_KEY, // e.g., the primary key in the cache table equals the primary key in the source table. PRIMARY_KEY_TO_PRIMARY_KEY, // e.g., the primary key in the cache table equals the primary key in the source table.

View File

@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@SuppressWarnings({ "checkstyle:javadoc", "DanglingJavadoc" })
/******************************************************************************* /*******************************************************************************
** List.of is "great", but annoying because it makes unmodifiable lists... ** List.of is "great", but annoying because it makes unmodifiable lists...
** So, replace it with this, which returns ArrayLists, which "don't suck" ** So, replace it with this, which returns ArrayLists, which "don't suck"

View File

@ -27,7 +27,6 @@ import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
@SuppressWarnings({ "checkstyle:javadoc", "DanglingJavadoc" })
/******************************************************************************* /*******************************************************************************
** Map.of is "great", but annoying because it makes unmodifiable maps, and it ** Map.of is "great", but annoying because it makes unmodifiable maps, and it
** NPE's on nulls... So, replace it with this, which returns HashMaps (or maps ** NPE's on nulls... So, replace it with this, which returns HashMaps (or maps

View File

@ -1,5 +1,22 @@
/* /*
* Copyright © 2022-2023. ColdTrack <contact@coldtrack.com>. All Rights Reserved. * QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2024. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.kingsrook.qqq.backend.core.actions.dashboard.widgets; package com.kingsrook.qqq.backend.core.actions.dashboard.widgets;

View File

@ -1,5 +1,22 @@
/* /*
* Copyright © 2022-2023. ColdTrack <contact@coldtrack.com>. All Rights Reserved. * QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2024. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.kingsrook.qqq.backend.core.actions.dashboard.widgets; package com.kingsrook.qqq.backend.core.actions.dashboard.widgets;

View File

@ -67,7 +67,8 @@ class ProcessMetaDataActionTest extends BaseTest
@Test @Test
public void test_notFound() public void test_notFound()
{ {
assertThrows(QNotFoundException.class, () -> { assertThrows(QNotFoundException.class, () ->
{
ProcessMetaDataInput request = new ProcessMetaDataInput(); ProcessMetaDataInput request = new ProcessMetaDataInput();
request.setProcessName("willNotBeFound"); request.setProcessName("willNotBeFound");
new ProcessMetaDataAction().execute(request); new ProcessMetaDataAction().execute(request);

View File

@ -65,7 +65,8 @@ class TableMetaDataActionTest extends BaseTest
@Test @Test
public void test_notFound() public void test_notFound()
{ {
assertThrows(QUserFacingException.class, () -> { assertThrows(QUserFacingException.class, () ->
{
TableMetaDataInput request = new TableMetaDataInput(); TableMetaDataInput request = new TableMetaDataInput();
request.setTableName("willNotBeFound"); request.setTableName("willNotBeFound");
new TableMetaDataAction().execute(request); new TableMetaDataAction().execute(request);

View File

@ -51,16 +51,16 @@ public class RunProcessUpdateStepListTest extends BaseTest
{ {
private static final String PROCESS_NAME = RunProcessUpdateStepListTest.class.getSimpleName(); private static final String PROCESS_NAME = RunProcessUpdateStepListTest.class.getSimpleName();
private final static String STEP_START = "start"; private static final String STEP_START = "start";
private final static String STEP_A = "a"; private static final String STEP_A = "a";
private final static String STEP_B = "b"; private static final String STEP_B = "b";
private final static String STEP_C = "c"; private static final String STEP_C = "c";
private final static String STEP_1 = "1"; private static final String STEP_1 = "1";
private final static String STEP_2 = "2"; private static final String STEP_2 = "2";
private final static String STEP_3 = "3"; private static final String STEP_3 = "3";
private final static String STEP_END = "end"; private static final String STEP_END = "end";
private final static List<String> LETTERS_STEP_LIST = List.of( private static final List<String> LETTERS_STEP_LIST = List.of(
STEP_START, STEP_START,
STEP_A, STEP_A,
STEP_B, STEP_B,
@ -68,7 +68,7 @@ public class RunProcessUpdateStepListTest extends BaseTest
STEP_END STEP_END
); );
private final static List<String> NUMBERS_STEP_LIST = List.of( private static final List<String> NUMBERS_STEP_LIST = List.of(
STEP_START, STEP_START,
STEP_1, STEP_1,
STEP_2, STEP_2,

View File

@ -36,10 +36,10 @@ import com.kingsrook.qqq.backend.core.BaseTest;
import com.kingsrook.qqq.backend.core.context.QContext; import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance; import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DateTimeDisplayValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat; import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData; import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType; import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DateTimeDisplayValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData; import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.utils.TestUtils; import com.kingsrook.qqq.backend.core.utils.TestUtils;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -169,10 +169,10 @@ public class QInstanceValidatorTest extends BaseTest
public void test_validateNullTablesAndProcesses() public void test_validateNullTablesAndProcesses()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
qInstance.setTables(null); qInstance.setTables(null);
qInstance.setProcesses(null); qInstance.setProcesses(null);
}, },
true, true,
"At least 1 table must be defined"); "At least 1 table must be defined");
} }
@ -187,10 +187,10 @@ public class QInstanceValidatorTest extends BaseTest
public void test_validateEmptyTablesAndProcesses() public void test_validateEmptyTablesAndProcesses()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
qInstance.setTables(new HashMap<>()); qInstance.setTables(new HashMap<>());
qInstance.setProcesses(new HashMap<>()); qInstance.setProcesses(new HashMap<>());
}, },
true, true,
"At least 1 table must be defined"); "At least 1 table must be defined");
} }
@ -548,7 +548,8 @@ public class QInstanceValidatorTest extends BaseTest
//////////////////////////////////////// ////////////////////////////////////////
// make sure our always failer fails. // // make sure our always failer fails. //
//////////////////////////////////////// ////////////////////////////////////////
assertValidationFailureReasonsAllowingExtraReasons((qInstance) -> { assertValidationFailureReasonsAllowingExtraReasons((qInstance) ->
{
}, "always fail"); }, "always fail");
} }
finally finally
@ -558,7 +559,8 @@ public class QInstanceValidatorTest extends BaseTest
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// make sure if remove all plugins, we don't fail // // make sure if remove all plugins, we don't fail //
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
assertValidationSuccess((qInstance) -> { assertValidationSuccess((qInstance) ->
{
}); });
} }
} }
@ -627,6 +629,9 @@ public class QInstanceValidatorTest extends BaseTest
*******************************************************************************/ *******************************************************************************/
public static class CustomizerWithNoVoidConstructor public static class CustomizerWithNoVoidConstructor
{ {
/***************************************************************************
**
***************************************************************************/
public CustomizerWithNoVoidConstructor(boolean b) public CustomizerWithNoVoidConstructor(boolean b)
{ {
@ -640,6 +645,9 @@ public class QInstanceValidatorTest extends BaseTest
*******************************************************************************/ *******************************************************************************/
private static class CustomizerWithPrivateVisibility extends AbstractPostQueryCustomizer private static class CustomizerWithPrivateVisibility extends AbstractPostQueryCustomizer
{ {
/***************************************************************************
**
***************************************************************************/
public CustomizerWithPrivateVisibility() public CustomizerWithPrivateVisibility()
{ {
System.out.println("eh?"); System.out.println("eh?");
@ -664,6 +672,9 @@ public class QInstanceValidatorTest extends BaseTest
*******************************************************************************/ *******************************************************************************/
public static class CustomizerWithOnlyPrivateConstructor public static class CustomizerWithOnlyPrivateConstructor
{ {
/***************************************************************************
**
***************************************************************************/
private CustomizerWithOnlyPrivateConstructor() private CustomizerWithOnlyPrivateConstructor()
{ {
@ -1108,15 +1119,16 @@ public class QInstanceValidatorTest extends BaseTest
@Test @Test
void testPossibleValueSourceMisConfiguredEnum() void testPossibleValueSourceMisConfiguredEnum()
{ {
assertValidationFailureReasons((qInstance) -> { assertValidationFailureReasons((qInstance) ->
QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(TestUtils.POSSIBLE_VALUE_SOURCE_STATE); {
possibleValueSource.setTableName("person"); QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(TestUtils.POSSIBLE_VALUE_SOURCE_STATE);
possibleValueSource.setSearchFields(List.of("id")); possibleValueSource.setTableName("person");
possibleValueSource.setOrderByFields(List.of(new QFilterOrderBy("id"))); possibleValueSource.setSearchFields(List.of("id"));
possibleValueSource.setCustomCodeReference(new QCodeReference()); possibleValueSource.setOrderByFields(List.of(new QFilterOrderBy("id")));
possibleValueSource.setEnumValues(null); possibleValueSource.setCustomCodeReference(new QCodeReference());
possibleValueSource.setType(QPossibleValueSourceType.ENUM); possibleValueSource.setEnumValues(null);
}, possibleValueSource.setType(QPossibleValueSourceType.ENUM);
},
"should not have a tableName", "should not have a tableName",
"should not have searchFields", "should not have searchFields",
"should not have orderByFields", "should not have orderByFields",
@ -1135,15 +1147,16 @@ public class QInstanceValidatorTest extends BaseTest
@Test @Test
void testPossibleValueSourceMisConfiguredTable() void testPossibleValueSourceMisConfiguredTable()
{ {
assertValidationFailureReasons((qInstance) -> { assertValidationFailureReasons((qInstance) ->
QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(TestUtils.POSSIBLE_VALUE_SOURCE_SHAPE); {
possibleValueSource.setTableName(null); QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(TestUtils.POSSIBLE_VALUE_SOURCE_SHAPE);
possibleValueSource.setSearchFields(null); possibleValueSource.setTableName(null);
possibleValueSource.setOrderByFields(new ArrayList<>()); possibleValueSource.setSearchFields(null);
possibleValueSource.setCustomCodeReference(new QCodeReference()); possibleValueSource.setOrderByFields(new ArrayList<>());
possibleValueSource.setEnumValues(List.of(new QPossibleValue<>("test"))); possibleValueSource.setCustomCodeReference(new QCodeReference());
possibleValueSource.setType(QPossibleValueSourceType.TABLE); possibleValueSource.setEnumValues(List.of(new QPossibleValue<>("test")));
}, possibleValueSource.setType(QPossibleValueSourceType.TABLE);
},
"should not have enum values", "should not have enum values",
"should not have a customCodeReference", "should not have a customCodeReference",
"is missing a tableName", "is missing a tableName",
@ -1165,15 +1178,16 @@ public class QInstanceValidatorTest extends BaseTest
@Test @Test
void testPossibleValueSourceMisConfiguredCustom() void testPossibleValueSourceMisConfiguredCustom()
{ {
assertValidationFailureReasons((qInstance) -> { assertValidationFailureReasons((qInstance) ->
QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(TestUtils.POSSIBLE_VALUE_SOURCE_CUSTOM); {
possibleValueSource.setTableName("person"); QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(TestUtils.POSSIBLE_VALUE_SOURCE_CUSTOM);
possibleValueSource.setSearchFields(List.of("id")); possibleValueSource.setTableName("person");
possibleValueSource.setOrderByFields(List.of(new QFilterOrderBy("id"))); possibleValueSource.setSearchFields(List.of("id"));
possibleValueSource.setCustomCodeReference(null); possibleValueSource.setOrderByFields(List.of(new QFilterOrderBy("id")));
possibleValueSource.setEnumValues(List.of(new QPossibleValue<>("test"))); possibleValueSource.setCustomCodeReference(null);
possibleValueSource.setType(QPossibleValueSourceType.CUSTOM); possibleValueSource.setEnumValues(List.of(new QPossibleValue<>("test")));
}, possibleValueSource.setType(QPossibleValueSourceType.CUSTOM);
},
"should not have enum values", "should not have enum values",
"should not have a tableName", "should not have a tableName",
"should not have searchFields", "should not have searchFields",
@ -1272,10 +1286,10 @@ public class QInstanceValidatorTest extends BaseTest
"action missing a name"); "action missing a name");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
List<TableAutomationAction> actions = qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY).getAutomationDetails().getActions(); List<TableAutomationAction> actions = qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY).getAutomationDetails().getActions();
actions.add(actions.get(0)); actions.add(actions.get(0));
}, },
"more than one action named"); "more than one action named");
} }
@ -1315,19 +1329,19 @@ public class QInstanceValidatorTest extends BaseTest
void testTableAutomationActionProcessName() void testTableAutomationActionProcessName()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
TableAutomationAction action = getAction0(qInstance); TableAutomationAction action = getAction0(qInstance);
action.setCodeReference(null); action.setCodeReference(null);
action.setProcessName("notAProcess"); action.setProcessName("notAProcess");
}, },
"unrecognized processName"); "unrecognized processName");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
TableAutomationAction action = getAction0(qInstance); TableAutomationAction action = getAction0(qInstance);
action.setCodeReference(null); action.setCodeReference(null);
action.setProcessName(TestUtils.PROCESS_NAME_BASEPULL); action.setProcessName(TestUtils.PROCESS_NAME_BASEPULL);
}, },
"different table"); "different table");
} }
@ -1340,19 +1354,19 @@ public class QInstanceValidatorTest extends BaseTest
void testTableAutomationActionCodeReferenceAndProcessName() void testTableAutomationActionCodeReferenceAndProcessName()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
TableAutomationAction action = getAction0(qInstance); TableAutomationAction action = getAction0(qInstance);
action.setCodeReference(null); action.setCodeReference(null);
action.setProcessName(null); action.setProcessName(null);
}, },
"missing both"); "missing both");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
TableAutomationAction action = getAction0(qInstance); TableAutomationAction action = getAction0(qInstance);
action.setCodeReference(new QCodeReference(TestUtils.CheckAge.class)); action.setCodeReference(new QCodeReference(TestUtils.CheckAge.class));
action.setProcessName(TestUtils.PROCESS_NAME_INCREASE_BIRTHDATE); action.setProcessName(TestUtils.PROCESS_NAME_INCREASE_BIRTHDATE);
}, },
"has both"); "has both");
} }
@ -1365,21 +1379,21 @@ public class QInstanceValidatorTest extends BaseTest
void testTableAutomationActionFilter() void testTableAutomationActionFilter()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
TableAutomationAction action = getAction0(qInstance); TableAutomationAction action = getAction0(qInstance);
action.setFilter(new QQueryFilter() action.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria()) .withCriteria(new QFilterCriteria())
); );
}, },
"without a field name", "without an operator"); "without a field name", "without an operator");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
TableAutomationAction action = getAction0(qInstance); TableAutomationAction action = getAction0(qInstance);
action.setFilter(new QQueryFilter() action.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria("notAField", QCriteriaOperator.EQUALS, Collections.emptyList())) .withCriteria(new QFilterCriteria("notAField", QCriteriaOperator.EQUALS, Collections.emptyList()))
); );
}, },
"unrecognized field"); "unrecognized field");
} }
@ -1484,13 +1498,13 @@ public class QInstanceValidatorTest extends BaseTest
void testQueueProviderSQSAttributes() void testQueueProviderSQSAttributes()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
SQSQueueProviderMetaData queueProvider = (SQSQueueProviderMetaData) qInstance.getQueueProvider(TestUtils.DEFAULT_QUEUE_PROVIDER); SQSQueueProviderMetaData queueProvider = (SQSQueueProviderMetaData) qInstance.getQueueProvider(TestUtils.DEFAULT_QUEUE_PROVIDER);
queueProvider.setAccessKey(null); queueProvider.setAccessKey(null);
queueProvider.setSecretKey(""); queueProvider.setSecretKey("");
queueProvider.setRegion(null); queueProvider.setRegion(null);
queueProvider.setBaseURL(""); queueProvider.setBaseURL("");
}, },
"Missing accessKey", "Missing secretKey", "Missing region", "Missing baseURL"); "Missing accessKey", "Missing secretKey", "Missing region", "Missing baseURL");
} }
@ -1607,43 +1621,43 @@ public class QInstanceValidatorTest extends BaseTest
void testReportDataSourceNames() void testReportDataSourceNames()
{ {
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// enricher will give us a default name if only 1 data source, so, set 1st one to null name, then add a second // // enricher will give us a default name if only 1 data source, so, set 1st one to null name, then add a second //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QReportMetaData report = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON); QReportMetaData report = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON);
report.setDataSources(new ArrayList<>(report.getDataSources())); report.setDataSources(new ArrayList<>(report.getDataSources()));
report.getDataSources().get(0).setName(null); report.getDataSources().get(0).setName(null);
report.getDataSources().add(new QReportDataSource() report.getDataSources().add(new QReportDataSource()
.withName("2nd") .withName("2nd")
.withSourceTable(TestUtils.TABLE_NAME_PERSON) .withSourceTable(TestUtils.TABLE_NAME_PERSON)
); );
}, },
"Missing name for a dataSource", "Missing name for a dataSource",
"unrecognized dataSourceName"); "unrecognized dataSourceName");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
/////////////////////////////////// ///////////////////////////////////
// same as above, but "" vs null // // same as above, but "" vs null //
/////////////////////////////////// ///////////////////////////////////
QReportMetaData report = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON); QReportMetaData report = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON);
report.setDataSources(new ArrayList<>(report.getDataSources())); report.setDataSources(new ArrayList<>(report.getDataSources()));
report.getDataSources().get(0).setName(""); report.getDataSources().get(0).setName("");
report.getDataSources().add(new QReportDataSource() report.getDataSources().add(new QReportDataSource()
.withName("2nd") .withName("2nd")
.withSourceTable(TestUtils.TABLE_NAME_PERSON) .withSourceTable(TestUtils.TABLE_NAME_PERSON)
); );
}, },
"Missing name for a dataSource", "Missing name for a dataSource",
"unrecognized dataSourceName"); "unrecognized dataSourceName");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
List<QReportDataSource> dataSources = new ArrayList<>(qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getDataSources()); List<QReportDataSource> dataSources = new ArrayList<>(qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getDataSources());
dataSources.add(dataSources.get(0)); dataSources.add(dataSources.get(0));
qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).setDataSources(dataSources); qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).setDataSources(dataSources);
}, },
"More than one dataSource with name"); "More than one dataSource with name");
} }
@ -1702,19 +1716,19 @@ public class QInstanceValidatorTest extends BaseTest
"has both a sourceTable and a staticDataSupplier"); "has both a sourceTable and a staticDataSupplier");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
QReportDataSource dataSource = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getDataSources().get(0); QReportDataSource dataSource = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getDataSources().get(0);
dataSource.setSourceTable(null); dataSource.setSourceTable(null);
dataSource.setStaticDataSupplier(new QCodeReference(null, QCodeType.JAVA)); dataSource.setStaticDataSupplier(new QCodeReference(null, QCodeType.JAVA));
}, },
"missing a code reference name"); "missing a code reference name");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
QReportDataSource dataSource = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getDataSources().get(0); QReportDataSource dataSource = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getDataSources().get(0);
dataSource.setSourceTable(null); dataSource.setSourceTable(null);
dataSource.setStaticDataSupplier(new QCodeReference(ArrayList.class)); dataSource.setStaticDataSupplier(new QCodeReference(ArrayList.class));
}, },
"is not of the expected type"); "is not of the expected type");
} }
@ -1773,11 +1787,11 @@ public class QInstanceValidatorTest extends BaseTest
"has a column with no name"); "has a column with no name");
assertValidationFailureReasons((qInstance) -> assertValidationFailureReasons((qInstance) ->
{ {
List<QReportField> columns = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).getColumns(); List<QReportField> columns = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).getColumns();
columns.get(0).setName("id"); columns.get(0).setName("id");
columns.get(1).setName("id"); columns.get(1).setName("id");
}, },
"has multiple columns named: id"); "has multiple columns named: id");
} }
@ -1990,35 +2004,35 @@ public class QInstanceValidatorTest extends BaseTest
"Table A exposedJoin B is missing a label"); "Table A exposedJoin B is missing a label");
assertValidationFailureReasons(qInstance -> assertValidationFailureReasons(qInstance ->
{ {
qInstance.addTable(newTable("A", "id").withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("B").withJoinPath(List.of("notAJoin")))); qInstance.addTable(newTable("A", "id").withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("B").withJoinPath(List.of("notAJoin"))));
qInstance.addTable(newTable("B", "id", "aId")); qInstance.addTable(newTable("B", "id", "aId"));
qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("B").withName("AB").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId"))); qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("B").withName("AB").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId")));
}, },
"does not match a valid join connection in the instance"); "does not match a valid join connection in the instance");
assertValidationFailureReasons(qInstance -> assertValidationFailureReasons(qInstance ->
{ {
qInstance.addTable(newTable("A", "id") qInstance.addTable(newTable("A", "id")
.withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("foo").withJoinPath(List.of("AB"))) .withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("foo").withJoinPath(List.of("AB")))
.withExposedJoin(new ExposedJoin().withJoinTable("C").withLabel("foo").withJoinPath(List.of("AC"))) .withExposedJoin(new ExposedJoin().withJoinTable("C").withLabel("foo").withJoinPath(List.of("AC")))
); );
qInstance.addTable(newTable("B", "id", "aId")); qInstance.addTable(newTable("B", "id", "aId"));
qInstance.addTable(newTable("C", "id", "aId")); qInstance.addTable(newTable("C", "id", "aId"));
qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("B").withName("AB").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId"))); qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("B").withName("AB").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId")));
qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("C").withName("AC").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId"))); qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("C").withName("AC").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId")));
}, },
"more than one join labeled: foo"); "more than one join labeled: foo");
assertValidationFailureReasons(qInstance -> assertValidationFailureReasons(qInstance ->
{ {
qInstance.addTable(newTable("A", "id") qInstance.addTable(newTable("A", "id")
.withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("B1").withJoinPath(List.of("AB"))) .withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("B1").withJoinPath(List.of("AB")))
.withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("B2").withJoinPath(List.of("AB"))) .withExposedJoin(new ExposedJoin().withJoinTable("B").withLabel("B2").withJoinPath(List.of("AB")))
); );
qInstance.addTable(newTable("B", "id", "aId")); qInstance.addTable(newTable("B", "id", "aId"));
qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("B").withName("AB").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId"))); qInstance.addJoin(new QJoinMetaData().withLeftTable("A").withRightTable("B").withName("AB").withType(JoinType.ONE_TO_ONE).withJoinOn(new JoinOn("id", "aId")));
}, },
"than one join with the joinPath: [AB]"); "than one join with the joinPath: [AB]");
assertValidationSuccess(qInstance -> assertValidationSuccess(qInstance ->
@ -2275,11 +2289,14 @@ public class QInstanceValidatorTest extends BaseTest
/////////////////////////////////////////////// /***************************************************************************
// test classes for validating process steps // ** test classes for validating process steps
/////////////////////////////////////////////// ***************************************************************************/
public abstract class TestAbstractClass extends AbstractTransformStep public abstract class TestAbstractClass extends AbstractTransformStep
{ {
/***************************************************************************
**
***************************************************************************/
public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
{ {
} }
@ -2287,17 +2304,23 @@ public class QInstanceValidatorTest extends BaseTest
/////////////////////////////////////////////// /***************************************************************************
// // **
/////////////////////////////////////////////// ***************************************************************************/
private class TestPrivateClass extends AbstractTransformStep private class TestPrivateClass extends AbstractTransformStep
{ {
/***************************************************************************
**
***************************************************************************/
public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
{ {
} }
/***************************************************************************
**
***************************************************************************/
@Override @Override
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen) public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
{ {
@ -2307,11 +2330,14 @@ public class QInstanceValidatorTest extends BaseTest
/////////////////////////////////////////////// /***************************************************************************
// // **
/////////////////////////////////////////////// ***************************************************************************/
public class TestNoArgsConstructorClass extends AbstractTransformStep public class TestNoArgsConstructorClass extends AbstractTransformStep
{ {
/***************************************************************************
**
***************************************************************************/
public TestNoArgsConstructorClass(int i) public TestNoArgsConstructorClass(int i)
{ {
@ -2319,12 +2345,18 @@ public class QInstanceValidatorTest extends BaseTest
/***************************************************************************
**
***************************************************************************/
public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
{ {
} }
/***************************************************************************
**
***************************************************************************/
@Override @Override
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen) public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
{ {

View File

@ -33,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/******************************************************************************* /*******************************************************************************
** Unit test for com.kingsrook.qqq.backend.core.logging.LogUtils ** Unit test for com.kingsrook.qqq.backend.core.logging.LogUtils
*******************************************************************************/ *******************************************************************************/
@SuppressWarnings("checkstyle:FileTabCharacter")
class LogUtilsTest extends BaseTest class LogUtilsTest extends BaseTest
{ {
private static final QLogger LOG = QLogger.getLogger(LogUtilsTest.class); private static final QLogger LOG = QLogger.getLogger(LogUtilsTest.class);
@ -123,6 +124,7 @@ class LogUtilsTest extends BaseTest
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
@SuppressWarnings("checkstyle:FileTabCharacter")
@Test @Test
void testFilterStackTraceMySqlConnection() void testFilterStackTraceMySqlConnection()
{ {

View File

@ -52,7 +52,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*******************************************************************************/ *******************************************************************************/
class CaseChangeBehaviorTest extends BaseTest class CaseChangeBehaviorTest extends BaseTest
{ {
public static final String FIELD = "firstName" ; public static final String FIELD = "firstName";

View File

@ -138,10 +138,12 @@ class BulkInsertTransformStepTest extends BaseTest
private QTableMetaData defineTable(QTableMetaData TABLE_NAME, QInstance instance) /***************************************************************************
**
***************************************************************************/
private QTableMetaData defineTable(QTableMetaData table, QInstance instance)
{ {
QTableMetaData table = TABLE_NAME table.withPrimaryKeyField("id")
.withPrimaryKeyField("id")
.withField(new QFieldMetaData("id", QFieldType.INTEGER)) .withField(new QFieldMetaData("id", QFieldType.INTEGER))
.withField(new QFieldMetaData("uuid", QFieldType.STRING)) .withField(new QFieldMetaData("uuid", QFieldType.STRING))
.withField(new QFieldMetaData("sku", QFieldType.STRING)) .withField(new QFieldMetaData("sku", QFieldType.STRING))
@ -203,6 +205,9 @@ class BulkInsertTransformStepTest extends BaseTest
/***************************************************************************
**
***************************************************************************/
private boolean recordEquals(QRecord record, String uuid, String sku, Integer storeId) private boolean recordEquals(QRecord record, String uuid, String sku, Integer storeId)
{ {
return (record.getValue("uuid").equals(uuid) return (record.getValue("uuid").equals(uuid)

View File

@ -64,6 +64,9 @@ class BasicETLTransformFunctionTest extends BaseTest
/***************************************************************************
**
***************************************************************************/
private String doRemoveNonNumericValuesFromMappedRecords(QFieldType fieldType, String inputValue) private String doRemoveNonNumericValuesFromMappedRecords(QFieldType fieldType, String inputValue)
{ {
String field = "field"; String field = "field";

View File

@ -48,7 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
*******************************************************************************/ *******************************************************************************/
class MergeDuplicatesProcessTest extends BaseTest class MergeDuplicatesProcessTest extends BaseTest
{ {
String PROCESS_NAME = "testMergeProcess"; private static final String PROCESS_NAME = "testMergeProcess";

View File

@ -54,8 +54,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*******************************************************************************/ *******************************************************************************/
class TableSyncProcessTest extends BaseTest class TableSyncProcessTest extends BaseTest
{ {
String PROCESS_NAME = "testSyncProcess"; private static final String PROCESS_NAME = "testSyncProcess";
String TABLE_NAME_PEOPLE_SYNC = "peopleSync"; private static final String TABLE_NAME_PEOPLE_SYNC = "peopleSync";

View File

@ -35,7 +35,7 @@ import org.quartz.SchedulerException;
*******************************************************************************/ *******************************************************************************/
public class QuartzTestUtils public class QuartzTestUtils
{ {
public final static String QUARTZ_SCHEDULER_NAME = "TestQuartzScheduler"; public static final String QUARTZ_SCHEDULER_NAME = "TestQuartzScheduler";

View File

@ -32,6 +32,9 @@ import com.kingsrook.qqq.backend.core.model.data.QRecord;
*******************************************************************************/ *******************************************************************************/
public class PersonQRecord extends QRecord public class PersonQRecord extends QRecord
{ {
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withLastName(String lastName) public PersonQRecord withLastName(String lastName)
{ {
setValue("lastName", lastName); setValue("lastName", lastName);
@ -40,6 +43,9 @@ public class PersonQRecord extends QRecord
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withFirstName(String firstName) public PersonQRecord withFirstName(String firstName)
{ {
setValue("firstName", firstName); setValue("firstName", firstName);
@ -48,6 +54,9 @@ public class PersonQRecord extends QRecord
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withBirthDate(LocalDate birthDate) public PersonQRecord withBirthDate(LocalDate birthDate)
{ {
setValue("birthDate", birthDate); setValue("birthDate", birthDate);
@ -56,6 +65,9 @@ public class PersonQRecord extends QRecord
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withNoOfShoes(Integer noOfShoes) public PersonQRecord withNoOfShoes(Integer noOfShoes)
{ {
setValue("noOfShoes", noOfShoes); setValue("noOfShoes", noOfShoes);
@ -64,6 +76,9 @@ public class PersonQRecord extends QRecord
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withPrice(BigDecimal price) public PersonQRecord withPrice(BigDecimal price)
{ {
setValue("price", price); setValue("price", price);
@ -72,6 +87,9 @@ public class PersonQRecord extends QRecord
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withCost(BigDecimal cost) public PersonQRecord withCost(BigDecimal cost)
{ {
setValue("cost", cost); setValue("cost", cost);
@ -80,6 +98,9 @@ public class PersonQRecord extends QRecord
/***************************************************************************
**
***************************************************************************/
public PersonQRecord withHomeStateId(int homeStateId) public PersonQRecord withHomeStateId(int homeStateId)
{ {
setValue("homeStateId", homeStateId); setValue("homeStateId", homeStateId);

View File

@ -93,6 +93,9 @@ class JsonUtilsTest extends BaseTest
*******************************************************************************/ *******************************************************************************/
private static class LooksLikeAnEntityButJustThrowsInItsGetterMethod private static class LooksLikeAnEntityButJustThrowsInItsGetterMethod
{ {
/***************************************************************************
**
***************************************************************************/
public String getValue() public String getValue()
{ {
throw new IllegalStateException("Test"); throw new IllegalStateException("Test");

View File

@ -117,6 +117,9 @@ public class BaseAPIActionUtil
/***************************************************************************
**
***************************************************************************/
public enum UpdateHttpMethod public enum UpdateHttpMethod
{PUT, POST} {PUT, POST}

View File

@ -95,8 +95,7 @@ public class TestUtils
.withAuthorizationType(AuthorizationType.API_KEY_HEADER) .withAuthorizationType(AuthorizationType.API_KEY_HEADER)
.withBaseUrl("http://localhost:9999/mock") .withBaseUrl("http://localhost:9999/mock")
.withContentType("application/json") .withContentType("application/json")
.withActionUtil(new QCodeReference(MockApiActionUtils.class)) .withActionUtil(new QCodeReference(MockApiActionUtils.class)));
);
} }
@ -115,8 +114,7 @@ public class TestUtils
.withBackendDetails(new APITableBackendDetails() .withBackendDetails(new APITableBackendDetails()
.withTablePath("mock") .withTablePath("mock")
.withTableWrapperObjectName("mocks") .withTableWrapperObjectName("mocks")
) ));
);
} }
@ -147,8 +145,7 @@ public class TestUtils
.withAuthorizationType(AuthorizationType.BASIC_AUTH_API_KEY) .withAuthorizationType(AuthorizationType.BASIC_AUTH_API_KEY)
.withBaseUrl("https://api.easypost.com/v2/") .withBaseUrl("https://api.easypost.com/v2/")
.withContentType("application/json") .withContentType("application/json")
.withActionUtil(new QCodeReference(EasyPostUtils.class)) .withActionUtil(new QCodeReference(EasyPostUtils.class)));
);
} }
@ -170,8 +167,7 @@ public class TestUtils
.withBackendDetails(new APITableBackendDetails() .withBackendDetails(new APITableBackendDetails()
.withTablePath("variant") .withTablePath("variant")
.withTableWrapperObjectName("variant") .withTableWrapperObjectName("variant")
) ));
);
} }
@ -191,7 +187,6 @@ public class TestUtils
.withBackendDetails(new APITableBackendDetails() .withBackendDetails(new APITableBackendDetails()
.withTablePath("trackers") .withTablePath("trackers")
.withTableWrapperObjectName("tracker") .withTableWrapperObjectName("tracker")
) ));
);
} }
} }

View File

@ -50,7 +50,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*******************************************************************************/ *******************************************************************************/
public class FilesystemBackendModuleTest public class FilesystemBackendModuleTest
{ {
private final String PATH_THAT_WONT_EXIST = "some/path/that/wont/exist"; private static final String PATH_THAT_WONT_EXIST = "some/path/that/wont/exist";

View File

@ -47,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*******************************************************************************/ *******************************************************************************/
public class S3BackendModuleTest extends BaseS3Test public class S3BackendModuleTest extends BaseS3Test
{ {
private final String PATH_THAT_WONT_EXIST = "some/path/that/wont/exist"; private static final String PATH_THAT_WONT_EXIST = "some/path/that/wont/exist";

View File

@ -37,6 +37,9 @@ import org.junit.jupiter.api.Test;
public class PathMatcherGlobTest public class PathMatcherGlobTest
{ {
/***************************************************************************
**
***************************************************************************/
@Test @Test
public void testPathMatcher() throws Exception public void testPathMatcher() throws Exception
{ {

View File

@ -158,8 +158,7 @@ public class TestUtils
.withName(TABLE_NAME_PERSON) .withName(TABLE_NAME_PERSON)
.withType(QPossibleValueSourceType.TABLE) .withType(QPossibleValueSourceType.TABLE)
.withTableName(TABLE_NAME_PERSON) .withTableName(TABLE_NAME_PERSON)
.withValueFormatAndFields(PVSValueFormatAndFields.LABEL_ONLY) .withValueFormatAndFields(PVSValueFormatAndFields.LABEL_ONLY));
);
} }

View File

@ -201,8 +201,7 @@ public class TestUtils
.withName(TABLE_NAME_PERSON) .withName(TABLE_NAME_PERSON)
.withType(QPossibleValueSourceType.TABLE) .withType(QPossibleValueSourceType.TABLE)
.withTableName(TABLE_NAME_PERSON) .withTableName(TABLE_NAME_PERSON)
.withValueFormatAndFields(PVSValueFormatAndFields.LABEL_ONLY) .withValueFormatAndFields(PVSValueFormatAndFields.LABEL_ONLY));
);
} }

View File

@ -103,7 +103,8 @@ public class RDBMSDeleteActionTest extends RDBMSActionTest
DeleteOutput deleteResult = new RDBMSDeleteAction().execute(deleteInput); DeleteOutput deleteResult = new RDBMSDeleteAction().execute(deleteInput);
assertEquals(3, deleteResult.getDeletedRecordCount(), "Should delete one row"); assertEquals(3, deleteResult.getDeletedRecordCount(), "Should delete one row");
assertEquals(0, deleteResult.getRecordsWithErrors().size(), "should have no errors"); assertEquals(0, deleteResult.getRecordsWithErrors().size(), "should have no errors");
runTestSql("SELECT id FROM person", (rs -> { runTestSql("SELECT id FROM person", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -177,7 +178,8 @@ public class RDBMSDeleteActionTest extends RDBMSActionTest
assertTrue(deleteResult.getRecordsWithErrors().stream().noneMatch(r -> r.getErrors().isEmpty()), "All we got back should have errors"); assertTrue(deleteResult.getRecordsWithErrors().stream().noneMatch(r -> r.getErrors().isEmpty()), "All we got back should have errors");
assertEquals(3, deleteResult.getDeletedRecordCount(), "Should get back that 3 were deleted"); assertEquals(3, deleteResult.getDeletedRecordCount(), "Should get back that 3 were deleted");
runTestSql("SELECT id FROM child_table", (rs -> { runTestSql("SELECT id FROM child_table", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -223,7 +225,8 @@ public class RDBMSDeleteActionTest extends RDBMSActionTest
assertEquals(1, queryStats.get(QueryManager.STAT_QUERIES_RAN), "Number of queries ran"); assertEquals(1, queryStats.get(QueryManager.STAT_QUERIES_RAN), "Number of queries ran");
assertEquals(3, deleteResult.getDeletedRecordCount(), "Should get back that 3 were deleted"); assertEquals(3, deleteResult.getDeletedRecordCount(), "Should get back that 3 were deleted");
runTestSql("SELECT id FROM child_table", (rs -> { runTestSql("SELECT id FROM child_table", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -275,7 +278,8 @@ public class RDBMSDeleteActionTest extends RDBMSActionTest
assertTrue(deleteResult.getRecordsWithErrors().stream().noneMatch(r -> r.getErrors().isEmpty()), "All we got back should have errors"); assertTrue(deleteResult.getRecordsWithErrors().stream().noneMatch(r -> r.getErrors().isEmpty()), "All we got back should have errors");
assertEquals(3, deleteResult.getDeletedRecordCount(), "Should get back that 3 were deleted"); assertEquals(3, deleteResult.getDeletedRecordCount(), "Should get back that 3 were deleted");
runTestSql("SELECT id FROM child_table", (rs -> { runTestSql("SELECT id FROM child_table", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {

View File

@ -188,9 +188,13 @@ public class RDBMSInsertActionTest extends RDBMSActionTest
/***************************************************************************
**
***************************************************************************/
private void assertAnInsertedPersonRecord(String firstName, String lastName, Integer id) throws Exception private void assertAnInsertedPersonRecord(String firstName, String lastName, Integer id) throws Exception
{ {
runTestSql("SELECT * FROM person WHERE last_name = '" + lastName + "'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = '" + lastName + "'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {

View File

@ -118,7 +118,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
assertEquals(1, updateResult.getRecords().size(), "Should return 1 row"); assertEquals(1, updateResult.getRecords().size(), "Should return 1 row");
assertEquals(2, updateResult.getRecords().get(0).getValue("id"), "Should have id=2 in the row"); assertEquals(2, updateResult.getRecords().get(0).getValue("id"), "Should have id=2 in the row");
// todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors"); // todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors");
runTestSql("SELECT * FROM person WHERE last_name = 'Kirk'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'Kirk'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -129,7 +130,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
} }
assertEquals(1, rowsFound); assertEquals(1, rowsFound);
})); }));
runTestSql("SELECT * FROM person WHERE last_name = 'Maes'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'Maes'", (rs ->
{
if(rs.next()) if(rs.next())
{ {
fail("Should not have found Maes any more."); fail("Should not have found Maes any more.");
@ -176,7 +178,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
assertEquals(3, updateResult.getRecords().get(1).getValue("id"), "Should have expected ids in the row"); assertEquals(3, updateResult.getRecords().get(1).getValue("id"), "Should have expected ids in the row");
assertEquals(5, updateResult.getRecords().get(2).getValue("id"), "Should have expected ids in the row"); assertEquals(5, updateResult.getRecords().get(2).getValue("id"), "Should have expected ids in the row");
// todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors"); // todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors");
runTestSql("SELECT * FROM person WHERE last_name = 'From Bewitched'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'From Bewitched'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -188,7 +191,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
} }
assertEquals(1, rowsFound); assertEquals(1, rowsFound);
})); }));
runTestSql("SELECT * FROM person WHERE last_name = 'Chamberlain'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'Chamberlain'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -199,7 +203,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
} }
assertEquals(1, rowsFound); assertEquals(1, rowsFound);
})); }));
runTestSql("SELECT * FROM person WHERE last_name = 'Richardson'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'Richardson'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -243,7 +248,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
assertEquals(1, updateResult.getRecords().get(0).getValue("id"), "Should have expected ids in the row"); assertEquals(1, updateResult.getRecords().get(0).getValue("id"), "Should have expected ids in the row");
assertEquals(3, updateResult.getRecords().get(1).getValue("id"), "Should have expected ids in the row"); assertEquals(3, updateResult.getRecords().get(1).getValue("id"), "Should have expected ids in the row");
// todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors"); // todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors");
runTestSql("SELECT * FROM person WHERE last_name = 'From Bewitched'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'From Bewitched'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -255,7 +261,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
} }
assertEquals(1, rowsFound); assertEquals(1, rowsFound);
})); }));
runTestSql("SELECT * FROM person WHERE last_name = 'Tim''s Uncle'", (rs -> { runTestSql("SELECT * FROM person WHERE last_name = 'Tim''s Uncle'", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -294,7 +301,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
assertEquals(5, updateResult.getRecords().size(), "Should return 5 rows"); assertEquals(5, updateResult.getRecords().size(), "Should return 5 rows");
// todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors"); // todo - add errors to QRecord? assertTrue(updateResult.getRecords().stream().noneMatch(qrs -> CollectionUtils.nullSafeHasContents(qrs.getErrors())), "There should be no errors");
runTestSql("SELECT * FROM person WHERE id <= 5", (rs -> { runTestSql("SELECT * FROM person WHERE id <= 5", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {
@ -414,7 +422,8 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
private String selectModifyDate(Integer id) throws Exception private String selectModifyDate(Integer id) throws Exception
{ {
StringBuilder modifyDate = new StringBuilder(); StringBuilder modifyDate = new StringBuilder();
runTestSql("SELECT modify_date FROM person WHERE id = " + id, (rs -> { runTestSql("SELECT modify_date FROM person WHERE id = " + id, (rs ->
{
if(rs.next()) if(rs.next())
{ {
modifyDate.append(rs.getString("modify_date")); modifyDate.append(rs.getString("modify_date"));

View File

@ -39,6 +39,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
@Disabled("This was okay for POC, but shouldn't run in CI") @Disabled("This was okay for POC, but shouldn't run in CI")
class ConnectionManagerTest extends BaseTest class ConnectionManagerTest extends BaseTest
{ {
/***************************************************************************
**
***************************************************************************/
@Test @Test
public void test() throws SQLException public void test() throws SQLException
{ {
@ -101,6 +104,9 @@ class ConnectionManagerTest extends BaseTest
/***************************************************************************
**
***************************************************************************/
private RDBMSBackendMetaData getAuroraBacked() private RDBMSBackendMetaData getAuroraBacked()
{ {
QMetaDataVariableInterpreter interpreter = new QMetaDataVariableInterpreter(); QMetaDataVariableInterpreter interpreter = new QMetaDataVariableInterpreter();

View File

@ -69,6 +69,9 @@ public class ApiProcessMetaData
/***************************************************************************
**
***************************************************************************/
public enum AsyncMode public enum AsyncMode
{ {
NEVER, NEVER,

View File

@ -49,7 +49,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*******************************************************************************/ *******************************************************************************/
class GetTableApiFieldsActionTest extends BaseTest class GetTableApiFieldsActionTest extends BaseTest
{ {
private final String TABLE_NAME = "testTable"; private static final String TABLE_NAME = "testTable";
Function<List<? extends QFieldMetaData>, Set<String>> fieldListToNameSet = l -> l.stream().map(f -> f.getName()).collect(Collectors.toSet()); Function<List<? extends QFieldMetaData>, Set<String>> fieldListToNameSet = l -> l.stream().map(f -> f.getName()).collect(Collectors.toSet());

View File

@ -80,8 +80,8 @@ class ApiInstanceMetaDataTest
{ {
assertValidationErrors(makeBaselineValidApiInstanceMetaData() assertValidationErrors(makeBaselineValidApiInstanceMetaData()
.withCurrentVersion(new APIVersion("2023.Q1")) .withCurrentVersion(new APIVersion("2023.Q1"))
.withSupportedVersions(List.of(new APIVersion("2022.Q3"), new APIVersion("2022.Q4"))) .withSupportedVersions(List.of(new APIVersion("2022.Q3"), new APIVersion("2022.Q4"))),
, List.of("supportedVersions [[2022.Q3, 2022.Q4]] does not contain currentVersion [2023.Q1]")); List.of("supportedVersions [[2022.Q3, 2022.Q4]] does not contain currentVersion [2023.Q1]"));
assertValidationErrors(makeBaselineValidApiInstanceMetaData() assertValidationErrors(makeBaselineValidApiInstanceMetaData()
.withCurrentVersion(new APIVersion("2023.Q1")) .withCurrentVersion(new APIVersion("2023.Q1"))

View File

@ -136,13 +136,12 @@ class QJavalinAccessLoggerTest
QInstance qInstance = TestUtils.defineInstance(); QInstance qInstance = TestUtils.defineInstance();
new QJavalinImplementation(qInstance, new QJavalinMetaData() new QJavalinImplementation(qInstance, new QJavalinMetaData()
.withLoggerDisabled(false) .withLoggerDisabled(false)
.withLogFilter(logEntry -> .withLogFilter(logEntry -> switch(logEntry.logType())
switch(logEntry.logType()) {
{ case START, PROCESS_SUMMARY -> false;
case START, PROCESS_SUMMARY -> false; case END_SUCCESS, END_SUCCESS_SLOW -> true;
case END_SUCCESS, END_SUCCESS_SLOW -> true; case END_FAIL -> logEntry.actionName().startsWith("yes");
case END_FAIL -> logEntry.actionName().startsWith("yes"); }));
}));
System.out.println("shouldn't log"); System.out.println("shouldn't log");
QJavalinAccessLogger.logStart("test"); // shouldn't log QJavalinAccessLogger.logStart("test"); // shouldn't log

View File

@ -53,6 +53,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
*******************************************************************************/ *******************************************************************************/
class QJavalinScriptsHandlerTest extends QJavalinTestBase class QJavalinScriptsHandlerTest extends QJavalinTestBase
{ {
/***************************************************************************
**
***************************************************************************/
@BeforeEach @BeforeEach
public void beforeEach() throws Exception public void beforeEach() throws Exception
{ {

View File

@ -96,7 +96,7 @@ public class QJavalinTestBase
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
static protected void restartServerWithInstance(QInstance qInstance) throws QInstanceValidationException protected static void restartServerWithInstance(QInstance qInstance) throws QInstanceValidationException
{ {
if(qJavalinImplementation != null) if(qJavalinImplementation != null)
{ {

View File

@ -368,6 +368,9 @@ class QBaseCustomLambdaHandlerTest
/***************************************************************************
**
***************************************************************************/
private String getNoBodyInputString() private String getNoBodyInputString()
{ {
return (""" return ("""

View File

@ -552,7 +552,8 @@ class QPicoCliImplementationTest
*******************************************************************************/ *******************************************************************************/
private void assertRowValueById(String tableName, String columnName, String value, Integer id) throws Exception private void assertRowValueById(String tableName, String columnName, String value, Integer id) throws Exception
{ {
TestUtils.runTestSql("SELECT " + columnName + " FROM " + tableName + " WHERE id=" + id, (rs -> { TestUtils.runTestSql("SELECT " + columnName + " FROM " + tableName + " WHERE id=" + id, (rs ->
{
if(rs.next()) if(rs.next())
{ {
assertEquals(value, rs.getString(1)); assertEquals(value, rs.getString(1));
@ -590,7 +591,8 @@ class QPicoCliImplementationTest
JSONObject deleteResult = JsonUtils.toJSONObject(testOutput.getOutput()); JSONObject deleteResult = JsonUtils.toJSONObject(testOutput.getOutput());
assertNotNull(deleteResult); assertNotNull(deleteResult);
assertEquals(2, deleteResult.getInt("deletedRecordCount")); assertEquals(2, deleteResult.getInt("deletedRecordCount"));
TestUtils.runTestSql("SELECT id FROM person", (rs -> { TestUtils.runTestSql("SELECT id FROM person", (rs ->
{
int rowsFound = 0; int rowsFound = 0;
while(rs.next()) while(rs.next())
{ {

View File

@ -125,7 +125,7 @@ public class SampleMetaDataProviderTest
{ {
InputStream primeTestDatabaseSqlStream = SampleMetaDataProviderTest.class.getResourceAsStream("/" + sqlFileName); InputStream primeTestDatabaseSqlStream = SampleMetaDataProviderTest.class.getResourceAsStream("/" + sqlFileName);
assertNotNull(primeTestDatabaseSqlStream); assertNotNull(primeTestDatabaseSqlStream);
List<String> lines = (List<String>) IOUtils.readLines(primeTestDatabaseSqlStream, StandardCharsets.UTF_8); List<String> lines = IOUtils.readLines(primeTestDatabaseSqlStream, StandardCharsets.UTF_8);
lines = lines.stream().filter(line -> !line.startsWith("-- ")).toList(); lines = lines.stream().filter(line -> !line.startsWith("-- ")).toList();
String joinedSQL = String.join("\n", lines); String joinedSQL = String.join("\n", lines);
for(String sql : joinedSQL.split(";")) for(String sql : joinedSQL.split(";"))
@ -168,8 +168,8 @@ public class SampleMetaDataProviderTest
*******************************************************************************/ *******************************************************************************/
private File copyTestFileToRandomNameUnderTable(QTableMetaData fedExTable) throws IOException private File copyTestFileToRandomNameUnderTable(QTableMetaData fedExTable) throws IOException
{ {
File destinationDir = new File(SampleMetaDataProvider.defineFilesystemBackend().getBasePath() + File.separator + File destinationDir = new File(SampleMetaDataProvider.defineFilesystemBackend().getBasePath() + File.separator
((FilesystemTableBackendDetails) fedExTable.getBackendDetails()).getBasePath()); + ((FilesystemTableBackendDetails) fedExTable.getBackendDetails()).getBasePath());
destinationDir.mkdirs(); destinationDir.mkdirs();
File destinationFile = new File(destinationDir.getAbsolutePath() + File.separator + UUID.randomUUID()); File destinationFile = new File(destinationDir.getAbsolutePath() + File.separator + UUID.randomUUID());
@ -227,4 +227,4 @@ public class SampleMetaDataProviderTest
}); });
} }
} }