Merged 5.1-MC1 (5.1.0) to HEAD (5.1)

119558 gcornwell: Merged code coverage improvements to 5.1-MC1 (5.1.0)
      r117774 gjames: RA-567: Increase /workflow/processes API code coverage
      r117773 gjames: RA-567: /workflow/processes coverage, removed unused ActivitiTypeConverter
      r116883 gjames: RA-531: reapplied change after merge, for MultiTServiceImpl test coverage
      r116629 gjames: RA-568 Increase /workflow/process-definitions API code coverage
      r116574 gjames: RA-569 Increase /workflow/tasks API code coverage
      r116286 gjames: RA-567: Increase /workflow/processes API code coverage
      r115853 gjames: RA-566: Increasing /people api coverage (description field)
      r115811 gjames: RA-566: Increasing /people api coverage
      r113007 gjames: Adding additional test coverage for DictionaryNamespaceComponent and DynamicNamespacePrefixResolver RA-521
      r113006 gjames: Adding additional test coverage for DictionaryNamespaceComponent and DictionaryComponent RA-514
      r112969 gjames: Adding additional test coverage for TemplateServiceImpl RA-530
      r112960 gjames: Alternative test approach for ModuleServiceImpl RA-520
      r112703 gjames: Adding additional test coverage for NodeLocatorService RA-522
      r112702 gjames: Adding additional test coverage for JobLockServiceImpl RA-516
      r112699 gjames: Adding additional test coverage for ModuleServiceImpl RA-520
      r112508 gjames: Adding additional test coverage for RenditionServiceImpl RA-526
      r112476 gjames: Adding additional test coverage for ContentServiceImpl RA-513
      r112475 gjames: Adding additional test coverage for MimetypeMap RA-519
      r112238 gjames: Adding additional test coverage for MimetypeMap RA-519
      r112237 gjames: Adding additional test coverage for TaggingService RA-529
      r112236 gjames: Adding additional test coverage for MultiTServiceImpl RA-531
      r112206 gjames: Adding additional test coverage for ContentServiceImpl RA-513
      r112167 gcornwell: RA-523: Increase NodeService code coverage (removed redundant code that was testing a version store we no longer use)
      r112102 gjames: Reverted changes to PermissionServiceImpl for RA-524
      r112048 gjames: Temporarily removed some PermissionServiceImpl code. I need to put it back.
      r111620 gjames: Adding additional test coverage for PermissionService RA-524
      r111619 gjames: Added some @Override to make Sonar happier
      r111456 gjames: Adding additional test coverage for AuthenticationService RA-509
      r111427 gjames: Adding additional test coverage for AttributeService RA-509
      r111317 gjames: Adding additional test coverage for WorkflowService RA-533


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@119945 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jean-Pierre Huynh
2015-12-10 10:35:05 +00:00
parent e0ff2eacee
commit f8fa061ba3
14 changed files with 297 additions and 223 deletions

View File

@@ -35,5 +35,5 @@ public interface People
* @throws NoSuchPersonException if personId does not exist
*/
Person getPerson(final String personId);
Person updatePerson(String personId, Person person);
//Person updatePerson(String personId, Person person);
}

View File

@@ -285,7 +285,7 @@ public class PeopleImpl implements People
return person;
}
/**
private void addToMap(Map<QName, Serializable> properties, QName name, Serializable value)
{
// if(name != null && value != null)
@@ -355,4 +355,5 @@ public class PeopleImpl implements People
return getPerson(personId);
}
*/
}

View File

@@ -62,7 +62,6 @@ import org.alfresco.repo.workflow.WorkflowPropertyHandlerRegistry;
import org.alfresco.repo.workflow.WorkflowQNameConverter;
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
import org.alfresco.repo.workflow.activiti.ActivitiNodeConverter;
import org.alfresco.repo.workflow.activiti.ActivitiTypeConverter;
import org.alfresco.repo.workflow.activiti.ActivitiUtil;
import org.alfresco.repo.workflow.activiti.properties.ActivitiPropertyConverter;
import org.alfresco.rest.antlr.WhereClauseParser;
@@ -141,7 +140,6 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
protected WorkflowPropertyHandlerRegistry handlerRegistry;
protected WorkflowAuthorityManager authorityManager;
protected ActivitiPropertyConverter propertyConverter;
protected ActivitiTypeConverter typeConverter;
public void setAuthorityDAO(AuthorityDAO authorityDAO)
{
@@ -256,15 +254,6 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
}
return propertyConverter;
}
protected ActivitiTypeConverter getTypeConverter()
{
if (typeConverter == null)
{
typeConverter = new ActivitiTypeConverter(activitiProcessEngine, getWorkflowFactory(), getPropertyConverter(), deployWorkflowsInTenant);
}
return typeConverter;
}
@Override
public CollectionWithPagingInfo<ProcessInfo> getProcesses(Parameters parameters)

View File

@@ -36,6 +36,8 @@ import org.activiti.engine.history.HistoricVariableInstance;
import org.activiti.engine.task.DelegationState;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.IdentityLinkType;
import org.activiti.engine.task.TaskInfo;
import org.activiti.engine.task.TaskInfoQuery;
import org.activiti.engine.task.TaskQuery;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.i18n.MessageService;
@@ -285,100 +287,8 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
}
List<QueryVariableHolder> variableProperties = propertyWalker.getVariableProperties();
if (variableProperties != null)
{
for (QueryVariableHolder queryVariableHolder : variableProperties)
{
if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES)
{
if (queryVariableHolder.getPropertyValue() instanceof String == false)
{
throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName());
}
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else
{
throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() +
" can only be used with an =, not comparison type");
}
}
}
setQueryUsingVariables(query, variableProperties);
// Add tenant-filtering
if(tenantService.isEnabled()) {
query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
@@ -467,100 +377,8 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
}
List<QueryVariableHolder> variableProperties = propertyWalker.getVariableProperties();
if (variableProperties != null)
{
for (QueryVariableHolder queryVariableHolder : variableProperties)
{
if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES)
{
if (queryVariableHolder.getPropertyValue() instanceof String == false)
{
throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName());
}
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else
{
throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() +
" can only be used with an =, not comparison type");
}
}
}
setQueryUsingVariables(query, variableProperties);
// Add tenant filtering
if (tenantService.isEnabled())
{
@@ -598,7 +416,104 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
private void setQueryUsingVariables(TaskInfoQuery<?, ? extends TaskInfo> query, List<QueryVariableHolder> variableProperties)
{
if (variableProperties != null)
{
for (QueryVariableHolder queryVariableHolder : variableProperties)
{
if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES)
{
if (queryVariableHolder.getPropertyValue() instanceof String == false)
{
throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName());
}
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
}
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION)
{
if (queryVariableHolder.isGlobalScope())
{
query.processVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
else
{
query.taskVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
}
}
else
{
throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() +
" can only be used with an =, not comparison type");
}
}
}
}
protected void addVariables(Task task, Boolean includeProcessVariables, Boolean includeTaskVariables,
Map<String, Object> processVariables, Map<String, Object> taskVariables, Map<String, TypeDefinition> definitionTypeMap)
{

View File

@@ -133,7 +133,7 @@ public class InvitationWebScriptTest extends BaseWebScriptTest
ppOne.put(ContentModel.PROP_EMAIL, email);
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
NodeRef person = personService.createPerson(ppOne);
String avatarUrl = makeAvatar(person);
String avatarUrl = makeAvatar(nodeService,person);
// Create expected user properties
HashMap<String, String> properties = new HashMap<String, String>(4);
@@ -511,7 +511,7 @@ public class InvitationWebScriptTest extends BaseWebScriptTest
}
}
private String makeAvatar(final NodeRef person)
public static String makeAvatar(final NodeService nodeService, final NodeRef person)
{
nodeService.addAspect(person, ContentModel.ASPECT_PREFERENCES, null);
ChildAssociationRef assoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, avatarQName,

View File

@@ -32,6 +32,7 @@ import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.test_category.OwnJVMTestsCategory;
@@ -125,7 +126,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
public void testCreateThumbnail() throws Exception
{
// Check for pdfToSWF transformation before doing test
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null)
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH, new TransformationOptions()) != null)
{
String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnails";

View File

@@ -6,6 +6,7 @@ import org.alfresco.service.cmr.site.SiteVisibility;
public abstract class EnterpriseTestFixture extends AbstractTestFixture
{
public static final String WITH_AVATAR = "withAvatar"; //If you set PersonInfo instantmsg to WITH_AVATAR, an avatar gets created.
public EnterpriseTestFixture(String[] configLocations, String[] classLocations, int port, String contextPath,
String servletName, int numMembersPerSite, boolean cleanup)
{
@@ -37,10 +38,10 @@ public abstract class EnterpriseTestFixture extends AbstractTestFixture
addPerson(new PersonInfo("David", "Smith", "david.smith", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("Bob", "Jones", "bob.jones", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("Bill", "Grainger", "bill.grainger", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("Bill", "Grainger", "bill.grainger", "password", null, "skype", "location", "telephone", "mob", WITH_AVATAR, "google"));
addPerson(new PersonInfo("Jill", "Fry", "jill.fry", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("Elvis", "Presley", "elvis.presley", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("John", "Lennon", "john.lennon", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("Elvis", "Presley", "elvis.presley", "password", null, "skype", "location", "telephone", "mob", WITH_AVATAR, "google"));
addPerson(new PersonInfo("John", "Lennon", "john.lennon", "password", null, "skype", "location", "telephone", "mob", WITH_AVATAR, "google"));
addPerson(new PersonInfo("George", "Harrison", "george.harrison", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("David", "Bowie", "david.bowie", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));
addPerson(new PersonInfo("Ford", "Prefect", "ford.prefect", "password", null, "skype", "location", "telephone", "mob", "instant", "google"));

View File

@@ -47,6 +47,7 @@ import org.alfresco.query.PagingResults;
import org.alfresco.repo.activities.feed.FeedGenerator;
import org.alfresco.repo.activities.feed.cleanup.FeedCleaner;
import org.alfresco.repo.activities.post.lookup.PostLookup;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.cleanup.ContentStoreCleaner;
import org.alfresco.repo.domain.activities.ActivityFeedEntity;
import org.alfresco.repo.domain.activities.ActivityPostDAO;
@@ -56,6 +57,7 @@ import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
import org.alfresco.repo.model.filefolder.HiddenAspect;
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
import org.alfresco.repo.node.index.NodeIndexer;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.site.SiteDoesNotExistException;
@@ -68,6 +70,7 @@ import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.repo.web.scripts.invitation.InvitationWebScriptTest;
import org.alfresco.rest.api.Activities;
import org.alfresco.rest.api.impl.node.ratings.RatingScheme;
import org.alfresco.rest.api.tests.client.data.Activity;
@@ -364,7 +367,30 @@ public class RepoService
{
lockService.unlock(nodeRef);
}
public NodeRef addUserDescription(final String personId, final TestNetwork network, final String personDescription)
{
return AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
{
//@Override
public NodeRef doWork() throws Exception
{
NodeRef userRef = personService.getPersonOrNull(personId);
if (userRef == null)
{
throw new AuthenticationException("User name does not exist: " + personId);
}
ContentWriter writer = contentService.getWriter(userRef, ContentModel.PROP_PERSONDESC, true);
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
writer.putContent(personDescription);
log("Updated person description " + personId + (network != null ? " in network " + network : ""));
return userRef;
}
});
}
public TestPerson createUser(final PersonInfo personInfo, final String username, final TestNetwork network)
{
return AuthenticationUtil.runAsSystem(new RunAsWork<TestPerson>()
@@ -390,11 +416,17 @@ public class RepoService
});
}
personService.createPerson(props);
NodeRef createdPerson = personService.createPerson(props);
// create authentication to represent user
authenticationService.createAuthentication(username, personInfo.getPassword().toCharArray());
if (EnterpriseTestFixture.WITH_AVATAR.equals(personInfo.getInstantmsg()))
{
InvitationWebScriptTest.makeAvatar(nodeService,createdPerson);
log("Made avatar for " + testPerson.getId() + (network != null ? " in network " + network : ""));
}
log("Created person " + testPerson.getId() + (network != null ? " in network " + network : ""));
publicApiContext.addUser(testPerson.getId());
@@ -1301,6 +1333,19 @@ public class RepoService
return person;
}
public NodeRef addUserDescription(final String personId, final String personDescription)
{
NodeRef personRef = TenantUtil.runAsTenant(new TenantRunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
return RepoService.this.addUserDescription(personId, TestNetwork.this, personDescription);
}
}, getId());
return personRef;
}
public TestPerson createUser(final PersonInfo personInfo)
{
final String username = publicApiContext.createUserName(personInfo.getUsername(), getId());
@@ -1746,7 +1791,7 @@ public class RepoService
public TestPerson(String firstName, String lastName, String username, String password, Company company, TestNetwork defaultAccount, String skype, String location, String tel,
String mob, String instantmsg, String google)
{
super(username, username, true, firstName, lastName, company, skype, location, tel, mob, instantmsg, google);
super(username, username, true, firstName, lastName, company, skype, location, tel, mob, instantmsg, google, null);
this.password = password;
this.enabled = true;
this.defaultAccount = defaultAccount;

View File

@@ -1,10 +1,12 @@
package org.alfresco.rest.api.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
@@ -73,5 +75,15 @@ public class TestPeople extends EnterpriseTestApi
{
assertEquals(HttpStatus.SC_UNAUTHORIZED, e.getHttpResponse().getStatusCode());
}
RepoService.TestPerson testP = account1.createUser();
String personId = testP.getId();
String desc = "<B>Nice person</B>";
account1.addUserDescription(personId, desc);
publicApiClient.setRequestContext(new RequestContext(account1.getId(), personId));
Person resp = publicApiClient.people().getPerson(personId);
assertEquals(resp.getId(), personId);
assertEquals(resp.getDescription(), desc);
}
}

View File

@@ -36,12 +36,13 @@ public class Person implements Serializable, Comparable<Person>, ExpectedCompari
private String mob;
private String instantmsg;
private String google;
private String description;
private static Collator collator = Collator.getInstance();
public Person(String id, String username, Boolean enabled, String firstName, String lastName,
Company company, String skype, String location, String tel,
String mob, String instantmsg, String google)
String mob, String instantmsg, String google, String description)
{
super();
if(id == null)
@@ -60,6 +61,7 @@ public class Person implements Serializable, Comparable<Person>, ExpectedCompari
this.mob = mob;
this.instantmsg = instantmsg;
this.google = google;
this.description = description;
}
public String getId()
@@ -165,7 +167,12 @@ public class Person implements Serializable, Comparable<Person>, ExpectedCompari
{
this.lastName = lastName;
}
public String getDescription()
{
return description;
}
@Override
public String toString()
{
@@ -181,6 +188,7 @@ public class Person implements Serializable, Comparable<Person>, ExpectedCompari
+ (mob != null ? "mob=" + mob + ", " : "")
+ (instantmsg != null ? "instantmsg=" + instantmsg + ", " : "")
+ (google != null ? "google=" + google + ", " : "")
+ (description != null ? "description=" + description + ", " : "")
+ "]";
}
@@ -219,7 +227,8 @@ public class Person implements Serializable, Comparable<Person>, ExpectedCompari
String userId = (String)jsonObject.get("id");
String firstName = (String)jsonObject.get("firstName");
String lastName = (String)jsonObject.get("lastName");
Boolean emailNotificationsEnabled = (Boolean)jsonObject.get("emailNotificationsEnabled");
String description = (String)jsonObject.get("description");
JSONObject companyJSON = (JSONObject)jsonObject.get("company");
Company company = null;
if(companyJSON != null)
@@ -234,13 +243,13 @@ public class Person implements Serializable, Comparable<Person>, ExpectedCompari
String companyEmail = (String)companyJSON.get("email");
company = new Company(organization, address1, address2, address3, postcode, companyTelephone, fax, companyEmail);
}
Person person = new Person(userId, email, enabled, firstName, lastName, company, skypeId, location, telephone, mobile, instantMessageId, googleId);
Person person = new Person(userId, email, enabled, firstName, lastName, company, skypeId, location, telephone, mobile, instantMessageId, googleId, description);
return person;
}
public Person restriced()
{
Person p = new Person(getId(), getEmail(), getEnabled(), getFirstName(), getLastName(), null, null, null, null, null, null, null);
Person p = new Person(getId(), getEmail(), getEnabled(), getFirstName(), getLastName(), null, null, null, null, null, null, null, null);
return p;
}

View File

@@ -388,9 +388,9 @@ public class ProcessDefinitionWorkflowApiTest extends EnterpriseWorkflowTestApi
.createProcessDefinitionQuery()
.processDefinitionKey(adhocKey)
.singleResult();
assertNotNull(activitiDefinition);
// Get a single process definitions
ProcessDefinitionsClient processDefinitionsClient = publicApiClient.processDefinitionsClient();
ProcessDefinition adhocDefinition = processDefinitionsClient.findProcessDefinitionById(activitiDefinition.getId());
@@ -415,7 +415,35 @@ public class ProcessDefinitionWorkflowApiTest extends EnterpriseWorkflowTestApi
assertEquals(activitiDefinition.getId(), adhocDefinition.getId());
assertEquals("activitiAdhoc", adhocDefinition.getKey());
}
@Test
public void testGetProcessDefinitionsImage() throws Exception
{
RequestContext requestContext = initApiClientWithTestUser();
ProcessDefinitionsClient processDefinitionsClient = publicApiClient.processDefinitionsClient();
String adhocKey = createProcessDefinitionKey("activitiAdhoc", requestContext);
org.activiti.engine.repository.ProcessDefinition activitiDefinition = activitiProcessEngine.getRepositoryService()
.createProcessDefinitionQuery()
.processDefinitionKey(adhocKey)
.singleResult();
assertNotNull(activitiDefinition);
try
{
HttpResponse response = processDefinitionsClient.findImageById(activitiDefinition.getId());
fail("Exception expected");
}
catch(PublicApiException expected)
{
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), expected.getHttpResponse().getStatusCode());
assertTrue(expected.getMessage().contains("No image available"));
}
}
@Test
public void testGetProcessDefinitionByIdUnexisting() throws Exception
{

View File

@@ -657,7 +657,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
assertNotNull(processList);
assertEquals(3, processList.getList().size());
assertNull(processList.getList().get(0).getProcessVariables());
paramMap = new HashMap<String, String>();
paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc2')");
processList = processesClient.getProcesses(paramMap);
@@ -737,7 +737,31 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(3, processList.getList().size());
paramMap = new HashMap<String, String>();
paramMap.put("where", "(variables/bpm_priority > 'd:int 1')");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(0, processList.getList().size());
paramMap = new HashMap<String, String>();
paramMap.put("where", "(variables/bpm_priority >= 'd:int 1')");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(3, processList.getList().size());
paramMap = new HashMap<String, String>();
paramMap.put("where", "(variables/bpm_priority < 'd:int 5')");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(3, processList.getList().size());
paramMap = new HashMap<String, String>();
paramMap.put("where", "(variables/bpm_priority <= 'd:int 4')");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(3, processList.getList().size());
paramMap = new HashMap<String, String>();
paramMap.put("where", "(variables/bpm_priority = 'd_int 5')");
processList = processesClient.getProcesses(paramMap);
@@ -994,7 +1018,31 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
assertEquals(process2.getId(), processList.getList().get(0).getId());
assertEquals(process1.getId(), processList.getList().get(1).getId());
assertEquals(process3.getId(), processList.getList().get(2).getId());
paramMap.put("orderBy", "startedAt ASC");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
paramMap.put("orderBy", "endedAt ASC");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
paramMap.put("orderBy", "durationInMillis ASC");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
// sort on more than 1.
paramMap.put("orderBy", "startedAt, endedAt");
try
{
processList = processesClient.getProcesses(paramMap);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.BAD_REQUEST.value(), e.getHttpResponse().getStatusCode());
}
// sort on non existing key
paramMap.put("orderBy", "businessKey2 ASC");
try

View File

@@ -1541,6 +1541,7 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi
// Test status filtering - completed
params.clear();
params.put("where", "(status = 'completed' AND processId = '" + processInstance.getId() + "')");
params.put("orderBy", "dueAt DESC");
assertTasksPresentInTaskQuery(params, tasksClient, false, completedTask.getId());
// Test status filtering - any
@@ -1575,6 +1576,7 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi
assertTasksPresentInTaskQuery(params, tasksClient, activeTask.getId());
params.put("where", "(status = 'completed' AND assignee = '" + anotherUserId + "')");
params.put("orderBy", "endedAt");
assertTasksPresentInTaskQuery(params, tasksClient, completedTask.getId());
params.put("where", "(status = 'any' AND assignee = '" + anotherUserId + "')");
@@ -1870,6 +1872,18 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi
{
assertEquals(HttpStatus.BAD_REQUEST.value(), expected.getHttpResponse().getStatusCode());
}
params.clear();
params.put("where", "(status = 'completed' AND processDefinitionName = 'Adhoc Activiti Process')");
JSONObject response = publicApiClient.processesClient().getTasks(processInstance.getId(), params);
assertNotNull(response);
JSONObject paginationJSON = (JSONObject) response.get("pagination");
assertEquals(1l, paginationJSON.get("count"));
params.clear();
params.put("where", "(status = 'any' AND variables/numberVar < 'd:int 5')");
assertEquals(0, getResultSizeForTaskQuery(params, tasksClient));
}
finally
{
@@ -2087,6 +2101,12 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi
assertEquals(taskList.get(0).getId(), taskJSON.get("id"));
taskJSON = (JSONObject) ((JSONObject) tasksListJSON.get(5)).get("entry");
assertEquals(taskList.get(numberOfTasks - 1).getId(), taskJSON.get("id"));
params.put("orderBy", "dueAt DESC");
tasksResponseJSON = tasksClient.findTasks(params);
tasksListJSON = (JSONArray) tasksResponseJSON.get("entries");
assertEquals(6, tasksListJSON.size());
}
finally
{

View File

@@ -127,7 +127,12 @@ public class WorkflowApiClient extends PublicApiClient
JSONObject entry = (JSONObject) response.getJsonResponse().get("entry");
return ProcessDefinitionParser.INSTANCE.parseEntry(entry);
}
public HttpResponse findImageById(String processDefinitionId) throws PublicApiException
{
return getSingle("process-definitions", processDefinitionId, "image", null, "Failed to get process definition");
}
public JSONObject findStartFormModel(String processDefinitionId) throws PublicApiException
{
HttpResponse response = getAll("process-definitions", processDefinitionId, "start-form-model", null, null,