2019-01-23 14:58:59 +01:00
package org.gcube.social_networking.socialutillibrary ;
2019-01-23 15:51:28 +01:00
import java.util.ArrayList ;
2019-01-23 14:58:59 +01:00
import java.util.List ;
2019-01-23 15:51:28 +01:00
import org.gcube.portlets.widgets.pickitem.shared.ItemBean ;
2019-01-24 11:39:36 +01:00
import org.gcube.socialnetworking.token.MessageParser ;
2019-01-23 14:58:59 +01:00
import org.junit.Test ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
public class MessageParserTest {
private static final Logger logger = LoggerFactory . getLogger ( MessageParserTest . class ) ;
2019-01-24 10:02:24 +01:00
public static final String TEST_11 = " Dear all, this is a test to ignore, to select a week for the upcoming 194th #Tcom event, "
+ " hosted by #Apple in #Cupertino, please use this #Doodle: http://Doodle.com/poll/not-existing-poll \ n \ n "
+ " We're closing the poll next Thursday 16th March. " ;
2019-01-23 14:58:59 +01:00
2019-01-24 10:02:24 +01:00
public static final String TEST_12 = " Just because I am so happy to have the SPARQL-endpoint available, \ n "
+ " sharing some sample SPARQL queries: \ n \ n " + " * Classes & usage counts: \ n "
+ " https://virtuoso.parthenos.d4science.org/sparql?default-graph-uri=&query=%09SELECT+%3Fp+%28COUNT%28%3Fp%29+as+%3FpCount%29++%0D%0A%09%09%09%09%09WHERE+%7B%5B%5D+%3Fp+%5B%5D%7D%0D%0A%09%09%09%09%09GROUP+BY+%3Fp&format=text%2Fhtml&timeout=0&debug=on \ n "
+ " \ n " + " * properties and usage counts: \ n "
+ " https://virtuoso.parthenos.d4science.org/sparql?default-graph-uri=&query=SELECT+%3Ftype+%28COUNT%28%3Ftype%29+as+%3FtypeCount%29++%0D%0A%09%09%09%09%09WHERE+%7B%5B%5D+a+%3Ftype%7D%0D%0A%09%09%09%09%09GROUP+BY+%3Ftype&format=text%2Fhtml&timeout=0&debug=on \ n " ;
2019-01-23 14:58:59 +01:00
2019-01-24 10:02:24 +01:00
public static final String TEST_13 = " Dear members, \ n "
+ " The item 'Webinar on Ontology Management using VOCBENCH in the context of AGINFRAPLUS Project' has been just published by Leonardo Candela . \ n "
+ " You can find it here: http://data.d4science.org/ctlg/AGINFRAplus/webinar_on_ontology_management_using_vocbench_in_the_context_of_aginfraplus_project \ n "
+ " #AGINFRAPLUS #VOCBENCH " ;
2019-01-23 14:58:59 +01:00
2019-01-24 10:02:24 +01:00
public static final String TEST_LUCA_1 = " Dear members, \ n "
+ " The item 'just a test with time fields' has been just published by Francesco Mangiacrapa. \ n "
+ " You can find it here: http://data-d.d4science.org/ctlg/NextNext/just_a_test_with_time_fields \ n "
+ " #Text_mining #Field_1 #B3 " ;
2019-01-23 14:58:59 +01:00
2019-01-24 10:02:24 +01:00
public static final String TEST_LUCA_2 = " Francesco Mangiacrapa prova <a href= \" # \" >Francesco Mangiacrapa</a> " ;
public static final String TEST_LUCA_3 = " test   " ;
public static final String TEST_LUCA_4 = " test &<nbsp < " ;
public static final String TEST_LUCA_5 = " Accedete a questo link che vi porta ad un post su linkedin. \ n " +
" https://www.linkedin.com/feed/update/urn:li:activity:6488779074213801984/ \ n " +
" I numeri riportati sono veri ed è motivo di orgoglio per tutti noi aver contribuito alla realizzazione della d4s infra che ha questo utilizzo via i diversi gateway. " ;
2019-01-23 14:58:59 +01:00
2019-01-24 10:51:47 +01:00
public static final String TEST_LUCA_6 = " (www.google.it) " ;
public static final String TEST_LUCA_7 = " Hello (https://doodle.com/poll/not-existing-poll) " ;
2019-01-23 14:58:59 +01:00
@Test
public void test ( ) {
2019-01-23 17:19:24 +01:00
String message = " Prova #Pippo Pollo http://google) <a href= \" /test \" >Luca</a> https://www.linkedin.com/feed/update/urn:li:activity:6488779074213801984 :) " ;
2019-01-23 14:58:59 +01:00
MessageParser messageParser = new MessageParser ( message ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
messageParser = new MessageParser ( TEST_11 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
messageParser = new MessageParser ( TEST_12 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
2019-01-23 17:19:24 +01:00
messageParser = new MessageParser ( TEST_13 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
2019-01-23 15:51:28 +01:00
List < ItemBean > mentionedUsers = new ArrayList < > ( ) ;
ItemBean itemBean = new ItemBean ( " 21150 " , " francesco.mangiacrapa " , " Francesco Mangiacrapa " , " " ) ;
itemBean . setItemGroup ( false ) ;
mentionedUsers . add ( itemBean ) ;
2019-01-24 10:02:24 +01:00
messageParser = new MessageParser ( TEST_LUCA_1 ) ;
2019-01-23 15:51:28 +01:00
logger . debug ( messageParser . getParsedMessage ( mentionedUsers , " /group/nextnext " ) ) ;
2019-01-24 10:02:24 +01:00
messageParser = new MessageParser ( TEST_LUCA_2 ) ;
logger . debug ( messageParser . getParsedMessage ( mentionedUsers , " /group/nextnext " ) ) ;
2019-01-23 14:58:59 +01:00
}
2019-01-24 10:02:24 +01:00
2019-01-23 14:58:59 +01:00
@Test
2019-01-24 10:02:24 +01:00
public void anotherTest ( ) {
MessageParser messageParser = new MessageParser ( TEST_LUCA_4 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
messageParser = new MessageParser ( TEST_LUCA_5 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
2019-01-23 14:58:59 +01:00
}
2019-01-24 10:51:47 +01:00
@Test
public void urlWithParentesisTest ( ) {
MessageParser messageParser = new MessageParser ( TEST_LUCA_6 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
messageParser = new MessageParser ( TEST_LUCA_7 ) ;
logger . debug ( messageParser . getParsedMessage ( ) ) ;
}
2019-01-23 14:58:59 +01:00
}