Repository: Wikidata/Wikidata-Toolkit
Pull request #578 (2021-05-08 16:53:22)

Allows empty representation list in Forms
Follows WikibaseLexemes change

codecov[bot]: # [Codecov](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) Report
> Merging [#578](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) (38c2ac4) into [master](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/commit/7b83a96bdf08fb2e7aae1b8566a53be62b993864?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) (7b83a96) will **decrease** coverage by `0.03%`.
> The diff coverage is `50.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/graphs/tree.svg?width=650&height=150&src=pr&token=QtTNJdTAbO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata)](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata)

```diff
@@             Coverage Diff              @@
##             master     #578      +/-   ##
============================================
- Coverage     81.05%   81.02%   -0.04%     
- Complexity     2084     2087       +3     
============================================
  Files           149      149              
  Lines          7286     7271      -15     
  Branches        893      889       -4     
============================================
- Hits           5906     5891      -15     
+ Misses         1112     1111       -1     
- Partials        268      269       +1     
```


| [Impacted Files](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...dtk/datamodel/implementation/FormDocumentImpl.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW1wbGVtZW50YXRpb24vRm9ybURvY3VtZW50SW1wbC5qYXZh) | `91.07% <50.00%> (+0.74%)` | `28.00 <0.00> (+1.00)` | |
| [...tk/datamodel/implementation/SenseDocumentImpl.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW1wbGVtZW50YXRpb24vU2Vuc2VEb2N1bWVudEltcGwuamF2YQ==) | `87.50% <50.00%> (-3.68%)` | `18.00 <0.00> (+2.00)` | :arrow_down: |
| [.../wikidata/wdtk/dumpfiles/EntityTimerProcessor.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kdW1wZmlsZXMvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kdW1wZmlsZXMvRW50aXR5VGltZXJQcm9jZXNzb3IuamF2YQ==) | `72.09% <0.00%> (-1.25%)` | `11.00% <0.00%> (ø%)` | |
| [...kidata/wdtk/rdf/values/QuantityValueConverter.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1yZGYvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9yZGYvdmFsdWVzL1F1YW50aXR5VmFsdWVDb252ZXJ0ZXIuamF2YQ==) | `71.42% <0.00%> (-0.99%)` | `5.00% <0.00%> (ø%)` | |
| [...a/wdtk/datamodel/interfaces/StatementDocument.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW50ZXJmYWNlcy9TdGF0ZW1lbnREb2N1bWVudC5qYXZh) | `71.23% <0.00%> (-0.77%)` | `45.00% <0.00%> (ø%)` | |
| [...a/wdtk/datamodel/implementation/ValueSnakImpl.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW1wbGVtZW50YXRpb24vVmFsdWVTbmFrSW1wbC5qYXZh) | `85.71% <0.00%> (-0.40%)` | `16.00% <0.00%> (ø%)` | |
| [...idata/wdtk/dumpfiles/DumpProcessingController.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kdW1wZmlsZXMvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kdW1wZmlsZXMvRHVtcFByb2Nlc3NpbmdDb250cm9sbGVyLmphdmE=) | `65.60% <0.00%> (-0.22%)` | `32.00% <0.00%> (ø%)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata). Last update [7b83a96...38c2ac4](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/578?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata).


Patch:
diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImpl.java
index 07cda9bd..8e636c2d 100644
--- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImpl.java
+++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImpl.java
@@ -22,7 +22,6 @@ package org.wikidata.wdtk.datamodel.implementation;
 
 import com.fasterxml.jackson.annotation.*;
 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import org.apache.commons.lang3.Validate;
 import org.wikidata.wdtk.datamodel.helpers.Equality;
 import org.wikidata.wdtk.datamodel.helpers.Hash;
 import org.wikidata.wdtk.datamodel.helpers.ToString;
@@ -68,11 +67,7 @@ public class FormDocumentImpl extends StatementDocumentImpl implements FormDocum
 			List<StatementGroup> statements,
 			long revisionId) {
 		super(id, statements, revisionId);
-		Validate.notNull(representations, "Forms representations should not be null");
-		if(representations.isEmpty()) {
-			throw new IllegalArgumentException("Forms should have at least one representation");
-		}
-		this.representations = constructTermMap(representations);
+		this.representations = (representations == null || representations.isEmpty()) ? Collections.emptyMap() : constructTermMap(representations);
 		this.grammaticalFeatures = (grammaticalFeatures == null) ? Collections.emptyList() : grammaticalFeatures;
 		this.grammaticalFeatures.sort(Comparator.comparing(EntityIdValue::getId));
 	}
@@ -90,11 +85,7 @@ public class FormDocumentImpl extends StatementDocumentImpl implements FormDocum
 			@JsonProperty("lastrevid") long revisionId,
 			@JacksonInject("siteIri") String siteIri) {
 		super(jsonId, claims, revisionId, siteIri);
-		Validate.notNull(representations, "Forms representations should not be null");
-		if(representations.isEmpty()) {
-			throw new IllegalArgumentException("Forms should have at least one representation");
-		}
-		this.representations = representations;
+		this.representations = (representations == null) ? Collections.emptyMap() : representations;
 		this.grammaticalFeatures = (grammaticalFeatures == null || grammaticalFeatures.isEmpty())
 				? Collections.emptyList()
 				: constructGrammaticalFeatures(grammaticalFeatures, siteIri);
diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImpl.java
index 6d4bfa3a..30155a00 100644
--- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImpl.java
+++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImpl.java
@@ -22,16 +22,12 @@ package org.wikidata.wdtk.datamodel.implementation;
 
 import com.fasterxml.jackson.annotation.*;
 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import org.apache.commons.lang3.Validate;
 import org.wikidata.wdtk.datamodel.helpers.Equality;
 import org.wikidata.wdtk.datamodel.helpers.Hash;
 import org.wikidata.wdtk.datamodel.helpers.ToString;
 import org.wikidata.wdtk.datamodel.interfaces.*;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
@@ -66,8 +62,7 @@ public class SenseDocumentImpl extends StatementDocumentImpl implements SenseDoc
 			List<StatementGroup> statements,
 			long revisionId) {
 		super(id, statements, revisionId);
-		Validate.notNull(glosses, "Senses glosses should not be null");
-		this.glosses = constructTermMap(glosses);
+		this.glosses = (glosses == null || glosses.isEmpty()) ? Collections.emptyMap() : constructTermMap(glosses);
 	}
 
 	/**
@@ -82,8 +77,7 @@ public class SenseDocumentImpl extends StatementDocumentImpl implements SenseDoc
 			@JsonProperty("lastrevid") long revisionId,
 			@JacksonInject("siteIri") String siteIri) {
 		super(jsonId, claims, revisionId, siteIri);
-		Validate.notNull(glosses, "Senses glosses should not be null");
-		this.glosses = glosses;
+		this.glosses = (glosses == null) ? Collections.emptyMap() : glosses;
 	}
 
 	/**


Test patch:
diff --git a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImplTest.java b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImplTest.java
index e5a7d5e0..306ef65f 100644
--- a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImplTest.java
+++ b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/FormDocumentImplTest.java
@@ -118,13 +118,13 @@ public class FormDocumentImplTest {
 	}
 
 	@Test
-	public void representationsNotNull() {
-		assertThrows(NullPointerException.class, () -> new FormDocumentImpl(fid,  null, gramFeatures, statementGroups, 1234));
+	public void representationsNull() {
+		assertEquals(Collections.emptyMap(), new FormDocumentImpl(fid,  null, gramFeatures, statementGroups, 1234).getRepresentations());
 	}
 
 	@Test
-	public void representationsNotEmpty() {
-		assertThrows(IllegalArgumentException.class, () -> new FormDocumentImpl(fid, Collections.emptyList(), gramFeatures, statementGroups, 1234));
+	public void representationsEmpty() {
+		assertEquals(Collections.emptyMap(), new FormDocumentImpl(fid, Collections.emptyList(), gramFeatures, statementGroups, 1234).getRepresentations());
 	}
 
 	@Test
diff --git a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImplTest.java b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImplTest.java
index 2774395b..10abe656 100644
--- a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImplTest.java
+++ b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/SenseDocumentImplTest.java
@@ -109,8 +109,8 @@ public class SenseDocumentImplTest {
 	}
 
 	@Test
-	public void glossesNotNull() {
-		assertThrows(NullPointerException.class, () -> new SenseDocumentImpl(sid,  null, statementGroups, 1234));
+	public void glossesNull() {
+		assertEquals(Collections.emptyMap(), new SenseDocumentImpl(sid,  null, statementGroups, 1234).getGlosses());
 	}
 
 	@Test