Commit 6adfaad8 authored by Florian Schäfer's avatar Florian Schäfer

Fix unit tests

parent ab42b5fe
......@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -18,13 +19,13 @@ public class WbgetclaimsTest extends WikidataActionApiTestAbstract {
public void test() throws IOException, URISyntaxException {
simpleJsonStub(ResourceFileLoader.getResourceBytes(WikidataActionApiQueryTest.class, "response/wbgetclaims/Q2.json"));
final WbgetclaimsResult result = ApiQueryClient.query(WikidataActionApiQuery.wbgetclaims("Q2"));
final Collection<WbgetclaimsResult.Claim> result = ApiQueryClient.query(WikidataActionApiQuery.wbgetclaims("Q2"));
assertEquals(216, result.getClaims().size()); // Total number of claims
assertEquals(WbgetclaimsResult.Claim.RANK.PREFERRED, result.getClaims().stream().filter(it -> "Q2$9bbb058a-48ab-0a81-e88e-82bba6b2abe5".equals(it.getId())).findFirst().get().getRank());
assertEquals("P31", result.getClaims().stream().filter(it -> "Q2$50fad68d-4f91-f878-6f29-e655af54690e".equals(it.getId())).findFirst().get().getMainSnak().getProperty());
assertEquals(216, result.size()); // Total number of claims
assertEquals(WbgetclaimsResult.Claim.RANK.PREFERRED, result.stream().filter(it -> "Q2$9bbb058a-48ab-0a81-e88e-82bba6b2abe5".equals(it.getId())).findFirst().get().getRank());
assertEquals("P31", result.stream().filter(it -> "Q2$50fad68d-4f91-f878-6f29-e655af54690e".equals(it.getId())).findFirst().get().getMainSnak().getProperty());
final Map<String, List<WbgetclaimsResult.Claim>> claimMap = result.getClaims().stream().collect(Collectors.groupingBy(it -> it.getMainSnak().getProperty()));
final Map<String, List<WbgetclaimsResult.Claim>> claimMap = result.stream().collect(Collectors.groupingBy(it -> it.getMainSnak().getProperty()));
assertEquals(97, claimMap.keySet().size()); // Number of different properties for which claims exist
simpleRequestVerify("format=json&utf8=1&formatversion=1&action=wbgetclaims&props=&entity=Q2");
......
......@@ -73,7 +73,7 @@ public class WikipediaActionApiQueryTest {
@Override
public SitematrixResult.Sitematrix.Site getSite() {
return new SitematrixResult.Sitematrix.Site("http://localhost:" + wmRule.port(), "dbname", "code", "false");
return new SitematrixResult.Sitematrix.Site("http://localhost:" + wmRule.port(), "dbname", "code", "false", "Wikipedia");
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment