@ -1,6 +1,6 @@
/ *
XOWA: the XOWA Offline Wiki Application
Copyright ( C ) 2012 - 20 17 gnosygnu @gmail.com
Copyright ( C ) 2012 - 20 20 gnosygnu @gmail.com
XOWA is licensed under the terms of the General Public License ( GPL ) Version 3 ,
or alternatively under the terms of the Apache License Version 2.0 .
@ -13,11 +13,16 @@ The terms of each license can be found in the source code repository:
GPLv3 License : https : //github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License : https : //github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
* /
package gplx.xowa.xtns.wbases.pfuncs ; import gplx.* ; import gplx.xowa.* ; import gplx.xowa.xtns.* ; import gplx.xowa.xtns.wbases.* ;
import org.junit.* ; import gplx.xowa.parsers.* ; import gplx.xowa.parsers.tmpls.* ;
package gplx.xowa.xtns.wbases.pfuncs ;
import gplx.Bry_ ;
import gplx.xowa.xtns.wbases.Wdata_wiki_mgr_fxt ;
import org.junit.Before ;
import org.junit.Test ;
public class Wdata_pf_property__basic__tst {
@Before public void init ( ) { fxt . Init ( ) ; } private final Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt ( ) ;
@Test public void String ( ) {
@Before public void init ( ) { fxt . Init ( ) ; } private final Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt ( ) ;
@Test public void String ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -25,7 +30,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "a" ) ;
fxt . Test_parse ( "{{#property:p2}}" , "" ) ;
}
@Test public void Entity ( ) {
@Test public void Entity ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q2" )
. Add_label ( "en" , "b" )
) ;
@ -35,7 +40,7 @@ public class Wdata_pf_property__basic__tst {
) ;
fxt . Test_parse ( "{{#property:p1}}" , "b" ) ;
}
@Test public void Entity_fr ( ) { // PURPOSE: non-English wiki should default to English label if non-English label not available; DATE:2013-12-19
@Test public void Entity_fr ( ) { // PURPOSE: non-English wiki should default to English label if non-English label not available; DATE:2013-12-19
// set wiki to French
fxt . Wiki ( ) . Wdata_wiki_lang_ ( Bry_ . new_a7 ( "fr" ) ) ;
@ -52,7 +57,7 @@ public class Wdata_pf_property__basic__tst {
// parse; should get en label
fxt . Test_parse ( "{{#property:p1}}" , "b" ) ;
}
@Test public void Entity_missing ( ) { // PURPOSE: wiki may refer to entity that no longer exists; EX: {{#property:p1}} which links to Q1, but p1 links to Q2 and Q2 was deleted; DATE:2014-02-01
@Test public void Entity_missing ( ) { // PURPOSE: wiki may refer to entity that no longer exists; EX: {{#property:p1}} which links to Q1, but p1 links to Q2 and Q2 was deleted; DATE:2014-02-01
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_entity_qid ( 1 , 2 ) ) // create wdata page Q1 with prop entity reference to Q2; note that Q2 is not created
. Add_sitelink ( "enwiki" , "Test_page" )
@ -60,7 +65,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "" ) ; // parse; get ""
}
@Test public void Time ( ) {
@Test public void Time ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_time ( 1 , "2012-01-02 03:04:05" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -68,7 +73,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "30405 2 Jan 2012" ) ; // NOTE: format is missing ":" b/c test does not init messages for html_wtr; DATE:2015-08-03
}
@Test public void Geodata ( ) {
@Test public void Geodata ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_geo ( 1 , "6.789" , "1.2345" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -76,7 +81,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "1°14'4.2"N, 6°47'20.4"E" ) ;
}
@Test public void Quantity__plus_minus__y ( ) {
@Test public void Quantity__plus_minus__y ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_quantity ( 1 , "+1234" , "1" , "+1236" , "+1232" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -84,7 +89,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "1,234±2" ) ;
}
@Test public void Quantity__plus_minus__n ( ) { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
@Test public void Quantity__plus_minus__n ( ) { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_quantity ( 1 , "+1234" , "1" , "+1234" , "+1234" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -92,7 +97,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "1,234" ) ;
}
@Test public void Quantity__range ( ) { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
@Test public void Quantity__range ( ) { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_quantity ( 1 , "+1234" , "1" , "+1236" , "+1233" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -100,7 +105,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "1,233-1,236" ) ;
}
@Test public void Quantity__long ( ) { // PURPOSE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
@Test public void Quantity__long ( ) { // PURPOSE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_quantity ( 1 , "+4321000000" , "1" , "4321000000" , "4321000000" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -108,7 +113,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "4,321,000,000" ) ;
}
@Test public void Quantity__unit__entity ( ) { // PURPOSE: get entity name; EX:{{#invoke:Wikidata|getUnits|P2386|FETCH_WIKIDATA}} PAGE:en.w:Arecibo_Observatory; DATE:2016-10-11
@Test public void Quantity__unit__entity ( ) { // PURPOSE: get entity name; EX:{{#invoke:Wikidata|getUnits|P2386|FETCH_WIKIDATA}} PAGE:en.w:Arecibo_Observatory; DATE:2016-10-11
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_quantity ( 1 , "+1234" , "http://www.wikidata.org/entity/Q2" , "+1236" , "+1232" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -121,7 +126,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "1,234±2 meter" ) ;
}
@Test public void Quantity__decimal ( ) {
@Test public void Quantity__decimal ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_quantity ( 1 , "+1234.50" , "1" , "+1236.75" , "+1232.25" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -129,7 +134,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "1,234.5±2.25" ) ;
}
@Test public void Monolingualtext ( ) {
@Test public void Monolingualtext ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_monolingual ( 1 , "la" , "Lorem ipsum dolor sit amet" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -137,7 +142,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "Lorem ipsum dolor sit amet" ) ;
}
@Test public void Novalue ( ) {
@Test public void Novalue ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_novalue ( 1 ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -145,7 +150,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "no value" ) ;
}
@Test public void Somevalue ( ) {
@Test public void Somevalue ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_somevalue ( 1 ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -153,7 +158,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "unknown value" ) ;
}
@Test public void Multiple ( ) {
@Test public void Multiple ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q1" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) , fxt . Make_claim_string ( 1 , "b" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -161,7 +166,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1}}" , "a" ) ; // only take first; DATE:2015-08-02
}
@Test public void Q ( ) {
@Test public void Q ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q2" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -169,7 +174,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1|q=Q2}}" , "a" ) ;
}
@Test public void Of ( ) {
@Test public void Of ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q2" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) )
. Add_sitelink ( "enwiki" , "Of_page" )
@ -177,7 +182,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1|of=Of_page}}" , "a" ) ;
}
@Test public void From ( ) {
@Test public void From ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Property:P2" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) )
) ;
@ -186,7 +191,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1|from=}}" , "" ) ;
fxt . Test_parse ( "{{#property:p1| from = P2 }}" , "a" ) ; // PURPOSE: trim ws; ISSUE#:361; DATE:2019-02-11
}
@Test public void Pid_as_name ( ) {
@Test public void Pid_as_name ( ) {
fxt . Init__docs__add ( fxt . Wdoc ( "Q2" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -195,7 +200,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:astronomic symbol}}" , "a" ) ;
}
@Test public void Empty_arg ( ) { // PURPOSE: {{#property:p1|}} should not fail / warn; DATE:2013-11-15
@Test public void Empty_arg ( ) { // PURPOSE: {{#property:p1|}} should not fail / warn; DATE:2013-11-15
fxt . Init__docs__add ( fxt . Wdoc ( "Q2" )
. Add_claims ( fxt . Make_claim_string ( 1 , "a" ) )
. Add_sitelink ( "enwiki" , "Test_page" )
@ -204,7 +209,7 @@ public class Wdata_pf_property__basic__tst {
fxt . Test_parse ( "{{#property:p1|}}" , "a" ) ;
}
@Test public void Parse_pid ( ) {
@Test public void Parse_pid ( ) {
fxt . Test_parse_pid ( "p123" , 123 ) ; // basic
fxt . Test_parse_pid ( "P123" , 123 ) ; // uppercase
fxt . Test_parse_pid_null ( "population" ) ; // name test