@@ -919,4 +919,156 @@ public void label_deleted() throws Exception {
919919 assertThat (label .isDefault (), is (false ));
920920 assertThat (label .getDescription (), is ("description" ));
921921 }
922+
923+ @ Test
924+ public void discussion_created () throws Exception {
925+ final GHEventPayload .Discussion discussionPayload = GitHub .offline ()
926+ .parseEventPayload (payload .asReader (), GHEventPayload .Discussion .class );
927+
928+ assertThat (discussionPayload .getAction (), is ("created" ));
929+ assertThat (discussionPayload .getRepository ().getFullName (), is ("gsmet/quarkus-bot-java-playground" ));
930+ assertThat (discussionPayload .getSender ().getLogin (), is ("gsmet" ));
931+
932+ GHRepositoryDiscussion discussion = discussionPayload .getDiscussion ();
933+
934+ GHRepositoryDiscussion .Category category = discussion .getCategory ();
935+
936+ assertThat (category .getId (), is (33522033L ));
937+ assertThat (category .getEmoji (), is (":pray:" ));
938+ assertThat (category .getName (), is ("Q&A" ));
939+ assertThat (category .getDescription (), is ("Ask the community for help" ));
940+ assertThat (category .getCreatedAt ().getTime (), is (1636991431000L ));
941+ assertThat (category .getUpdatedAt ().getTime (), is (1636991431000L ));
942+ assertThat (category .getSlug (), is ("q-a" ));
943+ assertThat (category .isAnswerable (), is (true ));
944+
945+ assertThat (discussion .getAnswerHtmlUrl (), is (nullValue ()));
946+ assertThat (discussion .getAnswerChosenAt (), is (nullValue ()));
947+ assertThat (discussion .getAnswerChosenBy (), is (nullValue ()));
948+
949+ assertThat (discussion .getHtmlUrl ().toString (),
950+ is ("https://github.com/gsmet/quarkus-bot-java-playground/discussions/78" ));
951+ assertThat (discussion .getId (), is (3698909L ));
952+ assertThat (discussion .getNodeId (), is ("D_kwDOEq3cwc4AOHDd" ));
953+ assertThat (discussion .getNumber (), is (78 ));
954+ assertThat (discussion .getTitle (), is ("Title of discussion" ));
955+
956+ assertThat (discussion .getUser ().getLogin (), is ("gsmet" ));
957+ assertThat (discussion .getUser ().getId (), is (1279749L ));
958+ assertThat (discussion .getUser ().getNodeId (), is ("MDQ6VXNlcjEyNzk3NDk=" ));
959+
960+ assertThat (discussion .getState (), is (GHRepositoryDiscussion .State .OPEN ));
961+ assertThat (discussion .isLocked (), is (false ));
962+ assertThat (discussion .getComments (), is (0 ));
963+ assertThat (discussion .getCreatedAt ().getTime (), is (1637584949000L ));
964+ assertThat (discussion .getUpdatedAt ().getTime (), is (1637584949000L ));
965+ assertThat (discussion .getAuthorAssociation (), is (GHCommentAuthorAssociation .OWNER ));
966+ assertThat (discussion .getActiveLockReason (), is (nullValue ()));
967+ assertThat (discussion .getBody (), is ("Body of discussion." ));
968+ }
969+
970+ @ Test
971+ public void discussion_answered () throws Exception {
972+ final GHEventPayload .Discussion discussionPayload = GitHub .offline ()
973+ .parseEventPayload (payload .asReader (), GHEventPayload .Discussion .class );
974+
975+ assertThat (discussionPayload .getAction (), is ("answered" ));
976+ assertThat (discussionPayload .getRepository ().getFullName (), is ("gsmet/quarkus-bot-java-playground" ));
977+ assertThat (discussionPayload .getSender ().getLogin (), is ("gsmet" ));
978+
979+ GHRepositoryDiscussion discussion = discussionPayload .getDiscussion ();
980+
981+ GHRepositoryDiscussion .Category category = discussion .getCategory ();
982+
983+ assertThat (category .getId (), is (33522033L ));
984+ assertThat (category .getEmoji (), is (":pray:" ));
985+ assertThat (category .getName (), is ("Q&A" ));
986+ assertThat (category .getDescription (), is ("Ask the community for help" ));
987+ assertThat (category .getCreatedAt ().getTime (), is (1636991431000L ));
988+ assertThat (category .getUpdatedAt ().getTime (), is (1636991431000L ));
989+ assertThat (category .getSlug (), is ("q-a" ));
990+ assertThat (category .isAnswerable (), is (true ));
991+
992+ assertThat (discussion .getAnswerHtmlUrl ().toString (),
993+ is ("https://github.com/gsmet/quarkus-bot-java-playground/discussions/78#discussioncomment-1681242" ));
994+ assertThat (discussion .getAnswerChosenAt ().getTime (), is (1637585047000L ));
995+ assertThat (discussion .getAnswerChosenBy ().getLogin (), is ("gsmet" ));
996+
997+ assertThat (discussion .getHtmlUrl ().toString (),
998+ is ("https://github.com/gsmet/quarkus-bot-java-playground/discussions/78" ));
999+ assertThat (discussion .getId (), is (3698909L ));
1000+ assertThat (discussion .getNodeId (), is ("D_kwDOEq3cwc4AOHDd" ));
1001+ assertThat (discussion .getNumber (), is (78 ));
1002+ assertThat (discussion .getTitle (), is ("Title of discussion" ));
1003+
1004+ assertThat (discussion .getUser ().getLogin (), is ("gsmet" ));
1005+ assertThat (discussion .getUser ().getId (), is (1279749L ));
1006+ assertThat (discussion .getUser ().getNodeId (), is ("MDQ6VXNlcjEyNzk3NDk=" ));
1007+
1008+ assertThat (discussion .getState (), is (GHRepositoryDiscussion .State .OPEN ));
1009+ assertThat (discussion .isLocked (), is (false ));
1010+ assertThat (discussion .getComments (), is (1 ));
1011+ assertThat (discussion .getCreatedAt ().getTime (), is (1637584949000L ));
1012+ assertThat (discussion .getUpdatedAt ().getTime (), is (1637585047000L ));
1013+ assertThat (discussion .getAuthorAssociation (), is (GHCommentAuthorAssociation .OWNER ));
1014+ assertThat (discussion .getActiveLockReason (), is (nullValue ()));
1015+ assertThat (discussion .getBody (), is ("Body of discussion." ));
1016+ }
1017+
1018+ @ Test
1019+ public void discussion_labeled () throws Exception {
1020+ final GHEventPayload .Discussion discussionPayload = GitHub .offline ()
1021+ .parseEventPayload (payload .asReader (), GHEventPayload .Discussion .class );
1022+
1023+ assertThat (discussionPayload .getAction (), is ("labeled" ));
1024+ assertThat (discussionPayload .getRepository ().getFullName (), is ("gsmet/quarkus-bot-java-playground" ));
1025+ assertThat (discussionPayload .getSender ().getLogin (), is ("gsmet" ));
1026+
1027+ GHRepositoryDiscussion discussion = discussionPayload .getDiscussion ();
1028+
1029+ GHRepositoryDiscussion .Category category = discussion .getCategory ();
1030+
1031+ assertThat (category .getId (), is (33522033L ));
1032+ assertThat (category .getEmoji (), is (":pray:" ));
1033+ assertThat (category .getName (), is ("Q&A" ));
1034+ assertThat (category .getDescription (), is ("Ask the community for help" ));
1035+ assertThat (category .getCreatedAt ().getTime (), is (1636991431000L ));
1036+ assertThat (category .getUpdatedAt ().getTime (), is (1636991431000L ));
1037+ assertThat (category .getSlug (), is ("q-a" ));
1038+ assertThat (category .isAnswerable (), is (true ));
1039+
1040+ assertThat (discussion .getAnswerHtmlUrl (), is (nullValue ()));
1041+ assertThat (discussion .getAnswerChosenAt (), is (nullValue ()));
1042+ assertThat (discussion .getAnswerChosenBy (), is (nullValue ()));
1043+
1044+ assertThat (discussion .getHtmlUrl ().toString (),
1045+ is ("https://github.com/gsmet/quarkus-bot-java-playground/discussions/78" ));
1046+ assertThat (discussion .getId (), is (3698909L ));
1047+ assertThat (discussion .getNodeId (), is ("D_kwDOEq3cwc4AOHDd" ));
1048+ assertThat (discussion .getNumber (), is (78 ));
1049+ assertThat (discussion .getTitle (), is ("Title of discussion" ));
1050+
1051+ assertThat (discussion .getUser ().getLogin (), is ("gsmet" ));
1052+ assertThat (discussion .getUser ().getId (), is (1279749L ));
1053+ assertThat (discussion .getUser ().getNodeId (), is ("MDQ6VXNlcjEyNzk3NDk=" ));
1054+
1055+ assertThat (discussion .getState (), is (GHRepositoryDiscussion .State .OPEN ));
1056+ assertThat (discussion .isLocked (), is (false ));
1057+ assertThat (discussion .getComments (), is (0 ));
1058+ assertThat (discussion .getCreatedAt ().getTime (), is (1637584949000L ));
1059+ assertThat (discussion .getUpdatedAt ().getTime (), is (1637584961000L ));
1060+ assertThat (discussion .getAuthorAssociation (), is (GHCommentAuthorAssociation .OWNER ));
1061+ assertThat (discussion .getActiveLockReason (), is (nullValue ()));
1062+ assertThat (discussion .getBody (), is ("Body of discussion." ));
1063+
1064+ GHLabel label = discussionPayload .getLabel ();
1065+ assertThat (label .getId (), is (2543373314L ));
1066+ assertThat (label .getNodeId (), is ("MDU6TGFiZWwyNTQzMzczMzE0" ));
1067+ assertThat (label .getUrl ().toString (),
1068+ is ("https://api.github.com/repos/gsmet/quarkus-bot-java-playground/labels/area/hibernate-validator" ));
1069+ assertThat (label .getName (), is ("area/hibernate-validator" ));
1070+ assertThat (label .getColor (), is ("ededed" ));
1071+ assertThat (label .isDefault (), is (false ));
1072+ assertThat (label .getDescription (), is (nullValue ()));
1073+ }
9221074}
0 commit comments