use of org.alfresco.repo.dictionary.M2Association in project alfresco-remote-api by Alfresco.
the class CustomModelImportTest method testUploadModel_UnsupportedModelElements.
public void testUploadModel_UnsupportedModelElements() throws Exception {
// Note: here we only test a couple of not-supported model elements to check for the correct status code.
// This test should be removed when we implement the required support
long timestamp = System.currentTimeMillis();
final String modelName = getClass().getSimpleName() + timestamp;
final String prefix = "prefix" + timestamp;
final String uri = "uriNamespace" + timestamp;
final String aspectName = prefix + QName.NAMESPACE_PREFIX + "testAspec";
final String typeName = prefix + QName.NAMESPACE_PREFIX + "testType";
final String associationName = prefix + QName.NAMESPACE_PREFIX + "testAssociation";
M2Model model = M2Model.createModel(prefix + QName.NAMESPACE_PREFIX + modelName);
model.createNamespace(uri, prefix);
model.setAuthor("John Doe");
model.createAspect(aspectName);
model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
M2Type type = model.createType(typeName);
// Add 'association' not supported yet.
M2Association association = type.createAssociation(associationName);
association.setSourceMandatory(false);
association.setSourceMany(false);
association.setTargetMandatory(false);
association.setTargetClassName("cm:content");
ByteArrayOutputStream xml = new ByteArrayOutputStream();
model.toXML(xml);
ZipEntryContext context = new ZipEntryContext(modelName + ".xml", xml.toByteArray());
File zipFile = createZip(context);
PostRequest postRequest = buildMultipartPostRequest(zipFile);
// <associations> element is not supported yet
sendRequest(postRequest, 409);
type.removeAssociation(associationName);
// Add 'mandatory-aspect' not supported yet.
type.addMandatoryAspect(aspectName);
xml = new ByteArrayOutputStream();
model.toXML(xml);
context = new ZipEntryContext(modelName + ".xml", xml.toByteArray());
zipFile = createZip(context);
postRequest = buildMultipartPostRequest(zipFile);
// <mandatory-aspects> element is not supported yet
sendRequest(postRequest, 409);
}
Aggregations