├── benten-hackernews-bolt ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ └── benten.properties │ │ └── java │ │ │ ├── BentenHackerNewsApplication.java │ │ │ └── com │ │ │ └── intuit │ │ │ └── benten │ │ │ └── hackernews │ │ │ ├── model │ │ │ ├── HackernewsItemIdList.java │ │ │ └── HackernewsSetRange.java │ │ │ ├── exceptions │ │ │ └── BentenHackernewsException.java │ │ │ ├── actionhandlers │ │ │ ├── HackernewsGetNewStoriesActionHandler.java │ │ │ ├── HackernewsGetTopStoriesActionHandler.java │ │ │ ├── HackernewsGetBestStoriesActionHandler.java │ │ │ ├── HackernewsGetLatestAskStoriesActionHandler.java │ │ │ ├── HackernewsGetLatestJobStoriesActionHandler.java │ │ │ └── HackernewsGetLatestShowStoriesActionHandler.java │ │ │ ├── properties │ │ │ └── HackernewsProperties.java │ │ │ └── utils │ │ │ ├── FetchHackernewsItemTask.java │ │ │ ├── HackernewsExecutorService.java │ │ │ └── SlackHackerNewsMessageRenderer.java │ └── test │ │ └── resources │ │ └── benten.properties └── pom.xml ├── benten-mock └── src │ └── main │ ├── resources │ ├── error-mock.feature │ ├── increment.js │ ├── board-get-response.json │ ├── jenkins-mock.feature │ └── transitions.json │ └── java │ └── com │ └── intuit │ └── benten │ └── mock │ └── MockFeatureServerRunner.java ├── benten-starter ├── src │ └── main │ │ ├── resources │ │ ├── error-mock.feature │ │ ├── increment.js │ │ ├── board-get-response.json │ │ ├── jenkins-mock.feature │ │ ├── benten.properties │ │ └── transitions.json │ │ └── java │ │ └── BentenStarterApplication.java └── Dockerfile ├── benten-jira-bolt └── src │ ├── test │ ├── java │ │ └── com │ │ │ └── intuit │ │ │ └── benten │ │ │ └── jira │ │ │ ├── error-mock.feature │ │ │ ├── increment.js │ │ │ ├── board-get-response.json │ │ │ ├── JiraClientIntegrationTester.java │ │ │ ├── FeatureServerRunner.java │ │ │ ├── JiraClientUsingMockTest.java │ │ │ ├── http │ │ │ ├── JiraClientTest.java │ │ │ ├── JiraAgileClientTest.java │ │ │ └── JiraGhClientTest.java │ │ │ ├── actionhandlers │ │ │ ├── JiraActionHandlerTest.java │ │ │ ├── JiraVelocityActionHandlerTest.java │ │ │ ├── CycleTimeCalulatorTest.java │ │ │ ├── JiraCycleTimeActionHandlerTest.java │ │ │ ├── JiraAssignIssuesToUserActionHandlerTest.java │ │ │ └── JiraCreateIssueActionHandlerTest.java │ │ │ ├── conversationcatalysts │ │ │ └── JiraCreateIssueConversationCatalystTest.java │ │ │ └── transitions.json │ └── resources │ │ └── benten.properties │ └── main │ ├── java │ ├── com │ │ └── intuit │ │ │ └── benten │ │ │ └── jira │ │ │ ├── actionhandlers │ │ │ ├── helpers │ │ │ │ └── JiraActionHelper.java │ │ │ ├── ThreeParameterFunction.java │ │ │ ├── JiraActionParameters.java │ │ │ ├── JiraActions.java │ │ │ ├── JiraHelpActionHandler.java │ │ │ └── JiraCommentActionHandler.java │ │ │ ├── model │ │ │ ├── agile │ │ │ │ ├── Board.java │ │ │ │ └── AgileResource.java │ │ │ ├── ghc │ │ │ │ ├── StatField.java │ │ │ │ ├── GhResource.java │ │ │ │ ├── EstimateSum.java │ │ │ │ ├── SprintReport.java │ │ │ │ ├── EstimateStatistic.java │ │ │ │ └── Sprint.java │ │ │ ├── ChangeLog.java │ │ │ ├── Visibility.java │ │ │ ├── Votes.java │ │ │ ├── Priority.java │ │ │ ├── Security.java │ │ │ ├── ProjectCategory.java │ │ │ ├── Resolution.java │ │ │ ├── Transition.java │ │ │ ├── LinkType.java │ │ │ ├── JiraError.java │ │ │ ├── IssueLink.java │ │ │ ├── Component.java │ │ │ ├── ChangeLogEntry.java │ │ │ ├── Status.java │ │ │ ├── Watches.java │ │ │ ├── Version.java │ │ │ ├── IssueType.java │ │ │ ├── User.java │ │ │ ├── ChangeLogItem.java │ │ │ ├── Attachment.java │ │ │ ├── bentenjira │ │ │ │ └── Velocity.java │ │ │ ├── Comment.java │ │ │ ├── TimeTracking.java │ │ │ └── WorkLog.java │ │ │ ├── exceptions │ │ │ └── BentenJiraException.java │ │ │ ├── utils │ │ │ └── HelpItems.java │ │ │ ├── http │ │ │ ├── JiraAgileHttpHelper.java │ │ │ ├── JiraGhHttpHelper.java │ │ │ └── BentenHttpClient.java │ │ │ └── properties │ │ │ └── JiraProperties.java │ └── BentenJiraApplication.java │ └── resources │ └── benten.properties ├── benten-archetype ├── src │ └── main │ │ └── resources │ │ ├── archetype-resources │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── error-mock.feature │ │ │ ├── increment.js │ │ │ ├── board-get-response.json │ │ │ ├── benten.properties │ │ │ ├── jenkins-mock.feature │ │ │ └── transitions.json │ │ │ └── java │ │ │ └── BentenStarterApplication.java │ │ └── META-INF │ │ └── maven │ │ └── archetype-metadata.xml └── pom.xml ├── benten-core └── src │ ├── main │ ├── resources │ │ ├── benten.png │ │ ├── benten.properties │ │ └── logback.xml │ └── java │ │ └── com │ │ └── intuit │ │ └── benten │ │ ├── exceptions │ │ ├── AiException.java │ │ └── ImageGenerationException.java │ │ ├── rest │ │ ├── HelloController.java │ │ └── MockController.java │ │ ├── nlp │ │ ├── dialogflow │ │ │ └── DialogFlowActions.java │ │ └── NlpClient.java │ │ ├── channel │ │ └── slack │ │ │ ├── SlackUser.java │ │ │ ├── BentenHtmlToSlackMsgConverter.java │ │ │ └── SlackHelperPayload.java │ │ ├── properties │ │ ├── AiProperties.java │ │ ├── SlackProperties.java │ │ └── BentenProxyConfig.java │ │ ├── BentenApplication.java │ │ ├── renderers │ │ └── SlackMessageRenderer.java │ │ ├── converters │ │ └── HtmlToImageConverter.java │ │ └── handlers │ │ └── BentenConversationCatalystFactory.java │ └── test │ ├── java │ └── com │ │ └── intuit │ │ └── benten │ │ ├── channel │ │ └── slack │ │ │ └── SlackChannelTest.java │ │ ├── converters │ │ └── HtmlToImageConverterTest.java │ │ ├── rest │ │ └── HelloControllerTest.java │ │ └── ai │ │ └── dialogflow │ │ └── DialogFlowClientTest.java │ └── resources │ ├── benten.properties │ └── application-test.properties ├── .travis.yml ├── benten-flickr-bolt └── src │ ├── test │ ├── java │ │ └── com │ │ │ └── intuit │ │ │ └── benten │ │ │ ├── camera-by-brand.json │ │ │ ├── BaseFlickrTest.java │ │ │ ├── flickr │ │ │ └── helpers │ │ │ │ ├── FlickrResultBuilder.java │ │ │ │ └── FlickrMessageBuilder.java │ │ │ └── FlickrClientMockConfig.java │ └── resources │ │ └── benten.properties │ └── main │ ├── java │ ├── com │ │ └── intuit │ │ │ └── benten │ │ │ └── flickr │ │ │ ├── utils │ │ │ ├── SearchItems.java │ │ │ └── SearchUtils.java │ │ │ ├── exceptions │ │ │ └── BentenFlickrException.java │ │ │ ├── actionhandlers │ │ │ ├── FlickrActions.java │ │ │ ├── FlickrActionParamaters.java │ │ │ ├── FlickrTrendyPhotosActionHandler.java │ │ │ └── FlickrBrandCamerasActionHandler.java │ │ │ └── properties │ │ │ └── FlickrProperties.java │ └── BentenFlickrApplication.java │ └── resources │ └── benten.properties ├── benten-common ├── src │ └── main │ │ └── java │ │ └── com │ │ └── intuit │ │ └── benten │ │ └── common │ │ ├── exceptions │ │ ├── BentenException.java │ │ └── TableDimensionsException.java │ │ ├── actionhandlers │ │ ├── ActionHandlerFactory.java │ │ ├── BentenActionHandler.java │ │ ├── BentenHtmlResponse.java │ │ ├── BentenSlackField.java │ │ ├── BentenSlackResponse.java │ │ ├── BentenHandlerResponse.java │ │ └── BentenSlackAttachment.java │ │ ├── conversationcatalysts │ │ ├── ConversationCatalystFactory.java │ │ └── ConversationCatalyst.java │ │ ├── channel │ │ ├── Channel.java │ │ └── ChannelInformation.java │ │ ├── bentennlp │ │ ├── Question.java │ │ ├── Answer.java │ │ ├── Parameter.java │ │ └── ConversationFragment.java │ │ ├── annotations │ │ ├── ActionHandler.java │ │ └── BentenConversationCatalyst.java │ │ ├── constants │ │ └── SlackConstants.java │ │ ├── nlp │ │ └── BentenConversation.java │ │ ├── http │ │ └── IdleConnectionMonitorThread.java │ │ ├── model │ │ └── TableToHtmlConverter.java │ │ └── helpers │ │ └── BentenMessageHelper.java └── pom.xml ├── benten-jenkins-bolt └── src │ ├── main │ ├── java │ │ ├── com │ │ │ └── intuit │ │ │ │ └── benten │ │ │ │ └── jenkins │ │ │ │ ├── exceptions │ │ │ │ └── BentenJenkinsException.java │ │ │ │ ├── actionhandlers │ │ │ │ ├── JenkinsActionParameters.java │ │ │ │ ├── JenkinsActions.java │ │ │ │ ├── JenkinsHelpActionHandler.java │ │ │ │ ├── JenkinsBuildJobByJobNameActionHandler.java │ │ │ │ ├── JenkinsSearchJobByPrefixActionHandler.java │ │ │ │ ├── JenkinsJobDetailsByJobNameActionHandler.java │ │ │ │ └── JenkinsShowConsoleLogForBuildNumberActionHandler.java │ │ │ │ ├── utils │ │ │ │ └── HelpItems.java │ │ │ │ ├── properties │ │ │ │ └── JenkinsProperties.java │ │ │ │ └── model │ │ │ │ └── JenkinsJobBuildParameter.java │ │ └── BentenJenkinsApplication.java │ └── resources │ │ └── benten.properties │ └── test │ ├── java │ └── com │ │ └── intuit │ │ └── benten │ │ └── jenkins │ │ ├── FeatureServerRunner.java │ │ ├── jenkins-mock.feature │ │ ├── BaseJenkinsTest.java │ │ ├── helpers │ │ └── JenkinsMessageBuilder.java │ │ ├── actionhandlers │ │ ├── JenkinsSearchJobByPrefixActionHandleTest.java │ │ └── JenkinsJobDetailsByJobNameActionHandlerTest.java │ │ └── JenkinsClientMockConfig.java │ └── resources │ └── benten.properties ├── benten-weather-bolt ├── src │ ├── main │ │ ├── java │ │ │ └── com.intuit.benten │ │ │ │ ├── BentenWeatherApplication.java │ │ │ │ └── weather │ │ │ │ ├── properties │ │ │ │ └── WeatherProperties.java │ │ │ │ ├── client │ │ │ │ └── BentenWeatherClient.java │ │ │ │ └── actionhandlers │ │ │ │ └── BentenWeatherActionHandler.java │ │ └── resources │ │ │ └── benten.properties │ └── test │ │ ├── resources │ │ └── benten.properties │ │ └── java │ │ └── com │ │ └── intuit │ │ └── benten │ │ └── weather │ │ ├── client │ │ └── BentenWeatherClientTest.java │ │ └── actionhandlers │ │ └── BentenWeatherActionHandlerTest.java └── pom.xml ├── .gitignore ├── benten-examples └── pom.xml ├── LICENSE ├── CONTRIBUTING.md └── os-project-logo.svg /benten-hackernews-bolt/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | 3 | -------------------------------------------------------------------------------- /benten-mock/src/main/resources/error-mock.feature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benten-starter/src/main/resources/error-mock.feature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/error-mock.feature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/resources/error-mock.feature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benten-core/src/main/resources/benten.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intuit/benten/HEAD/benten-core/src/main/resources/benten.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: trusty 3 | jdk: 4 | - oraclejdk8 5 | sudo: false 6 | addons: 7 | apt: 8 | packages: 9 | - oracle-java8-installer 10 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/test/java/com/intuit/benten/camera-by-brand.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "iPhone 11" 4 | }, 5 | { 6 | "name": "iPhone X" 7 | }, 8 | { 9 | "name": "iPhone 8" 10 | } 11 | ] -------------------------------------------------------------------------------- /benten-starter/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tomcat:9-jre8-alpine 2 | EXPOSE 8080 3 | 4 | ADD target/benten-starter*.war /usr/local/tomcat/webapps/benten.war 5 | 6 | 7 | ##docker build -f Dockerfile -t benten . 8 | ##docker container run -it --publish 8081:8080 benten -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | # Benten AI configuration 2 | benten.ai.token= 3 | 4 | # Benten Hacker News configuration 5 | benten.hackernews.baseUrl=https://hacker-news.firebaseio.com 6 | benten.hackernews.apiVersion=v0 -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/actionhandlers/helpers/JiraActionHelper.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers.helpers; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class JiraActionHelper { 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/utils/SearchItems.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.utils; 2 | 3 | /** 4 | * Created by itstc on 2019-10-11 5 | */ 6 | public class SearchItems { 7 | public static final String GOOGLE_SEARCH_URL = "https://google.com/search?q="; 8 | } 9 | -------------------------------------------------------------------------------- /benten-mock/src/main/resources/increment.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var varName = '_curId'; 3 | karate.set(varName, 0); 4 | return function() { 5 | var curId = karate.get(varName); 6 | var nextId = curId + 1; 7 | karate.set(varName, nextId); 8 | return ~~nextId; 9 | } 10 | } -------------------------------------------------------------------------------- /benten-starter/src/main/resources/increment.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var varName = '_curId'; 3 | karate.set(varName, 0); 4 | return function() { 5 | var curId = karate.get(varName); 6 | var nextId = curId + 1; 7 | karate.set(varName, nextId); 8 | return ~~nextId; 9 | } 10 | } -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/increment.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var varName = '_curId'; 3 | karate.set(varName, 0); 4 | return function() { 5 | var curId = karate.get(varName); 6 | var nextId = curId + 1; 7 | karate.set(varName, nextId); 8 | return ~~nextId; 9 | } 10 | } -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/actionhandlers/ThreeParameterFunction.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | @FunctionalInterface 8 | public interface ThreeParameterFunction { 9 | public R apply(T t, U u); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/resources/increment.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var varName = '_curId'; 3 | karate.set(varName, 0); 4 | return function() { 5 | var curId = karate.get(varName); 6 | var nextId = curId + 1; 7 | karate.set(varName, nextId); 8 | return ~~nextId; 9 | } 10 | } -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/exceptions/BentenException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.exceptions; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class BentenException extends RuntimeException{ 8 | public BentenException(String message) { 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/exceptions/BentenFlickrException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.exceptions; 2 | 3 | /** 4 | * Created by itstc on 2019-10-07 5 | */ 6 | public class BentenFlickrException extends RuntimeException { 7 | public BentenFlickrException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /benten-mock/src/main/resources/board-get-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "maxResults":50, 3 | "startAt":0, 4 | "isLast":true, 5 | "values":[ 6 | { 7 | "id":15493, 8 | "self":"https://jira.benten.com/rest/agile/1.0/board/15493", 9 | "name":"Combined_Services_Team_view", 10 | "type":"scrum" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /benten-starter/src/main/resources/board-get-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "maxResults":50, 3 | "startAt":0, 4 | "isLast":true, 5 | "values":[ 6 | { 7 | "id":15493, 8 | "self":"https://jira.benten.com/rest/agile/1.0/board/15493", 9 | "name":"Combined_Services_Team_view", 10 | "type":"scrum" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/exceptions/BentenJenkinsException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.exceptions; 2 | 3 | /** 4 | * Created by sshashidhar on 2/24/18. 5 | */ 6 | public class BentenJenkinsException extends RuntimeException { 7 | public BentenJenkinsException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/BentenFlickrApplication.java: -------------------------------------------------------------------------------- 1 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 2 | import org.springframework.context.annotation.ComponentScan; 3 | 4 | /** 5 | * Created by itstc on 2019-10-07 6 | */ 7 | @ComponentScan("com.intuit.benten") 8 | @EnableAutoConfiguration 9 | public class BentenFlickrApplication { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /benten-weather-bolt/src/main/java/com.intuit.benten/BentenWeatherApplication.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten; 2 | 3 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 4 | import org.springframework.context.annotation.ComponentScan; 5 | 6 | @ComponentScan("com.intuit.benten") 7 | @EnableAutoConfiguration 8 | public class BentenWeatherApplication { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/ActionHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | import java.util.HashMap; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public interface ActionHandlerFactory { 10 | 11 | HashMap getActionHandlerMap(); 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/exceptions/AiException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.exceptions; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class AiException extends RuntimeException { 8 | 9 | public AiException(){ 10 | 11 | } 12 | 13 | public AiException(String message){ 14 | super(message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/BentenActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | import com.intuit.benten.common.nlp.BentenMessage; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public interface BentenActionHandler { 10 | BentenHandlerResponse handle(BentenMessage bentenMessage); 11 | } 12 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/board-get-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "maxResults":50, 3 | "startAt":0, 4 | "isLast":true, 5 | "values":[ 6 | { 7 | "id":15493, 8 | "self":"https://jira.benten.com/rest/agile/1.0/board/15493", 9 | "name":"Combined_Services_Team_view", 10 | "type":"scrum" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/BentenHackerNewsApplication.java: -------------------------------------------------------------------------------- 1 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 2 | import org.springframework.context.annotation.ComponentScan; 3 | 4 | /** 5 | * Created by jleveroni on 10/09/2019 6 | */ 7 | @ComponentScan("com.intuit.benten") 8 | @EnableAutoConfiguration 9 | public class BentenHackerNewsApplication { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | src 6 | 7 | **/** 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/resources/board-get-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "maxResults":50, 3 | "startAt":0, 4 | "isLast":true, 5 | "values":[ 6 | { 7 | "id":15493, 8 | "self":"https://jira.benten.com/rest/agile/1.0/board/15493", 9 | "name":"Combined_Services_Team_view", 10 | "type":"scrum" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/conversationcatalysts/ConversationCatalystFactory.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.conversationcatalysts; 2 | 3 | import java.util.HashMap; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public interface ConversationCatalystFactory { 10 | 11 | HashMap getConversationCatalystMap(); 12 | } 13 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/channel/Channel.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.channel; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public interface Channel { 10 | void sendMessage(BentenHandlerResponse bentenHandlerResponse, ChannelInformation channelInformation); 11 | } 12 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/exceptions/ImageGenerationException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.exceptions; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class ImageGenerationException extends RuntimeException{ 8 | public ImageGenerationException(){ 9 | 10 | } 11 | public ImageGenerationException(String message){ 12 | super(message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/bentennlp/Question.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.bentennlp; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Question { 8 | 9 | private String value; 10 | 11 | public String getValue() { 12 | return value; 13 | } 14 | 15 | public void setValue(String value) { 16 | this.value = value; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/bentennlp/Answer.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.bentennlp; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Answer { 8 | 9 | private String value; 10 | 11 | public String getValue() { 12 | return value; 13 | } 14 | 15 | public void setValue(String value) { 16 | this.value = value; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/rest/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.rest; 2 | 3 | import org.springframework.web.bind.annotation.RestController; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/health") 10 | public String index() { 11 | return "Benten is up and running!"; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/BentenJiraApplication.java: -------------------------------------------------------------------------------- 1 | import org.springframework.boot.SpringApplication; 2 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.context.annotation.ComponentScan; 5 | 6 | @ComponentScan("com.intuit.benten.common") 7 | @EnableAutoConfiguration 8 | public class BentenJiraApplication { 9 | 10 | } -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/exceptions/TableDimensionsException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.exceptions; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class TableDimensionsException extends Exception { 8 | 9 | public TableDimensionsException(){ 10 | 11 | } 12 | 13 | public TableDimensionsException(String message){ 14 | super(message); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/agile/Board.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.agile; 2 | 3 | 4 | /** 5 | * @author Divakar Ungatla 6 | * @version 1.0 7 | */ 8 | public class Board extends AgileResource{ 9 | 10 | private String type; 11 | 12 | public String getType() { 13 | return type; 14 | } 15 | 16 | public void setType(String type) { 17 | this.type = type; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ghc/StatField.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.ghc; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class StatField { 8 | 9 | private String value; 10 | 11 | public String getValue() { 12 | return value; 13 | } 14 | 15 | public void setValue(String statFieldValue) { 16 | this.value = statFieldValue; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/BentenHtmlResponse.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class BentenHtmlResponse { 8 | 9 | public String getHtml() { 10 | return html; 11 | } 12 | 13 | public void setHtml(String html) { 14 | this.html = html; 15 | } 16 | 17 | private String html; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/conversationcatalysts/ConversationCatalyst.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.conversationcatalysts; 2 | 3 | import com.intuit.benten.common.bentennlp.Conversation; 4 | import com.intuit.benten.common.nlp.BentenMessage; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public interface ConversationCatalyst { 11 | Conversation getConversation(BentenMessage bentenMessage); 12 | } 13 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/exceptions/BentenJiraException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.exceptions; 2 | 3 | 4 | import com.intuit.benten.common.exceptions.BentenException; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | 11 | public class BentenJiraException extends BentenException { 12 | public BentenJiraException(String message) { 13 | super(message); 14 | } 15 | } 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsActionParameters.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | /** 4 | * Created by sshashidhar on 2/24/18. 5 | */ 6 | public class JenkinsActionParameters { 7 | 8 | public static String PARAMETER_JOB_PREFIX = "jobPrefix"; 9 | public static String PARAMETER_JOB_JOBNAME = "jobName"; 10 | public static final String PARAMETER_HELP_ITEM = "helpItem"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/BentenJenkinsApplication.java: -------------------------------------------------------------------------------- 1 | import org.springframework.boot.SpringApplication; 2 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.context.annotation.ComponentScan; 5 | 6 | /** 7 | * Created by sshashidhar on 2/22/18. 8 | */ 9 | @ComponentScan("com.intuit.benten") 10 | @EnableAutoConfiguration 11 | public class BentenJenkinsApplication { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/nlp/dialogflow/DialogFlowActions.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.nlp.dialogflow; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class DialogFlowActions { 8 | 9 | public static final String ACTION_SMALL_TALK = "smalltalk"; 10 | public static final String ACTION_INPUT_UNKOWN = "input.unknown"; 11 | public static final String ACTION_WELCOME = "input.welcome"; 12 | public static final String ACTION_HELP= "action_help"; 13 | } 14 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/test/resources/benten.properties: -------------------------------------------------------------------------------- 1 | # benten jira configuration 2 | benten.jira.baseurl=http://localhost:8001/ 3 | 4 | # benten jenkins configuration 5 | benten.jenkins.baseUrl=http://localhost:8001 6 | 7 | # Benten AI configuration 8 | benten.ai.token= 9 | 10 | # Benten slack configuration 11 | benten.slack.token= 12 | 13 | # Benten Hacker News configuration 14 | benten.hackernews.baseUrl=https://hacker-news.firebaseio.com 15 | benten.hackernews.apiVersion=v0 -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/actionhandlers/FlickrActions.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.actionhandlers; 2 | 3 | /** 4 | * Created by itstc on 2019-10-07 5 | */ 6 | public class FlickrActions { 7 | public static final String ACTION_FLICKR_SEARCH_PHOTOS = "action_flickr_search_photos"; 8 | public static final String ACTION_FLICKR_TRENDY_PHOTOS = "action_flickr_trendy_photos"; 9 | public static final String ACTION_FLICKR_BRAND_CAMERAS = "action_flickr_brand_cameras"; 10 | } 11 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/annotations/ActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @author Divakar Ungatla 10 | * @version 1.0 11 | */ 12 | @Target({ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface ActionHandler { 15 | String action(); 16 | } 17 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/model/HackernewsItemIdList.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import java.util.List; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class HackernewsItemIdList { 9 | public List itemIds; 10 | 11 | public List getItemIds() { return itemIds; } 12 | public void setItemIds(List itemIds) { this.itemIds = itemIds; } 13 | } 14 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/nlp/NlpClient.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.nlp; 2 | 3 | import com.intuit.benten.common.nlp.BentenMessage; 4 | import com.intuit.benten.exceptions.AiException; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public interface NlpClient { 11 | BentenMessage sendText(String text, String sessionId) throws AiException; 12 | BentenMessage sendText(String text, String sessionId, boolean reset) throws AiException; 13 | boolean isActionable(String action); 14 | } 15 | -------------------------------------------------------------------------------- /benten-core/src/test/java/com/intuit/benten/channel/slack/SlackChannelTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.channel.slack; 2 | 3 | import allbegray.slack.rtm.Event; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | /** 11 | * @author Divakar Ungatla 12 | * @version 1.0 13 | */ 14 | 15 | public class SlackChannelTest { 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/utils/HelpItems.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.utils; 2 | 3 | /** 4 | * Created by sshashidhar on 20/06/18. 5 | */ 6 | public class HelpItems { 7 | 8 | public static final String JENKINS_JOB_DETAILS = "jenkins_job_details_help"; 9 | public static final String JENKINS_SEARCH_JOB = "jenkins_search_job_help"; 10 | public static final String JENKINS_BUILD_JOB = "jenkins_build_job_help"; 11 | 12 | public static final String JENKINS_HELP = "jenkins_help"; 13 | } 14 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ChangeLog.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class ChangeLog { 11 | 12 | private List histories = null; 13 | 14 | public List getHistories() { 15 | return histories; 16 | } 17 | 18 | public void setHistories(List histories) { 19 | this.histories = histories; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/annotations/BentenConversationCatalyst.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @author Divakar Ungatla 10 | * @version 1.0 11 | */ 12 | @Target({ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface BentenConversationCatalyst { 15 | String action(); 16 | } 17 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/actionhandlers/FlickrActionParamaters.java: -------------------------------------------------------------------------------- 1 | 2 | package com.intuit.benten.flickr.actionhandlers; 3 | 4 | /** 5 | * Created by itstc on 2019-10-07 6 | */ 7 | public class FlickrActionParamaters { 8 | public static final String PARAMETER_MEDIA_TYPE = "mediaType"; 9 | public static final String PARAMETER_SEARCH_VALUE = "searchValue"; 10 | public static final String PARAMETER_SEARCH_LIMIT = "searchLimit"; 11 | public static final String PARAMETER_BRAND_NAME = "brandName"; 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | .idea 26 | .project 27 | .settings 28 | .classpath 29 | *.iml 30 | karate.log 31 | *-secret.properties 32 | *catalina.* 33 | */target/* 34 | 35 | #target folders 36 | */target/* 37 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/channel/ChannelInformation.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.channel; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class ChannelInformation { 8 | 9 | private String channelId; 10 | 11 | public ChannelInformation(String channelId){ 12 | this.channelId = channelId; 13 | } 14 | 15 | public String getChannelId() { 16 | return channelId; 17 | } 18 | 19 | public void setChannelId(String channelId) { 20 | this.channelId = channelId; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /benten-weather-bolt/src/main/java/com.intuit.benten/weather/properties/WeatherProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.weather.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.PropertySource; 7 | 8 | @Configuration 9 | @ConfigurationProperties("benten.weather") 10 | @PropertySource("classpath:benten.properties") 11 | @Data 12 | public class WeatherProperties { 13 | String baseUrl; 14 | String token; 15 | } 16 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/exceptions/BentenHackernewsException.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.exceptions; 2 | 3 | /** 4 | * Created by jleveroni on 10/09/2019 5 | */ 6 | public class BentenHackernewsException extends RuntimeException { 7 | public BentenHackernewsException(String hackerNewsMessage) { 8 | super(hackerNewsMessage); 9 | } 10 | 11 | public BentenHackernewsException(String hackerNewsMessage, String message) { 12 | super("[BentenHackernewsException] " + hackerNewsMessage + " " + message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/model/HackernewsSetRange.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.model; 2 | 3 | public class HackernewsSetRange { 4 | private Integer min; 5 | private Integer max; 6 | 7 | public HackernewsSetRange(Integer floor, Integer ceiling) { 8 | min = floor; 9 | max = ceiling; 10 | } 11 | 12 | public Integer getMin() { return min; } 13 | public void setMin(Integer min) { this.min = min; } 14 | public Integer getMax() { return max; } 15 | public void setMax(Integer max) { this.max = max; } 16 | } 17 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/constants/SlackConstants.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.constants; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class SlackConstants { 8 | public static final String CURRENT_USER = "currentUser"; 9 | public static final String USER_OF_INTEREST = "userOfInterest"; 10 | public static final String COMMENT ="comment" ; 11 | public static final String PROJECT_KEY = "projectKey"; 12 | public static final String SUMMARY = "summary"; 13 | public static final String ISSUE_TYPE = "issueType"; 14 | } 15 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ghc/GhResource.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.ghc; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class GhResource { 8 | 9 | private String id; 10 | private String name; 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Visibility.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Visibility { 8 | private String type; 9 | private String value; 10 | 11 | public String getType() { 12 | return type; 13 | } 14 | 15 | public void setType(String type) { 16 | this.type = type; 17 | } 18 | 19 | public String getValue() { 20 | return value; 21 | } 22 | 23 | public void setValue(String value) { 24 | this.value = value; 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/agile/AgileResource.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.agile; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class AgileResource { 8 | 9 | private String id; 10 | private String name; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/bentennlp/Parameter.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.bentennlp; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Parameter { 8 | 9 | private String name; 10 | private String value; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getValue() { 21 | return value; 22 | } 23 | 24 | public void setValue(String value) { 25 | this.value = value; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benten-archetype/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.intuit.benten 7 | benten-parent 8 | 0.1.5 9 | 10 | com.intuit.benten 11 | benten-archetype 12 | 13 | benten-archetype 14 | http://maven.apache.org 15 | 16 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Votes.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Votes { 8 | private int votes = 0; 9 | private boolean hasVoted = false; 10 | 11 | public int getVotes() { 12 | return votes; 13 | } 14 | 15 | public void setVotes(int votes) { 16 | this.votes = votes; 17 | } 18 | 19 | public boolean isHasVoted() { 20 | return hasVoted; 21 | } 22 | 23 | public void setHasVoted(boolean hasVoted) { 24 | this.hasVoted = hasVoted; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/JiraClientIntegrationTester.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | /** 6 | * 7 | * @author pthomas3 8 | */ 9 | //@RunWith(SpringRunner.class) 10 | //@ActiveProfiles("secret") 11 | //@EnableAutoConfiguration 12 | //@SpringBootTest 13 | public class JiraClientIntegrationTester extends AbstractJiraClientTest { 14 | 15 | @Autowired 16 | private BentenJiraClient client; 17 | 18 | @Override 19 | protected BentenJiraClient getClient() { 20 | return client; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /benten-core/src/test/resources/benten.properties: -------------------------------------------------------------------------------- 1 | # benten proxy configuration 2 | 3 | #benten.proxy.port= 4 | #benten.proxy.host= 5 | #benten.proxy.protocol=http 6 | 7 | #benten ai configuration 8 | benten.ai.token= 9 | 10 | #benten slack configuration 11 | benten.slack.token= 12 | 13 | #benten jira configuration 14 | benten.jira.username= 15 | benten.jira.password= 16 | benten.jira.baseurl=http://localhost:8001/ 17 | 18 | 19 | benten.jenkins.username= 20 | benten.jenkins.password= 21 | benten.jenkins.baseUrl=http://localhost:8001 22 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Priority.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Priority { 8 | 9 | private String iconUrl = null; 10 | private String name = null; 11 | 12 | public String getIconUrl() { 13 | return iconUrl; 14 | } 15 | 16 | public void setIconUrl(String iconUrl) { 17 | this.iconUrl = iconUrl; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /benten-core/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | # benten proxy configuration 2 | 3 | #benten.proxy.port= 4 | #benten.proxy.host= 5 | #benten.proxy.protocol=http 6 | 7 | #benten ai configuration 8 | benten.ai.projectId= 9 | 10 | #benten slack configuration 11 | benten.slack.token= 12 | 13 | #benten jira configuration 14 | benten.jira.username= 15 | benten.jira.password= 16 | benten.jira.baseurl=http://localhost:8001/ 17 | 18 | 19 | benten.jenkins.username= 20 | benten.jenkins.password= 21 | benten.jenkins.baseUrl=http://localhost:8001 22 | -------------------------------------------------------------------------------- /benten-core/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # benten proxy configuration 2 | 3 | #benten.proxy.port= 4 | #benten.proxy.host= 5 | #benten.proxy.protocol=http 6 | 7 | #benten ai configuration 8 | benten.ai.token= 9 | 10 | #benten slack configuration 11 | benten.slack.token= 12 | 13 | #benten jira configuration 14 | benten.jira.username= 15 | benten.jira.password= 16 | benten.jira.baseurl=http://localhost:8001/ 17 | 18 | 19 | benten.jenkins.username= 20 | benten.jenkins.password= 21 | benten.jenkins.baseUrl=http://localhost:8001 22 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/FeatureServerRunner.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira; 2 | 3 | import com.intuit.karate.FileUtils; 4 | import com.intuit.karate.netty.FeatureServer; 5 | import org.junit.Test; 6 | 7 | import java.io.File; 8 | 9 | /** 10 | * @author Divakar Ungatla 11 | * @version 1.0 12 | */ 13 | public class FeatureServerRunner { 14 | 15 | @Test 16 | public void testServer() { 17 | File file = FileUtils.getFileRelativeTo(FeatureServerRunner.class, "jira-mock.feature"); 18 | FeatureServer server = FeatureServer.start(file, 8095, false, null); 19 | server.waitSync(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ghc/EstimateSum.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.ghc; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class EstimateSum extends GhResource{ 8 | 9 | private Double value = null; 10 | private String text = null; 11 | 12 | public Double getValue() { 13 | return value; 14 | } 15 | 16 | public void setValue(Double value) { 17 | this.value = value; 18 | } 19 | 20 | public String getText() { 21 | return text; 22 | } 23 | 24 | public void setText(String text) { 25 | this.text = text; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/FeatureServerRunner.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins; 2 | 3 | import com.intuit.karate.FileUtils; 4 | import com.intuit.karate.netty.FeatureServer; 5 | import org.junit.Test; 6 | 7 | import java.io.File; 8 | 9 | /** 10 | * @author Divakar Ungatla 11 | * @version 1.0 12 | */ 13 | public class FeatureServerRunner { 14 | 15 | @Test 16 | public void testServer() { 17 | File file = FileUtils.getFileRelativeTo(FeatureServerRunner.class, "jenkins-mock.feature"); 18 | FeatureServer server = FeatureServer.start(file, 8095, false, null); 19 | server.waitSync(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Security.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Security { 8 | private String description = null; 9 | private String name = null; 10 | 11 | public String getDescription() { 12 | return description; 13 | } 14 | 15 | public void setDescription(String description) { 16 | this.description = description; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/JiraClientUsingMockTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | /** 6 | * 7 | * @author pthomas3 8 | */ 9 | //@RunWith(SpringRunner.class) 10 | //@ActiveProfiles("mock") 11 | //@ContextConfiguration(classes = JiraClientMockConfig.class) 12 | //@EnableAutoConfiguration 13 | public class JiraClientUsingMockTest extends AbstractJiraClientTest { 14 | 15 | @Autowired 16 | private BentenJiraClient client; 17 | 18 | @Override 19 | protected BentenJiraClient getClient() { 20 | return client; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ProjectCategory.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class ProjectCategory { 8 | private String name = null; 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public String getDescription() { 19 | return description; 20 | } 21 | 22 | public void setDescription(String description) { 23 | this.description = description; 24 | } 25 | 26 | private String description = null; 27 | } 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Resolution.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Resolution { 8 | 9 | private String description = null; 10 | private String name = null; 11 | 12 | public String getDescription() { 13 | return description; 14 | } 15 | 16 | public void setDescription(String description) { 17 | this.description = description; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | # benten proxy configuration 2 | 3 | #benten.proxy.port= 4 | #benten.proxy.host= 5 | #benten.proxy.protocol=http 6 | 7 | #benten ai configuration 8 | benten.ai.token= 9 | 10 | #benten slack configuration 11 | benten.slack.token= 12 | 13 | #benten jira configuration 14 | benten.jira.username= 15 | benten.jira.password= 16 | benten.jira.baseurl=http://localhost:8001/ 17 | 18 | 19 | benten.jenkins.username= 20 | benten.jenkins.password= 21 | benten.jenkins.baseUrl=http://localhost:8001 22 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/test/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ghc/SprintReport.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.ghc; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class SprintReport extends GhResource { 8 | 9 | private Sprint sprint; 10 | private Contents contents; 11 | 12 | public Sprint getSprint() { 13 | return sprint; 14 | } 15 | 16 | public void setSprint(Sprint sprint) { 17 | this.sprint = sprint; 18 | } 19 | 20 | public Contents getContents() { 21 | return contents; 22 | } 23 | 24 | public void setContents(Contents contents) { 25 | this.contents = contents; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/channel/slack/SlackUser.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.channel.slack; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class SlackUser { 8 | 9 | private String name; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | private String id; 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String toString(){ 30 | return "user="+this.name; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/actionhandlers/HackernewsGetNewStoriesActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.annotations.ActionHandler; 5 | import com.intuit.benten.hackernews.utils.HackernewsConstants; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by jleveroni on 10/09/2019 10 | */ 11 | @Component 12 | @ActionHandler(action = HackernewsConstants.Actions.ACTION_HACKERNEWS_GET_NEW_STORIES) 13 | public class HackernewsGetNewStoriesActionHandler extends BaseHackernewsGetCollectionAction implements BentenActionHandler { 14 | 15 | } -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/properties/AiProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | @Component 12 | @ConfigurationProperties("benten.ai") 13 | @PropertySource(value = "classpath:benten.properties") 14 | public class AiProperties { 15 | 16 | private String projectId; 17 | 18 | public String getProjectId() { return projectId; } 19 | 20 | public void setProjectId(String projectId) { this.projectId = projectId; } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/test/java/com/intuit/benten/BaseFlickrTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten; 2 | import org.junit.Test; 3 | import org.junit.runner.RunWith; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.test.context.ActiveProfiles; 6 | import org.springframework.test.context.ContextConfiguration; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | 10 | /** 11 | * Created by itstc on 2019-10-15 12 | */ 13 | @RunWith(SpringRunner.class) 14 | @ActiveProfiles("mock") 15 | @ContextConfiguration(classes={FlickrClientMockConfig.class}) 16 | @EnableAutoConfiguration 17 | public class BaseFlickrTest { 18 | 19 | @Test 20 | public void test(){} 21 | } 22 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/actionhandlers/HackernewsGetTopStoriesActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.annotations.ActionHandler; 5 | import com.intuit.benten.hackernews.utils.HackernewsConstants; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by jleveroni on 10/09/2019 10 | */ 11 | @Component 12 | @ActionHandler(action = HackernewsConstants.Actions.ACTION_HACKERNEWS_GET_TOP_STORIES) 13 | public class HackernewsGetTopStoriesActionHandler extends BaseHackernewsGetCollectionAction implements BentenActionHandler { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/actionhandlers/JiraActionParameters.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class JiraActionParameters { 8 | 9 | public static final String PARAMETER_TIME = "time"; 10 | public static final String PARAMETER_ISSUE_KEY = "issueKey"; 11 | public static final String PARAMETER_STATUS = "status"; 12 | public static final String PARAMETER_COMMENT = "comment"; 13 | public static final String PARAMETER_BOARD_NAME = "boardName"; 14 | public static final String PARAMETER_NO_OF_SPRINTS = "noOfSprints"; 15 | public static final String PARAMETER_HELP_ITEM = "helpItem"; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/actionhandlers/HackernewsGetBestStoriesActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.annotations.ActionHandler; 5 | import com.intuit.benten.hackernews.utils.HackernewsConstants; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by jleveroni on 10/11/2019 10 | */ 11 | @Component 12 | @ActionHandler(action = HackernewsConstants.Actions.ACTION_HACKERNEWS_GET_BEST_STORIES) 13 | public class HackernewsGetBestStoriesActionHandler extends BaseHackernewsGetCollectionAction implements BentenActionHandler { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/actionhandlers/HackernewsGetLatestAskStoriesActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.annotations.ActionHandler; 5 | import com.intuit.benten.hackernews.utils.HackernewsConstants; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by jleveroni on 10/11/2019 10 | */ 11 | @Component 12 | @ActionHandler(action = HackernewsConstants.Actions.ACTION_HACKERNEWS_GET_LATEST_ASKS) 13 | public class HackernewsGetLatestAskStoriesActionHandler extends BaseHackernewsGetCollectionAction implements BentenActionHandler { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/properties/SlackProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | @Component 12 | @ConfigurationProperties("benten.slack") 13 | @PropertySource(value = "classpath:benten.properties") 14 | public class SlackProperties { 15 | 16 | private String token; 17 | 18 | public String getToken() { 19 | return token; 20 | } 21 | 22 | public void setToken(String token) { 23 | this.token = token; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ghc/EstimateStatistic.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.ghc; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class EstimateStatistic { 8 | 9 | private String statFieldId; 10 | private StatField statFieldValue; 11 | 12 | public String getStatFieldId() { 13 | return statFieldId; 14 | } 15 | 16 | public void setStatFieldId(String statFieldId) { 17 | this.statFieldId = statFieldId; 18 | } 19 | 20 | public StatField getStatFieldValue() { 21 | return statFieldValue; 22 | } 23 | 24 | public void setStatFieldValue(StatField statField) { 25 | this.statFieldValue = statField; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/actionhandlers/HackernewsGetLatestJobStoriesActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.annotations.ActionHandler; 5 | import com.intuit.benten.hackernews.utils.HackernewsConstants; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by jleveroni on 10/11/2019 10 | */ 11 | @Component 12 | @ActionHandler(action = HackernewsConstants.Actions.ACTION_HACKERNEWS_GET_LATEST_JOB_STORIES) 13 | public class HackernewsGetLatestJobStoriesActionHandler extends BaseHackernewsGetCollectionAction implements BentenActionHandler { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/actionhandlers/HackernewsGetLatestShowStoriesActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.annotations.ActionHandler; 5 | import com.intuit.benten.hackernews.utils.HackernewsConstants; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by jleveroni on 10/11/2019 10 | */ 11 | @Component 12 | @ActionHandler(action = HackernewsConstants.Actions.ACTION_HACKERNEWS_GET_LATEST_SHOW_STORIES) 13 | public class HackernewsGetLatestShowStoriesActionHandler extends BaseHackernewsGetCollectionAction implements BentenActionHandler { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/utils/SearchUtils.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.utils; 2 | 3 | import org.springframework.web.util.UriUtils; 4 | 5 | import java.io.UnsupportedEncodingException; 6 | import java.nio.charset.StandardCharsets; 7 | 8 | /** 9 | * Created by itstc on 2019-10-11 10 | */ 11 | public class SearchUtils { 12 | public static String generateGoogleSearchUrl(String searchString) { 13 | try { 14 | String uriQuery = UriUtils.encode(searchString, StandardCharsets.UTF_8.name()); 15 | return SearchItems.GOOGLE_SEARCH_URL + uriQuery; 16 | } catch (UnsupportedEncodingException e) { 17 | e.printStackTrace(); 18 | return ""; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | 25 | benten.flickr.apikey= 26 | benten.flickr.secret= 27 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/channel/slack/BentenHtmlToSlackMsgConverter.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.channel.slack; 2 | 3 | import allbegray.slack.type.Attachment; 4 | import allbegray.slack.webapi.method.chats.ChatPostMessageMethod; 5 | import com.intuit.benten.common.actionhandlers.BentenHtmlResponse; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | public class BentenHtmlToSlackMsgConverter { 12 | 13 | public static ChatPostMessageMethod transform(BentenHtmlResponse bentenHtmlResponse, String text, String channel) { 14 | ChatPostMessageMethod chatPostMessageMethod = new ChatPostMessageMethod(channel, text); 15 | Attachment attachment = new Attachment(); 16 | 17 | return chatPostMessageMethod; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsActions.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | /** 4 | * Created by sshashidhar on 2/24/18. 5 | */ 6 | public class JenkinsActions { 7 | 8 | public static final String ACTION_JENKINS_SEARCH_BUILDS_BY_PREFIX = "action_jenkins_search_jobs_by_prefix"; 9 | public static final String ACTION_JENKINS_JOBDETAILS_BY_JOBNAME = "action_jenkins_job_details_by_name"; 10 | public static final String ACTION_JENKINS_BUILDJOB_BY_JOBNAME = "action_jenkins_buildjob_by_name"; 11 | public static final String ACTION_JENKINS_SHOWCONSOLELOG_FORBUILDNUMBER = "action_jenkins_showconsolelog_forbuildnumber"; 12 | public static final String ACTION_JENKINS_HELP = "action_jenkins_help"; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /benten-mock/src/main/java/com/intuit/benten/mock/MockFeatureServerRunner.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.mock; 2 | 3 | import com.intuit.karate.FileUtils; 4 | import com.intuit.karate.netty.FeatureServer; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.io.File; 8 | import java.io.InputStream; 9 | import java.net.URISyntaxException; 10 | 11 | /** 12 | * @author Divakar Ungatla 13 | * @version 1.0 14 | */ 15 | @Component 16 | public class MockFeatureServerRunner { 17 | 18 | public void testServer() throws URISyntaxException { 19 | File file = new File(getClass().getClassLoader().getResource("benten-mock.feature").toURI()); 20 | FeatureServer server = FeatureServer.start(file, 8001, false, null); 21 | //server.waitSync(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Transition.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Transition { 8 | 9 | private String id; 10 | private String name = null; 11 | private Status to = null; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public Status getTo() { 30 | return to; 31 | } 32 | 33 | public void setTo(Status to) { 34 | this.to = to; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /benten-core/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | benten.log 12 | 13 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/BentenApplication.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten; 2 | 3 | import com.intuit.benten.properties.BentenProxyConfig; 4 | import com.intuit.benten.properties.AiProperties; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | 12 | @ComponentScan("com.intuit.benten") 13 | public class BentenApplication { 14 | 15 | @Autowired 16 | AiProperties aiProperties; 17 | 18 | @Autowired 19 | BentenProxyConfig bentenProxyConfig; 20 | 21 | @PostConstruct 22 | public void startup(){ 23 | try { 24 | // MockFeatureServerRunner.testServer(); 25 | }catch(Exception ex){ 26 | //do nothing 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/http/JiraClientTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.http; 2 | 3 | import com.intuit.benten.jira.JiraClientMockConfig; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 7 | import org.springframework.test.context.ActiveProfiles; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * @author Divakar Ungatla 13 | * @version 1.0 14 | */ 15 | @RunWith(SpringRunner.class) 16 | @EnableAutoConfiguration 17 | //@SpringBootTest 18 | @ActiveProfiles("mock") 19 | @ContextConfiguration(classes=JiraClientMockConfig.class) 20 | public class JiraClientTest { 21 | 22 | @Test 23 | public void dummy(){} 24 | 25 | } 26 | -------------------------------------------------------------------------------- /benten-weather-bolt/src/test/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8095/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8095 24 | 25 | #benten openweather properties 26 | benten.weather.token=token 27 | benten.weather.baseUrl=https://api.openweathermap.org/data/2.5/weather?appid= 28 | -------------------------------------------------------------------------------- /benten-mock/src/main/resources/jenkins-mock.feature: -------------------------------------------------------------------------------- 1 | Feature: jenkins mock 2 | 3 | Background: 4 | 5 | Scenario: pathMatches('/job/{name}/api/json') 6 | * print requestHeaders 7 | * def response = read('job-by-name.json') 8 | 9 | Scenario: pathMatches('/api/json') 10 | * def response = read('all-jobs.json') 11 | 12 | Scenario: pathMatches('/job/{name}/build/api/json') && methodIs('post') 13 | * def responseStatus = 200 14 | * def response = read('job-by-name.json') 15 | * def responseHeaders = {} 16 | * set responseHeaders.Location = 'https://localhost:8001/queue/item/445/' 17 | 18 | Scenario: pathMatches('/job/{name}/{buildnumber}/api/json') && methodIs('get') 19 | * def responseStatus = 200 20 | * def response = read('job-by-build.json') 21 | 22 | 23 | Scenario: 24 | * print request 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /benten-starter/src/main/resources/jenkins-mock.feature: -------------------------------------------------------------------------------- 1 | Feature: jenkins mock 2 | 3 | Background: 4 | 5 | Scenario: pathMatches('/job/{name}/api/json') 6 | * print requestHeaders 7 | * def response = read('job-by-name.json') 8 | 9 | Scenario: pathMatches('/api/json') 10 | * def response = read('all-jobs.json') 11 | 12 | Scenario: pathMatches('/job/{name}/build/api/json') && methodIs('post') 13 | * def responseStatus = 200 14 | * def response = read('job-by-name.json') 15 | * def responseHeaders = {} 16 | * set responseHeaders.Location = 'https://localhost:8001/queue/item/445/' 17 | 18 | Scenario: pathMatches('/job/{name}/{buildnumber}/api/json') && methodIs('get') 19 | * def responseStatus = 200 20 | * def response = read('job-by-build.json') 21 | 22 | 23 | Scenario: 24 | * print request 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/LinkType.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class LinkType { 8 | 9 | private String name = null; 10 | private String inward = null; 11 | private String outward = null; 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | public void setName(String name) { 18 | this.name = name; 19 | } 20 | 21 | public String getInward() { 22 | return inward; 23 | } 24 | 25 | public void setInward(String inward) { 26 | this.inward = inward; 27 | } 28 | 29 | public String getOutward() { 30 | return outward; 31 | } 32 | 33 | public void setOutward(String outward) { 34 | this.outward = outward; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /benten-weather-bolt/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | #benten jenkins configuration 2 | 3 | # benten proxy configuration 4 | 5 | #benten.proxy.port= 6 | #benten.proxy.host= 7 | #benten.proxy.protocol=http 8 | 9 | #benten ai configuration 10 | benten.ai.token= 11 | 12 | #benten slack configuration 13 | benten.slack.token= 14 | 15 | #benten jira configuration 16 | benten.jira.username= 17 | benten.jira.password= 18 | benten.jira.baseurl=http://localhost:8001/ 19 | 20 | 21 | benten.jenkins.username= 22 | benten.jenkins.password= 23 | benten.jenkins.baseUrl=http://localhost:8001/ 24 | 25 | #benten openweather properties 26 | benten.weather.token= 27 | benten.weather.baseUrl=https://api.openweathermap.org/data/2.5/weather?appid= 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/actionhandlers/JiraActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | import com.intuit.benten.jira.JiraClientMockConfig; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 7 | import org.springframework.test.context.ActiveProfiles; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * @author Divakar Ungatla 13 | * @version 1.0 14 | */ 15 | @RunWith(SpringRunner.class) 16 | @EnableAutoConfiguration 17 | //@SpringBootTest 18 | @ActiveProfiles("mock") 19 | @ContextConfiguration(classes=JiraClientMockConfig.class) 20 | public class JiraActionHandlerTest { 21 | 22 | @Test 23 | public void dummy(){} 24 | } 25 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/jenkins-mock.feature: -------------------------------------------------------------------------------- 1 | Feature: jenkins mock 2 | 3 | Background: 4 | 5 | Scenario: pathMatches('/job/{name}/api/json') 6 | * print requestHeaders 7 | * def response = read('job-by-name.json') 8 | 9 | Scenario: pathMatches('/api/json') 10 | * def response = read('all-jobs.json') 11 | 12 | Scenario: pathMatches('/job/{name}/build/api/json') && methodIs('post') 13 | * def responseStatus = 200 14 | * def response = read('job-by-name.json') 15 | * def responseHeaders = {} 16 | * set responseHeaders.Location = 'https://localhost:8001/queue/item/445/' 17 | 18 | Scenario: pathMatches('/job/{name}/{buildnumber}/api/json') && methodIs('get') 19 | * def responseStatus = 200 20 | * def response = read('job-by-build.json') 21 | 22 | 23 | Scenario: 24 | * print request 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/JiraError.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import net.sf.json.JSONObject; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * @author Divakar Ungatla 11 | * @version 1.0 12 | */ 13 | public class JiraError { 14 | 15 | private List errorMessages; 16 | private JSONObject errors; 17 | 18 | 19 | public List getErrorMessages() { 20 | return errorMessages; 21 | } 22 | 23 | public void setErrorMessages(List errorMessages) { 24 | this.errorMessages = errorMessages; 25 | } 26 | 27 | public JSONObject getErrors() { 28 | return errors; 29 | } 30 | 31 | public void setErrors(JSONObject jsonObject) { 32 | this.errors = jsonObject; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/resources/jenkins-mock.feature: -------------------------------------------------------------------------------- 1 | Feature: jenkins mock 2 | 3 | Background: 4 | 5 | Scenario: pathMatches('/job/{name}/api/json') 6 | * print requestHeaders 7 | * def response = read('job-by-name.json') 8 | 9 | Scenario: pathMatches('/api/json') 10 | * def response = read('all-jobs.json') 11 | 12 | Scenario: pathMatches('/job/{name}/build/api/json') && methodIs('post') 13 | * def responseStatus = 200 14 | * def response = read('job-by-name.json') 15 | * def responseHeaders = {} 16 | * set responseHeaders.Location = 'https://localhost:8001/queue/item/445/' 17 | 18 | Scenario: pathMatches('/job/{name}/{buildnumber}/api/json') && methodIs('get') 19 | * def responseStatus = 200 20 | * def response = read('job-by-build.json') 21 | 22 | 23 | Scenario: 24 | * print request 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/renderers/SlackMessageRenderer.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.renderers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 4 | import com.intuit.benten.common.formatters.SlackFormatter; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class SlackMessageRenderer { 11 | 12 | public static BentenSlackResponse errorMessage(String errorMessage) { 13 | 14 | BentenSlackResponse bentenSlackResponse= new BentenSlackResponse(); 15 | SlackFormatter slackFormatter = SlackFormatter.create(); 16 | 17 | bentenSlackResponse.setSlackText(slackFormatter 18 | .text("An error occured when I tried to do this operation:") 19 | .newline() 20 | .code(errorMessage) 21 | .build()); 22 | 23 | return bentenSlackResponse; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /benten-core/src/test/java/com/intuit/benten/converters/HtmlToImageConverterTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.converters; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import javax.script.ScriptException; 10 | import java.io.InputStream; 11 | 12 | /** 13 | * @author Divakar Ungatla 14 | * @version 1.0 15 | */ 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest(classes={HtmlToImageConverter.class}) 18 | public class HtmlToImageConverterTest { 19 | 20 | @Test 21 | public void testGenerateImage() throws ScriptException { 22 | HtmlToImageConverter.decorateHtml("helllo"); 23 | InputStream image = HtmlToImageConverter.generateImage("jnnkanknva"); 24 | Assert.assertNotNull(image); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/IssueLink.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class IssueLink { 8 | private LinkType type = null; 9 | private Issue inwardIssue = null; 10 | private Issue outwardIssue = null; 11 | 12 | public LinkType getType() { 13 | return type; 14 | } 15 | 16 | public void setType(LinkType type) { 17 | this.type = type; 18 | } 19 | 20 | public Issue getInwardIssue() { 21 | return inwardIssue; 22 | } 23 | 24 | public void setInwardIssue(Issue inwardIssue) { 25 | this.inwardIssue = inwardIssue; 26 | } 27 | 28 | public Issue getOutwardIssue() { 29 | return outwardIssue; 30 | } 31 | 32 | public void setOutwardIssue(Issue outwardIssue) { 33 | this.outwardIssue = outwardIssue; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/BaseJenkinsTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 | import org.springframework.test.context.ActiveProfiles; 7 | import org.springframework.test.context.ContextConfiguration; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | /** 11 | * @author Divakar Ungatla 12 | * @version 1.0 13 | */ 14 | @RunWith(SpringRunner.class) 15 | //@SpringBootTest(classes={BentenJenkinsClient.class,JenkinsProperties.class,JenkinsSearchJobByPrefixActionHandler.class,JenkinsJobDetailsByJobNameActionHandler.class}) 16 | @ActiveProfiles("mock") 17 | @ContextConfiguration(classes={JenkinsClientMockConfig.class}) 18 | @EnableAutoConfiguration 19 | public class BaseJenkinsTest { 20 | 21 | @Test 22 | public void test(){} 23 | } 24 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Component.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Component { 8 | private String name = null; 9 | private String description = null; 10 | private boolean isAssigneeTypeValid = false; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getDescription() { 21 | return description; 22 | } 23 | 24 | public void setDescription(String description) { 25 | this.description = description; 26 | } 27 | 28 | public boolean isAssigneeTypeValid() { 29 | return isAssigneeTypeValid; 30 | } 31 | 32 | public void setAssigneeTypeValid(boolean assigneeTypeValid) { 33 | isAssigneeTypeValid = assigneeTypeValid; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/utils/HelpItems.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.utils; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class HelpItems { 8 | public static final String CREATE_ISSUE_HELP = "create_issue_help"; 9 | public static final String ASSIGN_ISSUE_HELP = "assign_issue_help"; 10 | public static final String COMMENT_ISSUE_HELP = "comment_issue_help"; 11 | public static final String ISSUE_DETAILS_HELP = "issue_details_help"; 12 | public static final String LOG_WORK_HELP = "log_work_help"; 13 | public static final String SEARCH_ISSUES_HELP = "search_issue_help"; 14 | public static final String SPRINT_VELOCITY_HELP = "sprint_velocity_help"; 15 | public static final String TRANSITION_ISSUE_HELP = "transition_issue_help"; 16 | public static final String CYCLE_TIME_HELP = "cycle_time_help"; 17 | 18 | public static final String JIRA_HELP = "jira_help"; 19 | } 20 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ChangeLogEntry.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class ChangeLogEntry { 11 | 12 | private User author = null; 13 | private Date created = null; 14 | private List items = null; 15 | 16 | public void setAuthor(User author) { 17 | this.author = author; 18 | } 19 | 20 | public void setCreated(Date created) { 21 | this.created = created; 22 | } 23 | 24 | public void setItems(List items) { 25 | this.items = items; 26 | } 27 | 28 | 29 | public User getAuthor() { 30 | return this.author; 31 | } 32 | 33 | public Date getCreated() { 34 | return this.created; 35 | } 36 | 37 | public List getItems() { 38 | return this.items; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /benten-examples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | benten-parent 7 | com.intuit.benten 8 | 0.1.5 9 | 10 | 4.0.0 11 | 12 | benten-examples 13 | 14 | 15 | com.intuit.benten 16 | benten-core 17 | 0.1.5 18 | 19 | 20 | org.apache.httpcomponents 21 | httpclient 22 | 4.5.5 23 | 24 | 25 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/properties/FlickrProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.properties; 2 | 3 | 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.PropertySource; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by itstc on 2019-10-07 10 | */ 11 | @Component 12 | @ConfigurationProperties("benten.flickr") 13 | @PropertySource("classpath:benten.properties") 14 | public class FlickrProperties { 15 | public static String apikey; 16 | public static String secret; 17 | 18 | public FlickrProperties() { 19 | 20 | } 21 | 22 | public String getApikey() { 23 | return apikey; 24 | } 25 | 26 | public void setApikey(String apikey) { 27 | this.apikey = apikey; 28 | } 29 | 30 | public String getSecret() { 31 | return secret; 32 | } 33 | 34 | public void setSecret(String secret) { 35 | this.secret = secret; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/nlp/BentenConversation.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.nlp; 2 | 3 | import com.intuit.benten.common.bentennlp.Conversation; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class BentenConversation { 10 | 11 | private Conversation conversation; 12 | private BentenMessage bentenMessage; 13 | 14 | public BentenConversation(Conversation conversation, BentenMessage bentenMessage){ 15 | this.conversation = conversation; 16 | this.bentenMessage = bentenMessage; 17 | } 18 | 19 | public Conversation getConversation() { 20 | return conversation; 21 | } 22 | 23 | public void setConversation(Conversation conversation) { 24 | this.conversation = conversation; 25 | } 26 | 27 | public BentenMessage getNlpBentenMessage() { 28 | return bentenMessage; 29 | } 30 | 31 | public void setNlpBentenMessage(BentenMessage bentenMessage) { 32 | this.bentenMessage = bentenMessage; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/BentenSlackField.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class BentenSlackField { 8 | 9 | private String title; 10 | private String value; 11 | private boolean isShort; 12 | 13 | public BentenSlackField(String title, String value, boolean isShort) { 14 | this.title = title; 15 | this.value = value; 16 | this.isShort = isShort; 17 | } 18 | 19 | public String getTitle() { 20 | return title; 21 | } 22 | 23 | public void setTitle(String title) { 24 | this.title = title; 25 | } 26 | 27 | public String getValue() { 28 | return value; 29 | } 30 | 31 | public void setValue(String value) { 32 | this.value = value; 33 | } 34 | 35 | public boolean isShort() { 36 | return isShort; 37 | } 38 | 39 | public void setShort(boolean aShort) { 40 | isShort = aShort; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Status.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Status { 8 | 9 | private String id; 10 | private String description = null; 11 | private String iconUrl = null; 12 | private String name = null; 13 | 14 | public String getDescription() { 15 | return description; 16 | } 17 | 18 | public void setDescription(String description) { 19 | this.description = description; 20 | } 21 | 22 | public String getIconUrl() { 23 | return iconUrl; 24 | } 25 | 26 | public void setIconUrl(String iconUrl) { 27 | this.iconUrl = iconUrl; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public String getId() { 39 | return id; 40 | } 41 | 42 | public void setId(String id) { 43 | this.id = id; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/actionhandlers/JiraActions.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class JiraActions { 8 | public static final String ACTION_JIRA_SEARCH_ISSUES = "action_jira_my_issues"; 9 | public static final String ACTION_JIRA_ISSUE_DETAILS = "action_jira_issue_details" ; 10 | public static final String ACTION_JIRA_LOG_WORK = "action_jira_log_work" ; 11 | public static final String ACTION_JIRA_ASSIGN_ISSUE = "action_jira_assign_issue" ; 12 | public static final String ACTION_JIRA_CYCLE_TIME = "action_jira_cycle_time"; 13 | public static final String ACTION_JIRA_SPRINT_VELOCITY = "action_jira_sprint_velocity"; 14 | public static final String ACTION_JIRA_CREATE_ISSUE = "action_jira_create" ; 15 | public static final String ACTION_JIRA_COMMENT_ISSUE = "action_jira_comment_issue"; 16 | public static final String ACTION_JIRA_TRANSITION_ISSUE = "action_jira_transition_issue"; 17 | public static final String ACTION_JIRA_HELP= "action_jira_help"; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/test/java/com/intuit/benten/flickr/helpers/FlickrResultBuilder.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.helpers; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.flickr4java.flickr.Transport; 6 | import com.flickr4java.flickr.cameras.Camera; 7 | import com.flickr4java.flickr.photos.Photo; 8 | import com.flickr4java.flickr.photos.PhotoList; 9 | 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by itstc on 2019-10-15 17 | */ 18 | public class FlickrResultBuilder { 19 | public static List getCamerasFromJSON(String filename) { 20 | ObjectMapper mapper = new ObjectMapper(); 21 | File file = new File("src/test/java/com/intuit/benten/" + filename); 22 | try { 23 | return (List) mapper.readValue(file,new TypeReference>(){}); 24 | } catch (IOException e) { 25 | e.printStackTrace(); 26 | return new ArrayList<>(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Intuit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/BentenSlackResponse.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class BentenSlackResponse { 11 | 12 | private String slackText; 13 | private List bentenSlackAttachments = new ArrayList<>(); 14 | 15 | 16 | public List getBentenSlackAttachments() { 17 | return bentenSlackAttachments; 18 | } 19 | 20 | public void setBentenSlackAttachments(List bentenSlackAttachments) { 21 | this.bentenSlackAttachments = bentenSlackAttachments; 22 | } 23 | 24 | public String getSlackText() { 25 | return slackText; 26 | } 27 | 28 | public void setSlackText(String slackText) { 29 | this.slackText = slackText; 30 | } 31 | 32 | public void addBentenSlackAttachment(BentenSlackAttachment bentenSlackAttachment){ 33 | this.bentenSlackAttachments.add(bentenSlackAttachment); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/properties/HackernewsProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * Created by jleveroni on 10/09/2019 9 | */ 10 | @Component 11 | @ConfigurationProperties("benten.hackernews") 12 | @PropertySource("classpath:benten.properties") 13 | public class HackernewsProperties { 14 | private String baseUrl; 15 | private String apiVersion; 16 | 17 | public String getBaseUrl() { 18 | return baseUrl; 19 | } 20 | 21 | public void setBaseUrl(String baseUrl) { 22 | this.baseUrl = baseUrl; 23 | } 24 | 25 | public String getApiVersion() { 26 | return apiVersion; 27 | } 28 | 29 | public void setApiVersion(String apiVersion) { 30 | this.apiVersion = apiVersion; 31 | } 32 | 33 | public String getUrlWithApiVersion() { 34 | return this.baseUrl + "/" + this.apiVersion; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /benten-weather-bolt/src/test/java/com/intuit/benten/weather/client/BentenWeatherClientTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.weather.client; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.JsonParser; 5 | import java.io.IOException; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 11 | import org.springframework.context.annotation.ComponentScan; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | @EnableAutoConfiguration 15 | @RunWith(SpringRunner.class) 16 | @ComponentScan(value = "com.intuit.benten") 17 | public class BentenWeatherClientTest { 18 | 19 | @Autowired 20 | BentenWeatherClient bentenWeatherClient; 21 | 22 | @Test 23 | public void testInvalidApiKey() throws IOException { 24 | String foo = bentenWeatherClient.getWeatherFromCurrentCity("foo"); 25 | JsonObject object = (JsonObject) new JsonParser().parse(foo); 26 | Assert.assertEquals(401, object.getAsJsonPrimitive("cod").getAsInt()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/rest/MockController.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.rest; 2 | 3 | import com.intuit.benten.common.http.HttpHelper; 4 | import org.apache.http.HttpResponse; 5 | import org.apache.http.client.methods.HttpGet; 6 | import org.apache.http.util.EntityUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.io.IOException; 13 | 14 | /** 15 | * @author Divakar Ungatla 16 | * @version 1.0 17 | */ 18 | @RestController 19 | public class MockController { 20 | 21 | @Autowired 22 | HttpHelper httpHelper; 23 | 24 | @RequestMapping("/browse/{id}") 25 | public String returnIssueFromMock(@PathVariable String id) throws IOException { 26 | HttpGet httpGet = new HttpGet("http://localhost:8001/browse/"+id); 27 | HttpResponse httpResponse = httpHelper.getClient().execute(httpGet); 28 | String response = EntityUtils.toString(httpResponse.getEntity()); 29 | return response; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Watches.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class Watches { 11 | private String name = null; 12 | private int watchCount = 0; 13 | private boolean isWatching = false; 14 | private List watchers = new ArrayList(); 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public int getWatchCount() { 25 | return watchCount; 26 | } 27 | 28 | public void setWatchCount(int watchCount) { 29 | this.watchCount = watchCount; 30 | } 31 | 32 | public boolean isWatching() { 33 | return isWatching; 34 | } 35 | 36 | public void setWatching(boolean watching) { 37 | isWatching = watching; 38 | } 39 | 40 | public List getWatchers() { 41 | return watchers; 42 | } 43 | 44 | public void setWatchers(List watchers) { 45 | this.watchers = watchers; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/http/JiraAgileClientTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.http; 2 | 3 | import com.intuit.benten.jira.model.Issue; 4 | import com.intuit.benten.jira.model.agile.Board; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author Divakar Ungatla 14 | * @version 1.0 15 | */ 16 | 17 | @EnableAutoConfiguration 18 | public class JiraAgileClientTest extends JiraClientTest{ 19 | 20 | @Autowired 21 | private JiraAgileHttpClient jiraAgileHttpClient; 22 | 23 | @Test 24 | public void testSprintsIssues() { 25 | String sprintid="71231"; 26 | List issues = jiraAgileHttpClient.sprintIssues(sprintid); 27 | Assert.assertTrue(issues.size()>0); 28 | } 29 | 30 | @Test 31 | public void testBoardsByName() { 32 | String boardName = "Combined_Services_Team_view"; 33 | List boards = jiraAgileHttpClient.boardsByName(boardName); 34 | Assert.assertEquals(boardName,boards.get(0).getName()); 35 | } 36 | } -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/http/JiraGhClientTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.http; 2 | 3 | import com.intuit.benten.jira.model.ghc.Sprint; 4 | import com.intuit.benten.jira.model.ghc.SprintReport; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author Divakar Ungatla 14 | * @version 1.0 15 | */ 16 | 17 | @EnableAutoConfiguration 18 | public class JiraGhClientTest extends JiraClientTest{ 19 | 20 | @Autowired 21 | private JiraGhClient jiraGhClient; 22 | 23 | @Test 24 | public void testSprints(){ 25 | String boarId = "15493"; 26 | List sprints = jiraGhClient.sprints(boarId); 27 | Assert.assertTrue(sprints.size()>0); 28 | } 29 | 30 | @Test 31 | public void testSprintReport(){ 32 | String boarId = "15493"; 33 | String sprintId = "71231"; 34 | SprintReport sprintReport = jiraGhClient.sprintReport(boarId,sprintId); 35 | Assert.assertEquals(sprintId,sprintReport.getSprint().getId()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/BentenHandlerResponse.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | @Component 10 | public class BentenHandlerResponse { 11 | 12 | private String slackText; 13 | private BentenSlackResponse bentenSlackResponse; 14 | private BentenHtmlResponse bentenHtmlResponse; 15 | 16 | public String getSlackText() { 17 | return slackText; 18 | } 19 | 20 | public void setSlackText(String slackText) { 21 | this.slackText = slackText; 22 | } 23 | 24 | public BentenSlackResponse getBentenSlackResponse() { 25 | return bentenSlackResponse; 26 | } 27 | 28 | public void setBentenSlackResponse(BentenSlackResponse bentenSlackResponse) { 29 | this.bentenSlackResponse = bentenSlackResponse; 30 | } 31 | 32 | public BentenHtmlResponse getBentenHtmlResponse() { 33 | return bentenHtmlResponse; 34 | } 35 | 36 | public void setBentenHtmlResponse(BentenHtmlResponse bentenHtmlResponse) { 37 | this.bentenHtmlResponse = bentenHtmlResponse; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /benten-starter/src/main/resources/benten.properties: -------------------------------------------------------------------------------- 1 | # benten proxy configuration 2 | benten.proxy.port= 3 | benten.proxy.host= 4 | benten.proxy.protocol=http 5 | 6 | #benten ai configuration 7 | benten.ai.projectId= 8 | 9 | #benten slack configuration 10 | benten.slack.token= 11 | 12 | #benten jira configuration 13 | benten.jira.username= 14 | benten.jira.password= 15 | benten.jira.baseurl=http://localhost:8001/ 16 | 17 | 18 | # benten jenkins configuration 19 | benten.jenkins.username= 20 | benten.jenkins.password= 21 | benten.jenkins.baseUrl=http://localhost:8001/ 22 | 23 | # Benten AI configuration 24 | benten.ai.token= 25 | 26 | # Benten slack configuration 27 | benten.slack.token= 28 | 29 | # Benten Hacker News configuration 30 | benten.hackernews.baseUrl=https://hacker-news.firebaseio.com 31 | benten.hackernews.apiVersion=v0 32 | 33 | benten.flickr.apikey= 34 | benten.flickr.secret= 35 | 36 | #benten openweather properties 37 | benten.weather.token= 38 | benten.weather.baseUrl=https://api.openweathermap.org/data/2.5/weather?appid= 39 | 40 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/bentennlp/ConversationFragment.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.bentennlp; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class ConversationFragment { 10 | 11 | private Question question; 12 | private Parameter parameter; 13 | private Answer answer; 14 | private Map allowedValues; 15 | 16 | public Question getQuestion() { 17 | return question; 18 | } 19 | 20 | public void setQuestion(Question question) { 21 | this.question = question; 22 | } 23 | 24 | public Parameter getParameter() { 25 | return parameter; 26 | } 27 | 28 | public void setParameter(Parameter parameter) { 29 | this.parameter = parameter; 30 | } 31 | 32 | public Answer getAnswer() { 33 | return answer; 34 | } 35 | 36 | public void setAnswer(Answer answer) { 37 | this.answer = answer; 38 | } 39 | 40 | public Map getAllowedValues() { 41 | return allowedValues; 42 | } 43 | 44 | public void setAllowedValues(Map allowedValues) { 45 | this.allowedValues = allowedValues; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/http/JiraAgileHttpHelper.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.http; 2 | 3 | import com.intuit.benten.jira.properties.JiraProperties; 4 | 5 | import java.net.URI; 6 | import java.net.URISyntaxException; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author Divakar Ungatla 12 | * @version 1.0 13 | */ 14 | public class JiraAgileHttpHelper { 15 | 16 | public static String getBaseUri() { 17 | return JiraProperties.baseurl+"/rest/agile/1.0/"; 18 | } 19 | 20 | public static URI sprintIssuesUri(String sprintId) throws URISyntaxException { 21 | Map queryParams = new HashMap(); 22 | queryParams.put("expand","changelog"); 23 | queryParams.put("jql","(type=story OR type=bug)"); 24 | URI searchUri = JiraHttpHelper.buildURI(getBaseUri() + "sprint/"+sprintId+"/issue", queryParams); 25 | return searchUri; 26 | } 27 | 28 | public static URI boardIdByNameUri(String name) throws URISyntaxException { 29 | Map queryParams = new HashMap(); 30 | queryParams.put("name",name); 31 | URI searchUri = JiraHttpHelper.buildURI(getBaseUri() + "board", queryParams); 32 | return searchUri; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/helpers/JenkinsMessageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.helpers; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.intuit.benten.jenkins.actionhandlers.JenkinsActionParameters; 5 | import com.intuit.benten.common.nlp.BentenMessage; 6 | 7 | import java.util.HashMap; 8 | 9 | /** 10 | * Created by sshashidhar on 2/24/18. 11 | */ 12 | public class JenkinsMessageBuilder { 13 | 14 | public static BentenMessage constructBentenMessage(JsonElement jobPrefix){ 15 | HashMap parameters = new HashMap(); 16 | BentenMessage bentenMessage = new BentenMessage(); 17 | parameters.put(JenkinsActionParameters.PARAMETER_JOB_PREFIX,jobPrefix); 18 | bentenMessage.setParameters(parameters); 19 | return bentenMessage; 20 | } 21 | 22 | public static BentenMessage constructBentenMessageForJobName(JsonElement jobName){ 23 | HashMap parameters = new HashMap(); 24 | BentenMessage bentenMessage = new BentenMessage(); 25 | parameters.put(JenkinsActionParameters.PARAMETER_JOB_JOBNAME,jobName); 26 | bentenMessage.setParameters(parameters); 27 | return bentenMessage; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /benten-weather-bolt/src/main/java/com.intuit.benten/weather/client/BentenWeatherClient.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.weather.client; 2 | 3 | import com.intuit.benten.common.http.HttpHelper; 4 | import com.intuit.benten.weather.properties.WeatherProperties; 5 | import java.io.IOException; 6 | import java.net.URLEncoder; 7 | import javax.annotation.PostConstruct; 8 | import org.apache.http.HttpResponse; 9 | import org.apache.http.client.methods.HttpGet; 10 | import org.apache.http.util.EntityUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | public class BentenWeatherClient { 16 | 17 | @Autowired 18 | private WeatherProperties weatherProperties; 19 | 20 | @Autowired 21 | private HttpHelper httpHelper; 22 | 23 | private String url; 24 | 25 | @PostConstruct 26 | public void setup() { 27 | url = weatherProperties.getBaseUrl() + weatherProperties.getToken(); 28 | } 29 | 30 | public String getWeatherFromCurrentCity(String city) throws IOException { 31 | HttpGet httpGet = new HttpGet(url + "&q=" + URLEncoder.encode(city,"UTF-8")); 32 | HttpResponse httpResponse = httpHelper.getClient().execute(httpGet); 33 | return EntityUtils.toString(httpResponse.getEntity()); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/actionhandlers/JenkinsSearchJobByPrefixActionHandleTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.jenkins.helpers.JenkinsMessageBuilder; 7 | import com.intuit.benten.jenkins.BaseJenkinsTest; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 12 | 13 | /** 14 | * Created by sshashidhar on 2/24/18. 15 | */ 16 | 17 | @EnableAutoConfiguration 18 | public class JenkinsSearchJobByPrefixActionHandleTest extends BaseJenkinsTest { 19 | 20 | @Autowired 21 | JenkinsSearchJobByPrefixActionHandler jenkinsSearchJobByPrefixActionHandler; 22 | 23 | @Test 24 | public void testHandleRequest(){ 25 | JsonElement jsonElement = new JsonPrimitive("DataConversions"); 26 | 27 | BentenHandlerResponse bentenHandlerResponse = 28 | jenkinsSearchJobByPrefixActionHandler.handle(JenkinsMessageBuilder.constructBentenMessage(jsonElement)); 29 | 30 | Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Version.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class Version { 8 | private String name = null; 9 | private boolean archived = false; 10 | private boolean released = false; 11 | private String releaseDate; 12 | private String description = null; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public boolean isArchived() { 23 | return archived; 24 | } 25 | 26 | public void setArchived(boolean archived) { 27 | this.archived = archived; 28 | } 29 | 30 | public boolean isReleased() { 31 | return released; 32 | } 33 | 34 | public void setReleased(boolean released) { 35 | this.released = released; 36 | } 37 | 38 | public String getReleaseDate() { 39 | return releaseDate; 40 | } 41 | 42 | public void setReleaseDate(String releaseDate) { 43 | this.releaseDate = releaseDate; 44 | } 45 | 46 | public String getDescription() { 47 | return description; 48 | } 49 | 50 | public void setDescription(String description) { 51 | this.description = description; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /benten-core/src/test/java/com/intuit/benten/rest/HelloControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.rest; 2 | 3 | import static org.hamcrest.Matchers.equalTo; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 5 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.http.MediaType; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | import org.springframework.test.web.servlet.MockMvc; 15 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 16 | 17 | //@RunWith(SpringRunner.class) 18 | //@SpringBootTest 19 | //@AutoConfigureMockMvc 20 | public class HelloControllerTest { 21 | 22 | // @Autowired 23 | // private MockMvc mvc; 24 | 25 | @Test 26 | public void getHello() throws Exception { 27 | // mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON)) 28 | // .andExpect(status().isOk()) 29 | // .andExpect(content().string(equalTo("Greetings from Spring Boot!"))); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/http/JiraGhHttpHelper.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.http; 2 | 3 | import com.intuit.benten.jira.properties.JiraProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.net.URI; 7 | import java.net.URISyntaxException; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author Divakar Ungatla 13 | * @version 1.0 14 | */ 15 | @Component 16 | public class JiraGhHttpHelper { 17 | 18 | 19 | public static String getBaseUri() { 20 | return JiraProperties.baseurl+"/rest/greenhopper/1.0/"; 21 | } 22 | 23 | public static URI sprintsUri(String boardId) throws URISyntaxException { 24 | Map queryParams = new HashMap(); 25 | URI searchUri = JiraHttpHelper.buildURI(getBaseUri() + "sprintquery/"+boardId, queryParams); 26 | return searchUri; 27 | } 28 | 29 | public static URI sprintReportUri(String boardId,String sprintId) throws URISyntaxException { 30 | Map queryParams = new HashMap(); 31 | queryParams.put("expand","changelog"); 32 | queryParams.put("rapidViewId",boardId); 33 | queryParams.put("sprintId",sprintId); 34 | URI searchUri = JiraHttpHelper.buildURI(getBaseUri() + "rapid/charts/sprintreport", queryParams); 35 | return searchUri; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/IssueType.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | 4 | import net.sf.json.JSONObject; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class IssueType { 11 | private String description = null; 12 | private String iconUrl = null; 13 | private String name = null; 14 | private boolean subtask = false; 15 | private JSONObject fields = null; 16 | 17 | public String getDescription() { 18 | return description; 19 | } 20 | 21 | public void setDescription(String description) { 22 | this.description = description; 23 | } 24 | 25 | public String getIconUrl() { 26 | return iconUrl; 27 | } 28 | 29 | public void setIconUrl(String iconUrl) { 30 | this.iconUrl = iconUrl; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public boolean isSubtask() { 42 | return subtask; 43 | } 44 | 45 | public void setSubtask(boolean subtask) { 46 | this.subtask = subtask; 47 | } 48 | 49 | public JSONObject getFields() { 50 | return fields; 51 | } 52 | 53 | public void setFields(JSONObject fields) { 54 | this.fields = fields; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/actionhandlers/JenkinsJobDetailsByJobNameActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.jenkins.helpers.JenkinsMessageBuilder; 7 | import com.intuit.benten.jenkins.BaseJenkinsTest; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 12 | 13 | /** 14 | * Created by sshashidhar on 2/25/18. 15 | */ 16 | 17 | @EnableAutoConfiguration 18 | public class JenkinsJobDetailsByJobNameActionHandlerTest extends BaseJenkinsTest{ 19 | 20 | @Autowired 21 | JenkinsJobDetailsByJobNameActionHandler jenkinsJobDetailsByJobNameActionHandler; 22 | 23 | @Test 24 | public void testHandleRequest(){ 25 | JsonElement jsonElement = new JsonPrimitive("DataConversions-Env-Stability"); 26 | 27 | BentenHandlerResponse bentenHandlerResponse = 28 | jenkinsJobDetailsByJobNameActionHandler.handle(JenkinsMessageBuilder.constructBentenMessageForJobName(jsonElement)); 29 | 30 | Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/properties/JenkinsProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | @Component 12 | @ConfigurationProperties("benten.jenkins") 13 | @PropertySource("classpath:benten.properties") 14 | public class JenkinsProperties { 15 | 16 | public static String baseurl; 17 | public static String username; 18 | public static String password; 19 | 20 | public JenkinsProperties(){ 21 | 22 | } 23 | 24 | public String getBaseurl() { 25 | return baseurl; 26 | } 27 | 28 | public void setBaseurl(String baseurl) { 29 | this.baseurl = baseurl; 30 | } 31 | 32 | public String getUsername() { 33 | return username; 34 | } 35 | 36 | public void setUsername(String username) { 37 | this.username = username; 38 | } 39 | 40 | public String getPassword() { 41 | return password; 42 | } 43 | 44 | public void setPassword(String password) { 45 | this.password = password; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ghc/Sprint.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.ghc; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class Sprint extends GhResource { 10 | private String state; 11 | private long originBoardId; 12 | private Date startDate; 13 | private Date endDate; 14 | private Date completeDate; 15 | 16 | public String getState() { 17 | return state; 18 | } 19 | 20 | public void setState(String state) { 21 | this.state = state; 22 | } 23 | 24 | public long getOriginBoardId() { 25 | return originBoardId; 26 | } 27 | 28 | public void setOriginBoardId(long originBoardId) { 29 | this.originBoardId = originBoardId; 30 | } 31 | 32 | public Date getStartDate() { 33 | return startDate; 34 | } 35 | 36 | public void setStartDate(Date startDate) { 37 | this.startDate = startDate; 38 | } 39 | 40 | public Date getEndDate() { 41 | return endDate; 42 | } 43 | 44 | public void setEndDate(Date endDate) { 45 | this.endDate = endDate; 46 | } 47 | 48 | public Date getCompleteDate() { 49 | return completeDate; 50 | } 51 | 52 | public void setCompleteDate(Date completeDate) { 53 | this.completeDate = completeDate; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /benten-weather-bolt/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | benten-weather-bolt 8 | jar 9 | 10 | 11 | com.intuit.benten 12 | benten-parent 13 | 0.1.5 14 | 15 | 16 | 17 | 18 | org.projectlombok 19 | lombok 20 | 1.18.10 21 | provided 22 | 23 | 24 | com.intuit.benten 25 | benten-common 26 | 0.1.5 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | src/test/java 35 | 36 | **/*.java 37 | 38 | 39 | 40 | src/test/resources 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/test/java/com/intuit/benten/FlickrClientMockConfig.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten; 2 | 3 | import com.intuit.benten.flickr.actionhandlers.FlickrBrandCamerasActionHandler; 4 | import com.intuit.benten.flickr.actionhandlers.FlickrSearchPhotosActionHandler; 5 | import com.intuit.benten.flickr.actionhandlers.FlickrTrendyPhotosActionHandler; 6 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 7 | import org.springframework.boot.test.mock.mockito.MockBean; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.Profile; 11 | 12 | /** 13 | * Created by itstc on 2019-10-15 14 | */ 15 | @Configuration 16 | @Profile("mock") 17 | @EnableAutoConfiguration 18 | public class FlickrClientMockConfig { 19 | @MockBean 20 | BentenFlickrClient bentenFlickrClient; 21 | 22 | @Bean 23 | public FlickrSearchPhotosActionHandler flickrSearchPhotosActionHandler() { 24 | return new FlickrSearchPhotosActionHandler(); 25 | } 26 | 27 | @Bean 28 | public FlickrTrendyPhotosActionHandler flickrTrendyPhotosActionHandler() { 29 | return new FlickrTrendyPhotosActionHandler(); 30 | } 31 | 32 | @Bean 33 | public FlickrBrandCamerasActionHandler flickrBrandCamerasActionHandler() { 34 | return new FlickrBrandCamerasActionHandler(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/http/BentenHttpClient.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.http; 2 | 3 | import com.intuit.benten.common.http.HttpHelper; 4 | import com.intuit.benten.jira.properties.JiraProperties; 5 | import org.apache.http.HttpResponse; 6 | import org.apache.http.auth.Credentials; 7 | import org.apache.http.auth.UsernamePasswordCredentials; 8 | import org.apache.http.client.methods.HttpRequestBase; 9 | import org.apache.http.impl.auth.BasicScheme; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | import java.io.IOException; 14 | 15 | /** 16 | * @author Divakar Ungatla 17 | * @version 1.0 18 | */ 19 | @Component 20 | public class BentenHttpClient { 21 | 22 | @Autowired 23 | private HttpHelper httpHelper; 24 | 25 | @Autowired 26 | private JiraProperties jiraProperties; 27 | 28 | protected HttpResponse request(HttpRequestBase req) throws IOException { 29 | req.addHeader("Accept", "application/json"); 30 | req.addHeader("Connection", "close"); 31 | Credentials creds = new UsernamePasswordCredentials(jiraProperties.getUsername(),jiraProperties.getPassword()); 32 | req.addHeader(BasicScheme.authenticate(creds, "utf-8", false)); 33 | HttpResponse httpResponse = this.httpHelper.getClient().execute(req); 34 | return httpResponse; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/User.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class User { 10 | private boolean active = false; 11 | 12 | private Map avatarUrls; 13 | private String displayName ; 14 | private String emailAddress; 15 | 16 | public boolean isActive() { 17 | return active; 18 | } 19 | 20 | public void setActive(boolean active) { 21 | this.active = active; 22 | } 23 | 24 | public Map getAvatarUrls() { 25 | return avatarUrls; 26 | } 27 | 28 | public void setAvatarUrls(Map avatarUrls) { 29 | this.avatarUrls = avatarUrls; 30 | } 31 | 32 | public String getDisplayName() { 33 | return displayName; 34 | } 35 | 36 | public void setDisplayName(String displayName) { 37 | this.displayName = displayName; 38 | } 39 | 40 | public String getEmailAddress() { 41 | return emailAddress; 42 | } 43 | 44 | public void setEmailAddress(String emailAddress) { 45 | this.emailAddress = emailAddress; 46 | } 47 | 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | private String name = null; 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsHelpActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | /** 4 | * Created by sshashidhar on 20/06/18. 5 | */ 6 | 7 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 8 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 9 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 10 | import com.intuit.benten.common.annotations.ActionHandler; 11 | import com.intuit.benten.common.helpers.BentenMessageHelper; 12 | import com.intuit.benten.common.nlp.BentenMessage; 13 | import com.intuit.benten.jenkins.utils.SlackJenkinsHelpRenderer; 14 | import org.springframework.stereotype.Component; 15 | 16 | @Component 17 | @ActionHandler(action = JenkinsActions.ACTION_JENKINS_HELP) 18 | public class JenkinsHelpActionHandler implements BentenActionHandler { 19 | @Override 20 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 21 | String helpItem = BentenMessageHelper.getParameterAsString(bentenMessage, JenkinsActionParameters.PARAMETER_HELP_ITEM); 22 | 23 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 24 | BentenSlackResponse bentenSlackResponse = SlackJenkinsHelpRenderer.renderHelpItem(helpItem); 25 | bentenHandlerResponse.setBentenSlackResponse(bentenSlackResponse); 26 | 27 | return bentenHandlerResponse; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/model/JenkinsJobBuildParameter.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by sshashidhar on 3/1/18. 7 | */ 8 | public class JenkinsJobBuildParameter { 9 | 10 | String name; 11 | String value; 12 | List choices; 13 | String defaultValue; 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getValue() { 24 | return value; 25 | } 26 | 27 | public void setValue(String value) { 28 | this.value = value; 29 | } 30 | 31 | public List getChoices() { 32 | return choices; 33 | } 34 | 35 | public void setChoices(List choices) { 36 | this.choices = choices; 37 | } 38 | 39 | public String getDefaultValue() { 40 | return defaultValue; 41 | } 42 | 43 | public void setDefaultValue(String defaultValue) { 44 | this.defaultValue = defaultValue; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "JenkinsJobBuildParameters{" + 50 | "name='" + name + '\'' + 51 | ", value='" + value + '\'' + 52 | ", choices=" + choices + 53 | ", defaultValue='" + defaultValue + '\'' + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/actionhandlers/JiraHelpActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 5 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 6 | import com.intuit.benten.common.annotations.ActionHandler; 7 | import com.intuit.benten.common.helpers.BentenMessageHelper; 8 | import com.intuit.benten.common.nlp.BentenMessage; 9 | import com.intuit.benten.jira.utils.HelpItems; 10 | import com.intuit.benten.jira.utils.SlackHelpRenderer; 11 | import org.springframework.stereotype.Component; 12 | 13 | 14 | /** 15 | * @author Divakar Ungatla 16 | * @version 1.0 17 | */ 18 | @Component 19 | @ActionHandler(action = JiraActions.ACTION_JIRA_HELP) 20 | public class JiraHelpActionHandler implements BentenActionHandler{ 21 | 22 | 23 | @Override 24 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 25 | 26 | String helpItem = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_HELP_ITEM); 27 | 28 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 29 | BentenSlackResponse bentenSlackResponse = SlackHelpRenderer.renderHelpItem(helpItem); 30 | bentenHandlerResponse.setBentenSlackResponse(bentenSlackResponse); 31 | 32 | return bentenHandlerResponse; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/properties/BentenProxyConfig.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | @Component 12 | @ConfigurationProperties("benten.proxy") 13 | @PropertySource(value = "classpath:benten.properties") 14 | public class BentenProxyConfig { 15 | 16 | public BentenProxyConfig(){ 17 | 18 | } 19 | 20 | public boolean isProxyEnabled() { 21 | return isProxyEnabled; 22 | } 23 | 24 | public void setProxyEnabled(boolean proxyEnabled) { 25 | isProxyEnabled = proxyEnabled; 26 | } 27 | 28 | private boolean isProxyEnabled; 29 | 30 | private String host; 31 | 32 | private int port; 33 | 34 | private String protocol; 35 | 36 | public String getHost() { 37 | return host; 38 | } 39 | 40 | public void setHost(String host) { 41 | this.host = host; 42 | } 43 | 44 | public int getPort() { 45 | return port; 46 | } 47 | 48 | public void setPort(int port) { 49 | this.port = port; 50 | } 51 | 52 | public String getProtocol() { 53 | return protocol; 54 | } 55 | 56 | public void setProtocol(String protocol) { 57 | this.protocol = protocol; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /benten-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 4.0.0 8 | 9 | com.intuit.benten 10 | benten-common 11 | jar 12 | 13 | 14 | com.intuit.benten 15 | benten-parent 16 | 0.1.5 17 | 18 | 19 | 20 | 21 | com.google.protobuf 22 | protobuf-java 23 | 3.10.0 24 | 25 | 26 | com.google.code.gson 27 | gson 28 | 2.8.2 29 | 30 | 31 | com.github.allbegray 32 | slack-api 33 | v1.5.1.RELEASE 34 | 35 | 36 | 37 | 38 | jitpack.io 39 | https://jitpack.io 40 | 41 | 42 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/actionhandlers/JiraVelocityActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.JsonPrimitive; 6 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 7 | import com.intuit.benten.common.nlp.BentenMessage; 8 | import com.intuit.benten.jira.helpers.MessageBuilder; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 13 | 14 | /** 15 | * @author Divakar Ungatla 16 | * @version 1.0 17 | */ 18 | 19 | @EnableAutoConfiguration 20 | public class JiraVelocityActionHandlerTest extends JiraActionHandlerTest { 21 | 22 | @Autowired 23 | JiraSprintVelocityActionHandler jiraSprintVelocityActionHandler; 24 | 25 | @Test 26 | public void testHandleRequest(){ 27 | BentenMessage bentenMessage; 28 | 29 | JsonElement boardName = new JsonPrimitive("Combined_Services_Team_view"); 30 | JsonElement noOfSprints = new JsonPrimitive("1"); 31 | 32 | bentenMessage = 33 | MessageBuilder.constructBentenSprintMessage(boardName,noOfSprints); 34 | BentenHandlerResponse bentenHandlerResponse = 35 | jiraSprintVelocityActionHandler.handle(bentenMessage); 36 | 37 | Assert.assertNotNull(bentenHandlerResponse.getBentenHtmlResponse()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/ChangeLogItem.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class ChangeLogItem { 8 | private String field = null; 9 | private String fieldType = null; 10 | private String from = null; 11 | private String fromString = null; 12 | private String to = null; 13 | private String toString = null; 14 | 15 | 16 | public String getField() { 17 | return field; 18 | } 19 | 20 | public void setField(String field) { 21 | this.field = field; 22 | } 23 | 24 | public String getFieldType() { 25 | return fieldType; 26 | } 27 | 28 | public void setFieldType(String fieldType) { 29 | this.fieldType = fieldType; 30 | } 31 | 32 | public String getFrom() { 33 | return from; 34 | } 35 | 36 | public void setFrom(String from) { 37 | this.from = from; 38 | } 39 | 40 | public String getFromString() { 41 | return fromString; 42 | } 43 | 44 | public void setFromString(String fromString) { 45 | this.fromString = fromString; 46 | } 47 | 48 | public String getTo() { 49 | return to; 50 | } 51 | 52 | public void setTo(String to) { 53 | this.to = to; 54 | } 55 | 56 | public String getToString() { 57 | return toString; 58 | } 59 | 60 | public void setToString(String toString) { 61 | this.toString = toString; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/properties/JiraProperties.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.properties; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | @Component 12 | @ConfigurationProperties("benten.jira") 13 | @PropertySource("classpath:benten.properties") 14 | public class JiraProperties { 15 | 16 | public static String baseurl; 17 | public static String username; 18 | public static String password; 19 | public static String herokuurl; 20 | 21 | public JiraProperties(){ 22 | 23 | } 24 | 25 | public String getBaseurl() { 26 | return baseurl; 27 | } 28 | 29 | public void setBaseurl(String baseurl) { 30 | this.baseurl = baseurl; 31 | } 32 | 33 | public String getUsername() { 34 | return username; 35 | } 36 | 37 | public void setUsername(String username) { 38 | this.username = username; 39 | } 40 | 41 | public String getPassword() { 42 | return password; 43 | } 44 | 45 | public void setPassword(String password) { 46 | this.password = password; 47 | } 48 | 49 | 50 | public String getHerokuurl() { 51 | return herokuurl; 52 | } 53 | 54 | public void setHerokuurl(String herokuurl) { 55 | JiraProperties.herokuurl = herokuurl; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Attachment.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class Attachment { 10 | 11 | private User author = null; 12 | private String filename = null; 13 | private Date created = null; 14 | private int size = 0; 15 | private String mimeType = null; 16 | private String content = null; 17 | 18 | public User getAuthor() { 19 | return author; 20 | } 21 | 22 | public void setAuthor(User author) { 23 | this.author = author; 24 | } 25 | 26 | public String getFilename() { 27 | return filename; 28 | } 29 | 30 | public void setFilename(String filename) { 31 | this.filename = filename; 32 | } 33 | 34 | public Date getCreated() { 35 | return created; 36 | } 37 | 38 | public void setCreated(Date created) { 39 | this.created = created; 40 | } 41 | 42 | public int getSize() { 43 | return size; 44 | } 45 | 46 | public void setSize(int size) { 47 | this.size = size; 48 | } 49 | 50 | public String getMimeType() { 51 | return mimeType; 52 | } 53 | 54 | public void setMimeType(String mimeType) { 55 | this.mimeType = mimeType; 56 | } 57 | 58 | public String getContent() { 59 | return content; 60 | } 61 | 62 | public void setContent(String content) { 63 | this.content = content; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/test/java/com/intuit/benten/flickr/helpers/FlickrMessageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.helpers; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import com.intuit.benten.common.nlp.BentenMessage; 6 | import com.intuit.benten.flickr.actionhandlers.FlickrActionParamaters; 7 | 8 | import java.util.HashMap; 9 | 10 | /** 11 | * Created by itstc on 2019-10-15 12 | */ 13 | public class FlickrMessageBuilder { 14 | public static BentenMessage constructBrandCamerasMessage(String brandName) { 15 | HashMap parameters = new HashMap(); 16 | BentenMessage bentenMessage = new BentenMessage(); 17 | parameters.put(FlickrActionParamaters.PARAMETER_BRAND_NAME, new JsonPrimitive(brandName)); 18 | bentenMessage.setParameters(parameters); 19 | return bentenMessage; 20 | } 21 | public static BentenMessage constructSearchPhotosMessage(String mediaType, String searchValue, String searchLimit) { 22 | HashMap parameters = new HashMap(); 23 | BentenMessage bentenMessage = new BentenMessage(); 24 | parameters.put(FlickrActionParamaters.PARAMETER_MEDIA_TYPE, new JsonPrimitive(mediaType)); 25 | parameters.put(FlickrActionParamaters.PARAMETER_SEARCH_VALUE, new JsonPrimitive(searchValue)); 26 | parameters.put(FlickrActionParamaters.PARAMETER_SEARCH_LIMIT, new JsonPrimitive(searchLimit)); 27 | bentenMessage.setParameters(parameters); 28 | return bentenMessage; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsBuildJobByJobNameActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | import com.intuit.benten.BentenJenkinsClient; 4 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.common.annotations.ActionHandler; 7 | import com.intuit.benten.common.helpers.BentenMessageHelper; 8 | import com.intuit.benten.common.nlp.BentenMessage; 9 | import com.intuit.benten.jenkins.utils.SlackJenkinsMessageRenderer; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by sshashidhar on 2/25/18. 15 | */ 16 | @Component 17 | @ActionHandler(action = JenkinsActions.ACTION_JENKINS_BUILDJOB_BY_JOBNAME) 18 | public class JenkinsBuildJobByJobNameActionHandler implements BentenActionHandler { 19 | 20 | @Autowired 21 | private BentenJenkinsClient bentenJenkinsClient; 22 | 23 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 24 | String jobName = BentenMessageHelper.getParameterAsString(bentenMessage,JenkinsActionParameters.PARAMETER_JOB_JOBNAME); 25 | 26 | String buildJob = bentenJenkinsClient.build(jobName); 27 | 28 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 29 | bentenHandlerResponse.setBentenSlackResponse(SlackJenkinsMessageRenderer.renderJobBuildStatus(buildJob)); 30 | 31 | return bentenHandlerResponse; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/converters/HtmlToImageConverter.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.converters; 2 | 3 | import com.intuit.benten.exceptions.ImageGenerationException; 4 | import gui.ava.html.image.generator.HtmlImageGenerator; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.imageio.ImageIO; 8 | import javax.script.ScriptException; 9 | import java.awt.image.BufferedImage; 10 | import java.io.*; 11 | 12 | /** 13 | * @author Divakar Ungatla 14 | * @version 1.0 15 | */ 16 | @Component 17 | public class HtmlToImageConverter { 18 | 19 | public static HtmlImageGenerator imageGenerator 20 | = new HtmlImageGenerator(); 21 | 22 | public static InputStream generateImage(String htmlAsText){ 23 | InputStream inputStream; 24 | try{ 25 | imageGenerator.loadHtml(htmlAsText); 26 | BufferedImage input = imageGenerator.getBufferedImage(); 27 | ByteArrayOutputStream output = new ByteArrayOutputStream(); 28 | ImageIO.write(input, "png", output); 29 | inputStream = new ByteArrayInputStream(output.toByteArray()); 30 | 31 | }catch(Exception e){ 32 | e.printStackTrace(); 33 | throw new ImageGenerationException(e.getMessage()); 34 | } 35 | return inputStream; 36 | } 37 | 38 | public static String decorateHtml(String html) throws ScriptException { 39 | StringBuilder stringBuilder = new StringBuilder(); 40 | stringBuilder.append("").append(html).append(""); 41 | return stringBuilder.toString(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | First of all, thanks for thinking of contributing to this project. :smile: 4 | 5 | - Before sending a Pull Request, please make sure that you have had a discussion with the project admins. 6 | - If a relevant issue already exists, discuss on the issue and make sure that the admins are okay with your approach 7 | - If no relevant issue exists, open a new issue and discuss 8 | 9 | Please proceed with a Pull Request only after the project admins or owners are okay with your approach. It'd be sad if your Pull Request (and your hard work) isn't accepted just because it isn't ideologically compatible. 10 | 11 | - Install the required dependencies. 12 | - Install Git so that you can clone and later submit a PR for this project. 13 | - Install Java JDK (>= 1.8.0_112) installed, from [this link](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). 14 | - Install Eclipse from [this link](http://www.eclipse.org/downloads/). 15 | - (optional) Install Maven from [this link](http://maven.apache.org), if you need to build the project from the command-line. 16 | 17 | - Have some issue with setting up the project? 18 | - [How to open the project in Eclipse as a Maven project?](https://stackoverflow.com/a/36242422/143475) 19 | - [Maven is not able to install the dependencies behind proxy!]() 20 | - Not listed here? Kindly search on Google / Stack Overflow. If you don't find a solution, feel free to open up a new issue in the issue tracker and maybe subsequently add it here. 21 | 22 | - Send in your Pull Request(s) to the `develop` branch of this repository. 23 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/actionhandlers/CycleTimeCalulatorTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | import com.intuit.benten.jira.actionhandlers.helpers.CycleTimeCalculator; 4 | import com.intuit.benten.jira.converters.JiraConverter; 5 | import com.intuit.benten.jira.model.ghc.Sprint; 6 | import com.intuit.benten.jira.model.Issue; 7 | import com.intuit.benten.jira.model.bentenjira.StoryCycleTime; 8 | import com.intuit.benten.jira.model.ghc.SprintReport; 9 | import net.sf.json.JSONObject; 10 | import org.junit.Ignore; 11 | import org.junit.Test; 12 | 13 | import java.io.IOException; 14 | import java.util.Date; 15 | 16 | /** 17 | * @author Divakar Ungatla 18 | * @version 1.0 19 | */ 20 | public class CycleTimeCalulatorTest { 21 | 22 | @Test 23 | @Ignore 24 | public void testCycleTimeCalculator() throws IOException { 25 | String json = "{}"; 26 | JSONObject jsonObject = JiraConverter.objectMapper.readValue(json, JSONObject.class); 27 | Issue issue = new Issue(jsonObject); 28 | Sprint sprint = new Sprint(); 29 | sprint.setStartDate(new Date("2/5/18 07:30 PM")); 30 | sprint.setEndDate(new Date("2/18/18 03:30 AM")); 31 | sprint.setCompleteDate(new Date("2/19/18 10:23 PM")); 32 | SprintReport sprintReport=new SprintReport(); 33 | sprintReport.setSprint(sprint); 34 | StoryCycleTime storyCycleTime =new CycleTimeCalculator().storyCycleTime(issue,sprintReport); 35 | float devCycleTime = storyCycleTime.getDevCycleTime(); 36 | float releaseCycleTime = storyCycleTime.getReleaseCycleTime(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/conversationcatalysts/JiraCreateIssueConversationCatalystTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.conversationcatalysts; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import com.intuit.benten.jira.JiraClientMockConfig; 6 | import com.intuit.benten.common.bentennlp.Conversation; 7 | import com.intuit.benten.jira.helpers.MessageBuilder; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 12 | import org.springframework.test.context.ActiveProfiles; 13 | import org.springframework.test.context.ContextConfiguration; 14 | import org.springframework.test.context.junit4.SpringRunner; 15 | 16 | /** 17 | * @author Divakar Ungatla 18 | * @version 1.0 19 | */ 20 | @RunWith(SpringRunner.class) 21 | @EnableAutoConfiguration 22 | //@SpringBootTest 23 | @ActiveProfiles("mock") 24 | @ContextConfiguration(classes=JiraClientMockConfig.class) 25 | public class JiraCreateIssueConversationCatalystTest{ 26 | 27 | @Autowired 28 | JiraCreateIssueConversationCatalyst jiraCreateIssueConversationCatalyst; 29 | 30 | @Test 31 | public void testHandleRequest(){ 32 | 33 | JsonElement projectKey = new JsonPrimitive("PSAA"); 34 | JsonElement issueType = new JsonPrimitive("Story"); 35 | 36 | Conversation conversation = 37 | jiraCreateIssueConversationCatalyst.getConversation(MessageBuilder.constructBentenCreateIssueCatalystMessage(projectKey,issueType)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/bentenjira/Velocity.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model.bentenjira; 2 | 3 | import com.intuit.benten.jira.model.ghc.GhIssue; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Divakar Ungatla 9 | * @version 1.0 10 | */ 11 | public class Velocity { 12 | 13 | private String sprintName; 14 | private Double totalIssuePoints; 15 | private Double completedIssuePoints; 16 | private List ghIssues; 17 | private Double averageVelocity; 18 | 19 | public String getSprintName() { 20 | return sprintName; 21 | } 22 | 23 | public void setSprintName(String sprintName) { 24 | this.sprintName = sprintName; 25 | } 26 | 27 | public Double getTotalIssuePoints() { 28 | return totalIssuePoints; 29 | } 30 | 31 | public void setTotalIssuePoints(Double totalIssuePoints) { 32 | this.totalIssuePoints = totalIssuePoints; 33 | } 34 | 35 | public Double getCompletedIssuePoints() { 36 | return completedIssuePoints; 37 | } 38 | 39 | public void setCompletedIssuePoints(Double completedIssuePoints) { 40 | this.completedIssuePoints = completedIssuePoints; 41 | } 42 | 43 | public Double getAverageVelocity() { 44 | return averageVelocity; 45 | } 46 | 47 | public void setAverageVelocity(Double averageVelocity) { 48 | this.averageVelocity = averageVelocity; 49 | } 50 | 51 | 52 | public List getGhIssues() { 53 | return ghIssues; 54 | } 55 | 56 | public void setGhIssues(List ghIssues) { 57 | this.ghIssues = ghIssues; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsSearchJobByPrefixActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | import com.intuit.benten.BentenJenkinsClient; 4 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.common.annotations.ActionHandler; 7 | import com.intuit.benten.common.helpers.BentenMessageHelper; 8 | import com.intuit.benten.common.nlp.BentenMessage; 9 | import com.intuit.benten.jenkins.utils.SlackJenkinsMessageRenderer; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | import java.util.Map; 14 | 15 | /** 16 | * Created by sshashidhar on 2/24/18. 17 | */ 18 | @Component 19 | @ActionHandler(action = JenkinsActions.ACTION_JENKINS_SEARCH_BUILDS_BY_PREFIX) 20 | public class JenkinsSearchJobByPrefixActionHandler implements BentenActionHandler { 21 | 22 | @Autowired 23 | private BentenJenkinsClient bentenJenkinsClient; 24 | 25 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 26 | String jobPrefix = BentenMessageHelper.getParameterAsString(bentenMessage,JenkinsActionParameters.PARAMETER_JOB_PREFIX); 27 | 28 | Map jobList = bentenJenkinsClient.getAllJobsWithPrefix(jobPrefix); 29 | 30 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 31 | bentenHandlerResponse.setBentenSlackResponse(SlackJenkinsMessageRenderer.renderJobList(jobList.values())); 32 | 33 | return bentenHandlerResponse; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsJobDetailsByJobNameActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | import com.intuit.benten.BentenJenkinsClient; 4 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.common.annotations.ActionHandler; 7 | import com.intuit.benten.common.helpers.BentenMessageHelper; 8 | import com.intuit.benten.common.nlp.BentenMessage; 9 | import com.intuit.benten.jenkins.utils.SlackJenkinsMessageRenderer; 10 | import com.offbytwo.jenkins.model.JobWithDetails; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * Created by sshashidhar on 2/25/18. 16 | */ 17 | @Component 18 | @ActionHandler(action = JenkinsActions.ACTION_JENKINS_JOBDETAILS_BY_JOBNAME) 19 | public class JenkinsJobDetailsByJobNameActionHandler implements BentenActionHandler { 20 | 21 | @Autowired 22 | private BentenJenkinsClient bentenJenkinsClient; 23 | 24 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 25 | String jobName = BentenMessageHelper.getParameterAsString(bentenMessage,JenkinsActionParameters.PARAMETER_JOB_JOBNAME); 26 | 27 | JobWithDetails jobWithDetails = bentenJenkinsClient.getJobByJobName(jobName); 28 | 29 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 30 | bentenHandlerResponse.setBentenSlackResponse(SlackJenkinsMessageRenderer.renderJobDetailByJobName(jobWithDetails)); 31 | 32 | return bentenHandlerResponse; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/actionhandlers/JiraCycleTimeActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.JsonPrimitive; 6 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 7 | import com.intuit.benten.common.nlp.BentenMessage; 8 | import org.junit.Assert; 9 | import org.junit.Ignore; 10 | import org.junit.Test; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 13 | 14 | import java.util.HashMap; 15 | 16 | /** 17 | * @author Divakar Ungatla 18 | * @version 1.0 19 | */ 20 | @EnableAutoConfiguration 21 | public class JiraCycleTimeActionHandlerTest extends JiraActionHandlerTest{ 22 | 23 | @Autowired 24 | JiraCycleTimeActionHandler jiraCycleTimeActionHandler; 25 | 26 | @Test 27 | @Ignore 28 | public void testHandleRequest(){ 29 | BentenMessage bentenMessage = new BentenMessage(); 30 | 31 | JsonElement boardName = new JsonPrimitive("Combined_Services_Team_view"); 32 | JsonElement noOfSprints = new JsonPrimitive("1"); 33 | 34 | HashMap parameters = new HashMap<>(); 35 | parameters.put(JiraActionParameters.PARAMETER_BOARD_NAME,boardName); 36 | parameters.put(JiraActionParameters.PARAMETER_NO_OF_SPRINTS,noOfSprints); 37 | bentenMessage.setParameters(parameters); 38 | 39 | BentenHandlerResponse bentenHandlerResponse = 40 | jiraCycleTimeActionHandler.handle(bentenMessage); 41 | 42 | Assert.assertNotNull(bentenHandlerResponse.getBentenHtmlResponse()); 43 | 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/main/java/com/intuit/benten/jenkins/actionhandlers/JenkinsShowConsoleLogForBuildNumberActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins.actionhandlers; 2 | 3 | import com.intuit.benten.BentenJenkinsClient; 4 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.common.annotations.ActionHandler; 7 | import com.intuit.benten.common.helpers.BentenMessageHelper; 8 | import com.intuit.benten.common.nlp.BentenMessage; 9 | import com.intuit.benten.jenkins.utils.SlackJenkinsMessageRenderer; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by sshashidhar on 18/06/18. 15 | */ 16 | @Component 17 | @ActionHandler(action = JenkinsActions.ACTION_JENKINS_SHOWCONSOLELOG_FORBUILDNUMBER) 18 | public class JenkinsShowConsoleLogForBuildNumberActionHandler implements BentenActionHandler { 19 | 20 | @Autowired 21 | private BentenJenkinsClient bentenJenkinsClient; 22 | 23 | @Override 24 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 25 | String jobName = BentenMessageHelper.getParameterAsString(bentenMessage,JenkinsActionParameters.PARAMETER_JOB_JOBNAME); 26 | 27 | int buildNumber = bentenJenkinsClient.getLatestBuildNumber(jobName); 28 | String buildConsoleLog = bentenJenkinsClient.showConsoleLogForJobWithBuildNumber(jobName,buildNumber); 29 | 30 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 31 | bentenHandlerResponse.setBentenSlackResponse(SlackJenkinsMessageRenderer.renderJobConsoleLogText(buildConsoleLog)); 32 | 33 | return bentenHandlerResponse; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /os-project-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 17 | 18 | 20 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/utils/FetchHackernewsItemTask.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.utils; 2 | 3 | import com.intuit.benten.common.http.HttpHelper; 4 | import com.intuit.benten.hackernews.exceptions.BentenHackernewsException; 5 | import org.apache.http.HttpResponse; 6 | import org.apache.http.client.methods.HttpGet; 7 | import java.util.concurrent.Callable; 8 | 9 | public class FetchHackernewsItemTask implements Callable { 10 | private Integer itemId; 11 | private String uri; 12 | private HttpHelper httpHelper; 13 | 14 | public FetchHackernewsItemTask(String url, Integer id) { 15 | httpHelper = new HttpHelper(); 16 | uri = url; 17 | itemId = id; 18 | } 19 | 20 | @Override 21 | public HttpResponse call() { 22 | try { 23 | if (uri == null || itemId == null) { 24 | throw new BentenHackernewsException("either the uri or itemId was null"); 25 | } 26 | 27 | String sb = uri + "/" 28 | + HackernewsConstants.ApiEndpoints.ITEM + "/" 29 | + itemId + HackernewsConstants.ApiEndpoints.JSON 30 | + HackernewsConstants.ApiEndpoints.PRETTY_PRINT; 31 | HttpGet request = new HttpGet(sb); 32 | HttpResponse res = httpHelper.getClient().execute(request); 33 | 34 | if (res.getStatusLine().getStatusCode() != 200) { 35 | throw new BentenHackernewsException( 36 | HackernewsConstants.ErrorMessages.ITEM_REQUEST_FAILED + res.getStatusLine().getReasonPhrase()); 37 | } 38 | 39 | return res; 40 | } catch (Exception e) { 41 | throw new BentenHackernewsException(e.getMessage()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/Comment.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class Comment { 10 | private String issueKey = null; 11 | private User author = null; 12 | private String body = null; 13 | private Date created = null; 14 | private Date updated = null; 15 | private User updatedAuthor = null; 16 | private Visibility visibility = null; 17 | 18 | public String getIssueKey() { 19 | return issueKey; 20 | } 21 | 22 | public void setIssueKey(String issueKey) { 23 | this.issueKey = issueKey; 24 | } 25 | 26 | public User getAuthor() { 27 | return author; 28 | } 29 | 30 | public void setAuthor(User author) { 31 | this.author = author; 32 | } 33 | 34 | public String getBody() { 35 | return body; 36 | } 37 | 38 | public void setBody(String body) { 39 | this.body = body; 40 | } 41 | 42 | public Date getCreated() { 43 | return created; 44 | } 45 | 46 | public void setCreated(Date created) { 47 | this.created = created; 48 | } 49 | 50 | public Date getUpdated() { 51 | return updated; 52 | } 53 | 54 | public void setUpdated(Date updated) { 55 | this.updated = updated; 56 | } 57 | 58 | public User getUpdatedAuthor() { 59 | return updatedAuthor; 60 | } 61 | 62 | public void setUpdatedAuthor(User updatedAuthor) { 63 | this.updatedAuthor = updatedAuthor; 64 | } 65 | 66 | public Visibility getVisibility() { 67 | return visibility; 68 | } 69 | 70 | public void setVisibility(Visibility visibility) { 71 | this.visibility = visibility; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/utils/HackernewsExecutorService.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.utils; 2 | 3 | import com.fasterxml.jackson.databind.DeserializationFeature; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.intuit.benten.hackernews.exceptions.BentenHackernewsException; 6 | import com.intuit.benten.hackernews.model.HackernewsItem; 7 | import org.apache.http.util.EntityUtils; 8 | import java.util.concurrent.Executors; 9 | import java.util.stream.Collectors; 10 | import org.springframework.stereotype.Component; 11 | import org.apache.http.HttpResponse; 12 | import java.util.concurrent.Future; 13 | import java.util.concurrent.ExecutorService; 14 | import java.util.List; 15 | 16 | @Component 17 | public class HackernewsExecutorService { 18 | private ExecutorService executorService = Executors.newFixedThreadPool(HackernewsConstants.HACKERNEWS_MAX_THREADS); 19 | private ObjectMapper objectMapper = new ObjectMapper() 20 | .disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES); 21 | 22 | public List submitFetchHackernewsItemTasks(List tasks) { 23 | try { 24 | List> futures = executorService.invokeAll(tasks); 25 | return futures.stream().map(x -> { 26 | try { 27 | String json = EntityUtils.toString(x.get().getEntity()); 28 | return objectMapper.readValue(json, HackernewsItem.class); 29 | } catch (Exception e) { 30 | throw new BentenHackernewsException(e.getMessage()); 31 | } 32 | }).collect(Collectors.toList()); 33 | } catch (InterruptedException e) { 34 | throw new BentenHackernewsException(e.getMessage()); 35 | } 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/actionhandlers/FlickrTrendyPhotosActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.actionhandlers; 2 | 3 | import com.flickr4java.flickr.photos.Photo; 4 | import com.flickr4java.flickr.photos.PhotoList; 5 | import com.intuit.benten.BentenFlickrClient; 6 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 7 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 8 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 9 | import com.intuit.benten.common.annotations.ActionHandler; 10 | import com.intuit.benten.common.nlp.BentenMessage; 11 | import com.intuit.benten.flickr.utils.SlackFlickrMessageRenderer; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * Created by itstc on 2019-10-10 17 | */ 18 | @Component 19 | @ActionHandler(action=FlickrActions.ACTION_FLICKR_TRENDY_PHOTOS) 20 | public class FlickrTrendyPhotosActionHandler implements BentenActionHandler { 21 | 22 | @Autowired 23 | BentenFlickrClient bentenFlickrClient; 24 | 25 | @Override 26 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 27 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 28 | try { 29 | PhotoList response = bentenFlickrClient.getTrendyPhotos(); 30 | bentenHandlerResponse.setBentenSlackResponse(SlackFlickrMessageRenderer.renderList(response)); 31 | } catch(Exception e) { 32 | BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); 33 | bentenSlackResponse.setSlackText("Unable to retrieve trendy photos."); 34 | bentenHandlerResponse.setBentenSlackResponse(bentenSlackResponse); 35 | } 36 | 37 | return bentenHandlerResponse; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /benten-starter/src/main/java/BentenStarterApplication.java: -------------------------------------------------------------------------------- 1 | 2 | import com.intuit.benten.mock.MockFeatureServerRunner; 3 | import com.intuit.benten.nlp.NlpClient; 4 | import com.intuit.benten.nlp.dialogflow.DialogFlowClient; 5 | import com.intuit.benten.properties.AiProperties; 6 | import com.intuit.benten.properties.BentenProxyConfig; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.boot.builder.SpringApplicationBuilder; 11 | import org.springframework.boot.web.support.SpringBootServletInitializer; 12 | import org.springframework.context.ConfigurableApplicationContext; 13 | import org.springframework.context.annotation.Bean; 14 | 15 | import javax.annotation.PostConstruct; 16 | 17 | 18 | @SpringBootApplication(scanBasePackages={"com.intuit.benten","com.example"}) 19 | @EnableAutoConfiguration 20 | public class BentenStarterApplication extends SpringBootServletInitializer { 21 | 22 | @Autowired 23 | AiProperties aiProperties; 24 | 25 | @Autowired 26 | MockFeatureServerRunner mockFeatureServerRunner; 27 | 28 | @Bean 29 | public NlpClient aiClient(){ 30 | 31 | return new DialogFlowClient(aiProperties.getProjectId()); 32 | } 33 | 34 | @PostConstruct 35 | public void setup(){ 36 | try { 37 | mockFeatureServerRunner.testServer(); 38 | }catch(Exception ex){ 39 | ex.printStackTrace(); 40 | } 41 | } 42 | 43 | public static void main(String[] args) { 44 | 45 | ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(BentenStarterApplication.class) 46 | .properties("spring.config.name:benten") 47 | .build().run(); 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /benten-core/src/test/java/com/intuit/benten/ai/dialogflow/DialogFlowClientTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.ai.dialogflow; 2 | 3 | //import BentenMessage; 4 | import com.intuit.benten.nlp.NlpClient; 5 | import com.intuit.benten.nlp.dialogflow.DialogFlowClient; 6 | import com.intuit.benten.properties.BentenProxyConfig; 7 | import com.intuit.benten.properties.AiProperties; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | /** 16 | * @author Divakar Ungatla 17 | * @version 1.0 18 | */ 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest(classes={NlpClient.class, BentenProxyConfig.class, AiProperties.class}) 21 | public class DialogFlowClientTest { 22 | 23 | private NlpClient nlpClient; 24 | 25 | @Autowired 26 | private BentenProxyConfig bentenProxyConfig; 27 | 28 | @Before 29 | public void setup() { 30 | nlpClient = new DialogFlowClient("project-id"); 31 | } 32 | 33 | @Test 34 | public void sendAMessageToNlpClient() { 35 | // BentenMessage bentenMessage = nlpClient.sendText("Book a ticket from Delhi to Bangalore on feb 20 th", "test"); 36 | // // Assert.assertEquals(bentenMessage.getAction(),"smalltalk.greetings.hello"); 37 | // Assert.assertEquals(bentenMessage.isActionComplete(),true); 38 | } 39 | 40 | // @Test(expected = AiException.class) 41 | public void sendAMessageToNlpClientFalseAuth() { 42 | // NlpClient nlpClient = new DialogFlowClient("invalid-token",bentenProxyConfig); 43 | // BentenMessage bentenMessage = nlpClient.sendText("hello", "test"); 44 | // Assert.assertEquals(bentenMessage.getAction(),"smalltalk.greetings.hello"); 45 | // Assert.assertEquals(bentenMessage.isActionComplete(),true); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/java/BentenStarterApplication.java: -------------------------------------------------------------------------------- 1 | import com.intuit.benten.mock.MockFeatureServerRunner; 2 | import com.intuit.benten.nlp.NlpClient; 3 | import com.intuit.benten.nlp.dialogflow.DialogFlowClient; 4 | import com.intuit.benten.properties.AiProperties; 5 | import com.intuit.benten.properties.BentenProxyConfig; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.builder.SpringApplicationBuilder; 10 | import org.springframework.boot.web.support.SpringBootServletInitializer; 11 | import org.springframework.context.ConfigurableApplicationContext; 12 | import org.springframework.context.annotation.Bean; 13 | 14 | import javax.annotation.PostConstruct; 15 | 16 | 17 | @SpringBootApplication(scanBasePackages={"com.intuit.benten"}) 18 | @EnableAutoConfiguration 19 | public class BentenStarterApplication extends SpringBootServletInitializer { 20 | 21 | @Autowired 22 | AiProperties aiProperties; 23 | 24 | @Autowired 25 | BentenProxyConfig bentenProxyConfig; 26 | 27 | @Autowired 28 | MockFeatureServerRunner mockFeatureServerRunner; 29 | 30 | @Bean 31 | public NlpClient aiClient(){ 32 | 33 | return new DialogFlowClient(aiProperties.getToken(),bentenProxyConfig); 34 | } 35 | 36 | @PostConstruct 37 | public void setup(){ 38 | try { 39 | mockFeatureServerRunner.testServer(); 40 | }catch(Exception ex){ 41 | ex.printStackTrace(); 42 | } 43 | } 44 | 45 | public static void main(String[] args) { 46 | 47 | ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(BentenStarterApplication.class) 48 | .properties("spring.config.name:benten") 49 | .build().run(); 50 | 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/http/IdleConnectionMonitorThread.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.intuit.benten.common.http; 5 | 6 | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * Idle Connection Monitor Thread - to check sanity of connections 14 | * 15 | * @author jkuria 16 | */ 17 | class IdleConnectionMonitorThread extends Thread { 18 | private static final Logger LOG = LoggerFactory 19 | .getLogger(IdleConnectionMonitorThread.class); 20 | 21 | private final PoolingHttpClientConnectionManager connMgr; 22 | 23 | private volatile boolean shutdown; 24 | 25 | private long reapInterval; 26 | 27 | private long idleConnectionsTimeout; 28 | 29 | public IdleConnectionMonitorThread( 30 | PoolingHttpClientConnectionManager connMgr, long reapInterval, 31 | long idleConnectionsTimeout) { 32 | super(); 33 | this.connMgr = connMgr; 34 | this.reapInterval = reapInterval; 35 | this.idleConnectionsTimeout = idleConnectionsTimeout; 36 | 37 | } 38 | 39 | @Override 40 | public void run() { 41 | try { 42 | while (!shutdown) { 43 | synchronized (this) { 44 | LOG.trace("Connection eviction thread running every {} ms", 45 | reapInterval); 46 | wait(reapInterval); 47 | // Close expired connections 48 | connMgr.closeExpiredConnections(); 49 | // Optionally, close connections 50 | // that have been idle longer than 30 sec 51 | LOG.trace("Closing idle connections older than {} ms", 52 | idleConnectionsTimeout); 53 | connMgr.closeIdleConnections(idleConnectionsTimeout, 54 | TimeUnit.MILLISECONDS); 55 | } 56 | } 57 | } catch (InterruptedException ex) { 58 | // terminate 59 | } 60 | } 61 | 62 | public void shutdown() { 63 | shutdown = true; 64 | synchronized (this) { 65 | notifyAll(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/TimeTracking.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | /** 4 | * @author Divakar Ungatla 5 | * @version 1.0 6 | */ 7 | public class TimeTracking { 8 | private String originalEstimate = null; 9 | private String remainingEstimate = null; 10 | private String timeSpent = null; 11 | private Integer originalEstimateSeconds = null; 12 | private Integer remainingEstimateSeconds = null; 13 | private Integer timeSpentSeconds = null; 14 | 15 | public String getOriginalEstimate() { 16 | return originalEstimate; 17 | } 18 | 19 | public void setOriginalEstimate(String originalEstimate) { 20 | this.originalEstimate = originalEstimate; 21 | } 22 | 23 | public String getRemainingEstimate() { 24 | return remainingEstimate; 25 | } 26 | 27 | public void setRemainingEstimate(String remainingEstimate) { 28 | this.remainingEstimate = remainingEstimate; 29 | } 30 | 31 | public String getTimeSpent() { 32 | return timeSpent; 33 | } 34 | 35 | public void setTimeSpent(String timeSpent) { 36 | this.timeSpent = timeSpent; 37 | } 38 | 39 | public Integer getOriginalEstimateSeconds() { 40 | return originalEstimateSeconds; 41 | } 42 | 43 | public void setOriginalEstimateSeconds(Integer originalEstimateSeconds) { 44 | this.originalEstimateSeconds = originalEstimateSeconds; 45 | } 46 | 47 | public Integer getRemainingEstimateSeconds() { 48 | return remainingEstimateSeconds; 49 | } 50 | 51 | public void setRemainingEstimateSeconds(Integer remainingEstimateSeconds) { 52 | this.remainingEstimateSeconds = remainingEstimateSeconds; 53 | } 54 | 55 | public Integer getTimeSpentSeconds() { 56 | return timeSpentSeconds; 57 | } 58 | 59 | public void setTimeSpentSeconds(Integer timeSpentSeconds) { 60 | this.timeSpentSeconds = timeSpentSeconds; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/actionhandlers/JiraAssignIssuesToUserActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 6 | import com.intuit.benten.jira.BentenJiraClient; 7 | import com.intuit.benten.jira.helpers.MessageBuilder; 8 | import com.intuit.benten.jira.helpers.TestHelper; 9 | import com.intuit.benten.jira.model.Issue; 10 | import org.junit.Assert; 11 | import org.junit.Test; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 14 | 15 | /** 16 | * @author Divakar Ungatla 17 | * @version 1.0 18 | */ 19 | 20 | @EnableAutoConfiguration 21 | public class JiraAssignIssuesToUserActionHandlerTest extends JiraActionHandlerTest { 22 | 23 | @Autowired 24 | JiraAssignIssueToUserActionHandler jiraAssignIssueToUserActionHandler; 25 | 26 | @Autowired 27 | BentenJiraClient bentenJiraClient; 28 | 29 | @Test 30 | public void testHandleRequest() throws InterruptedException { 31 | 32 | String issueKey = TestHelper.createStory(bentenJiraClient); 33 | TestHelper.updateAssigneeAndReporter(bentenJiraClient,issueKey); 34 | 35 | JsonElement currentUser = new JsonPrimitive(TestHelper.assigneeName); 36 | 37 | Thread.sleep(2000); 38 | 39 | BentenHandlerResponse bentenHandlerResponse = 40 | jiraAssignIssueToUserActionHandler.handle(MessageBuilder.constructBentenAssignIssueMessage(new JsonPrimitive(issueKey),currentUser)); 41 | 42 | Issue issue = TestHelper.getIssueDetails(bentenJiraClient,issueKey); 43 | Assert.assertEquals(TestHelper.assigneeName,issue.getAssignee().getName()); 44 | 45 | Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse()); 46 | Assert.assertTrue(bentenHandlerResponse.getBentenSlackResponse().getSlackText().contains(TestHelper.assigneeName)); 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /benten-jenkins-bolt/src/test/java/com/intuit/benten/jenkins/JenkinsClientMockConfig.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jenkins; 2 | 3 | import com.intuit.benten.BentenJenkinsClient; 4 | import com.intuit.benten.jenkins.actionhandlers.JenkinsJobDetailsByJobNameActionHandler; 5 | import com.intuit.benten.jenkins.actionhandlers.JenkinsSearchJobByPrefixActionHandler; 6 | import com.intuit.benten.jenkins.properties.JenkinsProperties; 7 | import com.intuit.karate.netty.FeatureServer; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.context.annotation.Profile; 12 | 13 | import java.io.File; 14 | 15 | /** 16 | * 17 | * @author divakar ungatla 18 | */ 19 | @Configuration 20 | @Profile("mock") 21 | @EnableAutoConfiguration 22 | public class JenkinsClientMockConfig { 23 | 24 | 25 | @Bean 26 | public JenkinsProperties jenkinsProperties(FeatureServer server) { 27 | JenkinsProperties props = new JenkinsProperties(); 28 | props.setBaseurl("http://localhost:" + server.getPort()); 29 | props.setUsername("scott"); 30 | props.setPassword("tiger"); 31 | return props; 32 | } 33 | 34 | @Bean 35 | public BentenJenkinsClient bentenJenkinsClient() { 36 | return new BentenJenkinsClient(); 37 | } 38 | 39 | 40 | @Bean 41 | public FeatureServer mockServer() { 42 | File file = new File("src/test/java/com/intuit/benten/jenkins/jenkins-mock.feature"); 43 | FeatureServer server = FeatureServer.start(file, 8001, false, null); 44 | return server; 45 | } 46 | 47 | @Bean 48 | public JenkinsSearchJobByPrefixActionHandler jenkinsSearchJobByPrefixActionHandler() { 49 | return new JenkinsSearchJobByPrefixActionHandler(); 50 | } 51 | 52 | @Bean 53 | public JenkinsJobDetailsByJobNameActionHandler jenkinsJobDetailsByJobNameActionHandler() { 54 | return new JenkinsJobDetailsByJobNameActionHandler(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/model/WorkLog.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.model; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class WorkLog { 10 | 11 | private User author = null; 12 | private String comment = null; 13 | private Date created = null; 14 | private Date updated = null; 15 | private User updateAuthor = null; 16 | private Date started = null; 17 | private String timeSpent = null; 18 | private int timeSpentSeconds = 0; 19 | 20 | public User getAuthor() { 21 | return author; 22 | } 23 | 24 | public void setAuthor(User author) { 25 | this.author = author; 26 | } 27 | 28 | public String getComment() { 29 | return comment; 30 | } 31 | 32 | public void setComment(String comment) { 33 | this.comment = comment; 34 | } 35 | 36 | public Date getCreated() { 37 | return created; 38 | } 39 | 40 | public void setCreated(Date created) { 41 | this.created = created; 42 | } 43 | 44 | public Date getUpdated() { 45 | return updated; 46 | } 47 | 48 | public void setUpdated(Date updated) { 49 | this.updated = updated; 50 | } 51 | 52 | public User getUpdateAuthor() { 53 | return updateAuthor; 54 | } 55 | 56 | public void setUpdateAuthor(User updateAuthor) { 57 | this.updateAuthor = updateAuthor; 58 | } 59 | 60 | public Date getStarted() { 61 | return started; 62 | } 63 | 64 | public void setStarted(Date started) { 65 | this.started = started; 66 | } 67 | 68 | public String getTimeSpent() { 69 | return timeSpent; 70 | } 71 | 72 | public void setTimeSpent(String timeSpent) { 73 | this.timeSpent = timeSpent; 74 | } 75 | 76 | public int getTimeSpentSeconds() { 77 | return timeSpentSeconds; 78 | } 79 | 80 | public void setTimeSpentSeconds(int timeSpentSeconds) { 81 | this.timeSpentSeconds = timeSpentSeconds; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/channel/slack/SlackHelperPayload.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.channel.slack; 2 | 3 | 4 | import com.intuit.benten.common.nlp.BentenMessage; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | 11 | public class SlackHelperPayload { 12 | 13 | private BentenMessage bentenMessage; 14 | private String channel; 15 | 16 | public void setNlpBentenMessage(BentenMessage bentenMessage) { 17 | this.bentenMessage = bentenMessage; 18 | } 19 | 20 | public void setChannel(String channel) { 21 | this.channel = channel; 22 | } 23 | 24 | private SlackUser currentUser; 25 | private boolean repeateQuestion = false; 26 | 27 | public SlackHelperPayload(BentenMessage bentenMessage, String channel) { 28 | this.bentenMessage = bentenMessage; 29 | this.channel = channel; 30 | } 31 | 32 | public SlackHelperPayload(BentenMessage bentenMessage, SlackUser slackUser, String channel) { 33 | this.bentenMessage = bentenMessage; 34 | this.channel = channel; 35 | this.currentUser = slackUser; 36 | } 37 | 38 | public SlackHelperPayload(BentenMessage bentenMessage, SlackUser slackUser, String channel, boolean repeateQuestion) { 39 | this.bentenMessage = bentenMessage; 40 | this.channel = channel; 41 | this.currentUser = slackUser; 42 | this.repeateQuestion=repeateQuestion; 43 | } 44 | 45 | public BentenMessage getNlpBentenMessage() { 46 | return bentenMessage; 47 | } 48 | 49 | public String getChannel() { 50 | return channel; 51 | } 52 | 53 | public SlackUser getCurrentUser() { 54 | return currentUser; 55 | } 56 | 57 | public void setCurrentUser(SlackUser currentUser) { 58 | this.currentUser = currentUser; 59 | } 60 | 61 | public boolean isRepeateQuestion() { 62 | return repeateQuestion; 63 | } 64 | 65 | public void setRepeateQuestion(boolean repeateQuestion) { 66 | this.repeateQuestion = repeateQuestion; 67 | } 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/actionhandlers/JiraCreateIssueActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import com.intuit.benten.jira.JiraClientMockConfig; 6 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 7 | import com.intuit.benten.jira.helpers.MessageBuilder; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 13 | import org.springframework.test.context.ActiveProfiles; 14 | import org.springframework.test.context.ContextConfiguration; 15 | import org.springframework.test.context.junit4.SpringRunner; 16 | 17 | /** 18 | * @author Divakar Ungatla 19 | * @version 1.0 20 | */ 21 | @RunWith(SpringRunner.class) 22 | @EnableAutoConfiguration 23 | //@SpringBootTest 24 | @ActiveProfiles("mock") 25 | @ContextConfiguration(classes=JiraClientMockConfig.class) 26 | public class JiraCreateIssueActionHandlerTest extends JiraActionHandlerTest { 27 | 28 | @Autowired 29 | JiraCreateIssueActionHandler jiraCreateIssueActionHandler; 30 | 31 | @Test 32 | public void testHandleRequest(){ 33 | 34 | JsonElement projectKey = new JsonPrimitive("PSAA"); 35 | JsonElement userOfInterest = new JsonPrimitive("dungatla"); 36 | JsonElement currentUser = new JsonPrimitive("dungatla"); 37 | JsonElement issueType = new JsonPrimitive("Story"); 38 | JsonElement summary = new JsonPrimitive("Summary"); 39 | 40 | 41 | BentenHandlerResponse bentenHandlerResponse = 42 | jiraCreateIssueActionHandler.handle(MessageBuilder.constructBentenCreateIssueMessage(projectKey,currentUser,userOfInterest,summary,issueType)); 43 | 44 | Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse()); 45 | Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse().getSlackText()); 46 | 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /benten-mock/src/main/resources/transitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expand": "transitions", 3 | "transitions": [ 4 | { 5 | "id": "4", 6 | "name": "Start Progress", 7 | "to": { 8 | "self": "https://jiraprf.benten.com/rest/api/2/status/3", 9 | "description": "This issue is being actively worked on at the moment by the assignee.", 10 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/inprogress.png", 11 | "name": "In Progress", 12 | "id": "3", 13 | "statusCategory": { 14 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 15 | "id": 4, 16 | "key": "indeterminate", 17 | "colorName": "yellow", 18 | "name": "In Progress" 19 | } 20 | } 21 | }, 22 | { 23 | "id": "2", 24 | "name": "Accept Issue", 25 | "to": { 26 | "self": "https://jiraprf.benten.com/rest/api/2/status/6", 27 | "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", 28 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/closed.png", 29 | "name": "Closed", 30 | "id": "6", 31 | "statusCategory": { 32 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/3", 33 | "id": 3, 34 | "key": "done", 35 | "colorName": "green", 36 | "name": "Done" 37 | } 38 | } 39 | }, 40 | { 41 | "id": "851", 42 | "name": "Issue Blocked", 43 | "to": { 44 | "self": "https://jiraprf.benten.com/rest/api/2/status/10011", 45 | "description": "", 46 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/needinfo.png", 47 | "name": "Blocked", 48 | "id": "10011", 49 | "statusCategory": { 50 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 51 | "id": 4, 52 | "key": "indeterminate", 53 | "colorName": "yellow", 54 | "name": "In Progress" 55 | } 56 | } 57 | } 58 | ] 59 | } -------------------------------------------------------------------------------- /benten-starter/src/main/resources/transitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expand": "transitions", 3 | "transitions": [ 4 | { 5 | "id": "4", 6 | "name": "Start Progress", 7 | "to": { 8 | "self": "https://jiraprf.benten.com/rest/api/2/status/3", 9 | "description": "This issue is being actively worked on at the moment by the assignee.", 10 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/inprogress.png", 11 | "name": "In Progress", 12 | "id": "3", 13 | "statusCategory": { 14 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 15 | "id": 4, 16 | "key": "indeterminate", 17 | "colorName": "yellow", 18 | "name": "In Progress" 19 | } 20 | } 21 | }, 22 | { 23 | "id": "2", 24 | "name": "Accept Issue", 25 | "to": { 26 | "self": "https://jiraprf.benten.com/rest/api/2/status/6", 27 | "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", 28 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/closed.png", 29 | "name": "Closed", 30 | "id": "6", 31 | "statusCategory": { 32 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/3", 33 | "id": 3, 34 | "key": "done", 35 | "colorName": "green", 36 | "name": "Done" 37 | } 38 | } 39 | }, 40 | { 41 | "id": "851", 42 | "name": "Issue Blocked", 43 | "to": { 44 | "self": "https://jiraprf.benten.com/rest/api/2/status/10011", 45 | "description": "", 46 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/needinfo.png", 47 | "name": "Blocked", 48 | "id": "10011", 49 | "statusCategory": { 50 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 51 | "id": 4, 52 | "key": "indeterminate", 53 | "colorName": "yellow", 54 | "name": "In Progress" 55 | } 56 | } 57 | } 58 | ] 59 | } -------------------------------------------------------------------------------- /benten-weather-bolt/src/test/java/com/intuit/benten/weather/actionhandlers/BentenWeatherActionHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.weather.actionhandlers; 2 | 3 | 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.JsonPrimitive; 6 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 7 | import com.intuit.benten.common.channel.Channel; 8 | import com.intuit.benten.common.channel.ChannelInformation; 9 | import com.intuit.benten.common.nlp.BentenMessage; 10 | import java.util.HashMap; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 16 | import org.springframework.context.annotation.ComponentScan; 17 | import org.springframework.test.context.junit4.SpringRunner; 18 | 19 | @EnableAutoConfiguration 20 | @RunWith(SpringRunner.class) 21 | @ComponentScan(value = "com.intuit.benten") 22 | public class BentenWeatherActionHandlerTest { 23 | 24 | @Autowired 25 | BentenWeatherActionHandler bentenWeatherActionHandler; 26 | 27 | @Test 28 | public void testHandleRRequest() { 29 | BentenHandlerResponse bentenHandlerResponse = bentenWeatherActionHandler.handle(constructBentenMessage("foo")); 30 | Assert.assertEquals(bentenHandlerResponse.getBentenSlackResponse().getSlackText(), 31 | BentenWeatherActionHandler.THANK_YOU_FOR_ASKING); 32 | } 33 | 34 | public static BentenMessage constructBentenMessage(String city) { 35 | HashMap parameters = new HashMap(); 36 | BentenMessage bentenMessage = new BentenMessage(); 37 | parameters.put(BentenWeatherActionHandler.CITY, new JsonPrimitive(city)); 38 | bentenMessage.setParameters(parameters); 39 | bentenMessage.setChannel(new Channel() { 40 | @Override 41 | public void sendMessage(final BentenHandlerResponse bentenHandlerResponse, 42 | final ChannelInformation channelInformation) { 43 | } 44 | }); 45 | return bentenMessage; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/test/java/com/intuit/benten/jira/transitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expand": "transitions", 3 | "transitions": [ 4 | { 5 | "id": "4", 6 | "name": "Start Progress", 7 | "to": { 8 | "self": "https://jiraprf.benten.com/rest/api/2/status/3", 9 | "description": "This issue is being actively worked on at the moment by the assignee.", 10 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/inprogress.png", 11 | "name": "In Progress", 12 | "id": "3", 13 | "statusCategory": { 14 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 15 | "id": 4, 16 | "key": "indeterminate", 17 | "colorName": "yellow", 18 | "name": "In Progress" 19 | } 20 | } 21 | }, 22 | { 23 | "id": "2", 24 | "name": "Accept Issue", 25 | "to": { 26 | "self": "https://jiraprf.benten.com/rest/api/2/status/6", 27 | "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", 28 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/closed.png", 29 | "name": "Closed", 30 | "id": "6", 31 | "statusCategory": { 32 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/3", 33 | "id": 3, 34 | "key": "done", 35 | "colorName": "green", 36 | "name": "Done" 37 | } 38 | } 39 | }, 40 | { 41 | "id": "851", 42 | "name": "Issue Blocked", 43 | "to": { 44 | "self": "https://jiraprf.benten.com/rest/api/2/status/10011", 45 | "description": "", 46 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/needinfo.png", 47 | "name": "Blocked", 48 | "id": "10011", 49 | "statusCategory": { 50 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 51 | "id": 4, 52 | "key": "indeterminate", 53 | "colorName": "yellow", 54 | "name": "In Progress" 55 | } 56 | } 57 | } 58 | ] 59 | } -------------------------------------------------------------------------------- /benten-weather-bolt/src/main/java/com.intuit.benten/weather/actionhandlers/BentenWeatherActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.weather.actionhandlers; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 4 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 5 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 6 | import com.intuit.benten.common.annotations.ActionHandler; 7 | import com.intuit.benten.common.helpers.BentenMessageHelper; 8 | import com.intuit.benten.common.nlp.BentenMessage; 9 | import com.intuit.benten.weather.util.WeatherResponseUtil; 10 | import com.intuit.benten.weather.client.BentenWeatherClient; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * @author Ashpak Shaikh 17 | * @version 1.0 18 | */ 19 | @Component 20 | @Slf4j 21 | @ActionHandler(action = "action_benten_weather") 22 | public class BentenWeatherActionHandler implements BentenActionHandler { 23 | 24 | public static final String CITY = "city"; 25 | public static final String THANK_YOU_FOR_ASKING = "`Thank you for asking`"; 26 | @Autowired 27 | BentenWeatherClient bentenWeatherClent; 28 | 29 | @Override 30 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 31 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 32 | BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); 33 | bentenHandlerResponse.setBentenSlackResponse(bentenSlackResponse); 34 | try { 35 | String city = BentenMessageHelper.getParameterAsString(bentenMessage, CITY); 36 | bentenSlackResponse.setSlackText(WeatherResponseUtil.format(bentenWeatherClent.getWeatherFromCurrentCity(city))); 37 | bentenMessage.getChannel().sendMessage(bentenHandlerResponse, bentenMessage.getChannelInformation()); 38 | } catch (Exception ex) { 39 | log.error("Exception caught ", ex); 40 | } 41 | bentenSlackResponse.setSlackText(THANK_YOU_FOR_ASKING); 42 | return bentenHandlerResponse; 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/src/main/java/com/intuit/benten/hackernews/utils/SlackHackerNewsMessageRenderer.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.hackernews.utils; 2 | 3 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 4 | import com.intuit.benten.common.formatters.SlackFormatter; 5 | import com.intuit.benten.hackernews.exceptions.BentenHackernewsException; 6 | import com.intuit.benten.hackernews.model.HackernewsItem; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jleveroni on 10/09/2019 12 | */ 13 | public class SlackHackerNewsMessageRenderer { 14 | public static BentenSlackResponse renderItemList(List stories) { 15 | BentenSlackResponse bentenSlackResponse= new BentenSlackResponse(); 16 | SlackFormatter slackFormatter = SlackFormatter.create(); 17 | slackFormatter.text("Here's what I was able to dig up:").newline(); 18 | 19 | for (HackernewsItem story : stories) { 20 | slackFormatter.bold(story.getTitle()) 21 | .italic("| By:").italic(story.getBy()).italic("|").text(" "); 22 | 23 | if (story.getUrl() == null) { 24 | slackFormatter.link( 25 | HackernewsConstants.ApiEndpoints.HACKERNEWS_ITEM_URL + story.getId(), 26 | "View article").newline(); 27 | } else { 28 | slackFormatter.link(story.getUrl(), "View article").newline(); 29 | } 30 | } 31 | 32 | bentenSlackResponse.setSlackText(slackFormatter.build()); 33 | return bentenSlackResponse; 34 | } 35 | 36 | public static BentenSlackResponse renderError(String action, BentenHackernewsException e) { 37 | BentenSlackResponse bentenSlackResponse= new BentenSlackResponse(); 38 | SlackFormatter slackFormatter = SlackFormatter.create(); 39 | 40 | slackFormatter.bold("An error occurred processing the ").text(action).text("action"); 41 | slackFormatter.text("Error description: ").text(e.getMessage()); 42 | bentenSlackResponse.setSlackText(slackFormatter.build()); 43 | return bentenSlackResponse; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/model/TableToHtmlConverter.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Divakar Ungatla 7 | * @version 1.0 8 | */ 9 | public class TableToHtmlConverter { 10 | 11 | public static String convertTableToHtmlTable(Table table){ 12 | 13 | String htmlTable = "

" + table.getTitle() + "

"; 14 | htmlTable += ""; 15 | for (int counter=0; counter < table.getRowHeaders().size();counter++) { 16 | boolean isFirst = (counter==0) ; 17 | htmlTable+=rowHeader(table.getRowHeaders().get(counter),isFirst); 18 | } 19 | 20 | for(int counter=0 ; counter< table.getRows().size();counter++){ 21 | List currentRow = table.getRows().get(counter); 22 | htmlTable+=""; 23 | 24 | for(int cellCounter =0; cellCounter" 38 | + text + ""; 39 | return rowHeader; 40 | } 41 | 42 | private static String rowElement(String text,int index,boolean isFirst){ 43 | String style = "\"border: 1px solid #000000; padding: 8px;border-top: none;"; 44 | style += isFirst ? "" : "border-left: none;"; 45 | style += (index%2 == 0) ? "background-color: #f2f2f2;\"" : "\""; 46 | String rowElement = ""; 49 | return rowElement; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /benten-archetype/src/main/resources/archetype-resources/src/main/resources/transitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expand": "transitions", 3 | "transitions": [ 4 | { 5 | "id": "4", 6 | "name": "Start Progress", 7 | "to": { 8 | "self": "https://jiraprf.benten.com/rest/api/2/status/3", 9 | "description": "This issue is being actively worked on at the moment by the assignee.", 10 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/inprogress.png", 11 | "name": "In Progress", 12 | "id": "3", 13 | "statusCategory": { 14 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 15 | "id": 4, 16 | "key": "indeterminate", 17 | "colorName": "yellow", 18 | "name": "In Progress" 19 | } 20 | } 21 | }, 22 | { 23 | "id": "2", 24 | "name": "Accept Issue", 25 | "to": { 26 | "self": "https://jiraprf.benten.com/rest/api/2/status/6", 27 | "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", 28 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/closed.png", 29 | "name": "Closed", 30 | "id": "6", 31 | "statusCategory": { 32 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/3", 33 | "id": 3, 34 | "key": "done", 35 | "colorName": "green", 36 | "name": "Done" 37 | } 38 | } 39 | }, 40 | { 41 | "id": "851", 42 | "name": "Issue Blocked", 43 | "to": { 44 | "self": "https://jiraprf.benten.com/rest/api/2/status/10011", 45 | "description": "", 46 | "iconUrl": "https://jiraprf.benten.com/images/icons/statuses/needinfo.png", 47 | "name": "Blocked", 48 | "id": "10011", 49 | "statusCategory": { 50 | "self": "https://jiraprf.benten.com/rest/api/2/statuscategory/4", 51 | "id": 4, 52 | "key": "indeterminate", 53 | "colorName": "yellow", 54 | "name": "In Progress" 55 | } 56 | } 57 | } 58 | ] 59 | } -------------------------------------------------------------------------------- /benten-flickr-bolt/src/main/java/com/intuit/benten/flickr/actionhandlers/FlickrBrandCamerasActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.flickr.actionhandlers; 2 | 3 | import com.flickr4java.flickr.FlickrException; 4 | import com.flickr4java.flickr.cameras.Camera; 5 | import com.intuit.benten.BentenFlickrClient; 6 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 7 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 8 | import com.intuit.benten.common.actionhandlers.BentenSlackResponse; 9 | import com.intuit.benten.common.annotations.ActionHandler; 10 | import com.intuit.benten.common.formatters.SlackFormatter; 11 | import com.intuit.benten.common.helpers.BentenMessageHelper; 12 | import com.intuit.benten.common.nlp.BentenMessage; 13 | import com.intuit.benten.flickr.exceptions.BentenFlickrException; 14 | import com.intuit.benten.flickr.utils.SlackFlickrMessageRenderer; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Component; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * Created by itstc on 2019-10-11 22 | */ 23 | @Component 24 | @ActionHandler(action=FlickrActions.ACTION_FLICKR_BRAND_CAMERAS) 25 | public class FlickrBrandCamerasActionHandler implements BentenActionHandler { 26 | 27 | @Autowired 28 | BentenFlickrClient bentenFlickrClient; 29 | 30 | @Override 31 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 32 | BentenHandlerResponse handlerResponse = new BentenHandlerResponse(); 33 | String brandName = BentenMessageHelper.getParameterAsString(bentenMessage, FlickrActionParamaters.PARAMETER_BRAND_NAME); 34 | try { 35 | List result = bentenFlickrClient.getBrandCameras(brandName); 36 | handlerResponse.setBentenSlackResponse(SlackFlickrMessageRenderer.renderList(result)); 37 | } catch (BentenFlickrException e) { 38 | BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); 39 | bentenSlackResponse.setSlackText(String.format("No cameras found for %s", brandName)); 40 | handlerResponse.setBentenSlackResponse(bentenSlackResponse); 41 | } 42 | 43 | return handlerResponse; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/helpers/BentenMessageHelper.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.helpers; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.google.gson.JsonArray; 5 | import com.google.gson.JsonElement; 6 | import com.google.gson.JsonObject; 7 | import com.intuit.benten.common.nlp.BentenMessage; 8 | 9 | import java.util.*; 10 | 11 | /** 12 | * @author Divakar Ungatla 13 | * @version 1.0 14 | */ 15 | public class BentenMessageHelper { 16 | public static String getParameterAsString(BentenMessage bentenMessage, String parameterName){ 17 | HashMap parameters = bentenMessage.getParameters(); 18 | if(parameters.containsKey(parameterName) && parameters.get(parameterName)!=null){ 19 | return parameters.get(parameterName).getAsString(); 20 | } 21 | return null; 22 | } 23 | public static Integer getParameterAsInteger(BentenMessage bentenMessage, String parameterName){ 24 | HashMap parameters = bentenMessage.getParameters(); 25 | if(parameters.containsKey(parameterName) && parameters.get(parameterName)!=null){ 26 | return parameters.get(parameterName).getAsInt(); 27 | } 28 | return null; 29 | } 30 | public static List getParameterAsList(BentenMessage bentenMessage, String parameterName ){ 31 | HashMap parameters = bentenMessage.getParameters(); 32 | List arrayList = null; 33 | 34 | if(parameters.containsKey(parameterName) && parameters.get(parameterName)!=null){ 35 | JsonArray jsonArray = parameters.get(parameterName).getAsJsonArray(); 36 | arrayList = new ArrayList<>(); 37 | for(int i=0;i < jsonArray.size();i++){ 38 | arrayList.add(jsonArray.get(i).getAsString()); 39 | } 40 | } 41 | return arrayList; 42 | } 43 | 44 | public static String getParameterAsString(Map parameters, String parameterName){ 45 | if(parameters.containsKey(parameterName) && parameters.get(parameterName)!=null){ 46 | return parameters.get(parameterName).getAsString(); 47 | } 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /benten-hackernews-bolt/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | benten-hackernews-bolt 8 | benten-hackernews-bolt 9 | jar 10 | 11 | 12 | com.intuit.benten 13 | benten-parent 14 | 0.1.5 15 | 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-starter 21 | ${spring.version} 22 | 23 | 24 | org.apache.httpcomponents 25 | httpclient 26 | 4.5.5 27 | 28 | 29 | net.sf.json-lib 30 | json-lib 31 | 2.4 32 | jdk15 33 | 34 | 35 | com.intuit.benten 36 | benten-common 37 | 0.1.5 38 | 39 | 40 | com.fasterxml.jackson.core 41 | jackson-core 42 | 2.9.4 43 | 44 | 45 | org.asynchttpclient 46 | async-http-client 47 | 2.4.3 48 | test 49 | 50 | 51 | com.intuit.karate 52 | karate-netty 53 | ${karate.version} 54 | test 55 | 56 | 57 | -------------------------------------------------------------------------------- /benten-jira-bolt/src/main/java/com/intuit/benten/jira/actionhandlers/JiraCommentActionHandler.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.jira.actionhandlers; 2 | 3 | import com.intuit.benten.common.annotations.ActionHandler; 4 | import com.intuit.benten.jira.BentenJiraClient; 5 | import com.intuit.benten.common.actionhandlers.BentenActionHandler; 6 | import com.intuit.benten.common.actionhandlers.BentenHandlerResponse; 7 | import com.intuit.benten.common.constants.SlackConstants; 8 | import com.intuit.benten.jira.exceptions.BentenJiraException; 9 | import com.intuit.benten.common.helpers.BentenMessageHelper; 10 | import com.intuit.benten.common.nlp.BentenMessage; 11 | import com.intuit.benten.jira.utils.SlackMessageRenderer; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * @author Divakar Ungatla 17 | * @version 1.0 18 | */ 19 | @Component 20 | @ActionHandler(action = JiraActions.ACTION_JIRA_COMMENT_ISSUE) 21 | public class JiraCommentActionHandler implements BentenActionHandler { 22 | 23 | @Autowired 24 | private BentenJiraClient bentenJiraClient; 25 | 26 | public BentenHandlerResponse handle(BentenMessage bentenMessage) { 27 | String issueKey = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_ISSUE_KEY); 28 | String currentUser = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.CURRENT_USER); 29 | String comment = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.COMMENT); 30 | 31 | BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); 32 | 33 | try { 34 | bentenJiraClient.comment(issueKey, comment, currentUser); 35 | bentenHandlerResponse 36 | .setBentenSlackResponse(SlackMessageRenderer.commentMessage(issueKey)); 37 | }catch(BentenJiraException e){ 38 | bentenHandlerResponse 39 | .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":")+1))); 40 | }catch (Exception e){ 41 | throw new BentenJiraException(e.getMessage()); 42 | } 43 | 44 | return bentenHandlerResponse; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /benten-core/src/main/java/com/intuit/benten/handlers/BentenConversationCatalystFactory.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.handlers; 2 | 3 | import com.intuit.benten.common.annotations.BentenConversationCatalyst; 4 | import com.intuit.benten.common.conversationcatalysts.ConversationCatalyst; 5 | import com.intuit.benten.common.conversationcatalysts.ConversationCatalystFactory; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.beans.factory.config.BeanDefinition; 10 | import org.springframework.context.ApplicationContext; 11 | import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; 12 | import org.springframework.core.type.filter.AnnotationTypeFilter; 13 | import org.springframework.stereotype.Component; 14 | 15 | import javax.annotation.PostConstruct; 16 | import java.util.HashMap; 17 | 18 | /** 19 | * @author Divakar Ungatla 20 | * @version 1.0 21 | */ 22 | @Component 23 | public class BentenConversationCatalystFactory implements ConversationCatalystFactory { 24 | 25 | private static final Logger logger = LoggerFactory.getLogger(BentenConversationCatalystFactory.class); 26 | 27 | @Autowired 28 | private ApplicationContext applicationContext; 29 | 30 | HashMap conversationCatalystMap = new HashMap<>(); 31 | 32 | ClassPathScanningCandidateComponentProvider scanner; 33 | 34 | @PostConstruct 35 | public void init() throws ClassNotFoundException { 36 | scanner = 37 | new ClassPathScanningCandidateComponentProvider(false); 38 | scanner.addIncludeFilter(new AnnotationTypeFilter(BentenConversationCatalyst.class)); 39 | 40 | for (BeanDefinition bd : scanner.findCandidateComponents("com.intuit.benten")) 41 | { 42 | Object object = applicationContext.getBean(Class.forName(bd.getBeanClassName())); 43 | conversationCatalystMap.put(object.getClass().getAnnotation(BentenConversationCatalyst.class).action(),(ConversationCatalyst) object); 44 | } 45 | 46 | } 47 | 48 | 49 | @Override 50 | public HashMap getConversationCatalystMap() { 51 | return conversationCatalystMap; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /benten-common/src/main/java/com/intuit/benten/common/actionhandlers/BentenSlackAttachment.java: -------------------------------------------------------------------------------- 1 | package com.intuit.benten.common.actionhandlers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Divakar Ungatla 8 | * @version 1.0 9 | */ 10 | public class BentenSlackAttachment { 11 | 12 | protected String title; 13 | protected String title_link; 14 | protected String text; 15 | protected String color; 16 | protected String image_url; 17 | protected String thumb_url; 18 | protected List bentenSlackFields = new ArrayList<>(); 19 | protected String pretext; 20 | 21 | public String getText() { 22 | return text; 23 | } 24 | 25 | public void setText(String text) { 26 | this.text = text; 27 | } 28 | 29 | public String getColor() { 30 | return color; 31 | } 32 | 33 | public void setColor(String color) { 34 | this.color = color; 35 | } 36 | 37 | public List getBentenSlackFields() { 38 | return bentenSlackFields; 39 | } 40 | 41 | public void setBentenSlackFields(List bentenSlackFields) { 42 | this.bentenSlackFields = bentenSlackFields; 43 | } 44 | 45 | public String getTitle() { 46 | return title; 47 | } 48 | 49 | public void setTitle(String title) { 50 | this.title = title; 51 | } 52 | 53 | public String getTitle_link() { 54 | return title_link; 55 | } 56 | 57 | public void setTitle_link(String title_link) { 58 | this.title_link = title_link; 59 | } 60 | 61 | public String getPretext() { 62 | return pretext; 63 | } 64 | 65 | public void setPretext(String pretext) { 66 | this.pretext = pretext; 67 | } 68 | 69 | public void addBentenSlackField(BentenSlackField bentenSlackField){ 70 | bentenSlackFields.add(bentenSlackField); 71 | } 72 | 73 | public String getImage_url() { 74 | return image_url; 75 | } 76 | 77 | public void setImage_url(String image_url) { 78 | this.image_url = image_url; 79 | } 80 | 81 | public String getThumb_url() { 82 | return thumb_url; 83 | } 84 | 85 | public void setThumb_url(String thumb_url) { 86 | this.thumb_url = thumb_url; 87 | } 88 | } 89 | --------------------------------------------------------------------------------
" 48 | + text + "