Revision 56150
Added by Alessia Bardi almost 5 years ago
modules/dnet-openaireplus-workflows/trunk/src/test/java/eu/dnetlib/msro/openaireplus/workflows/nodes/vre/VREPostJobNodeTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.workflows.nodes.vre; |
|
2 |
|
|
3 |
import org.junit.Assert; |
|
4 |
import org.junit.Test; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by Alessia Bardi on 2019-06-20. |
|
8 |
* |
|
9 |
* @author Alessia Bardi |
|
10 |
*/ |
|
11 |
public class VREPostJobNodeTest { |
|
12 |
|
|
13 |
private String textWithNewLine = "Hello\\n World\\n!"; |
|
14 |
private String expected = "Hello\n World\n!"; |
|
15 |
|
|
16 |
@Test |
|
17 |
public void testNewLine(){ |
|
18 |
String cleaned = textWithNewLine.replace("\\n", "\n"); |
|
19 |
Assert.assertEquals(expected, cleaned); |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/vre/VREPostJobNode.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
@Override |
44 | 44 |
protected String execute(final NodeToken token) throws Exception { |
45 |
|
|
46 |
log.debug("Posting text: "+getText()); |
|
47 |
|
|
45 | 48 |
CloseableHttpClient httpclient = HttpClients.createDefault(); |
46 | 49 |
try { |
47 | 50 |
URI postUri = new URIBuilder().setScheme(scheme).setHost(host).setPath(postPath).build(); |
... | ... | |
90 | 93 |
|
91 | 94 |
protected JSONObject createPostBody() { |
92 | 95 |
JSONObject obj = new JSONObject(); |
93 |
obj.put("text", text);
|
|
96 |
obj.put("text", text.replace("\\n", "\n"));
|
|
94 | 97 |
obj.put("preview_title", previewTitle); |
95 | 98 |
obj.put("preview_description", previewDescription); |
96 | 99 |
obj.put("image_url", httpImageUrl); |
Also available in: Unified diff
text from wf GUI comes with \\n instead of \n, so we clean the text before posting