CE-1402 add instance validation to CaseChangeBehavior

This commit is contained in:
2024-06-25 08:15:59 -05:00
parent b2cf1cc83b
commit dc84a9ef55
2 changed files with 56 additions and 0 deletions

View File

@ -44,6 +44,7 @@ import com.kingsrook.qqq.backend.core.utils.collections.ListBuilder;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/*******************************************************************************
@ -212,4 +213,30 @@ class CaseChangeBehaviorTest extends BaseTest
assertEquals("Circle", CaseChangeBehavior.NONE.applyToFilterCriteriaValue("Circle", qInstance, table, field));
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testValidation()
{
QTableMetaData table = QContext.getQInstance().getTable(TestUtils.TABLE_NAME_SHAPE);
///////////////////////////////////////////
// should be no errors on a string field //
///////////////////////////////////////////
assertTrue(CaseChangeBehavior.TO_UPPER_CASE.validateBehaviorConfiguration(table, table.getField("name")).isEmpty());
//////////////////////////////////////////
// should be an error on a number field //
//////////////////////////////////////////
assertEquals(1, CaseChangeBehavior.TO_LOWER_CASE.validateBehaviorConfiguration(table, table.getField("id")).size());
/////////////////////////////////////////
// NONE should be allowed on any field //
/////////////////////////////////////////
assertTrue(CaseChangeBehavior.NONE.validateBehaviorConfiguration(table, table.getField("id")).isEmpty());
}
}