diff --git a/src/main/java/com/yetanalytics/xapi/model/AbstractActor.java b/src/main/java/com/yetanalytics/xapi/model/AbstractActor.java
index 7e96a6b..0f18e1d 100644
--- a/src/main/java/com/yetanalytics/xapi/model/AbstractActor.java
+++ b/src/main/java/com/yetanalytics/xapi/model/AbstractActor.java
@@ -79,4 +79,12 @@ protected int countIFIs() {
}
public abstract boolean isValidAuthority();
+
+ @Override
+ public boolean isEmpty() {
+ return (
+ mbox == null && mbox_sha1sum == null &&
+ openid == null && account == null
+ );
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/AbstractObject.java b/src/main/java/com/yetanalytics/xapi/model/AbstractObject.java
index 068a861..69ebebb 100644
--- a/src/main/java/com/yetanalytics/xapi/model/AbstractObject.java
+++ b/src/main/java/com/yetanalytics/xapi/model/AbstractObject.java
@@ -7,7 +7,7 @@
* Abstract Class for serialization and deserialization of xAPI Objects
*/
@JsonDeserialize(using = AbstractObjectDeserializer.class)
-public class AbstractObject {
+public abstract class AbstractObject implements JSONObject {
private ObjectType objectType;
@@ -18,4 +18,6 @@ public void setObjectType(ObjectType objectType) {
this.objectType = objectType;
}
+ @Override
+ public abstract boolean isEmpty();
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Account.java b/src/main/java/com/yetanalytics/xapi/model/Account.java
index 5470ad3..eff18d8 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Account.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Account.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
@@ -10,7 +11,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class Account {
+public class Account implements JSONObject {
@NotNull
private String homePage;
@@ -30,4 +31,10 @@ public String getName() {
public void setName(String name) {
this.name = name;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return homePage == null && name == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Activity.java b/src/main/java/com/yetanalytics/xapi/model/Activity.java
index b730b25..4385d96 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Activity.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Activity.java
@@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jakarta.validation.Valid;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
@@ -33,4 +34,10 @@ public ActivityDefinition getDefinition() {
public void setDefinition(ActivityDefinition definition) {
this.definition = definition;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return id == null && definition == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/ActivityDefinition.java b/src/main/java/com/yetanalytics/xapi/model/ActivityDefinition.java
index b83e473..5439f8d 100644
--- a/src/main/java/com/yetanalytics/xapi/model/ActivityDefinition.java
+++ b/src/main/java/com/yetanalytics/xapi/model/ActivityDefinition.java
@@ -5,6 +5,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
/**
@@ -12,7 +13,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class ActivityDefinition {
+public class ActivityDefinition implements JSONObject {
private LangMap name;
private LangMap description;
@@ -162,6 +163,16 @@ private boolean isNoInteraction() {
);
}
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return (
+ name == null && description == null &&
+ type == null && moreInfo == null && extensions == null &&
+ interactionType == null && isNoInteraction()
+ );
+ }
+
@AssertTrue
public boolean isValidInteractionActivity() {
if (interactionType == null) {
diff --git a/src/main/java/com/yetanalytics/xapi/model/Agent.java b/src/main/java/com/yetanalytics/xapi/model/Agent.java
index a234efb..a7ae389 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Agent.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Agent.java
@@ -4,6 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
/**
@@ -17,6 +18,12 @@ public class Agent extends AbstractActor {
// Validation
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return super.isEmpty();
+ }
+
/**
* Assertion that the Agent has only 1 Inverse Functional Identifier (IFI).
* @return true if the Agent has exactly 1 IFI, false otherwise
diff --git a/src/main/java/com/yetanalytics/xapi/model/Attachment.java b/src/main/java/com/yetanalytics/xapi/model/Attachment.java
index 149f05a..d42c66a 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Attachment.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Attachment.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
@@ -10,7 +11,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class Attachment {
+public class Attachment implements JSONObject {
@NotNull
private String usageType;
@@ -68,5 +69,17 @@ public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
-
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return (
+ usageType == null &&
+ display == null &&
+ description == null &&
+ contentType == null &&
+ length == null &&
+ sha2 == null &&
+ fileUrl == null
+ );
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Context.java b/src/main/java/com/yetanalytics/xapi/model/Context.java
index da73c63..0aaee79 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Context.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Context.java
@@ -1,15 +1,18 @@
package com.yetanalytics.xapi.model;
import java.util.UUID;
+
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
+
/**
* Class representation of the Context Component of the
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class Context {
+public class Context implements JSONObject {
private UUID registration;
private AbstractActor instructor;
@@ -76,4 +79,19 @@ public void setExtensions(Extensions extensions) {
this.extensions = extensions;
}
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return (
+ registration == null &&
+ instructor == null &&
+ team == null &&
+ contextActivities == null &&
+ revision == null &&
+ platform == null &&
+ language == null &&
+ statement == null &&
+ extensions == null
+ );
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/ContextActivities.java b/src/main/java/com/yetanalytics/xapi/model/ContextActivities.java
index eb65d31..47f6104 100644
--- a/src/main/java/com/yetanalytics/xapi/model/ContextActivities.java
+++ b/src/main/java/com/yetanalytics/xapi/model/ContextActivities.java
@@ -4,6 +4,9 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.yetanalytics.xapi.model.deserializers.ContextActivityListDeserializer;
+
+import jakarta.validation.constraints.AssertFalse;
+
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -12,7 +15,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class ContextActivities {
+public class ContextActivities implements JSONObject {
@JsonDeserialize(using = ContextActivityListDeserializer.class)
private List parent;
@@ -48,4 +51,12 @@ public void setOther(List other) {
this.other = other;
}
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return (
+ parent == null && grouping == null &&
+ category == null && other == null
+ );
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Extensions.java b/src/main/java/com/yetanalytics/xapi/model/Extensions.java
index 09ee477..0156355 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Extensions.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Extensions.java
@@ -13,6 +13,8 @@
import com.yetanalytics.xapi.model.serializers.ExtensionSerializer;
import com.yetanalytics.xapi.util.Mapper;
+import jakarta.validation.constraints.AssertFalse;
+
/**
* A wrapper object for using xAPI Extensions.
*
@@ -22,7 +24,7 @@
*/
@JsonDeserialize(using = ExtensionDeserializer.class)
@JsonSerialize(using = ExtensionSerializer.class)
-public class Extensions {
+public class Extensions implements JSONObject {
private Map extMap = new HashMap<>();
@@ -96,4 +98,10 @@ public Set getKeys() {
public Map getMap() {
return extMap;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return extMap.isEmpty();
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Group.java b/src/main/java/com/yetanalytics/xapi/model/Group.java
index 333476e..7baae6e 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Group.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Group.java
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
/**
@@ -48,4 +49,11 @@ public boolean isValidAuthority() {
)
);
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ // zero-length member arrays still count as non-empty
+ return super.isEmpty() && member == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/InteractionComponent.java b/src/main/java/com/yetanalytics/xapi/model/InteractionComponent.java
index 0966dc4..6dd3cfd 100644
--- a/src/main/java/com/yetanalytics/xapi/model/InteractionComponent.java
+++ b/src/main/java/com/yetanalytics/xapi/model/InteractionComponent.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
@@ -9,7 +10,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class InteractionComponent {
+public class InteractionComponent implements JSONObject {
@NotNull
private String id;
@@ -32,5 +33,9 @@ public void setDescription(LangMap description) {
this.description = description;
}
-
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return id == null && description == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/JSONObject.java b/src/main/java/com/yetanalytics/xapi/model/JSONObject.java
new file mode 100644
index 0000000..157f6db
--- /dev/null
+++ b/src/main/java/com/yetanalytics/xapi/model/JSONObject.java
@@ -0,0 +1,5 @@
+package com.yetanalytics.xapi.model;
+
+public interface JSONObject {
+ public boolean isEmpty();
+}
diff --git a/src/main/java/com/yetanalytics/xapi/model/LangMap.java b/src/main/java/com/yetanalytics/xapi/model/LangMap.java
index cb451a4..6c964f5 100644
--- a/src/main/java/com/yetanalytics/xapi/model/LangMap.java
+++ b/src/main/java/com/yetanalytics/xapi/model/LangMap.java
@@ -9,6 +9,8 @@
import com.yetanalytics.xapi.model.deserializers.LangMapDeserializer;
import com.yetanalytics.xapi.model.serializers.LangMapSerializer;
+import jakarta.validation.constraints.AssertFalse;
+
/**
* Java wrapper object for the
* xAPI Language Map object.
@@ -18,7 +20,7 @@
*/
@JsonDeserialize(using = LangMapDeserializer.class)
@JsonSerialize(using = LangMapSerializer.class)
-public class LangMap {
+public class LangMap implements JSONObject {
private HashMap languageHashMap = new HashMap<>();
@@ -71,4 +73,10 @@ public Set getLanguageCodes() {
public Map getMap() {
return languageHashMap;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return languageHashMap.isEmpty();
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Result.java b/src/main/java/com/yetanalytics/xapi/model/Result.java
index b4e47db..8df9f04 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Result.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Result.java
@@ -4,13 +4,14 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import jakarta.validation.Valid;
+import jakarta.validation.constraints.AssertFalse;
/**
* Class representation of the Result component of the
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class Result {
+public class Result implements JSONObject {
@Valid
private Score score;
@@ -56,4 +57,17 @@ public Extensions getExtensions() {
public void setExtensions(Extensions extensions) {
this.extensions = extensions;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return (
+ score == null &&
+ success == null &&
+ completion == null &&
+ response == null &&
+ duration == null &&
+ extensions == null
+ );
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Score.java b/src/main/java/com/yetanalytics/xapi/model/Score.java
index 1388a56..043af7d 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Score.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Score.java
@@ -5,6 +5,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
@@ -14,7 +15,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class Score {
+public class Score implements JSONObject {
private BigDecimal raw;
private BigDecimal min;
@@ -77,4 +78,10 @@ public boolean isMinLessThanMax() {
return true;
}
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return raw == null && min == null && max == null && scaled == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Statement.java b/src/main/java/com/yetanalytics/xapi/model/Statement.java
index 7031777..2465dc4 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Statement.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Statement.java
@@ -11,6 +11,7 @@
import com.yetanalytics.xapi.model.serializers.DateTimeSerializer;
import jakarta.validation.Valid;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
@@ -204,4 +205,22 @@ public boolean isValidSubStatement() {
return true;
}
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return (
+ id == null &&
+ actor == null &&
+ verb == null &&
+ object == null &&
+ context == null &&
+ result == null &&
+ authority == null &&
+ timestamp == null &&
+ stored == null &&
+ version == null &&
+ attachments == null
+ );
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/StatementRef.java b/src/main/java/com/yetanalytics/xapi/model/StatementRef.java
index 477a7f5..2044fdd 100644
--- a/src/main/java/com/yetanalytics/xapi/model/StatementRef.java
+++ b/src/main/java/com/yetanalytics/xapi/model/StatementRef.java
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
@@ -25,4 +26,10 @@ public UUID getId() {
public void setId(UUID id) {
this.id = id;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return id == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/StatementResult.java b/src/main/java/com/yetanalytics/xapi/model/StatementResult.java
index 6272807..e29efb5 100644
--- a/src/main/java/com/yetanalytics/xapi/model/StatementResult.java
+++ b/src/main/java/com/yetanalytics/xapi/model/StatementResult.java
@@ -5,13 +5,14 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
* Class representation of a StatementResult from the 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class StatementResult {
+public class StatementResult implements JSONObject {
@NotNull
private List statements;
@@ -33,4 +34,10 @@ public String getMore() {
public void setMore(String more) {
this.more = more;
}
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return statements == null && more == null;
+ }
}
diff --git a/src/main/java/com/yetanalytics/xapi/model/Verb.java b/src/main/java/com/yetanalytics/xapi/model/Verb.java
index e6d1178..cd8c0ab 100644
--- a/src/main/java/com/yetanalytics/xapi/model/Verb.java
+++ b/src/main/java/com/yetanalytics/xapi/model/Verb.java
@@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.yetanalytics.xapi.model.deserializers.LangMapDeserializer;
+import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.NotNull;
/**
@@ -12,7 +13,7 @@
* 9274.1.1 xAPI Specification.
*/
@JsonInclude(Include.NON_NULL)
-public class Verb {
+public class Verb implements JSONObject {
public static final String VOIDING_VERB_IRI = "http://adlnet.gov/expapi/verbs/voided";
@@ -41,5 +42,10 @@ public void setDisplay(LangMap display) {
public boolean isVoiding() {
return id == VOIDING_VERB_IRI;
}
-
+
+ @Override
+ @AssertFalse
+ public boolean isEmpty() {
+ return id == null && display == null;
+ }
}
diff --git a/src/test/java/com/yetanalytics/XapiSerializationTest.java b/src/test/java/com/yetanalytics/XapiSerializationTest.java
index cedc222..30dc13f 100644
--- a/src/test/java/com/yetanalytics/XapiSerializationTest.java
+++ b/src/test/java/com/yetanalytics/XapiSerializationTest.java
@@ -1,7 +1,7 @@
package com.yetanalytics;
-import java.io.IOException;
import java.io.File;
+import java.io.IOException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -9,7 +9,8 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.flipkart.zjsonpatch.JsonDiff;
import com.yetanalytics.util.TestFileUtils;
-import com.yetanalytics.xapi.model.*;
+import com.yetanalytics.xapi.model.Statement;
+import com.yetanalytics.xapi.model.StatementResult;
import com.yetanalytics.xapi.util.Mapper;
import junit.framework.Test;
diff --git a/src/test/java/com/yetanalytics/model/AccountTest.java b/src/test/java/com/yetanalytics/model/AccountTest.java
index fa54cb3..bab6f03 100644
--- a/src/test/java/com/yetanalytics/model/AccountTest.java
+++ b/src/test/java/com/yetanalytics/model/AccountTest.java
@@ -27,6 +27,6 @@ public void testValidAccount() {
@Test
public void testEmptyAccount() {
- ValidationUtils.assertInvalid(validator, account, 2);
+ ValidationUtils.assertInvalid(validator, account, 3);
}
}
diff --git a/src/test/java/com/yetanalytics/model/ActivityDefinitionTest.java b/src/test/java/com/yetanalytics/model/ActivityDefinitionTest.java
index 19ab497..2baeb90 100644
--- a/src/test/java/com/yetanalytics/model/ActivityDefinitionTest.java
+++ b/src/test/java/com/yetanalytics/model/ActivityDefinitionTest.java
@@ -43,7 +43,7 @@ public void init() {
@Test
public void testEmptyDefinition() {
- ValidationUtils.assertValid(validator, definition);
+ ValidationUtils.assertInvalid(validator, definition);
}
@Test
diff --git a/src/test/java/com/yetanalytics/model/ActivityTest.java b/src/test/java/com/yetanalytics/model/ActivityTest.java
index 32c8082..e7a226c 100644
--- a/src/test/java/com/yetanalytics/model/ActivityTest.java
+++ b/src/test/java/com/yetanalytics/model/ActivityTest.java
@@ -26,14 +26,14 @@ public void testActivity() {
activity.setId("http://example.org/activity");
ValidationUtils.assertValid(validator, activity);
- // TODO: Enforce that definitions, as JSON objects, can't be empty
- // For now we allow them though
activity.setDefinition(definition);
+ definition.setMoreInfo("https://yetanalytics.com");
ValidationUtils.assertValid(validator, activity);
}
@Test
public void testEmptyActivity() {
- ValidationUtils.assertInvalid(validator, activity);
+ // One error for empty object, one error for missing ID
+ ValidationUtils.assertInvalid(validator, activity, 2);
}
}
diff --git a/src/test/java/com/yetanalytics/model/AgentTest.java b/src/test/java/com/yetanalytics/model/AgentTest.java
index 17bfd38..9a93650 100644
--- a/src/test/java/com/yetanalytics/model/AgentTest.java
+++ b/src/test/java/com/yetanalytics/model/AgentTest.java
@@ -51,12 +51,14 @@ public void testAccount() {
public void testInvalidAccount() {
Account account = new Account();
agent.setAccount(account);
- ValidationUtils.assertInvalid(validator, agent, 2);
+ // One error for empty account, one error each for missing properties
+ ValidationUtils.assertInvalid(validator, agent, 3);
}
@Test
public void testNoIFI() {
- ValidationUtils.assertInvalid(validator, agent);
+ // One error for empty agent, one error for missing IFI
+ ValidationUtils.assertInvalid(validator, agent, 2);
}
@Test
diff --git a/src/test/java/com/yetanalytics/model/AttachmentTest.java b/src/test/java/com/yetanalytics/model/AttachmentTest.java
index fe71f99..e03e389 100644
--- a/src/test/java/com/yetanalytics/model/AttachmentTest.java
+++ b/src/test/java/com/yetanalytics/model/AttachmentTest.java
@@ -47,6 +47,7 @@ public void testAttachment() {
@Test
public void testEmptyAttachment() {
- ValidationUtils.assertInvalid(validator, attachment, 5);
+ // One error for empty attachment, one error each for null properties
+ ValidationUtils.assertInvalid(validator, attachment, 6);
}
}
diff --git a/src/test/java/com/yetanalytics/model/GroupTest.java b/src/test/java/com/yetanalytics/model/GroupTest.java
index 691daf4..a2c11da 100644
--- a/src/test/java/com/yetanalytics/model/GroupTest.java
+++ b/src/test/java/com/yetanalytics/model/GroupTest.java
@@ -65,12 +65,14 @@ public void testAccount() {
public void testInvalidAccount() {
Account account = new Account();
group.setAccount(account);
- ValidationUtils.assertInvalid(validator, group, 2);
+ // One error for empty account, one error each for missing properties
+ ValidationUtils.assertInvalid(validator, group, 3);
}
@Test
public void testNoIFI() { // No member array => identified group
- ValidationUtils.assertInvalid(validator, group);
+ // One error for empty group object, one error for no IFI
+ ValidationUtils.assertInvalid(validator, group, 2);
}
@Test
diff --git a/src/test/java/com/yetanalytics/model/InteractionComponentTest.java b/src/test/java/com/yetanalytics/model/InteractionComponentTest.java
index 4183b5b..e74a1ad 100644
--- a/src/test/java/com/yetanalytics/model/InteractionComponentTest.java
+++ b/src/test/java/com/yetanalytics/model/InteractionComponentTest.java
@@ -32,6 +32,7 @@ public void testInteractionComponent() {
@Test
public void testEmpytInteractionComponent() {
- ValidationUtils.assertInvalid(validator, interactionComponent);
+ // One error for empty component, one error for missing ID
+ ValidationUtils.assertInvalid(validator, interactionComponent, 2);
}
}
diff --git a/src/test/java/com/yetanalytics/model/ScoreTest.java b/src/test/java/com/yetanalytics/model/ScoreTest.java
index a6e856f..0cb4f9b 100644
--- a/src/test/java/com/yetanalytics/model/ScoreTest.java
+++ b/src/test/java/com/yetanalytics/model/ScoreTest.java
@@ -22,8 +22,6 @@ public void init() {
@Test
public void testScore() {
- ValidationUtils.assertValid(validator, score); // TODO: Make invalid
-
score.setMin(new BigDecimal(0));
score.setMax(new BigDecimal(100));
score.setRaw(new BigDecimal(50));
@@ -31,6 +29,11 @@ public void testScore() {
ValidationUtils.assertValid(validator, score);
}
+ @Test
+ public void testEmptyScore() {
+ ValidationUtils.assertInvalid(validator, score);
+ }
+
@Test
public void testScaledTooSmall() {
score.setScaled(new BigDecimal(-2.0));
diff --git a/src/test/java/com/yetanalytics/model/StatementRefTest.java b/src/test/java/com/yetanalytics/model/StatementRefTest.java
index c20fd05..bca7432 100644
--- a/src/test/java/com/yetanalytics/model/StatementRefTest.java
+++ b/src/test/java/com/yetanalytics/model/StatementRefTest.java
@@ -29,6 +29,7 @@ public void testStatementRef() {
@Test
public void testEmptyStatementRef() {
- ValidationUtils.assertInvalid(validator, statementRef);
+ // One error for empty object, one error for missing ID
+ ValidationUtils.assertInvalid(validator, statementRef, 2);
}
}
diff --git a/src/test/java/com/yetanalytics/model/StatementResultTest.java b/src/test/java/com/yetanalytics/model/StatementResultTest.java
index f39a3d6..167f3e9 100644
--- a/src/test/java/com/yetanalytics/model/StatementResultTest.java
+++ b/src/test/java/com/yetanalytics/model/StatementResultTest.java
@@ -50,6 +50,7 @@ public void testStatementResult() {
@Test
public void testEmptyStatementResult() {
- ValidationUtils.assertInvalid(validator, statementResult);
+ // One error for empty statement res, one error for missing statement
+ ValidationUtils.assertInvalid(validator, statementResult, 2);
}
}
diff --git a/src/test/java/com/yetanalytics/model/StatementTest.java b/src/test/java/com/yetanalytics/model/StatementTest.java
index 33445e2..7be6481 100644
--- a/src/test/java/com/yetanalytics/model/StatementTest.java
+++ b/src/test/java/com/yetanalytics/model/StatementTest.java
@@ -61,7 +61,8 @@ public void testEmptyStatement() {
statement.setActor(null);
statement.setVerb(null);
statement.setObject(null);
- ValidationUtils.assertInvalid(validator, statement, 3);
+ // One error for empty statement, one error each for missing property
+ ValidationUtils.assertInvalid(validator, statement, 4);
}
@Test
diff --git a/src/test/java/com/yetanalytics/model/VerbTest.java b/src/test/java/com/yetanalytics/model/VerbTest.java
index d8920ca..88bd0f1 100644
--- a/src/test/java/com/yetanalytics/model/VerbTest.java
+++ b/src/test/java/com/yetanalytics/model/VerbTest.java
@@ -33,6 +33,7 @@ public void testVerb() {
@Test
public void testEmptyVerb() {
- ValidationUtils.assertInvalid(validator, verb);
+ // One error for empty verb, one error for missing ID
+ ValidationUtils.assertInvalid(validator, verb, 2);
}
}