diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java index 8b88bbcbd1..9e636bf8f7 100644 --- a/source/test-java/org/alfresco/opencmis/CMISTest.java +++ b/source/test-java/org/alfresco/opencmis/CMISTest.java @@ -23,10 +23,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import java.io.File; import java.io.Serializable; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -100,6 +102,7 @@ import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionEleme import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl; @@ -2252,4 +2255,63 @@ public class CMISTest AuthenticationUtil.popAuthentication(); } } + + /** + * MNT-11304: Test that Alfresco has no default boundaries for decimals + * @throws Exception + */ + @Test + public void testDecimalDefaultBoundaries() throws Exception + { + AuthenticationUtil.pushAuthentication(); + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + try + { + withCmisService(new CmisServiceCallback() + { + @Override + public Void execute(CmisService cmisService) + { + List repositories = cmisService.getRepositoryInfos(null); + assertTrue(repositories.size() > 0); + RepositoryInfo repo = repositories.get(0); + String repositoryId = repo.getId(); + + TypeDefinition decimalTypeDef = cmisService.getTypeDefinition(repositoryId, "D:tcdm:testdecimalstype", null); + + PropertyDecimalDefinitionImpl floatNoBoundsTypeDef = + (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:float"); + PropertyDecimalDefinitionImpl doubleNoBoundsTypeDef = + (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:double"); + + PropertyDecimalDefinitionImpl floatWithBoundsTypeDef = + (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:floatwithbounds"); + PropertyDecimalDefinitionImpl doubleWithBoundsTypeDef = + (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:doublewithbounds"); + + // test that there is not default boundaries for decimals + assertNull(floatNoBoundsTypeDef.getMinValue()); + assertNull(floatNoBoundsTypeDef.getMaxValue()); + + assertNull(doubleNoBoundsTypeDef.getMinValue()); + assertNull(doubleNoBoundsTypeDef.getMaxValue()); + + // test for pre-defined boundaries + assertTrue(floatWithBoundsTypeDef.getMinValue().equals(BigDecimal.valueOf(-10f))); + assertTrue(floatWithBoundsTypeDef.getMaxValue().equals(BigDecimal.valueOf(10f))); + + assertTrue(doubleWithBoundsTypeDef.getMinValue().equals(BigDecimal.valueOf(-10d))); + assertTrue(doubleWithBoundsTypeDef.getMaxValue().equals(BigDecimal.valueOf(10d))); + + return null; + } + }, CmisVersion.CMIS_1_1); + + } + finally + { + AuthenticationUtil.popAuthentication(); + } + } } diff --git a/source/test-resources/opencmis/testcmisdecimal_model.xml b/source/test-resources/opencmis/testcmisdecimal_model.xml new file mode 100644 index 0000000000..23dcf4f28e --- /dev/null +++ b/source/test-resources/opencmis/testcmisdecimal_model.xml @@ -0,0 +1,62 @@ + + + + Test CMIS Decimal for Boundaries Model + SSergey + 1.0 + + + + + + + + + + + + + + + Test Decimals Type + cm:content + + + Float + Float + d:float + + + Double + Double + d:double + + + Float With Boundaries + Float With Boundaries + d:float + + + -10 + 10 + + + + + Double With Boundaries + Double With Boundaries + d:double + + + -10 + 10 + + + + + + + diff --git a/source/test-resources/test-cmisinteger_modell-context.xml b/source/test-resources/test-cmisinteger_modell-context.xml index 96048b38a1..bd1a8e442a 100644 --- a/source/test-resources/test-cmisinteger_modell-context.xml +++ b/source/test-resources/test-cmisinteger_modell-context.xml @@ -7,6 +7,7 @@ opencmis/testcmisinteger_model.xml + opencmis/testcmisdecimal_model.xml opencmis/testcmis_item_model.xml tenant/exampleModel.xml