REPO-2705 / MNT-17961: Cannot create new Alfresco NON-versioned document with CMIS API Calls - test

This commit is contained in:
Ancuta Morarasu
2017-09-08 16:20:44 +03:00
parent 3c98f67e1a
commit 28366861fc

View File

@@ -3668,6 +3668,64 @@ public class CMISTest
AuthenticationUtil.popAuthentication();
}
}
@Test
public void testCreateDocWithVersioningStateNone() throws Exception
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
try
{
// get repository id
final String repositoryId = withCmisService(new CmisServiceCallback<String>()
{
@Override
public String execute(CmisService cmisService)
{
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0);
final String repositoryId = repo.getId();
return repositoryId;
}
}, CmisVersion.CMIS_1_1);
final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>()
{
@Override
public NodeRef execute(CmisService cmisService)
{
final PropertiesImpl properties = new PropertiesImpl();
String objectTypeId = "cmis:document";
properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, objectTypeId));
String fileName = "textFile" + GUID.generate();
properties.addProperty(new PropertyStringImpl(PropertyIds.NAME, fileName));
final ContentStreamImpl contentStream = new ContentStreamImpl(fileName, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Simple text plain document");
String nodeId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.NONE, null, null);
return new NodeRef(nodeId.substring(0, nodeId.indexOf(';')));
}
}, CmisVersion.CMIS_1_1);
// check versioning properties
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
{
@Override
public List<Void> execute() throws Throwable
{
assertTrue(nodeService.exists(documentNodeRef));
assertFalse(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE));
return null;
}
});
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
/**
* MNT-14951: Test that the list of parents can be retrieved for a folder.