mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
109455: Merged modules/custommodelmanagement/HEAD to DEV. 93923: SHA-300: Added ALFRESCO_MODEL_ADMINISTRATORS group. 95982: SHA-401: Implemented repo service for retrieving Custom Models. (WIP) 95983: SHA-400: Added Private REST API to retrieve custom model(s) - Get All models: http://localhost:8080/alfresco/api/-default-/private/alfresco/versions/1/cmm - Get the model: http://localhost:8080/alfresco/api/-default-/private/alfresco/versions/1/cmm/<model-name> 95984: SHA-401: Fixed the service to return null rather than throwing an exception, when the model does not exist. 96053: SHA-400: Modified the custom model API response to return the "status" as "ACTIVE" or "DRAFT". 96775: SHA-542: Added support to create a custom model. (WIP) 96779: SHA-543: Added Private REST API to create custom model(s). - SHA-539: Cleaned up test data. 96850: SHA-543: Added Author and Description properties to the custom model API. 97410: SHA-407, SHA-555: Added tests for custom model backend service and the related REST API. Also, a minor modification as a result of added tests. 97570: Modified the CMM REST API, per Kevin's request, to return empty arrays for model's types and aspects if they don't exist. 97731: SHA-386: Added support to activate custom models. Also, a minor modification to the backend service and REST API, based on the Alfresco REST API guidelines. 97775: SHA-386: Added tests for custom model activation (backend service). As well as, fixed the build failure by refactoring the public API tests. 97992: SHA-573, SHA-393, SHA-494: Added support to deactivate custom model, create a new type and create a new property group (aspect). 97994: Fixed the test as a result of renaming the service method. 98123: SHA-393, SHA-494: Enabled the CMM REST API to create/update Types and/or Aspects via PUT. Also added validations for aspect/type's name. 98259: SHA-453: Added backend and REST API support to delete a custom model. 98690: SHA-393, SHA-494, SHA-453, SHA-575: Added tests for custom model backend service and the related REST API. Also, a minor modification as a result of added tests. 99276: SHA-549: Added backend support to update a custom model. Also, refactored the service to externalise the error messages. - SHA-550: Added REST API support to update a custom model. - SHA-619: Made sure the backend service validates the model before creating a node. - SHA-623: Added checks to not allow a user to create a custom model with the same name as the bootstrapped models. 99287: SHA-619: Added InvalidCustomModelException for the CMM service to throw when the model validation fails. 99514: SHA-506: added backend and API support to create custom Type/Aspect properties. Also refactored the API to overcome the Public API limitations. 99522: SHA-506: Modified the Type/Aspect JSON payload to include a new read only property "prefixedName". 99527: Fixed Bamboo build failure as the result of r99522 commit. 99630: SHA-506: - Updated the API to exclude the inherited properties. - Added API tests for creating properties. - Modified the Custom Properties JSON response to include a new read only attribute "prefixedName". 99662: SHA-351: Updated the API to support 'mandatory' and 'mandatoryEnforced' properties. - SHA-410: Updated the API to support 'defaultValue' property. - SHA-506: Modified the Custom Properties JSON response to include 'description' and 'multiValued' attributes. 99669: SHA-506: Removed the unnecessary (at least in this sprint) methods from the backend service. 99684: SHA-638: Added checks to not allow a user to create a custom model with already in-use namespace prefix. 99959: SHA-679: Modified the custom model API to not import the already defined namespace. 100211: SHA-607: Modified the custom model API to support delete model's type. Also, removed the unnecessary test as we depend on the dictionary service, so no need to test it in the custom model API. 100281: Added Types and Aspects to the GET a single model API response, when it is requested with "?select=all" query string. 100335: Added test for "?select=all" query string within the GET a single model API (see rev 100281). 100366: SHA-612: Modified the custom model API to support delete model's aspect. 100738: SHA-698: Added checks so the model Admin is not allowed to deactivate a custom model when its types/aspects are parent to other models' types/aspects (regardless of the model being active or not). 100740: SHA-698: Fixed Bamboo build failures. 101085: SHA-703: Added dependency validation before deleting custom type/aspect in the custom model API. 101160: Modified the custom model API to return all properties (including the inherited properties) of the type/aspect, when requested by "?select=allProps". 101636: SHA-697. 101771: SHA-706: Made custom models hidden in the data dictionary. 101863: SHA-701: Added checks to not allow creating duplicate properties within the same model. Also, removed unnecessary/duplicate constants from the custom model service class. 101983: SHA-688: Fixed the error message by getting the root-cause-exception and returning its message. However, DictionaryException messages are not localised, so this will be fixed in the alfresco core. 102223: Fix for SHA-726: Not able to edit prefix field of deactivated model when model type is referenced within same model - The API will update the parent prefixed name with the new prefix. - Also, added more validations to the CMM API, when setting a type/asptect's parent. 102587: SHA-741, SHA-745, SHA-747: Added custom model Constraints support. 102725: SHA-784: Fixed parent validation of the type/aspect. 103030: SHA-741, SHA-745, SHA-747: Added tests for custom model Constraints. - Also fixed and refactored the API code as the result of tests. 103753: SHA-846: Added inline constraints support. Also: - Modified the backend CMM service to throw CustomModelConstraintException when the root cause is DuplicateDefinitionException. - Removed the duplicate name check from the CMM API, as now it will depend on the exceptions thrown upon model compilation. 103885: SHA-819, SHA-833: Added support to edit existing type/aspect. 103973: SHA-819, SHA-833: Added API tests for types/aspects Edit. Also, refactored CMM API tests by moving the tests to their corresponding test class. 104079: SHA-808: Fixed custom models bidirectional dependency. 104158: Deleted the ExtendedRepoAdminService class as the required functionality has been added (see SHA-879) to the core alfresco code. 104287: SHA-843: Modified the custom model API to support delete property. Also, minor refactoring of the API tests. 104403: SHA-842: Modified the custom model API to support Edit property. 104475: SHA-842: Added API tests for Edit property. 104569: SHA-913 - Remove case sensitive option from the UI - SHA-914 - Update PO and tests that use the case sensitive option - Remove case sensitive option on LIST constraint throughout Also: - Update Aikau version to 1.0.18 104690: Fixed Bamboo build failure caused by r104569. 104849: SHA-808: Fixed custom models circular dependencies. 105297: SHA-807: Added property default-value and constraint (REGEX, MINMAX and LENGTH) validators. 105642: SHA-950: Wrapped backend CMM service method with a NEW transaction, in order to catch the thrown exception within DictionaryModelTypeTransactionListener. Also refactored the CMM backend service tests as the result of this change. 106677: SHA-888, SHA-889, SHA-890: Added Backend and API support to export a custom model and its associated Share form. 106722: SHA-888, SHA-889, SHA-890: Fixed a few minor issues raised during code review. 107007: ACE-4019: Modified the CMM service to not start a new TX when creating a new model. 107070: Temporarily enabled (hard coded) index and facetable attributes in the custom model properties. 107296: GERMAN: Model Manager files localised as per EN-rev105921 107297: FRENCH: Model Manager localised files based on EN-rev105921 107315: SPANISH: Model Manager localised files based on EN-rev105921 107317: JAPANESE: Model Manager localised files based on EN-rev105921 107321: ITALIAN: Model Manager localised files based on EN-rev105921 107322: DUTCH: Model Manager localised files based on EN-rev105921 107335: SHA-889: Modified the CMM service to not throw an exception when exporting the model and its associated share extension module, where the Share extension module has not been created for the model yet. 107456: SHA-893: Added API support to upload/import a custom model and its associated Share extension module. 107560: SHA-893: Added model upload API tests as well as minor fixes. 107647: SHA-893: Fixed minor issues raised during code review. 107773: Docs review of message labels and errors. 107866: SHA-1126: Added check for the maximum value of the MINMAX constraint to be a positive nonzero value. 108117: SHA-832: Added validation for properties' default values to be checked against the property defined constraint. 108256: SHA-1194: Modified CMM API to support indexing options. 108510: SHA-1151: Externalised CMM rest API error messages. - SHA-1196: Changed the CMM Rest API input validator to use the same RegExs as the CMM Share. 108518: SHA-1194: Changed CMM property facetable options to include "UNSET". 108561: GERMAN: Model Manager files updated as per EN-rev107962 108562: FRENCH: Model Manager files updated as per EN-rev107962 108565: ITALIAN: Model Manager files updated as per EN-rev107962 108566: SPANISH: Model Manager files updated as per EN-rev107962 108567: JAPANESE: Model Manager files updated as per EN-rev107962 108568: NORWEGIAN Bokmal: Model Manager files updated as per EN-rev107962 108570: DUTCH: Model Manager files updated as per EN-rev107962 108571: RUSSIAN: Model Manager files updated as per EN-rev107962 108572: BRAZILIAN Portuguese: Model Manager files updated as per EN-rev107962 108573: SIMPLIFIED CHINESE: Model Manager files updated as per EN-rev107962 108604: Removed the unnecessary escaped quotation from the strings which don't have variables. 108721: Api message changes from docs. 108728: Changed "Property group" to "Aspect" in the CMM API error messages. 108934: Added the missing escaped quotation into API messages. 109037: Changes from docs for mandatory field character messages in the API. 109204: ITALIAN: Updated bundle based on EN rev109039 109205: GERMAN: Updated bundle based on EN rev109039 109206: FRENCH: Updated bundle based on EN rev109039 109223: GERMAN: Updated bundle based on EN rev109039 - fixed single quotes 109226: FRENCH: Updated bundle based on EN rev109039 - fixed single quotes 109228: ITALIAN: Updated bundle based on EN rev109039 - fixed single quotes 109230: FRENCH: Updated bundle based on EN rev109039 - fixed single quotes again 109235: JAPANESE: Updated bundle based on EN rev109039 109293: SPANISH: Updated bundle based on EN rev109039 109300: DUTCH: Updated bundle based on EN rev109039 109412: - Refactored the CMM JMX support to return CompositeData for performance reasons. - Reorganised a few of CMM classes/interfaces to make it easier for merging to alfresco core. - A minor fixes as a result of Find Bugs analysis. - Added the minimum and maximum repo versions for CMM module. 109421: NORWEGIAN: Updated bundle based on EN rev109039 109424: BRAZILIAN PORTUGUESE: Updated bundle based on EN rev109039 109426: RUSSIAN: Updated bundle based on EN rev109039 109427: CHINESE: Updated bundle based on EN rev10903 109475: Added CMM Model into the core services (missed from previous commit). 109480: SHA-723: Added custom models analytics in HeartBeat data. 109481: SHA-528: Added GROUP_ALFRESCO_MODEL_ADMINISTRATORS_AUTHORITY patch. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@109490 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
701 lines
40 KiB
Java
701 lines
40 KiB
Java
/*
|
|
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco 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 Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package org.alfresco.rest.api.tests;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertFalse;
|
|
import static org.junit.Assert.assertNotNull;
|
|
import static org.junit.Assert.assertNull;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
import org.alfresco.repo.dictionary.Facetable;
|
|
import org.alfresco.repo.dictionary.IndexTokenisationMode;
|
|
import org.alfresco.rest.api.model.CustomAspect;
|
|
import org.alfresco.rest.api.model.CustomModel;
|
|
import org.alfresco.rest.api.model.CustomModelConstraint;
|
|
import org.alfresco.rest.api.model.CustomModelNamedValue;
|
|
import org.alfresco.rest.api.model.CustomModelProperty;
|
|
import org.alfresco.rest.api.model.CustomType;
|
|
import org.alfresco.rest.api.model.CustomModel.ModelStatus;
|
|
import org.alfresco.rest.api.tests.client.HttpResponse;
|
|
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
|
import org.alfresco.service.cmr.dictionary.CustomModelService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.util.Pair;
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
* Tests the REST API of the properties of the {@link CustomModelService}.
|
|
*
|
|
* @author Jamal Kaabi-Mofrad
|
|
*/
|
|
public class TestCustomProperty extends BaseCustomModelApiTest
|
|
{
|
|
@Test
|
|
public void testCreateProperties() throws Exception
|
|
{
|
|
String modelName = "testModel" + System.currentTimeMillis();
|
|
Pair<String, String> namespacePair = getTestNamespaceUriPrefixPair();
|
|
// Create the model as a Model Administrator
|
|
createCustomModel(modelName, namespacePair, ModelStatus.DRAFT);
|
|
|
|
{
|
|
// Create aspect
|
|
String aspectName = "testAspect1" + System.currentTimeMillis();
|
|
CustomAspect aspect = createTypeAspect(CustomAspect.class, modelName, aspectName, null, null, null);
|
|
|
|
// Update the Aspect by adding property
|
|
CustomAspect payload = new CustomAspect();
|
|
String aspectPropName = "testAspect1Prop1" + System.currentTimeMillis();
|
|
CustomModelProperty aspectProp = new CustomModelProperty();
|
|
aspectProp.setName(aspectPropName);
|
|
aspectProp.setTitle("property title");
|
|
aspectProp.setMultiValued(true);
|
|
aspectProp.setIndexed(true);
|
|
aspectProp.setFacetable(Facetable.TRUE);
|
|
aspectProp.setIndexTokenisationMode(IndexTokenisationMode.BOTH);
|
|
List<CustomModelProperty> props = new ArrayList<>(1);
|
|
props.add(aspectProp);
|
|
payload.setProperties(props);
|
|
// Try to update the aspect as a non Admin user
|
|
put("cmm/" + modelName + "/aspects", nonAdminUserName, aspectName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 403);
|
|
|
|
// Try to update the aspect as a Model Administrator
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 400); // Type name is mandatory
|
|
|
|
// Add the mandatory aspect name to the payload
|
|
payload.setName(aspectName);
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated aspect
|
|
HttpResponse response = getSingle("cmm/" + modelName + "/aspects", customModelAdmin, aspect.getName(), 200);
|
|
CustomAspect returnedAspect = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomAspect.class);
|
|
// Check the aspect's added property
|
|
assertEquals(1, returnedAspect.getProperties().size());
|
|
CustomModelProperty customModelProperty = returnedAspect.getProperties().get(0);
|
|
assertEquals(aspectPropName, customModelProperty.getName());
|
|
assertEquals("property title", customModelProperty.getTitle());
|
|
assertEquals(namespacePair.getSecond() + QName.NAMESPACE_PREFIX + aspectPropName, customModelProperty.getPrefixedName());
|
|
assertEquals("Default data type is 'd:text'.", "d:text", customModelProperty.getDataType());
|
|
assertNull(customModelProperty.getDescription());
|
|
assertTrue(customModelProperty.isMultiValued());
|
|
assertFalse(customModelProperty.isMandatory());
|
|
assertFalse(customModelProperty.isMandatoryEnforced());
|
|
assertNull(customModelProperty.getDefaultValue());
|
|
assertTrue(customModelProperty.isIndexed());
|
|
assertEquals(Facetable.TRUE, customModelProperty.getFacetable());
|
|
assertEquals(IndexTokenisationMode.BOTH, customModelProperty.getIndexTokenisationMode());
|
|
|
|
// Test duplicate property name
|
|
aspectProp = new CustomModelProperty();
|
|
aspectProp.setName(aspectPropName); // Existing name
|
|
aspectProp.setTitle("new property title");
|
|
props = new ArrayList<>(1);
|
|
props.add(aspectProp);
|
|
payload.setProperties(props);
|
|
// Try to update the aspect as a Model Administrator
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 409); // property name already exists
|
|
}
|
|
|
|
{
|
|
// Create type
|
|
String typeName = "testType1" + System.currentTimeMillis();
|
|
CustomType type = createTypeAspect(CustomType.class, modelName, typeName, "test type1 title", "test type1 Desc", "cm:content");
|
|
|
|
// Update the Type by adding property
|
|
CustomType payload = new CustomType();
|
|
String typePropName = "testType1Prop1" + System.currentTimeMillis();
|
|
CustomModelProperty typeProp = new CustomModelProperty();
|
|
typeProp.setName(typePropName);
|
|
typeProp.setTitle("property title");
|
|
typeProp.setDataType("d:int");
|
|
typeProp.setIndexed(false);
|
|
typeProp.setFacetable(Facetable.FALSE);
|
|
typeProp.setIndexTokenisationMode(IndexTokenisationMode.FALSE);
|
|
List<CustomModelProperty> props = new ArrayList<>(1);
|
|
props.add(typeProp);
|
|
payload.setProperties(props);
|
|
|
|
// Try to update the type as a non Admin user
|
|
put("cmm/" + modelName + "/types", nonAdminUserName, typeName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 403);
|
|
|
|
// Try to update the type as a Model Administrator
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 400); // Type name is mandatory
|
|
|
|
// Add the mandatory type name to the payload
|
|
payload.setName(typeName);
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated type
|
|
HttpResponse response = getSingle("cmm/" + modelName + "/types", customModelAdmin, type.getName(), 200);
|
|
CustomType returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
// Check the type's added property
|
|
assertEquals(1, returnedType.getProperties().size());
|
|
CustomModelProperty customModelProperty = returnedType.getProperties().get(0);
|
|
assertEquals(typePropName, customModelProperty.getName());
|
|
assertEquals("property title", customModelProperty.getTitle());
|
|
assertEquals(namespacePair.getSecond() + QName.NAMESPACE_PREFIX + typePropName, customModelProperty.getPrefixedName());
|
|
assertEquals("d:int", customModelProperty.getDataType());
|
|
assertNull(customModelProperty.getDescription());
|
|
assertFalse(customModelProperty.isMultiValued());
|
|
assertFalse(customModelProperty.isMandatory());
|
|
assertFalse(customModelProperty.isMandatoryEnforced());
|
|
assertNull(customModelProperty.getDefaultValue());
|
|
assertFalse(customModelProperty.isIndexed());
|
|
assertEquals(Facetable.FALSE, customModelProperty.getFacetable());
|
|
assertEquals(IndexTokenisationMode.FALSE, customModelProperty.getIndexTokenisationMode());
|
|
|
|
// Retrieve the updated type with all the properties (include inherited)
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, type.getName()+SELECT_ALL_PROPS, 200);
|
|
returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
assertEquals(3, returnedType.getProperties().size());
|
|
// Check for the inherited properties
|
|
assertNotNull(getProperty(returnedType.getProperties(), "content")); // cm:content
|
|
assertNotNull(getProperty(returnedType.getProperties(), "name")); // cm:name
|
|
|
|
// Create another property and set all of its attributes
|
|
payload = new CustomType();
|
|
payload.setName(typeName);
|
|
String typePropName2 = "testType1Prop2" + System.currentTimeMillis();
|
|
typeProp = new CustomModelProperty();
|
|
typeProp.setName(typePropName2);
|
|
typeProp.setTitle("property2 title");
|
|
typeProp.setDescription("property2 desciption");
|
|
typeProp.setDataType("d:int");
|
|
typeProp.setDefaultValue("0");
|
|
typeProp.setMultiValued(false);
|
|
typeProp.setMandatory(true);
|
|
typeProp.setMandatoryEnforced(true);
|
|
props = new ArrayList<>(1);
|
|
props.add(typeProp);
|
|
payload.setProperties(props);
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated type
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, type.getName(), 200);
|
|
returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
// Check the type's added property
|
|
assertEquals(2, returnedType.getProperties().size());
|
|
customModelProperty = getProperty(returnedType.getProperties(), typePropName2);
|
|
assertNotNull(customModelProperty);
|
|
assertEquals(typePropName2, customModelProperty.getName());
|
|
assertEquals("property2 title", customModelProperty.getTitle());
|
|
assertEquals(namespacePair.getSecond() + QName.NAMESPACE_PREFIX + typePropName2, customModelProperty.getPrefixedName());
|
|
assertEquals("d:int", customModelProperty.getDataType());
|
|
assertEquals("property2 desciption", customModelProperty.getDescription());
|
|
assertFalse(customModelProperty.isMultiValued());
|
|
assertTrue(customModelProperty.isMandatory());
|
|
assertTrue(customModelProperty.isMandatoryEnforced());
|
|
assertEquals("0", customModelProperty.getDefaultValue());
|
|
|
|
// Test duplicate property name
|
|
typeProp = new CustomModelProperty();
|
|
typeProp.setName(typePropName2); // Existing name
|
|
typeProp.setTitle("new property title");
|
|
typeProp.setDataType("d:text");
|
|
props = new ArrayList<>(1);
|
|
props.add(typeProp);
|
|
payload.setProperties(props);
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(payload), SELECT_PROPS_QS, 409); // property name already exists
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testDeleteProperty() throws Exception
|
|
{
|
|
String modelName = "testModelDeleteProp" + System.currentTimeMillis();
|
|
Pair<String, String> namespacePair = getTestNamespaceUriPrefixPair();
|
|
// Create the model as a Model Administrator
|
|
createCustomModel(modelName, namespacePair, ModelStatus.DRAFT);
|
|
|
|
/*
|
|
* Create aspect and update it by adding two properties
|
|
*/
|
|
String aspectName = "testAspect1" + System.currentTimeMillis();
|
|
createTypeAspect(CustomAspect.class, modelName, aspectName, null, null, null);
|
|
// Update the Aspect by adding property - property one
|
|
CustomAspect aspectPayload = new CustomAspect();
|
|
aspectPayload.setName(aspectName);
|
|
|
|
String aspectPropNameOne = "testAspect1Prop1" + System.currentTimeMillis();
|
|
CustomModelProperty aspectPropOne = new CustomModelProperty();
|
|
aspectPropOne.setName(aspectPropNameOne);
|
|
aspectPropOne.setTitle("aspect property one title");
|
|
aspectPropOne.setMultiValued(true);
|
|
List<CustomModelProperty> props = new ArrayList<>(1);
|
|
props.add(aspectPropOne);
|
|
aspectPayload.setProperties(props);
|
|
// create property one
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 200);
|
|
|
|
// Update the Aspect by adding another property - property two
|
|
aspectPayload = new CustomAspect();
|
|
aspectPayload.setName(aspectName);
|
|
|
|
String aspectPropNameTwo = "testAspect1Prop2" + System.currentTimeMillis();
|
|
CustomModelProperty aspectPropTwo = new CustomModelProperty();
|
|
aspectPropTwo.setName(aspectPropNameTwo);
|
|
aspectPropTwo.setTitle("aspect property two title");
|
|
aspectPropTwo.setMandatory(true);
|
|
aspectPropTwo.setDataType("d:int");
|
|
aspectPropTwo.setDefaultValue("1");
|
|
props = new ArrayList<>(1);
|
|
props.add(aspectPropTwo);
|
|
aspectPayload.setProperties(props);
|
|
// create property two
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated aspect
|
|
HttpResponse response = getSingle("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, 200);
|
|
CustomAspect returnedAspect = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomAspect.class);
|
|
// Check the aspect's added properties
|
|
assertEquals(2, returnedAspect.getProperties().size());
|
|
|
|
/*
|
|
* Create type and update it by adding two properties
|
|
*/
|
|
String typeName = "testType1" + System.currentTimeMillis();
|
|
createTypeAspect(CustomType.class, modelName, typeName, "test type1 title", null, "cm:content");
|
|
|
|
// Update the Type by adding property - property one
|
|
CustomType typePayload = new CustomType();
|
|
typePayload.setName(typeName);
|
|
|
|
String typePropNameOne = "testType1Prop1" + System.currentTimeMillis();
|
|
CustomModelProperty typePropOne = new CustomModelProperty();
|
|
typePropOne.setName(typePropNameOne);
|
|
typePropOne.setTitle("type property one title");
|
|
props = new ArrayList<>(1);
|
|
props.add(typePropOne);
|
|
typePayload.setProperties(props);
|
|
// create property one
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(typePayload), SELECT_PROPS_QS, 200);
|
|
|
|
// Update the Type by adding another property - property two
|
|
typePayload = new CustomType();
|
|
typePayload.setName(typeName);
|
|
|
|
// Create inline MINMAX constraint
|
|
CustomModelConstraint inlineMinMaxConstraint = new CustomModelConstraint();
|
|
inlineMinMaxConstraint.setType("MINMAX");
|
|
inlineMinMaxConstraint.setTitle("test MINMAX title");
|
|
// Create the MinMax constraint's parameters
|
|
List<CustomModelNamedValue> parameters = new ArrayList<>(2);
|
|
parameters.add(buildNamedValue("maxValue", "100.0"));
|
|
parameters.add(buildNamedValue("minValue", "0.0"));
|
|
// Add the parameters into the constraint
|
|
inlineMinMaxConstraint.setParameters(parameters);
|
|
|
|
String typePropNameTwo = "testType1Prop2" + System.currentTimeMillis();
|
|
CustomModelProperty typePropTwo = new CustomModelProperty();
|
|
typePropTwo.setName(typePropNameTwo);
|
|
typePropTwo.setTitle("type property two title");
|
|
typePropTwo.setDataType("d:int");
|
|
typePropTwo.setConstraints(Arrays.asList(inlineMinMaxConstraint)); // add the inline constraint
|
|
props = new ArrayList<>(1);
|
|
props.add(typePropTwo);
|
|
typePayload.setProperties(props);
|
|
// create property one
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(typePayload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated type
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, typeName, 200);
|
|
CustomType returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
// Check the type's added properties
|
|
assertEquals(2, returnedType.getProperties().size());
|
|
|
|
// Delete aspect's property one - model is inactive
|
|
{
|
|
final String deletePropOneAspectQS = getPropDeleteUpdateQS(aspectPropNameOne, true);
|
|
// Try to delete propertyOne from aspect
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, null, deletePropOneAspectQS, 400); // missing payload
|
|
|
|
CustomAspect deletePropAspectPayload = new CustomAspect();
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(deletePropAspectPayload), deletePropOneAspectQS, 400); // missing aspect name
|
|
|
|
deletePropAspectPayload.setName(aspectName);
|
|
put("cmm/" + modelName + "/aspects", nonAdminUserName, aspectName, RestApiUtil.toJsonAsString(deletePropAspectPayload), deletePropOneAspectQS, 403); // unauthorised
|
|
// Delete as a Model Administrator
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(deletePropAspectPayload), deletePropOneAspectQS, 200);
|
|
|
|
// Check the property has been deleted
|
|
response = getSingle("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, 200);
|
|
returnedAspect = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomAspect.class);
|
|
assertEquals(1, returnedAspect.getProperties().size());
|
|
assertFalse("Property one should have been deleted.", aspectPropNameOne.equals(returnedAspect.getProperties().get(0).getName()));
|
|
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(deletePropAspectPayload), deletePropOneAspectQS, 404); //Not found
|
|
}
|
|
|
|
// Delete type's property two - model is inactive
|
|
{
|
|
final String deletePropTwoTypeQS = getPropDeleteUpdateQS(typePropNameTwo, true);
|
|
// Try to delete propertyOne from type
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, null, deletePropTwoTypeQS, 400); // missing payload
|
|
|
|
CustomType deletePropTypePayload = new CustomType();
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(deletePropTypePayload), deletePropTwoTypeQS,
|
|
400); // missing type name
|
|
|
|
deletePropTypePayload.setName(typeName);
|
|
put("cmm/" + modelName + "/types", nonAdminUserName, typeName, RestApiUtil.toJsonAsString(deletePropTypePayload), deletePropTwoTypeQS, 403); // unauthorised
|
|
// Delete as a Model Administrator
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(deletePropTypePayload), deletePropTwoTypeQS, 200);
|
|
|
|
// Check the property has been deleted
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, typeName, 200);
|
|
returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
assertEquals(1, returnedType.getProperties().size());
|
|
assertFalse("Property two should have been deleted.", typePropNameTwo.equals(returnedType.getProperties().get(0).getName()));
|
|
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(deletePropTypePayload), deletePropTwoTypeQS, 404); //Not found
|
|
}
|
|
|
|
// Note: at the time of writing, we can't delete a property of an active model, as ModelValidatorImpl.validateIndexedProperty depends on Solr
|
|
|
|
}
|
|
|
|
@Test
|
|
public void testUpdateProperty() throws Exception
|
|
{
|
|
String modelName = "testModelUpdateProp" + System.currentTimeMillis();
|
|
Pair<String, String> namespacePair = getTestNamespaceUriPrefixPair();
|
|
// Create the model as a Model Administrator
|
|
createCustomModel(modelName, namespacePair, ModelStatus.DRAFT);
|
|
|
|
/*
|
|
* Create aspect and update it by adding a property
|
|
*/
|
|
String aspectName = "testAspect1" + System.currentTimeMillis();
|
|
createTypeAspect(CustomAspect.class, modelName, aspectName, null, null, null);
|
|
// Update the Aspect by adding property
|
|
CustomAspect aspectPayload = new CustomAspect();
|
|
aspectPayload.setName(aspectName);
|
|
|
|
String aspectPropName = "testAspect1Prop" + System.currentTimeMillis();
|
|
CustomModelProperty aspectProp = new CustomModelProperty();
|
|
aspectProp.setName(aspectPropName);
|
|
aspectProp.setTitle("aspect property title");
|
|
aspectProp.setMultiValued(true);
|
|
List<CustomModelProperty> props = new ArrayList<>(1);
|
|
props.add(aspectProp);
|
|
aspectPayload.setProperties(props);
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated aspect
|
|
HttpResponse response = getSingle("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, 200);
|
|
CustomAspect returnedAspect = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomAspect.class);
|
|
// Check the aspect's added property
|
|
assertEquals(1, returnedAspect.getProperties().size());
|
|
|
|
/*
|
|
* Create type and update it by adding a property
|
|
*/
|
|
String typeName = "testType1" + System.currentTimeMillis();
|
|
createTypeAspect(CustomType.class, modelName, typeName, "test type1 title", null, "cm:content");
|
|
|
|
// Update the Type by adding property - property one
|
|
CustomType typePayload = new CustomType();
|
|
typePayload.setName(typeName);
|
|
|
|
// Create inline MINMAX constraint
|
|
CustomModelConstraint inlineMinMaxConstraint = new CustomModelConstraint();
|
|
inlineMinMaxConstraint.setType("MINMAX");
|
|
inlineMinMaxConstraint.setTitle("test MINMAX title");
|
|
// Create the MinMax constraint's parameters
|
|
List<CustomModelNamedValue> parameters = new ArrayList<>(2);
|
|
parameters.add(buildNamedValue("maxValue", "100.0"));
|
|
parameters.add(buildNamedValue("minValue", "0.0"));
|
|
// Add the parameters into the constraint
|
|
inlineMinMaxConstraint.setParameters(parameters);
|
|
|
|
String typePropName = "testType1Prop" + System.currentTimeMillis();
|
|
CustomModelProperty typeProp = new CustomModelProperty();
|
|
typeProp.setName(typePropName);
|
|
typeProp.setDataType("d:int");
|
|
typeProp.setTitle("type property title");
|
|
typeProp.setDefaultValue("0");
|
|
typeProp.setConstraints(Arrays.asList(inlineMinMaxConstraint)); // add the inline constraint
|
|
props = new ArrayList<>(1);
|
|
props.add(typeProp);
|
|
typePayload.setProperties(props);
|
|
// create property
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(typePayload), SELECT_PROPS_QS, 200);
|
|
|
|
// Retrieve the updated type
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, typeName, 200);
|
|
CustomType returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
// Check the type's added property
|
|
assertEquals(1, returnedType.getProperties().size());
|
|
|
|
// Update aspect's property - model is inactive
|
|
{
|
|
final String updatePropOneAspectQS = getPropDeleteUpdateQS(aspectPropName, false);
|
|
// Try to update property from aspect
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, null, updatePropOneAspectQS, 400); // missing payload
|
|
|
|
CustomAspect updatePropAspectPayload = new CustomAspect();
|
|
CustomModelProperty propertyAspect = new CustomModelProperty();
|
|
propertyAspect.setTitle("new Title");
|
|
propertyAspect.setDescription("new Desc");
|
|
propertyAspect.setDataType("d:int"); // the original value was d:text
|
|
propertyAspect.setMultiValued(false); // the original value was true
|
|
propertyAspect.setMandatory(true); // the original value was false
|
|
propertyAspect.setDefaultValue("10");
|
|
List<CustomModelProperty> modifiedProp = new ArrayList<>(1);
|
|
modifiedProp.add(propertyAspect);
|
|
updatePropAspectPayload.setProperties(modifiedProp);
|
|
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(updatePropAspectPayload), updatePropOneAspectQS, 400); // missing aspect name
|
|
|
|
// set a random name
|
|
updatePropAspectPayload.setName(aspectName + System.currentTimeMillis());
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(updatePropAspectPayload), updatePropOneAspectQS, 404); // Aspect not found
|
|
|
|
// set the correct name
|
|
updatePropAspectPayload.setName(aspectName);
|
|
// the requested property name dose not match the payload
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(updatePropAspectPayload), updatePropOneAspectQS, 400);
|
|
|
|
// set the property name that matches the requested property
|
|
propertyAspect.setName(aspectPropName);
|
|
put("cmm/" + modelName + "/aspects", nonAdminUserName, aspectName, RestApiUtil.toJsonAsString(updatePropAspectPayload), updatePropOneAspectQS, 403); // unauthorised
|
|
// Update as a Model Administrator
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(updatePropAspectPayload), updatePropOneAspectQS, 200);
|
|
|
|
// Check the property has been updated
|
|
response = getSingle("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, 200);
|
|
returnedAspect = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomAspect.class);
|
|
assertEquals(1, returnedAspect.getProperties().size());
|
|
CustomModelProperty modifiedAspectProperty = returnedAspect.getProperties().get(0);
|
|
compareCustomModelProperties(propertyAspect, modifiedAspectProperty, "prefixedName", "indexTokenisationMode");
|
|
}
|
|
|
|
// Activate the model
|
|
CustomModel statusPayload = new CustomModel();
|
|
statusPayload.setStatus(ModelStatus.ACTIVE);
|
|
put("cmm", customModelAdmin, modelName, RestApiUtil.toJsonAsString(statusPayload), SELECT_STATUS_QS, 200);
|
|
|
|
// Update type's property - model is active
|
|
{
|
|
final String updatePropTwoTypeQS = getPropDeleteUpdateQS(typePropName, false);
|
|
CustomType updatePropTypePayload = new CustomType();
|
|
updatePropTypePayload.setName(typeName);
|
|
CustomModelProperty propertyType = new CustomModelProperty();
|
|
propertyType.setName(typePropName);
|
|
propertyType.setTitle("new Title");
|
|
propertyType.setDescription("new Desc");
|
|
propertyType.setDataType("d:long"); // the original value was d:int
|
|
propertyType.setDefaultValue("5");
|
|
List<CustomModelProperty> modifiedProp = new ArrayList<>(1);
|
|
modifiedProp.add(propertyType);
|
|
updatePropTypePayload.setProperties(modifiedProp);
|
|
|
|
// Unauthorised
|
|
put("cmm/" + modelName + "/types", nonAdminUserName, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 403);
|
|
// Try to update an active model as a Model Administrator - Cannot change the data type of the property of an active model
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 409);
|
|
|
|
// Set the data type with its original value
|
|
propertyType.setDataType("d:int");
|
|
propertyType.setMultiValued(true);// the original value was false
|
|
// Cannot change the multi-valued option of the property of an active model
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 409);
|
|
|
|
propertyType.setMultiValued(false);
|
|
propertyType.setMandatory(true);// the original value was false
|
|
// Cannot change the mandatory option of the property of an active model
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 409);
|
|
|
|
propertyType.setMandatory(false);
|
|
propertyType.setMandatoryEnforced(true);// the original value was false
|
|
// Cannot change the mandatory-enforced option of the property of an active model
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 409);
|
|
|
|
// Set the mandatory-enforced with its original value
|
|
propertyType.setMandatoryEnforced(false);
|
|
// Update the MinMax constraint's parameters
|
|
parameters = new ArrayList<>(2);
|
|
parameters.add(buildNamedValue("maxValue", "120.0")); // the original value was 100.0
|
|
parameters.add(buildNamedValue("minValue", "20.0")); // the original value was 0.0
|
|
// Add the parameters into the constraint
|
|
inlineMinMaxConstraint.setParameters(parameters);
|
|
propertyType.setConstraints(Arrays.asList(inlineMinMaxConstraint)); // add the updated inline constraint
|
|
|
|
// Try to Update - constraint violation. The default value is 5 which is not in the MinMax range [20, 120]
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 409);
|
|
|
|
propertyType.setDefaultValue("25"); // we changed the MinMax constraint to be [20, 120]
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 200);
|
|
|
|
// Check the property has been updated
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, typeName, 200);
|
|
returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
assertEquals(1, returnedType.getProperties().size());
|
|
CustomModelProperty modifiedTypeProperty = returnedType.getProperties().get(0);
|
|
assertEquals("new Title", modifiedTypeProperty.getTitle());
|
|
assertEquals("new Desc", modifiedTypeProperty.getDescription());
|
|
assertEquals("25", modifiedTypeProperty.getDefaultValue());
|
|
assertEquals("Shouldn't be able to change the data type of the property of an active model." ,"d:int", modifiedTypeProperty.getDataType());
|
|
assertFalse(modifiedTypeProperty.isMandatory());
|
|
assertFalse(modifiedTypeProperty.isMultiValued());
|
|
assertFalse(modifiedTypeProperty.isMandatoryEnforced());
|
|
assertEquals(1, modifiedTypeProperty.getConstraints().size());
|
|
CustomModelConstraint modifiedConstraint = modifiedTypeProperty.getConstraints().get(0);
|
|
assertEquals("MINMAX", modifiedConstraint.getType());
|
|
assertEquals("120.0", getParameterSimpleValue(modifiedConstraint.getParameters(), "maxValue"));
|
|
assertEquals("20.0", getParameterSimpleValue(modifiedConstraint.getParameters(), "minValue"));
|
|
|
|
// Change the constraint type and parameter
|
|
inlineMinMaxConstraint.setType("LENGTH");
|
|
inlineMinMaxConstraint.setTitle("test LENGTH title");
|
|
parameters = new ArrayList<>(2);
|
|
parameters.add(buildNamedValue("maxLength", "256"));
|
|
parameters.add(buildNamedValue("minLength", "0"));
|
|
// Add the parameters into the constraint
|
|
inlineMinMaxConstraint.setParameters(parameters);
|
|
propertyType.setConstraints(Arrays.asList(inlineMinMaxConstraint));
|
|
// LENGTH can only be used with textual data type
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 400);
|
|
|
|
//update the property by removing the constraint
|
|
propertyType.setConstraints(Collections.<CustomModelConstraint>emptyList());
|
|
put("cmm/" + modelName + "/types", customModelAdmin, typeName, RestApiUtil.toJsonAsString(updatePropTypePayload), updatePropTwoTypeQS, 200);
|
|
|
|
response = getSingle("cmm/" + modelName + "/types", customModelAdmin, typeName, 200);
|
|
returnedType = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), CustomType.class);
|
|
assertEquals(1, returnedType.getProperties().size());
|
|
modifiedTypeProperty = returnedType.getProperties().get(0);
|
|
assertEquals(0, modifiedTypeProperty.getConstraints().size());
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testValidatePropertyDefaultValue() throws Exception
|
|
{
|
|
String modelName = "testModelPropDefaultValue" + System.currentTimeMillis();
|
|
Pair<String, String> namespacePair = getTestNamespaceUriPrefixPair();
|
|
// Create the model as a Model Administrator
|
|
createCustomModel(modelName, namespacePair, ModelStatus.DRAFT);
|
|
|
|
/*
|
|
* Create aspect and update it by adding a property
|
|
*/
|
|
String aspectName = "testAspect1" + System.currentTimeMillis();
|
|
createTypeAspect(CustomAspect.class, modelName, aspectName, null, null, null);
|
|
// Update the Aspect by adding property
|
|
CustomAspect aspectPayload = new CustomAspect();
|
|
aspectPayload.setName(aspectName);
|
|
|
|
String aspectPropName = "testAspectProp" + System.currentTimeMillis();
|
|
final String updatePropAspectQS = getPropDeleteUpdateQS(aspectPropName, false);
|
|
|
|
CustomModelProperty aspectProp = new CustomModelProperty();
|
|
aspectProp.setName(aspectPropName);
|
|
aspectProp.setTitle("aspect property title");
|
|
List<CustomModelProperty> props = new ArrayList<>(1);
|
|
props.add(aspectProp);
|
|
aspectPayload.setProperties(props);
|
|
|
|
// d:int tests
|
|
{
|
|
aspectProp.setDataType("d:int");
|
|
aspectProp.setDefaultValue(" ");// space
|
|
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
|
|
aspectProp.setDefaultValue("abc"); // text
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
|
|
aspectProp.setDefaultValue("1.0"); // double
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
|
|
aspectProp.setDefaultValue("1,2,3"); // text
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
}
|
|
|
|
// d:float tests
|
|
{
|
|
aspectProp.setDataType("d:float");
|
|
aspectProp.setDefaultValue(" ");// space
|
|
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
|
|
aspectProp.setDefaultValue("abc"); // text
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
|
|
aspectProp.setDefaultValue("1,2,3"); // text
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 400);
|
|
|
|
aspectProp.setDefaultValue("1.0"); // float
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), SELECT_PROPS_QS, 200);
|
|
|
|
aspectProp.setDefaultValue("1.0f"); // float - update
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 200);
|
|
|
|
aspectProp.setDefaultValue("1.0d"); // double - update
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 200);
|
|
}
|
|
|
|
// d:boolean tests
|
|
{
|
|
aspectProp.setDataType("d:boolean");
|
|
aspectProp.setDefaultValue(" ");// space
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 400);
|
|
|
|
aspectProp.setDefaultValue("abc"); // text
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 400);
|
|
|
|
aspectProp.setDefaultValue("1"); // number
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 400);
|
|
|
|
aspectProp.setDefaultValue("true"); // valid value
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 200);
|
|
|
|
aspectProp.setDefaultValue("false"); // valid value
|
|
// create property
|
|
put("cmm/" + modelName + "/aspects", customModelAdmin, aspectName, RestApiUtil.toJsonAsString(aspectPayload), updatePropAspectQS, 200);
|
|
}
|
|
}
|
|
|
|
private String getPropDeleteUpdateQS(String propName, boolean isDelete)
|
|
{
|
|
String req = (isDelete ? "&delete=" : "&update=");
|
|
return SELECT_PROPS_QS + req + propName;
|
|
}
|
|
}
|