1818import io .micronaut .test .annotation .MockBean ;
1919import io .micronaut .test .extensions .junit5 .annotation .MicronautTest ;
2020import jakarta .inject .Inject ;
21+ import jakarta .inject .Singleton ;
2122import org .junit .jupiter .api .Assertions ;
2223import org .junit .jupiter .api .Test ;
2324
@@ -51,7 +52,7 @@ public class CommandsTest {
5152 SlackSignature .Generator signatureGenerator = new SlackSignature .Generator (signingSecret );
5253
5354 @ Primary
54- @ MockBean ( AppConfig . class )
55+ @ Singleton
5556 AppConfig mockSlackAppConfig () throws IOException , SlackApiException {
5657 AppConfig config = AppConfig .builder ().signingSecret (signingSecret ).singleTeamBotToken (botToken ).build ();
5758 config .setSlack (mockSlack ());
@@ -76,7 +77,7 @@ Slack mockSlack() throws IOException, SlackApiException {
7677 public void command () {
7778 MutableHttpRequest <String > request = HttpRequest .POST ("/slack/events" , "" );
7879 request .header ("Content-Type" , "application/x-www-form-urlencoded" );
79- String timestamp = "" + (System .currentTimeMillis () / 1000 );
80+ String timestamp = String . valueOf (System .currentTimeMillis () / 1000 );
8081 request .header (SlackSignature .HeaderNames .X_SLACK_REQUEST_TIMESTAMP , timestamp );
8182 String signature = signatureGenerator .generate (timestamp , helloBody );
8283 request .header (SlackSignature .HeaderNames .X_SLACK_SIGNATURE , signature );
@@ -90,7 +91,7 @@ public void command() {
9091 public void invalidSignature () {
9192 MutableHttpRequest <String > request = HttpRequest .POST ("/slack/events" , "" );
9293 request .header ("Content-Type" , "application/x-www-form-urlencoded" );
93- String timestamp = "" + (System .currentTimeMillis () / 1000 - 30 * 60 );
94+ String timestamp = String . valueOf (System .currentTimeMillis () / 1000 - 30 * 60 );
9495 request .header (SlackSignature .HeaderNames .X_SLACK_REQUEST_TIMESTAMP , timestamp );
9596 String signature = signatureGenerator .generate (timestamp , helloBody );
9697 request .header (SlackSignature .HeaderNames .X_SLACK_SIGNATURE , signature );
@@ -122,7 +123,7 @@ public void invalidSignature() {
122123 public void regexp_matching () {
123124 MutableHttpRequest <String > request = HttpRequest .POST ("/slack/events" , "" );
124125 request .header ("Content-Type" , "application/x-www-form-urlencoded" );
125- String timestamp = "" + (System .currentTimeMillis () / 1000 );
126+ String timestamp = String . valueOf (System .currentTimeMillis () / 1000 );
126127 request .header (SlackSignature .HeaderNames .X_SLACK_REQUEST_TIMESTAMP , timestamp );
127128 String signature = signatureGenerator .generate (timestamp , submissionBody );
128129 request .header (SlackSignature .HeaderNames .X_SLACK_SIGNATURE , signature );
0 commit comments