Search in sources :

Example 6 with UpdateComment

use of org.wso2.carbon.humantask.core.engine.commands.UpdateComment in project carbon-apimgt by wso2.

the class APIStoreImplTestCase method testUpdateComment.

@Test(description = "Update comment")
public void testUpdateComment() throws APIManagementException {
    ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
    APIStore apiStore = getApiStoreImpl(apiDAO);
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Mockito.when(apiDAO.isAPIExists(api.getId())).thenReturn(true);
    Comment comment = SampleTestObjectCreator.createDefaultComment(api.getId());
    Mockito.when(apiDAO.getCommentByUUID(UUID, api.getId())).thenReturn(comment);
    apiStore.updateComment(comment, UUID, api.getId(), "admin");
    Mockito.verify(apiDAO, Mockito.times(1)).isAPIExists(api.getId());
    Mockito.verify(apiDAO, Mockito.times(1)).updateComment(comment, UUID, api.getId());
}
Also used : Comment(org.wso2.carbon.apimgt.core.models.Comment) CompositeAPI(org.wso2.carbon.apimgt.core.models.CompositeAPI) API(org.wso2.carbon.apimgt.core.models.API) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) APIStore(org.wso2.carbon.apimgt.core.api.APIStore) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 7 with UpdateComment

use of org.wso2.carbon.humantask.core.engine.commands.UpdateComment in project carbon-business-process by wso2.

the class TaskOperationsImpl method updateComment.

/**
 * Updates the identified comment with the supplied new text.
 * @param taskIdURI : task identifier
 * @param commentId : comment identifier
 * @param s : new comment in plain text.
 * @throws IllegalStateFault
 * @throws IllegalOperationFault
 * @throws IllegalArgumentFault
 * @throws IllegalAccessFault
 */
public void updateComment(final URI taskIdURI, final URI commentId, final String s) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                UpdateComment updateCommentCommand = new UpdateComment(getCaller(), taskId, new Long(commentId.toString()), s);
                updateCommentCommand.execute();
                return null;
            }
        });
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : UpdateComment(org.wso2.carbon.humantask.core.engine.commands.UpdateComment) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Aggregations

Comment (org.wso2.carbon.apimgt.core.models.Comment)5 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)4 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)3 SQLException (java.sql.SQLException)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 BeforeTest (org.testng.annotations.BeforeTest)2 Test (org.testng.annotations.Test)2 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)2 APICommentException (org.wso2.carbon.apimgt.core.exception.APICommentException)2 API (org.wso2.carbon.apimgt.core.models.API)2 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)2 CommentDTO (org.wso2.carbon.apimgt.rest.api.store.dto.CommentDTO)2 Request (org.wso2.msf4j.Request)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.core.exception.APIMgtResourceNotFoundException)1 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)1 UpdateComment (org.wso2.carbon.humantask.core.engine.commands.UpdateComment)1