-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Allow null message in SlackMessage #31288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pinging @elastic/es-core-infra |
@elasticmachine test this please |
@albendz ty for the contribution. ill be pulling this down today to check it out. |
A few comments so far. Your branch is a bit old, and this can very easily cause our CI to fail. We move fast :) We typically will push the merge commit to your remote, but I noticed that you were also requesting a PR from your master branch, and not some other branch that would be named anything you wish. I don't like to push to other people's master branch, just because I wouldn't want someone doing it to mine! It is too late for changing the branch and keeping this PR open. I think we should leave it as is, and next time you push, go ahead and do it from a aptly named branch. You can easily merge into your master by fetching the elastic repo's changes, and just issuing a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be testing these against our real slack install as well, so we I can verify what happens when both attachments and text are null. Again, TYVM for the contribution!!!
final String text; | ||
final Attachment[] attachments; | ||
String text; | ||
Attachment[] attachments; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for making these non final? Our objects are typically final. And assigning null to these still counts as making sure they are final. It is very atypical for us to assign setters to objects like this to set these values after construction of the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can correct this. There's no reason for them not to be final.
public void setText(String text) { this.text = text;} | ||
|
||
public void setAttachments(Attachment[] attachments) { this.attachments = attachments;} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see previous comment about final
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.
@@ -602,6 +602,11 @@ public void testUrlPathIsFiltered() throws Exception { | |||
} | |||
} | |||
|
|||
public void canHaveNullTextAndAttachment() throws Exception { | |||
SlackMessage slackMessage = new SlackMessage("from", new String[] {"to"}, "icon"); | |||
assertThat(slackMessage.getText(), is(null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing a compile error for me, pls use assertNull(object)
so it compiles clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.
One other thing I realized is that the issue itself is saying "if we have an attachment, do not require the text from the message itself". This would be better if the constructor could not pass in both attachments and text as null, but one that lets text be null if you pass an attachment in. editI did a test where I removed both text and attachment, and got the following back:
So this definitely wont work with both being null. |
@hub-cap I'll change this so there are finals again, will make sure it's attachments OR text and not null for both. I'll update my fork as well. |
@hub-cap Sorry about being so slow on this - It takes me a very long time to run the build and test. Is there a way to speed this up without losing test coverage? Are there particular hardware requirements that might make it faster to run this project? |
I have created a new branch here (https://github.com/albendz/elasticsearch/tree/slack_message_empty_text). Would you like me to create a new pull request? |
@@ -602,6 +602,11 @@ public void testUrlPathIsFiltered() throws Exception { | |||
} | |||
} | |||
|
|||
public void canHaveNullTextAndAttachment() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will not get executed as a test if the method does not begin with test
if you prefer a new pull request, that is ok. Just be sure to reference this pull request when you open it (and close this one too!). Also, be sure to take @spinscale comment to make sure your test is run. |
New Pull Request: #31596 |
There is no reason to be sorry @albendz! This stuff takes a long time :) Hours for the full check build to be run!! Sometimes it makes sense to run only the pieces that you are testing, but that requires some gradle knowledge about what you are testing, and definitely running it on newer hardware is best. Most of the engineers have newer macbook pro's or linux machines, and many of the elastic engineers run full checks on a desktop or cloud machine because it can destroy your entire laptop productivity! I personally have a bunch of second hand dual proc server grade hardware that I run the checks on, with boatloads of ram :) |
Adding constructors to the slack message class to support more flexibility in null parameters. Additionally provided setters for use-cases where this can be added before message template is created.
#30071
Read and executed all template tasks for contribution. Signed CLA but maybe submitted too soon for check to pass.