-
Notifications
You must be signed in to change notification settings - Fork 27
Add a workflow task that sends a message to topic in TIBCO #123
Conversation
2b29fe1
to
7a96bf6
Compare
private Tibjms service; | ||
private String url; | ||
private String caFile; | ||
private String username; | ||
private String password; |
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'd suggest to make these private 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.
@gciavarrini fixed
String caFile = "/cafile"; | ||
String url = "ssl://localhost:7222"; | ||
String username = "username"; | ||
String passowrd = "password"; | ||
String topic = "topic"; | ||
String message = "test message"; |
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'd suggest to make this private 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.
why?
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.
private
= it's a best practice to keep the scope as narrow as you can.
final
= It's a good practice to declare final a variable to be sure that it won't be modified unintentionally, and in addition it makes the understanding of code easier.
TBH this strings can be declared private static final
so we're stating that such variables are constants and that they are associated with the class (not the instance of the class)
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.
@gciavarrini fixed
Tibjms tibjms = Mockito.mock(Tibjms.class); | ||
TibcoWorkFlowTask task = new TibcoWorkFlowTask(tibjms, url, caFile, username, passowrd); |
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.
It's a good practice to initialize objects in @Before
method.
In this way, the object is recreated before each test.
In addition, make these objects private as well.
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.
good practice? I don't think so. Not in this case. In the case of simple initialization, we have the Java language that works for us. You don't need to use additional libraries.
Why make them private? No one is going to use this class outside the test. The default is package-private.
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.
If you modify the object inside one of tests, then following tests will use a "dirty" object.
Regarding the private
= It's a good practice to start to use the narrow privilege and the increase it if needed (so, private
is more restrictive then package-private
). Ideally, a good practice is to create immutable classes, but I understand that we can be flexible in this.
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.
The Before does not solve it. It only happens once in the beginning. If test A changes something then test B will see a dirty obj.
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 think you're confusing @Before
with @BeforeClass
public class Example {
@BeforeClass
public static void classSetUp(){
System.out.println("Before Class");
}
@Before
public void setUp(){
System.out.println("Before");
}
@Test
public void test1(){
System.out.println("Test 1");
}
@Test
public void test2(){
System.out.println("Test 2");
}
}
when you execute all the tests in the Example
class then they print:
Before Class
Before
Test 1
Before
Test 2
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.
fixed
tasks/src/test/java/com/redhat/parodos/tasks/TibcoWorkFlowTaskTest.java
Outdated
Show resolved
Hide resolved
tasks/src/test/java/com/redhat/parodos/tasks/TibcoWorkFlowTaskTest.java
Outdated
Show resolved
Hide resolved
tasks/src/test/java/com/redhat/parodos/tasks/TibcoWorkFlowTaskTest.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,34 @@ | |||
// @formatter:off |
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.
why is it necessary to disable the formatter for the whole file?
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.
so I don't need to execute it for every change. I don't need this formatter.
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.
that will eventually end as s project with multiple formatting while the convention is to use spring formatted.
while I find it PITA to keep running the formatted, we'd better handle auto-format rather than skip it.
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.
why not skip?
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.
@gciavarrini fixed
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.
It is still there. Can you double check?
pom.xml
Outdated
@@ -62,6 +62,7 @@ | |||
<module>notification-service</module> | |||
<module>pattern-detection-library</module> | |||
<module>coverage</module> | |||
<module>tasks</module> |
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 module is going to be used for all common tasks
I think it should be renamed to more informative name
I suggest: workflow-common-tasks
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.
We know it is common. We know it is for workflow. Why add all this text? I can somehow understand the addition of 'workflow-'. Some how ...
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.
We know its common
, I'm not sure how clear it would be for new users, I think its better to make it explicit so it would more clear.
Anyway, I don't have any problem with changing to workflow-tasks
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.
used prebuilt-tasks. workflow-tasks collides with existing workflow task objects
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.
@nirarg fixed
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 suggest to keep this module directory only with the tasks files
Remove all other utils files to another sub-directory
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.
it only makes it more complex. I will move the whole tibco task to a sub-directory
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 think, for the long term, we would like to avoid having one directory contains many files
Need to keep it clean, maybe should use here more hierarchical folders
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.
more hierarchy more problems more difficulties reading and following files
/retest |
b8e2d18
to
1b60873
Compare
@@ -0,0 +1,10 @@ | |||
#!/bin/bash | |||
if [ -f "tibjms.jar" ]; then exit 0; fi | |||
rm -rf /tmp/tibco |
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.
nit: maybe mktemp -d tibco-XXX
?
(just in case there are few build processes running on the same machine)
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.
really? isn't each build in its own container?
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 don't know. maybe @eloycoto knows?
prebuilt-tasks/src/main/java/com/redhat/parodos/tasks/tibco/TibjmsImpl.java
Outdated
Show resolved
Hide resolved
prebuilt-tasks/pom.xml
Outdated
<version>1.18.24</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> |
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 haven't seen a direct use of this dependency.
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 did not add it. I think it is for the '@slf4j'
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.
'@slf4j' comes from lombok. pls try to build without that dependency and see if it is actually being used.
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.
fixed
prebuilt-tasks/src/main/java/com/redhat/parodos/tasks/tibco/TibjmsImpl.java
Outdated
Show resolved
Hide resolved
prebuilt-tasks/src/test/java/com/redhat/parodos/tasks/tibco/TibcoWorkFlowTaskTest.java
Outdated
Show resolved
Hide resolved
workflow-examples/pom.xml
Outdated
<groupId>dev.parodos</groupId> | ||
<artifactId>prebuilt-tasks</artifactId> | ||
<version>${revision}</version> | ||
<scope>compile</scope> |
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.
compile
is the default scope. It can be removed.
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.
@masayag fixed
@@ -0,0 +1,34 @@ | |||
// @formatter:off |
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.
that will eventually end as s project with multiple formatting while the convention is to use spring formatted.
while I find it PITA to keep running the formatted, we'd better handle auto-format rather than skip it.
String topic = getParameterValue(workContext, "topic"); | ||
String message = getParameterValue(workContext, "message"); | ||
|
||
log.debug("sending to topic " + topic + " message: " + message); |
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.
instead of string concatenation, use
log.debug("sending to topic {} message: {}", topic, message);
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.
and that's why?
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.
that's what preventing approval of this PR?
prebuilt-tasks/src/test/java/com/redhat/parodos/tasks/tibco/TibcoWorkFlowTaskTest.java
Outdated
Show resolved
Hide resolved
map = Map.of("topic",topic,"message",message); | ||
} else { | ||
map = new HashMap(); | ||
} |
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.
Why do not create the HashMap before the if
and then add value if withParams
is true ?
HashMap<String, String> map = new HashMap<>();
if(withParams){
map.put("topic", topic);
map.put("message", message);
}
In addition, map
is a variable name too generic, what about messageMap
or something more "declarative"?
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.
why? see my previous comment. I changed it just so we can continue
prebuilt-tasks/src/main/java/com/redhat/parodos/tasks/tibco/TibcoWorkFlowTask.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,34 @@ | |||
// @formatter:off |
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.
It is still there. Can you double check?
prebuilt-tasks/src/test/java/com/redhat/parodos/tasks/tibco/TibcoWorkFlowTaskTest.java
Outdated
Show resolved
Hide resolved
private final String caFile = "/cafile"; | ||
private final String url = "ssl://localhost:7222"; | ||
private final String username = "username"; | ||
private final String passowrd = "password"; | ||
private final String topic = "topic"; | ||
private final String message = "test message"; |
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.
missing static
as per our previous discussion :)
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.
does it really matter?
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.
fixed
709c466
to
a527101
Compare
lgtm |
FLPATH-145 https://issues.redhat.com/browse/FLPATH-145 Signed-off-by: Yaron Dayagi <ydayagi@redhat.com>
/lgtm |
@gciavarrini please remove |
/approve |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gciavarrini, pkliczewski, ydayagi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
FLPATH-145 https://issues.redhat.com/browse/FLPATH-145