Skip to content

Commit

Permalink
LPS-155275 Include integration tests for Custom Object Fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielwas committed Jun 2, 2022
1 parent ad17386 commit d497366
Showing 1 changed file with 55 additions and 0 deletions.
Expand Up @@ -89,6 +89,35 @@ public class ObjectFieldLocalServiceTest {
public static final AggregateTestRule aggregateTestRule =
new LiferayIntegrationTestRule();

@Test
public void testAddCustomObjectField() throws Exception {

// Reserved name

String[] reservedNames = {
"actions", "companyId", "createDate", "creator", "dateCreated",
"dateModified", "externalReferenceCode", "groupId", "id",
"lastPublishDate", "modifiedDate", "statusByUserId",
"statusByUserName", "statusDate", "userId", "userName"
};

for (String reservedName : reservedNames) {
try {
_testAddCustomObjectField(
ObjectFieldUtil.createObjectField(
"Text", "String", reservedName,
_getObjectFieldSettings("Text")));

Assert.fail();
}
catch (ObjectFieldNameException objectFieldNameException) {
Assert.assertEquals(
"Reserved name " + reservedName,
objectFieldNameException.getMessage());
}
}
}

@Test
public void testAddSystemObjectField() throws Exception {

Expand Down Expand Up @@ -913,6 +942,32 @@ private boolean _hasColumn(String tableName, String columnName)
}
}

private void _testAddCustomObjectField(ObjectField... objectFields)
throws Exception {

ObjectDefinition objectDefinition = null;

try {
objectDefinition =
_objectDefinitionLocalService.addCustomObjectDefinition(
TestPropsValues.getUserId(),
LocalizedMapUtil.getLocalizedMap(
RandomTestUtil.randomString()),
"A" + RandomTestUtil.randomString(), null, null,
LocalizedMapUtil.getLocalizedMap(
RandomTestUtil.randomString()),
ObjectDefinitionConstants.SCOPE_COMPANY,
ObjectDefinitionConstants.STORAGE_TYPE_DEFAULT,
Arrays.asList(objectFields));
}
finally {
if (objectDefinition != null) {
_objectDefinitionLocalService.deleteObjectDefinition(
objectDefinition);
}
}
}

private String _testAddSystemObjectField(ObjectField... objectFields)
throws Exception {

Expand Down

0 comments on commit d497366

Please sign in to comment.