Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate if the statement ID is of the right format #500

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public Claim getClaim(EntityIdValue subject, Snak mainSnak,
return getStatement(
subject, mainSnak, qualifiers,
Collections. emptyList(), StatementRank.NORMAL,
"empty id 12345").getClaim();
"Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d").getClaim();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ public class StatementImpl implements Statement {

private List<SnakGroup> qualifiersGroups;

/**
* Checks if the statement ID consists of a first part
* with the entity id of the item the statement belongs to, the separator $, plus
* a random hash of the form
* /^\{?[A-Z\d]{8}-[A-Z\d]{4}-[A-Z\d]{4}-[A-Z\d]{4}-[A-Z\d]{12}\}?\z/
*
* @param statementID
* @return true if the statement ID is of the valid format
*/
public static boolean validateStatementID(String statementID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you raise an exception if the ID is not valid, then returning a boolean is not useful. If the function returns, then you aready know the ID is valid.

{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put curly brace in the same line like all the code base.

if(statementID.equals(""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use curly braces with if to avoid ambiguities.

return true;

String separator = "\\$";
String statementFormat ="^\\{?[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}\\}?$";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will validate millions of IDs. I belive it would be better to precompile the pattern using Pattern.compile and store it in a final static class field.


String[] statementParts = statementID.split(separator);
if(statementParts.length != 2)
throw new IllegalArgumentException("Statement ID does not have the correct number of parts");

if(statementParts[0].charAt(0) != 'Q' && statementParts[0].charAt(0) != 'P' && statementParts[0].charAt(0) != 'L' && statementParts[0].charAt(0) != 'M')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are actually more types (forms, senses, media-info...). You could use EntityIdValueImpl.guessEntityTypeFromId that will does the same thing and supports all types.

throw new TypeNotPresentException("Query,Property or Lexeme", null);

if(!statementParts[1].matches(statementFormat))
throw new IllegalStateException("Statement part does not have a correct format");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation of this line is inconsistent with the rest. Also, I do not think IllegalStateException is appropriate: this should only be used when you detect that some data structure has reached an inconsistent state. To validate arguments, IllegalArgumentException is the one to use.


return true;
}

/**
* Constructor.
* <p>
Expand Down Expand Up @@ -102,6 +132,7 @@ public StatementImpl(
List<Reference> references,
EntityIdValue subjectId) {
this.statementId = (statementId == null) ? "" : statementId;
boolean check = validateStatementID(this.statementId);

Validate.notNull(rank, "No rank provided to create a statement.");
this.rank = rank;
Expand Down Expand Up @@ -131,6 +162,7 @@ public StatementImpl(
List<Reference> references,
EntityIdValue subjectId) {
this.statementId = (statementId == null) ? "" : statementId;
boolean check = validateStatementID(statementId);
Validate.notNull(rank, "No rank provided to create a statement.");
this.rank = rank;
Validate.notNull(mainSnak, "No main snak provided to create a statement.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private Statement getBrokenStatement() {
return Datamodel.makeStatement(
getTestItemIdValue(2), brokenSnak,
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "id");
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private StatementGroup makeTestStatementGroup(
subjectIdValue,
Datamodel.makeSomeValueSnak(propertyIdValue),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "statement-id-" + propertyIdValue.getId());
StatementRank.NORMAL, propertyIdValue.getId() + "$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
return Datamodel.makeStatementGroup(Collections.singletonList(statement));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ public final void testGetStatement() {
factory.getItemIdValue("Q42", "foo"),
factory.getNoValueSnak(factory.getPropertyIdValue("P42", "foo")),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "MyId");
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
Statement o2 = factory.getStatement(
factory.getItemIdValue("Q42", "foo"),
factory.getNoValueSnak(factory.getPropertyIdValue("P42", "foo")),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "MyId");
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
assertEquals(o1, o2);
}

Expand All @@ -356,7 +356,7 @@ public final void testGetStatementGroup() {
factory.getItemIdValue("Q42", "foo"),
factory.getNoValueSnak(factory.getPropertyIdValue("P42", "foo")),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "MyId");
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
StatementGroup o1 = Datamodel.makeStatementGroup(Collections.singletonList(s));
StatementGroup o2 = factory.getStatementGroup(Collections.singletonList(s));
assertEquals(o1, o2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private StatementGroup makeTestStatementGroup(
Datamodel.makeWikidataItemIdValue("Q42"),
Datamodel.makeSomeValueSnak(propertyIdValue),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL,"statement-id-" + propertyIdValue.getId());
StatementRank.NORMAL,propertyIdValue.getId() + "$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
return Datamodel.makeStatementGroup(Collections
.singletonList(statement));
}
Expand Down Expand Up @@ -367,7 +367,7 @@ public void testDeepCopyReferencesFilter() {
Statement statement = Datamodel.makeStatement(
Datamodel.makeWikidataItemIdValue("Q42"), snak,
Collections.emptyList(), Collections.singletonList(reference),
StatementRank.NORMAL,"statement-id-" + propertyIdValue.getId());
StatementRank.NORMAL,propertyIdValue.getId() + "$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
StatementGroup statementGroup = Datamodel
.makeStatementGroup(Collections.singletonList(statement));
ItemDocument itemDocument = Datamodel.makeItemDocument(
Expand All @@ -381,7 +381,7 @@ public void testDeepCopyReferencesFilter() {
Statement statementFiltered = Datamodel.makeStatement(
Datamodel.makeWikidataItemIdValue("Q42"), snak,
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL,"statement-id-" + propertyIdValue.getId());
StatementRank.NORMAL,propertyIdValue.getId() + "$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
StatementGroup statementGroupFiltered = Datamodel
.makeStatementGroup(Collections
.singletonList(statementFiltered));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testSerializer() throws IOException {
Datamodel.makeStatement(qid1,
Datamodel.makeNoValueSnak(Datamodel.makeWikidataPropertyIdValue("P42")),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "MyId"
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d"
)))), Collections.emptyMap(), 1234);
ItemDocument id2 = Datamodel.makeItemDocument(
Datamodel.makeWikidataItemIdValue("Q2"),
Expand Down Expand Up @@ -121,8 +121,8 @@ public void testStatementToJson() {
Statement s = Datamodel.makeStatement(ItemIdValue.NULL,
Datamodel.makeNoValueSnak(Datamodel.makeWikidataPropertyIdValue("P1")),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "MyId");
String json = "{\"rank\":\"normal\",\"id\":\"MyId\",\"mainsnak\":{\"property\":\"P1\",\"snaktype\":\"novalue\"},\"type\":\"statement\"}";
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
String json = "{\"rank\":\"normal\",\"id\":\"Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d\",\"mainsnak\":{\"property\":\"P1\",\"snaktype\":\"novalue\"},\"type\":\"statement\"}";
JsonComparator.compareJsonStrings(json, JsonSerializer.getJsonString(s));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public void testComplexStatement() {

Statement stmt1 = Datamodel.makeStatement(i,
Datamodel.makeValueSnak(p, i), Collections.singletonList(sg),
Collections.singletonList(r), StatementRank.PREFERRED, "id");
Collections.singletonList(r), StatementRank.PREFERRED, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
Statement stmt2 = StatementBuilder.forSubjectAndProperty(i, p)
.withRank(StatementRank.PREFERRED).withValue(i)
.withQualifierSomeValue(p).withQualifierNoValue(p)
.withQualifierValue(p, i).withId("id").withReference(r).build();
.withQualifierValue(p, i).withId("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d").withReference(r).build();

assertEquals(stmt1, stmt2);
}
Expand All @@ -87,10 +87,10 @@ public void testQualifierList() {

Statement stmt1 = Datamodel.makeStatement(i,
Datamodel.makeValueSnak(p, i), Collections.singletonList(sg),
Collections.singletonList(r), StatementRank.PREFERRED, "id");
Collections.singletonList(r), StatementRank.PREFERRED, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
Statement stmt2 = StatementBuilder.forSubjectAndProperty(i, p)
.withRank(StatementRank.PREFERRED).withValue(i)
.withQualifiers(stmt1.getQualifiers()).withId("id")
.withQualifiers(stmt1.getQualifiers()).withId("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d")
.withReference(r).build();

assertEquals(stmt1, stmt2);
Expand All @@ -112,11 +112,11 @@ public void testReferenceList() {

Statement stmt1 = Datamodel.makeStatement(i,
Datamodel.makeValueSnak(p, i), Collections.singletonList(sg),
Arrays.asList(r1, r2), StatementRank.PREFERRED, "id");
Arrays.asList(r1, r2), StatementRank.PREFERRED, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
Statement stmt2 = StatementBuilder.forSubjectAndProperty(i, p)
.withRank(StatementRank.PREFERRED).withValue(i)
.withQualifierSomeValue(p).withQualifierNoValue(p)
.withQualifierValue(p, i).withId("id")
.withQualifierValue(p, i).withId("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d")
.withReferences(Arrays.asList(r1, r2)).build();

assertEquals(stmt1, stmt2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public final void testGetStatementGroup() {
factory.getItemIdValue("Q42", "foo"),
factory.getNoValueSnak(factory.getPropertyIdValue("P42", "foo")),
Collections.emptyList(), Collections.emptyList(),
StatementRank.NORMAL, "MyId");
StatementRank.NORMAL, "Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d");
StatementGroup o1 = new StatementGroupImpl(Collections.singletonList(s));
StatementGroup o2 = factory.getStatementGroup(Collections.singletonList(s));
assertEquals(o1, o2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FormDocumentImplTest {
new ItemIdValueImpl("Q2", "http://example.com/entity/"),
new ItemIdValueImpl("Q1", "http://example.com/entity/")
);
private final Statement s = new StatementImpl("MyId", StatementRank.NORMAL,
private final Statement s = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P42", "http://example.com/entity/")),
Collections.emptyList(), Collections.emptyList(), fid);
private final List<StatementGroup> statementGroups = Collections.singletonList(
Expand All @@ -52,7 +52,7 @@ public class FormDocumentImplTest {
private final FormDocument fd1 = new FormDocumentImpl(fid, repList, gramFeatures, statementGroups, 1234);
private final FormDocument fd2 = new FormDocumentImpl(fid, repList, gramFeatures, statementGroups, 1234);

private final String JSON_FORM = "{\"type\":\"form\",\"id\":\"L42-F1\",\"grammaticalFeatures\":[\"Q1\",\"Q2\"],\"representations\":{\"en\":{\"language\":\"en\",\"value\":\"rep\"}},\"claims\":{\"P42\":[{\"rank\":\"normal\",\"id\":\"MyId\",\"mainsnak\":{\"property\":\"P42\",\"snaktype\":\"somevalue\"},\"type\":\"statement\"}]},\"lastrevid\":1234}";
private final String JSON_FORM = "{\"type\":\"form\",\"id\":\"L42-F1\",\"grammaticalFeatures\":[\"Q1\",\"Q2\"],\"representations\":{\"en\":{\"language\":\"en\",\"value\":\"rep\"}},\"claims\":{\"P42\":[{\"rank\":\"normal\",\"id\":\"Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d\",\"mainsnak\":{\"property\":\"P42\",\"snaktype\":\"somevalue\"},\"type\":\"statement\"}]},\"lastrevid\":1234}";

@Test
public void fieldsAreCorrect() {
Expand Down Expand Up @@ -124,7 +124,7 @@ public void statementGroupsCanBeNull() {
@Test(expected = IllegalArgumentException.class)
public void statementGroupsUseSameSubject() {
FormIdValue iid2 = new FormIdValueImpl("Q23", "http://example.org/");
Statement s2 = new StatementImpl("MyId", StatementRank.NORMAL,
Statement s2 = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P42", "http://wikibase.org/entity/")),
Collections.emptyList(), Collections.emptyList(), iid2);
StatementGroup sg2 = new StatementGroupImpl(Collections.singletonList(s2));
Expand Down Expand Up @@ -175,7 +175,7 @@ public void testWithExistingGrammaticalFeatures() {

@Test
public void testAddStatement() {
Statement fresh = new StatementImpl("MyFreshId", StatementRank.NORMAL,
Statement fresh = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P29", "http://example.com/entity/")),
Collections.emptyList(), Collections.emptyList(), fid);
Claim claim = fresh.getClaim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ItemDocumentImplTest {
private final ObjectMapper mapper = new DatamodelMapper("http://example.com/entity/");

private final ItemIdValue iid = new ItemIdValueImpl("Q42", "http://example.com/entity/");
private final Statement s = new StatementImpl("MyId", StatementRank.NORMAL,
private final Statement s = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P42", "http://example.com/entity/")),
Collections.emptyList(), Collections.emptyList(), iid);
private final List<StatementGroup> statementGroups = Collections.singletonList(
Expand All @@ -66,7 +66,7 @@ public class ItemDocumentImplTest {
private final String JSON_ITEM_LABEL = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":{\"en\":{\"language\":\"en\",\"value\":\"label\"}},\"descriptions\":{},\"aliases\":{},\"claims\":{},\"sitelinks\":{}}";
private final String JSON_ITEM_DESCRIPTION = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":{},\"descriptions\":{\"fr\":{\"language\":\"fr\",\"value\":\"des\"}},\"aliases\":{},\"claims\":{},\"sitelinks\":{}}";
private final String JSON_ITEM_ALIASES = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":{},\"descriptions\":{},\"aliases\":{\"de\":[{\"language\":\"de\",\"value\":\"alias\"}]},\"claims\":{},\"sitelinks\":{}}";
private final String JSON_ITEM_STATEMENTS = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":{},\"descriptions\":{},\"aliases\":{},\"claims\":{\"P42\":[{\"rank\":\"normal\",\"id\":\"MyId\",\"mainsnak\":{\"property\":\"P42\",\"snaktype\":\"somevalue\"},\"type\":\"statement\"}]},\"sitelinks\":{}}";
private final String JSON_ITEM_STATEMENTS = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":{},\"descriptions\":{},\"aliases\":{},\"claims\":{\"P42\":[{\"rank\":\"normal\",\"id\":\"Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d\",\"mainsnak\":{\"property\":\"P42\",\"snaktype\":\"somevalue\"},\"type\":\"statement\"}]},\"sitelinks\":{}}";
private final String JSON_ITEM_SITELINKS = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":{},\"descriptions\":{},\"aliases\":{},\"claims\":{},\"sitelinks\":{\"enwiki\":{\"title\":\"Douglas Adams\",\"site\":\"enwiki\",\"badges\":[]}}}";
private final String JSON_ITEM_EMPTY_ARRAYS = "{\"type\":\"item\",\"id\":\"Q42\",\"labels\":[],\"descriptions\":[],\"aliases\":[],\"claims\":[],\"sitelinks\":[]}";

Expand Down Expand Up @@ -278,7 +278,7 @@ public void testWithOverridenAliases() {

@Test
public void testAddStatement() {
Statement fresh = new StatementImpl("MyFreshId", StatementRank.NORMAL,
Statement fresh = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P29", "http://example.com/entity/")),
Collections.emptyList(), Collections.emptyList(), iid);
Claim claim = fresh.getClaim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class LexemeDocumentImplTest {
private final LexemeIdValue lid = new LexemeIdValueImpl("L42", "http://example.com/entity/");
private final ItemIdValue lexCat = new ItemIdValueImpl("Q1", "http://example.com/entity/");
private final ItemIdValue language = new ItemIdValueImpl("Q2", "http://example.com/entity/");
private final Statement s = new StatementImpl("MyId", StatementRank.NORMAL,
private final Statement s = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P42", "http://example.com/entity/")),
Collections.emptyList(), Collections.emptyList(), lid);
private final List<StatementGroup> statementGroups = Collections.singletonList(
Expand All @@ -69,7 +69,7 @@ public class LexemeDocumentImplTest {
private final LexemeDocument ld1 = new LexemeDocumentImpl(lid, lexCat, language, lemmaList, statementGroups, forms, senses, 1234);
private final LexemeDocument ld2 = new LexemeDocumentImpl(lid, lexCat, language, lemmaList, statementGroups, forms, senses, 1234);

private final String JSON_LEXEME = "{\"type\":\"lexeme\",\"id\":\"L42\",\"lexicalCategory\":\"Q1\",\"language\":\"Q2\",\"lemmas\":{\"en\":{\"language\":\"en\",\"value\":\"lemma\"}},\"claims\":{\"P42\":[{\"rank\":\"normal\",\"id\":\"MyId\",\"mainsnak\":{\"property\":\"P42\",\"snaktype\":\"somevalue\"},\"type\":\"statement\"}]},\"forms\":[{\"type\":\"form\",\"id\":\"L42-F1\",\"representations\":{\"en\":{\"language\":\"en\",\"value\":\"foo\"}},\"grammaticalFeatures\":[],\"claims\":{}}],\"senses\":[{\"type\":\"sense\",\"id\":\"L42-S1\",\"glosses\":{\"en\":{\"language\":\"en\",\"value\":\"foo meaning\"}},\"claims\":{}}],\"lastrevid\":1234}";
private final String JSON_LEXEME = "{\"type\":\"lexeme\",\"id\":\"L42\",\"lexicalCategory\":\"Q1\",\"language\":\"Q2\",\"lemmas\":{\"en\":{\"language\":\"en\",\"value\":\"lemma\"}},\"claims\":{\"P42\":[{\"rank\":\"normal\",\"id\":\"Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d\",\"mainsnak\":{\"property\":\"P42\",\"snaktype\":\"somevalue\"},\"type\":\"statement\"}]},\"forms\":[{\"type\":\"form\",\"id\":\"L42-F1\",\"representations\":{\"en\":{\"language\":\"en\",\"value\":\"foo\"}},\"grammaticalFeatures\":[],\"claims\":{}}],\"senses\":[{\"type\":\"sense\",\"id\":\"L42-S1\",\"glosses\":{\"en\":{\"language\":\"en\",\"value\":\"foo meaning\"}},\"claims\":{}}],\"lastrevid\":1234}";

@Test
public void fieldsAreCorrect() {
Expand Down Expand Up @@ -173,7 +173,7 @@ public void statementGroupsCanBeNull() {
@Test(expected = IllegalArgumentException.class)
public void statementGroupsUseSameSubject() {
LexemeIdValue iid2 = new LexemeIdValueImpl("Q23", "http://example.org/");
Statement s2 = new StatementImpl("MyId", StatementRank.NORMAL,
Statement s2 = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P42", "http://wikibase.org/entity/")),
Collections.emptyList(), Collections.emptyList(), iid2);
StatementGroup sg2 = new StatementGroupImpl(Collections.singletonList(s2));
Expand Down Expand Up @@ -235,7 +235,7 @@ public void testWithLemmaInNewLanguage() {

@Test
public void testAddStatement() {
Statement fresh = new StatementImpl("MyFreshId", StatementRank.NORMAL,
Statement fresh = new StatementImpl("Q5721$b763ede3-42b3-5ecb-ec0e-4bb85d4d348d", StatementRank.NORMAL,
new SomeValueSnakImpl(new PropertyIdValueImpl("P29", "http://example.com/entity/")),
Collections.emptyList(), Collections.emptyList(), lid);
Claim claim = fresh.getClaim();
Expand Down
Loading