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;
}
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);
}
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");
}
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;
}
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;
}
Aggregations