Search in sources :

Example 51 with Comment

use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.

the class SampleTestObjectCreator method createAlternativeComment.

public static Comment createAlternativeComment(String apiId) {
    Comment comment = new Comment();
    comment.setUuid(UUID.randomUUID().toString());
    comment.setApiId(apiId);
    comment.setCommentText("this is a sample comment - alternative");
    comment.setCommentedUser("admin");
    comment.setUpdatedUser("admin");
    comment.setCreatedTime(LocalDateTime.now());
    comment.setUpdatedTime(LocalDateTime.now());
    return comment;
}
Also used : Comment(org.wso2.carbon.apimgt.core.models.Comment)

Example 52 with Comment

use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.

the class CommentMappingUtilTestCase method testFromCommentToDTO.

@Test
public void testFromCommentToDTO() {
    String commentUUID = UUID.randomUUID().toString();
    Comment comment = new Comment();
    comment.setUuid(commentUUID);
    comment.setCommentedUser("commentedUser");
    comment.setCommentText("this is a comment");
    comment.setCreatedUser("createdUser");
    comment.setUpdatedUser("updatedUser");
    comment.setCreatedTime(LocalDateTime.now().minusHours(1));
    comment.setUpdatedTime(LocalDateTime.now());
    CommentDTO commentDTO = commentMappingUtil.fromCommentToDTO(comment);
    Assert.assertEquals(commentDTO.getCommentId().toString(), commentUUID);
}
Also used : Comment(org.wso2.carbon.apimgt.core.models.Comment) CommentDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CommentDTO) Test(org.junit.Test)

Example 53 with Comment

use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.

the class CommentMappingUtilTestCase method testFromDTOToComment.

@Test
public void testFromDTOToComment() {
    String apiID = UUID.randomUUID().toString();
    String username = "user";
    CommentDTO commentDTO = new CommentDTO();
    commentDTO.setApiId(apiID);
    commentDTO.setCommentText("comment text");
    commentDTO.setCreatedBy("creater");
    commentDTO.setLastUpdatedBy("updater");
    Comment comment = commentMappingUtil.fromDTOToComment(commentDTO, username);
    Assert.assertEquals(comment.getApiId(), apiID);
    Assert.assertEquals(comment.getCommentText(), "comment text");
}
Also used : Comment(org.wso2.carbon.apimgt.core.models.Comment) CommentDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CommentDTO) Test(org.junit.Test)

Example 54 with Comment

use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.

the class ApiDAOImpl method constructCommentFromResultSet.

/**
 * Constructs a comment object from a resulset object
 *
 * @param rs result set object
 * @return
 * @throws SQLException
 */
private Comment constructCommentFromResultSet(ResultSet rs) throws SQLException {
    Comment comment = new Comment();
    comment.setUuid(rs.getString("UUID"));
    comment.setCommentText(rs.getString("COMMENT_TEXT"));
    comment.setCommentedUser(rs.getString("USER_IDENTIFIER"));
    comment.setApiId(rs.getString("API_ID"));
    comment.setCreatedUser(rs.getString("CREATED_BY"));
    comment.setCreatedTime(rs.getTimestamp("CREATED_TIME").toLocalDateTime());
    comment.setUpdatedUser(rs.getString("UPDATED_BY"));
    comment.setUpdatedTime(rs.getTimestamp("LAST_UPDATED_TIME").toLocalDateTime());
    return comment;
}
Also used : Comment(org.wso2.carbon.apimgt.core.models.Comment)

Example 55 with Comment

use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.

the class APIStoreImpl method getCommentByUUID.

@Override
public Comment getCommentByUUID(String commentId, String apiId) throws APICommentException, APIMgtResourceNotFoundException {
    Comment comment;
    try {
        failIfApiNotExists(apiId);
        comment = getApiDAO().getCommentByUUID(commentId, apiId);
        if (comment == null) {
            String errorMsg = "Couldn't find comment with comment_id - " + commentId + " for api_id " + apiId;
            log.error(errorMsg);
            throw new APIMgtResourceNotFoundException(errorMsg, ExceptionCodes.COMMENT_NOT_FOUND);
        }
    } catch (APIMgtDAOException e) {
        String errorMsg = "Error occurred while retrieving comment for comment_id " + commentId + " for api_id " + apiId;
        log.error(errorMsg, e);
        throw new APICommentException(errorMsg, e, e.getErrorHandler());
    }
    return comment;
}
Also used : Comment(org.wso2.carbon.apimgt.core.models.Comment) APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIMgtResourceNotFoundException(org.wso2.carbon.apimgt.core.exception.APIMgtResourceNotFoundException) APICommentException(org.wso2.carbon.apimgt.core.exception.APICommentException)

Aggregations

Comment (org.wso2.carbon.apimgt.core.models.Comment)36 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)28 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)23 Test (org.testng.annotations.Test)22 SQLException (java.sql.SQLException)18 BeforeTest (org.testng.annotations.BeforeTest)18 API (org.wso2.carbon.apimgt.core.models.API)17 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)17 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)16 Comment (org.wso2.carbon.apimgt.api.model.Comment)16 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)15 PreparedStatement (java.sql.PreparedStatement)13 Connection (java.sql.Connection)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 ArrayList (java.util.ArrayList)10 CommentDTO (org.wso2.carbon.apimgt.rest.api.store.dto.CommentDTO)9 URI (java.net.URI)8 URISyntaxException (java.net.URISyntaxException)8 Test (org.junit.Test)8