http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/main/java/org/apache/streams/util/schema/GenerationConfig.java ---------------------------------------------------------------------- diff --git a/streams-util/src/main/java/org/apache/streams/util/schema/GenerationConfig.java b/streams-util/src/main/java/org/apache/streams/util/schema/GenerationConfig.java new file mode 100644 index 0000000..d4b2c3f --- /dev/null +++ b/streams-util/src/main/java/org/apache/streams/util/schema/GenerationConfig.java @@ -0,0 +1,116 @@ +package org.apache.streams.util.schema; + +import java.io.File; +import java.io.FileFilter; +import java.net.URL; +import java.util.Iterator; + +/** + * GenerationConfig represents the common fields and field accessors for + * streams modules that transform schemas into generated-sources or generated-resources + */ +public interface GenerationConfig { + + /** + * Gets the 'source' configuration option. + * + * @return The source file(s) or directory(ies) from which JSON Schema will + * be read. + */ + Iterator<URL> getSource(); + + /** + * Gets the 'targetDirectory' configuration option. + * + * @return The target directory into which generated types will be written + * (may or may not exist before types are written) + */ + File getTargetDirectory(); + + /** + * Gets the 'outputEncoding' configuration option. + * + * @return The character encoding that should be used when writing output files. + */ + String getOutputEncoding(); + + /** + * Gets the file filter used to isolate the schema mapping files in the + * source directories. + * + * @return the file filter use when scanning for schema files. + */ + FileFilter getFileFilter(); + + /** + * Gets the 'includeAdditionalProperties' configuration option. + * + * @return Whether to allow 'additional properties' support in objects. + * Setting this to false will disable additional properties support, + * regardless of the input schema(s). + */ +// boolean isIncludeAdditionalProperties(); + + /** + * Gets the 'targetVersion' configuration option. + * + * @return The target version for generated source files. + */ +// String getTargetVersion(); + +// /** +// * Gets the `includeDynamicAccessors` configuraiton option. +// * +// * @return Whether to include dynamic getters, setters, and builders +// * or to omit these methods. +// */ +// boolean isIncludeDynamicAccessors(); + +// /** +// * Gets the `dateTimeType` configuration option. +// * <p> +// * Example values: +// * <ul> +// * <li><code>org.joda.time.LocalDateTime</code> (Joda)</li> +// * <li><code>java.time.LocalDateTime</code> (JSR310)</li> +// * <li><code>null</code> (default behavior)</li> +// * </ul> +// * +// * @return The java type to use instead of {@link java.util.Date} +// * when adding date type fields to generate Java types. +// */ +// String getDateTimeType(); +// +// /** +// * Gets the `dateType` configuration option. +// * <p> +// * Example values: +// * <ul> +// * <li><code>org.joda.time.LocalDate</code> (Joda)</li> +// * <li><code>java.time.LocalDate</code> (JSR310)</li> +// * <li><code>null</code> (default behavior)</li> +// * </ul> +// * +// * @return The java type to use instead of string +// * when adding string type fields with a format of date (not +// * date-time) to generated Java types. +// */ +// String getDateType(); +// +// /** +// * Gets the `timeType` configuration option. +// * <p> +// * Example values: +// * <ul> +// * <li><code>org.joda.time.LocalTime</code> (Joda)</li> +// * <li><code>java.time.LocalTime</code> (JSR310)</li> +// * <li><code>null</code> (default behavior)</li> +// * </ul> +// * +// * @return The java type to use instead of string +// * when adding string type fields with a format of time (not +// * date-time) to generated Java types. +// */ +// String getTimeType(); + +}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/main/java/org/apache/streams/util/schema/Schema.java ---------------------------------------------------------------------- diff --git a/streams-util/src/main/java/org/apache/streams/util/schema/Schema.java b/streams-util/src/main/java/org/apache/streams/util/schema/Schema.java new file mode 100644 index 0000000..fc0a3f2 --- /dev/null +++ b/streams-util/src/main/java/org/apache/streams/util/schema/Schema.java @@ -0,0 +1,57 @@ +package org.apache.streams.util.schema; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.net.URI; + +/** + * A JSON Schema document. + */ +public class Schema { + + private final URI id; + private final URI uri; + private final JsonNode content; + private final Schema parent; + private final boolean generate; + + public Schema(URI uri, JsonNode content, Schema parent, boolean generate) { + this.uri = uri; + this.content = content; + this.parent = parent; + this.generate = generate; + this.id = content.has("id") ? URI.create(content.get("id").asText()) : null; + } + + public URI getId() { + return id; + } + + public URI getURI() { + return uri; + } + + public JsonNode getContent() { + return content; + } + + public JsonNode getParentContent() { + if( parent != null ) + return parent.getContent(); + else return null; + } + + public URI getParentURI() { + if( parent != null ) return parent.getURI(); + else return null; + } + + public boolean isGenerated() { + return generate; + } + + public Schema getParent() { + return parent; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStore.java ---------------------------------------------------------------------- diff --git a/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStore.java b/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStore.java new file mode 100644 index 0000000..07e9bef --- /dev/null +++ b/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStore.java @@ -0,0 +1,42 @@ +package org.apache.streams.util.schema; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Optional; + +import java.net.URI; +import java.util.Comparator; +import java.util.Iterator; + +/** + * A SchemaStore resolves and indexes json schemas and makes their properties available. + * + * Implementations include + * - SchemaStoreImpl + */ +public interface SchemaStore extends Comparator<Schema> { + + Schema create(URI uri); + + Schema create(Schema parent, String path); + + void clearCache(); + + Integer getSize(); + + Optional<Schema> getById(URI id); + + Optional<Schema> getByUri(URI uri); + + Integer getFileUriCount(); + + Integer getHttpUriCount(); + + Iterator<Schema> getSchemaIterator(); + + ObjectNode resolveProperties(Schema schema, ObjectNode fieldNode, String resourceId); + + ObjectNode resolveItems(Schema schema, ObjectNode fieldNode, String resourceId); + + @Override + int compare(Schema left, Schema right); +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStoreImpl.java ---------------------------------------------------------------------- diff --git a/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStoreImpl.java b/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStoreImpl.java new file mode 100644 index 0000000..9585742 --- /dev/null +++ b/streams-util/src/main/java/org/apache/streams/util/schema/SchemaStoreImpl.java @@ -0,0 +1,347 @@ +package org.apache.streams.util.schema; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Optional; +import com.google.common.collect.Lists; +import com.google.common.collect.Ordering; +import org.apache.commons.lang3.StringUtils; +import org.jsonschema2pojo.ContentResolver; +import org.jsonschema2pojo.FragmentResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import static org.apache.streams.util.schema.URIUtil.safeResolve; + +/** + * Created by steve on 4/30/16. + */ +public class SchemaStoreImpl extends Ordering<Schema> implements SchemaStore { + + private final static Logger LOGGER = LoggerFactory.getLogger(SchemaStore.class); + private final static JsonNodeFactory NODE_FACTORY = JsonNodeFactory.instance; + + protected Map<URI, Schema> schemas = new HashMap(); + protected FragmentResolver fragmentResolver = new FragmentResolver(); + protected ContentResolver contentResolver = new ContentResolver(); + + public SchemaStoreImpl() { + } + + @Override + public synchronized Schema create(URI uri) { + if(!getByUri(uri).isPresent()) { + URI baseURI = URIUtil.removeFragment(uri); + JsonNode baseNode = this.contentResolver.resolve(baseURI); + if(uri.toString().contains("#") && !uri.toString().endsWith("#")) { + Schema newSchema = new Schema(baseURI, baseNode, null, true); + this.schemas.put(baseURI, newSchema); + JsonNode childContent = this.fragmentResolver.resolve(baseNode, '#' + StringUtils.substringAfter(uri.toString(), "#")); + this.schemas.put(uri, new Schema(uri, childContent, newSchema, false)); + } else { + if( baseNode.has("extends") && baseNode.get("extends").isObject()) { + URI ref = URI.create(((ObjectNode)baseNode.get("extends")).get("$ref").asText()); + URI absoluteURI; + if( ref.isAbsolute()) + absoluteURI = ref; + else + absoluteURI = baseURI.resolve(ref); + JsonNode parentNode = this.contentResolver.resolve(absoluteURI); + Schema parentSchema = null; + if( this.schemas.get(absoluteURI) != null ) { + parentSchema = this.schemas.get(absoluteURI); + } else { + parentSchema = create(absoluteURI); + } + this.schemas.put(uri, new Schema(uri, baseNode, parentSchema, true)); + } else { + this.schemas.put(uri, new Schema(uri, baseNode, null, true)); + } + } + List<JsonNode> refs = baseNode.findValues("$ref"); + for( JsonNode ref : refs ) { + if( ref.isValueNode() ) { + String refVal = ref.asText(); + URI refURI = null; + try { + refURI = URI.create(refVal); + } catch( Exception e ) { + LOGGER.info("Exception: {}", e.getMessage()); + } + if (refURI != null && !getByUri(refURI).isPresent()) { + if (refURI.isAbsolute()) + create(refURI); + else + create(baseURI.resolve(refURI)); + } + } + } + } + + return this.schemas.get(uri); + } + + @Override + public Schema create(Schema parent, String path) { + if(path.equals("#")) { + return parent; + } else { + path = StringUtils.stripEnd(path, "#?&/"); + URI id = parent != null && parent.getId() != null?parent.getId().resolve(path):URI.create(path); + if(this.selfReferenceWithoutParentFile(parent, path)) { + this.schemas.put(id, new Schema(id, this.fragmentResolver.resolve(parent.getParentContent(), path), parent, false)); + return this.schemas.get(id); + } else { + return this.create(id); + } + } + } + + protected boolean selfReferenceWithoutParentFile(Schema parent, String path) { + return parent != null && (parent.getId() == null || parent.getId().toString().startsWith("#/")) && path.startsWith("#/"); + } + + @Override + public synchronized void clearCache() { + this.schemas.clear(); + } + + @Override + public Integer getSize() { + return schemas.size(); + } + + @Override + public Optional<Schema> getById(URI id) { + for( Schema schema : schemas.values() ) { + if( schema.getId() != null && schema.getId().equals(id) ) + return Optional.of(schema); + } + return Optional.absent(); + } + + @Override + public Optional<Schema> getByUri(URI uri) { + for( Schema schema : schemas.values() ) { + if( schema.getURI().equals(uri) ) + return Optional.of(schema); + } + return Optional.absent(); + } + + @Override + public Integer getFileUriCount() { + int count = 0; + for( Schema schema : schemas.values() ) { + if( schema.getURI().getScheme().equals("file") ) + count++; + } + return count; + } + + @Override + public Integer getHttpUriCount() { + int count = 0; + for( Schema schema : schemas.values() ) { + if( schema.getURI().getScheme().equals("http") ) + count++; + } + return count; + } + + @Override + public Iterator<Schema> getSchemaIterator() { + List<Schema> schemaList = Lists.newArrayList(schemas.values()); + Collections.sort(schemaList, this); + return schemaList.iterator(); + } + + @Override + public ObjectNode resolveProperties(Schema schema, ObjectNode fieldNode, String resourceId) { + // this should return something more suitable like: + // Map<String, Pair<Schema, ObjectNode>> + ObjectNode schemaProperties = NODE_FACTORY.objectNode(); + ObjectNode parentProperties = NODE_FACTORY.objectNode(); + if (fieldNode == null) { + ObjectNode schemaContent = (ObjectNode) schema.getContent(); + if( schemaContent.has("properties") ) { + schemaProperties = (ObjectNode) schemaContent.get("properties"); + if (schema.getParentContent() != null) { + ObjectNode parentContent = (ObjectNode) schema.getParentContent(); + if (parentContent.has("properties")) { + parentProperties = (ObjectNode) parentContent.get("properties"); + } + } + } + } else if (fieldNode != null && fieldNode.size() > 0) { + if( fieldNode.has("properties") && fieldNode.get("properties").isObject() && fieldNode.get("properties").size() > 0 ) + schemaProperties = (ObjectNode) fieldNode.get("properties"); + URI parentURI = null; + if( fieldNode.has("$ref") || fieldNode.has("extends") ) { + JsonNode refNode = fieldNode.get("$ref"); + JsonNode extendsNode = fieldNode.get("extends"); + if (refNode != null && refNode.isValueNode()) + parentURI = URI.create(refNode.asText()); + else if (extendsNode != null && extendsNode.isObject()) + parentURI = URI.create(extendsNode.get("$ref").asText()); + ObjectNode parentContent = null; + URI absoluteURI; + if (parentURI.isAbsolute()) + absoluteURI = parentURI; + else { + absoluteURI = schema.getURI().resolve(parentURI); + if (!absoluteURI.isAbsolute() || (absoluteURI.isAbsolute() && !getByUri(absoluteURI).isPresent() )) + absoluteURI = schema.getParentURI().resolve(parentURI); + } + if (absoluteURI != null && absoluteURI.isAbsolute()) { + if (getByUri(absoluteURI).isPresent()) + parentContent = (ObjectNode) getByUri(absoluteURI).get().getContent(); + if (parentContent != null && parentContent.isObject() && parentContent.has("properties")) { + parentProperties = (ObjectNode) parentContent.get("properties"); + } else if (absoluteURI.getPath().endsWith("#properties")) { + absoluteURI = URI.create(absoluteURI.toString().replace("#properties", "")); + parentProperties = (ObjectNode) getByUri(absoluteURI).get().getContent().get("properties"); + } + } + } + + + } + + ObjectNode resolvedProperties = NODE_FACTORY.objectNode(); + if (parentProperties != null && parentProperties.size() > 0) + resolvedProperties = SchemaUtil.mergeProperties(schemaProperties, parentProperties); + else resolvedProperties = schemaProperties.deepCopy(); + + return resolvedProperties; + } + + public ObjectNode resolveItems(Schema schema, ObjectNode fieldNode, String resourceId) { + ObjectNode schemaItems = NODE_FACTORY.objectNode(); + ObjectNode parentItems = NODE_FACTORY.objectNode(); + if (fieldNode == null) { + ObjectNode schemaContent = (ObjectNode) schema.getContent(); + if( schemaContent.has("items") ) { + schemaItems = (ObjectNode) schemaContent.get("items"); + if (schema.getParentContent() != null) { + ObjectNode parentContent = (ObjectNode) schema.getParentContent(); + if (parentContent.has("items")) { + parentItems = (ObjectNode) parentContent.get("items"); + } + } + } + } else if (fieldNode != null && fieldNode.size() > 0) { + if (fieldNode.has("items") && fieldNode.get("items").isObject() && fieldNode.get("items").size() > 0) + schemaItems = (ObjectNode) fieldNode.get("items"); + URI parentURI = null; + if( fieldNode.has("$ref") || fieldNode.has("extends") ) { + JsonNode refNode = fieldNode.get("$ref"); + JsonNode extendsNode = fieldNode.get("extends"); + if (refNode != null && refNode.isValueNode()) + parentURI = URI.create(refNode.asText()); + else if (extendsNode != null && extendsNode.isObject()) + parentURI = URI.create(extendsNode.get("$ref").asText()); + ObjectNode parentContent = null; + URI absoluteURI; + if (parentURI.isAbsolute()) + absoluteURI = parentURI; + else { + absoluteURI = schema.getURI().resolve(parentURI); + if (!absoluteURI.isAbsolute() || (absoluteURI.isAbsolute() && !getByUri(absoluteURI).isPresent() )) + absoluteURI = schema.getParentURI().resolve(parentURI); + } + if (absoluteURI != null && absoluteURI.isAbsolute()) { + if (getByUri(absoluteURI).isPresent()) + parentContent = (ObjectNode) getByUri(absoluteURI).get().getContent(); + if (parentContent != null && parentContent.isObject() && parentContent.has("items")) { + parentItems = (ObjectNode) parentContent.get("items"); + } else if (absoluteURI.getPath().endsWith("#items")) { + absoluteURI = URI.create(absoluteURI.toString().replace("#items", "")); + parentItems = (ObjectNode) getByUri(absoluteURI).get().getContent().get("items"); + } + } + } + } + + ObjectNode resolvedItems = NODE_FACTORY.objectNode(); + if (parentItems != null && parentItems.size() > 0) + resolvedItems = SchemaUtil.mergeProperties(schemaItems, parentItems); + else resolvedItems = schemaItems.deepCopy(); + + return resolvedItems; + } + + @Override + public int compare(Schema left, Schema right) { + // are they the same? + if( left.equals(right)) return 0; + // is one an ancestor of the other + Schema candidateAncestor = left; + while( candidateAncestor.getParent() != null ) { + candidateAncestor = candidateAncestor.getParent(); + if( candidateAncestor.equals(right)) + return 1; + } + candidateAncestor = right; + while( candidateAncestor.getParent() != null ) { + candidateAncestor = candidateAncestor.getParent(); + if( candidateAncestor.equals(left)) + return -1; + } + // does one have a field that reference the other? + for( JsonNode refNode : left.getContent().findValues("$ref") ) { + String refText = refNode.asText(); + Optional<URI> resolvedURI = safeResolve(left.getURI(), refText); + if( resolvedURI.isPresent() && resolvedURI.get().equals(right.getURI())) + return 1; + } + for( JsonNode refNode : right.getContent().findValues("$ref") ) { + String refText = refNode.asText(); + Optional<URI> resolvedURI = safeResolve(right.getURI(), refText); + if( resolvedURI.isPresent() && resolvedURI.get().equals(left.getURI())) + return -1; + } + // does one have a field that reference a third schema that references the other? + for( JsonNode refNode : left.getContent().findValues("$ref") ) { + String refText = refNode.asText(); + Optional<URI> possibleConnectorURI = safeResolve(left.getURI(), refText); + if( possibleConnectorURI.isPresent()) { + Optional<Schema> possibleConnector = getByUri(possibleConnectorURI.get()); + if (possibleConnector.isPresent()) { + for (JsonNode connectorRefNode : possibleConnector.get().getContent().findValues("$ref")) { + String connectorRefText = connectorRefNode.asText(); + Optional<URI> resolvedURI = safeResolve(possibleConnector.get().getURI(), connectorRefText); + if (resolvedURI.isPresent() && resolvedURI.get().equals(right.getURI())) + return 1; + } + } + } + } + for( JsonNode refNode : right.getContent().findValues("$ref") ) { + String refText = refNode.asText(); + Optional<URI> possibleConnectorURI = safeResolve(right.getURI(), refText); + if( possibleConnectorURI.isPresent()) { + Optional<Schema> possibleConnector = getByUri(possibleConnectorURI.get()); + if (possibleConnector.isPresent()) { + for (JsonNode connectorRefNode : possibleConnector.get().getContent().findValues("$ref")) { + String connectorRefText = connectorRefNode.asText(); + Optional<URI> resolvedURI = safeResolve(possibleConnector.get().getURI(), connectorRefText); + if (resolvedURI.isPresent() && resolvedURI.get().equals(left.getURI())) + return -1; + } + } + } + } + return 0; + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/main/java/org/apache/streams/util/schema/SchemaUtil.java ---------------------------------------------------------------------- diff --git a/streams-util/src/main/java/org/apache/streams/util/schema/SchemaUtil.java b/streams-util/src/main/java/org/apache/streams/util/schema/SchemaUtil.java new file mode 100644 index 0000000..f8b0070 --- /dev/null +++ b/streams-util/src/main/java/org/apache/streams/util/schema/SchemaUtil.java @@ -0,0 +1,49 @@ +package org.apache.streams.util.schema; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URL; +import java.util.Iterator; +import java.util.Map; + +import static org.apache.commons.lang3.StringUtils.isEmpty; + +/** + * SchemaUtil contains methods to assist in resolving schemas and schema fragments. + */ +public class SchemaUtil { + + private final static Logger LOGGER = LoggerFactory.getLogger(SchemaUtil.class); + private static final JsonNodeFactory NODE_FACTORY = JsonNodeFactory.instance; + public static final String ILLEGAL_CHARACTER_REGEX = "[^0-9a-zA-Z_$]"; + + public static String childQualifiedName(String parentQualifiedName, String childSimpleName) { + String safeChildName = childSimpleName.replaceAll(ILLEGAL_CHARACTER_REGEX, "_"); + return isEmpty(parentQualifiedName) ? safeChildName : parentQualifiedName + "." + safeChildName; + } + + public static ObjectNode readSchema(URL schemaUrl) { + + ObjectNode schemaNode = NODE_FACTORY.objectNode(); + schemaNode.put("$ref", schemaUrl.toString()); + return schemaNode; + + } + + public static ObjectNode mergeProperties(ObjectNode content, ObjectNode parent) { + + ObjectNode merged = parent.deepCopy(); + Iterator<Map.Entry<String, JsonNode>> fields = content.fields(); + for( ; fields.hasNext(); ) { + Map.Entry<String, JsonNode> field = fields.next(); + String fieldId = field.getKey(); + merged.put(fieldId, field.getValue().deepCopy()); + } + return merged; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/main/java/org/apache/streams/util/schema/URIUtil.java ---------------------------------------------------------------------- diff --git a/streams-util/src/main/java/org/apache/streams/util/schema/URIUtil.java b/streams-util/src/main/java/org/apache/streams/util/schema/URIUtil.java new file mode 100644 index 0000000..af468e3 --- /dev/null +++ b/streams-util/src/main/java/org/apache/streams/util/schema/URIUtil.java @@ -0,0 +1,30 @@ +package org.apache.streams.util.schema; + +import com.google.common.base.Optional; +import org.apache.commons.lang3.StringUtils; + +import java.net.URI; + +/** + * URIUtil contains methods to assist in resolving URIs and URI fragments. + */ +public class URIUtil { + + public static URI removeFragment(URI id) { + return URI.create(StringUtils.substringBefore(id.toString(), "#")); + } + + public static URI removeFile(URI id) { + return URI.create(StringUtils.substringBeforeLast(id.toString(), "/")); + } + + public static Optional<URI> safeResolve(URI absolute, String relativePart) { + if( !absolute.isAbsolute()) return Optional.absent(); + try { + return Optional.of(absolute.resolve(relativePart)); + } catch( IllegalArgumentException e ) { + return Optional.absent(); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaOrderingTest.java ---------------------------------------------------------------------- diff --git a/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaOrderingTest.java b/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaOrderingTest.java new file mode 100644 index 0000000..6deaa98 --- /dev/null +++ b/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaOrderingTest.java @@ -0,0 +1,150 @@ +package org.apache.streams.util.schema.test; + +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; +import org.apache.streams.util.schema.Schema; +import org.apache.streams.util.schema.SchemaStore; +import org.apache.streams.util.schema.SchemaStoreImpl; +import org.junit.Test; + +import java.io.File; +import java.util.Iterator; +import java.util.List; + +/** + * Created by sblackmon on 5/3/16. + */ +public class SchemaOrderingTest { + + @Test + public void compareVerbParent() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File update = new File("target/test-classes/verbs/update.json"); + schemaStore.create(update.toURI()); + File activity = new File("target/test-classes/activity.json"); + schemaStore.create(activity.toURI()); + assert( schemaStore.compare( schemaStore.getByUri(update.toURI()).get(), schemaStore.getByUri(activity.toURI()).get()) == 1); + Iterator<Schema> schemaIterator = schemaStore.getSchemaIterator(); + assertContainsItemsEndingWithInOrder( + schemaIterator, + Lists.newArrayList( + "activity.json", + "update.json" + ) + ); + } + + @Test + public void compareObjectTypeParent() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File alert = new File("target/test-classes/objectTypes/alert.json"); + schemaStore.create(alert.toURI()); + File object = new File("target/test-classes/object.json"); + schemaStore.create(object.toURI()); + assert( schemaStore.compare( schemaStore.getByUri(object.toURI()).get(), schemaStore.getByUri(alert.toURI()).get()) == -1); + Iterator<Schema> schemaIterator = schemaStore.getSchemaIterator(); + assertContainsItemsEndingWithInOrder( + schemaIterator, + Lists.newArrayList( + "object.json", + "alert.json" + ) + ); + } + + @Test + public void compareUnrelated() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File alert = new File("target/test-classes/objectTypes/alert.json"); + schemaStore.create(alert.toURI()); + File update = new File("target/test-classes/verbs/update.json"); + schemaStore.create(update.toURI()); + assert( schemaStore.compare( schemaStore.getByUri(alert.toURI()).get(), schemaStore.getByUri(update.toURI()).get()) == 0); + } + + @Test + public void compareVerbFieldRef() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File update = new File("target/test-classes/verbs/update.json"); + schemaStore.create(update.toURI()); + File object = new File("target/test-classes/object.json"); + schemaStore.create(object.toURI()); + assert( schemaStore.compare( schemaStore.getByUri(update.toURI()).get(), schemaStore.getByUri(object.toURI()).get()) == 1); + Iterator<Schema> schemaIterator = schemaStore.getSchemaIterator(); + assertContainsItemsEndingWithInOrder( + schemaIterator, + Lists.newArrayList( + "object.json", + "update.json" + ) + ); + } + + @Test + public void compareObjectTypeFieldRef() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File alert = new File("target/test-classes/objectTypes/alert.json"); + schemaStore.create(alert.toURI()); + File media_link = new File("target/test-classes/media_link.json"); + schemaStore.create(media_link.toURI()); + assert( schemaStore.compare( schemaStore.getByUri(media_link.toURI()).get(), schemaStore.getByUri(alert.toURI()).get()) == -1); + Iterator<Schema> schemaIterator = schemaStore.getSchemaIterator(); + assertContainsItemsEndingWithInOrder( + schemaIterator, + Lists.newArrayList( + "media_link.json", + "object.json", + "alert.json" + ) + ); + } + + @Test + public void compareVerbAncestorIndirect() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File update = new File("target/test-classes/verbs/update.json"); + schemaStore.create(update.toURI()); + File media_link = new File("target/test-classes/media_link.json"); + schemaStore.create(media_link.toURI()); + assert( schemaStore.getByUri(media_link.toURI()).isPresent()); + assert( schemaStore.getByUri(update.toURI()).isPresent()); + assert( schemaStore.compare( schemaStore.getByUri(media_link.toURI()).get(), schemaStore.getByUri(update.toURI()).get()) == -1); + Iterator<Schema> schemaIterator = schemaStore.getSchemaIterator(); + assertContainsItemsEndingWithInOrder( + schemaIterator, + Lists.newArrayList( + "media_link.json", + "update.json" + ) + ); + } + + + public void assertContainsItemsEndingWithInOrder(Iterator<Schema> iterator, List<String> items) { + for( String item : items ) { + Optional<Schema> tryFind = Iterators.tryFind( iterator, new SchemaUriEndsWithPredicate(item) ); + assert( tryFind.isPresent() ); + } + } + + public class SchemaUriEndsWithPredicate implements Predicate<Schema> { + + private String endsWith; + + public SchemaUriEndsWithPredicate(String endsWith) { + this.endsWith = endsWith; + } + + @Override + public boolean apply(Schema input) { + return input.getURI().getPath().endsWith(endsWith); + } + + @Override + public boolean equals(Object object) { + return false; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaStoreTest.java ---------------------------------------------------------------------- diff --git a/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaStoreTest.java b/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaStoreTest.java new file mode 100644 index 0000000..9aa7661 --- /dev/null +++ b/streams-util/src/test/java/org/apache/streams/util/schema/test/SchemaStoreTest.java @@ -0,0 +1,71 @@ +package org.apache.streams.util.schema.test; + +import org.apache.streams.util.schema.Schema; +import org.apache.streams.util.schema.SchemaStore; +import org.apache.streams.util.schema.SchemaStoreImpl; +import org.junit.Test; + +import java.io.File; +import java.net.URI; + +/** + * Created by sblackmon on 5/2/16. + */ +public class SchemaStoreTest { + + @Test + public void indexMediaLink() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File file = new File("target/test-classes/media_link.json"); + schemaStore.create(file.toURI()); + assert( schemaStore.getFileUriCount() == 1); + assert( schemaStore.getByUri(file.toURI()).isPresent()); + assert( schemaStore.getById(schemaStore.getByUri(file.toURI()).get().getId()).isPresent()); + } + + @Test + public void indexApprove() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File file = new File("target/test-classes/verbs/approve.json"); + schemaStore.create(file.toURI()); + assert( schemaStore.getFileUriCount() == 4); + assert( schemaStore.getByUri(file.toURI()).isPresent()); + assert( schemaStore.getById(schemaStore.getByUri(file.toURI()).get().getId()).isPresent()); + } + + @Test + public void indexCollection() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File file = new File("target/test-classes/collection.json"); + schemaStore.create(file.toURI()); + assert( schemaStore.getFileUriCount() == 3); + assert( schemaStore.getByUri(file.toURI()).isPresent()); + assert( schemaStore.getById(schemaStore.getByUri(file.toURI()).get().getId()).isPresent()); + Schema collection = schemaStore.getByUri(file.toURI()).get(); + assert( collection.getParent() == null ); + assert( schemaStore.getById( + URI.create("http://streams.incubator.apache.org/site/0.3-incubating-SNAPSHOT/streams-schemas/object.json#" + )).isPresent()); + } + + @Test + public void indexUpdate() { + SchemaStore schemaStore = new SchemaStoreImpl(); + File file = new File("target/test-classes/verbs/update.json"); + schemaStore.create(file.toURI()); + assert( schemaStore.getFileUriCount() == 4); + assert( schemaStore.getByUri(file.toURI()).isPresent()); + assert( schemaStore.getById(schemaStore.getByUri(file.toURI()).get().getId()).isPresent()); + Schema update = schemaStore.getByUri(file.toURI()).get(); + assert( update.getParent() != null ); + assert( update.getParent().getId().getScheme().equals("http")); + assert( update.getParent().getId().getHost().equals("streams.incubator.apache.org")); + assert( update.getParent().getId().getPath().startsWith("/site/0.3-incubating-SNAPSHOT/streams-schemas")); + assert( update.getParent().getId().getPath().endsWith("activity.json")); + } + + // test create from messed up URI + + // test create from URI with messed up reference + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/accept.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/accept.json b/streams-util/src/test/resources/activities/accept.json new file mode 100644 index 0000000..c1dfd5f --- /dev/null +++ b/streams-util/src/test/resources/activities/accept.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "accept", + "object": { + "objectType": "job", + "displayName": "Director of Marketing" + }, + "title": "Sally accepted the Director of Marketing job." +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/access.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/access.json b/streams-util/src/test/resources/activities/access.json new file mode 100644 index 0000000..93bc6e2 --- /dev/null +++ b/streams-util/src/test/resources/activities/access.json @@ -0,0 +1,17 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "access", + "object": { + "objectType": "file", + "displayName": "4Q2012 Sales Forecast.xls" + }, + "published": "2012-12-12T12:12:12Z", + "title": "Joe accessed the file \"4Q2012 Sales Forecast.xls\"" +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/acknowledge.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/acknowledge.json b/streams-util/src/test/resources/activities/acknowledge.json new file mode 100644 index 0000000..2b69fa7 --- /dev/null +++ b/streams-util/src/test/resources/activities/acknowledge.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "acknowledge", + "object": { + "objectType": "issue", + "displayName": "#123: There is a problem with the build" + }, + "content": "Sally acknowledged Issue #123" +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/add.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/add.json b/streams-util/src/test/resources/activities/add.json new file mode 100644 index 0000000..b4e8151 --- /dev/null +++ b/streams-util/src/test/resources/activities/add.json @@ -0,0 +1,21 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "add", + "object": { + "objectType": "image", + "displayName": "My cat", + "fullImage": {"url": "http://example.org/cat.jpg"} + }, + "target": { + "objectType": "collection", + "displayName": "Joe's Photo Album", + "objectTypes": ["image"] + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/agree.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/agree.json b/streams-util/src/test/resources/activities/agree.json new file mode 100644 index 0000000..3034cd8 --- /dev/null +++ b/streams-util/src/test/resources/activities/agree.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "agree", + "object": { + "objectType": "article", + "displayName": "Some Random Article Online" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/append.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/append.json b/streams-util/src/test/resources/activities/append.json new file mode 100644 index 0000000..d8fb3be --- /dev/null +++ b/streams-util/src/test/resources/activities/append.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "append", + "object": {"content": "This is some text"}, + "target": { + "objectType": "file", + "displayName": "log.txt" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/approve.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/approve.json b/streams-util/src/test/resources/activities/approve.json new file mode 100644 index 0000000..b6f378e --- /dev/null +++ b/streams-util/src/test/resources/activities/approve.json @@ -0,0 +1,20 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "approve", + "object": { + "objectType": "task", + "actor": {"displayName": "Joe"}, + "verb": "join", + "object": { + "objectType": "group", + "displayName": "Administrators" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/archive.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/archive.json b/streams-util/src/test/resources/activities/archive.json new file mode 100644 index 0000000..557dcdf --- /dev/null +++ b/streams-util/src/test/resources/activities/archive.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "archive", + "object": { + "objectType": "file", + "displayName": "4Q2012 Sales Forecast.xls" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/assign.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/assign.json b/streams-util/src/test/resources/activities/assign.json new file mode 100644 index 0000000..51b8a51 --- /dev/null +++ b/streams-util/src/test/resources/activities/assign.json @@ -0,0 +1,20 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "assign", + "object": { + "objectType": "issue", + "displayName": "Issue #123: Some Issue" + }, + "target": { + "objectType": "person", + "displayName": "Joe" + }, + "title": "Sally assigned Issue #123 to Joe" +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/at.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/at.json b/streams-util/src/test/resources/activities/at.json new file mode 100644 index 0000000..64a77f9 --- /dev/null +++ b/streams-util/src/test/resources/activities/at.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "at", + "object": { + "objectType": "place", + "displayName": "Acme, Co." + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/attach.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/attach.json b/streams-util/src/test/resources/activities/attach.json new file mode 100644 index 0000000..716616b --- /dev/null +++ b/streams-util/src/test/resources/activities/attach.json @@ -0,0 +1,20 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "attach", + "object": { + "objectType": "binary", + "data": "dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=" + }, + "target": { + "objectType": "issue", + "displayName": "Issue #123" + }, + "title": "Sally added an attachment to Issue #123" +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/attend.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/attend.json b/streams-util/src/test/resources/activities/attend.json new file mode 100644 index 0000000..f8c0838 --- /dev/null +++ b/streams-util/src/test/resources/activities/attend.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "attend", + "object": { + "objectType": "event", + "displayName": "Sally's Meeting" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/author.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/author.json b/streams-util/src/test/resources/activities/author.json new file mode 100644 index 0000000..1903700 --- /dev/null +++ b/streams-util/src/test/resources/activities/author.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "author", + "object": { + "objectType": "file", + "displayName": "4Q2012 Sales Forecast.xls" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/authorize.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/authorize.json b/streams-util/src/test/resources/activities/authorize.json new file mode 100644 index 0000000..2d9d1b3 --- /dev/null +++ b/streams-util/src/test/resources/activities/authorize.json @@ -0,0 +1,23 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "authorize", + "object": { + "objectType": "task", + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "access", + "object": { + "objectType": "place", + "displayName": "Joe's Home" + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/borrow.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/borrow.json b/streams-util/src/test/resources/activities/borrow.json new file mode 100644 index 0000000..e21809a --- /dev/null +++ b/streams-util/src/test/resources/activities/borrow.json @@ -0,0 +1,21 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "borrow", + "object": { + "objectType": "book", + "displayName": "Cloud Atlas" + }, + "target": { + "objectType": "person", + "displayName": "Joe" + }, + "title": "Sally borrowed the book 'Cloud Atlas' from Joe" +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/build.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/build.json b/streams-util/src/test/resources/activities/build.json new file mode 100644 index 0000000..78878e1 --- /dev/null +++ b/streams-util/src/test/resources/activities/build.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "build", + "object": { + "objectType": "application", + "displayName": "MyApp Builder 12345" + } +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/cancel.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/cancel.json b/streams-util/src/test/resources/activities/cancel.json new file mode 100644 index 0000000..b7aba81 --- /dev/null +++ b/streams-util/src/test/resources/activities/cancel.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "cancel", + "object": { + "objectType": "offer", + "displayName": "Free Money!" + }, + "title": "Sally cancelled the offer for free money." +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/checkin.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/checkin.json b/streams-util/src/test/resources/activities/checkin.json new file mode 100644 index 0000000..97216b9 --- /dev/null +++ b/streams-util/src/test/resources/activities/checkin.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "checkin", + "object": { + "objectType": "place", + "displayName": "Acme, Co" + }, + "title": "Joe checked in at Acme, Co" +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/close.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/close.json b/streams-util/src/test/resources/activities/close.json new file mode 100644 index 0000000..362e3f6 --- /dev/null +++ b/streams-util/src/test/resources/activities/close.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "close", + "object": { + "objectType": "issue", + "displayName": "Issue #123" + }, + "title": "Joe closed issue #123" +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/complete.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/complete.json b/streams-util/src/test/resources/activities/complete.json new file mode 100644 index 0000000..06694a7 --- /dev/null +++ b/streams-util/src/test/resources/activities/complete.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "complete", + "object": { + "objectType": "process", + "displayName": "Some long process" + } +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/confirm.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/confirm.json b/streams-util/src/test/resources/activities/confirm.json new file mode 100644 index 0000000..9307c38 --- /dev/null +++ b/streams-util/src/test/resources/activities/confirm.json @@ -0,0 +1,17 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "confirm", + "object": { + "objectType": "issue", + "displayName": "Issue #123" + }, + "title": "Joe confirmed issue #123" +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/consume.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/consume.json b/streams-util/src/test/resources/activities/consume.json new file mode 100644 index 0000000..ed907e3 --- /dev/null +++ b/streams-util/src/test/resources/activities/consume.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "consume", + "object": { + "objectType": "product", + "displayName": "Some amazing product" + } +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/create.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/create.json b/streams-util/src/test/resources/activities/create.json new file mode 100644 index 0000000..5d8afb3 --- /dev/null +++ b/streams-util/src/test/resources/activities/create.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "create", + "object": { + "objectType": "product", + "displayName": "Some amazing product" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/delete.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/delete.json b/streams-util/src/test/resources/activities/delete.json new file mode 100644 index 0000000..6943046 --- /dev/null +++ b/streams-util/src/test/resources/activities/delete.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "delete", + "object": { + "objectType": "file", + "displayName": "4Q2012 Sales Forecast.xls" + }, + "title": "Joe is probably going to get fired." +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/deliver.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/deliver.json b/streams-util/src/test/resources/activities/deliver.json new file mode 100644 index 0000000..620f0b5 --- /dev/null +++ b/streams-util/src/test/resources/activities/deliver.json @@ -0,0 +1,20 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "deliver", + "object": { + "objectType": "note", + "displayName": "Bad News", + "content": "Joe deleted the sales forecast" + }, + "target": { + "objectType": "person", + "displayName": "Joe's Boss" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/deny.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/deny.json b/streams-util/src/test/resources/activities/deny.json new file mode 100644 index 0000000..b83ca60 --- /dev/null +++ b/streams-util/src/test/resources/activities/deny.json @@ -0,0 +1,23 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "deny", + "object": { + "objectType": "task", + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "delete", + "object": { + "objectType": "file", + "displayName": "4Q2012 Sales Forecast.xls" + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/disagree.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/disagree.json b/streams-util/src/test/resources/activities/disagree.json new file mode 100644 index 0000000..8614e88 --- /dev/null +++ b/streams-util/src/test/resources/activities/disagree.json @@ -0,0 +1,30 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "disagree", + "object": { + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "deny", + "object": { + "objectType": "task", + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "delete", + "object": { + "objectType": "file", + "displayName": "4Q2012 Sales Forecast.xls" + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/dislike.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/dislike.json b/streams-util/src/test/resources/activities/dislike.json new file mode 100644 index 0000000..16c2148 --- /dev/null +++ b/streams-util/src/test/resources/activities/dislike.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "dislike", + "object": { + "objectType": "person", + "displayName": "Sally" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/experience.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/experience.json b/streams-util/src/test/resources/activities/experience.json new file mode 100644 index 0000000..d81d024 --- /dev/null +++ b/streams-util/src/test/resources/activities/experience.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally" + }, + "verb": "experience", + "object": { + "objectType": "event", + "displayName": "Disciplinary Action for Joe" + } +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/favorite.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/favorite.json b/streams-util/src/test/resources/activities/favorite.json new file mode 100644 index 0000000..3df99bf --- /dev/null +++ b/streams-util/src/test/resources/activities/favorite.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe's Boss" + }, + "verb": "favorite", + "object": { + "objectType": "person", + "displayName": "Sally" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/find.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/find.json b/streams-util/src/test/resources/activities/find.json new file mode 100644 index 0000000..9c25c59 --- /dev/null +++ b/streams-util/src/test/resources/activities/find.json @@ -0,0 +1,19 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "find", + "object": { + "objectType": "application", + "displayName": "Unapproved Software Application" + }, + "location": { + "objectType": "place", + "displayName": "Sally's Computer" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/flag-as-inappropriate.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/flag-as-inappropriate.json b/streams-util/src/test/resources/activities/flag-as-inappropriate.json new file mode 100644 index 0000000..6f4d202 --- /dev/null +++ b/streams-util/src/test/resources/activities/flag-as-inappropriate.json @@ -0,0 +1,24 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Sally's Boss" + }, + "verb": "flag-as-inappropriate", + "object": { + "objectType": "application", + "displayName": "Unapproved Software Application", + "location": { + "displayName": "Sally's Computer" + } + }, + "context": { + "objectType": "issue", + "displayName": "Issue #125", + "types": ["http://example.org/violation-of-corporate-policy"] + } +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/follow.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/follow.json b/streams-util/src/test/resources/activities/follow.json new file mode 100644 index 0000000..fc8c992 --- /dev/null +++ b/streams-util/src/test/resources/activities/follow.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe" + }, + "verb": "follow", + "object": { + "objectType": "issue", + "displayName": "Issue #125" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/give.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/give.json b/streams-util/src/test/resources/activities/give.json new file mode 100644 index 0000000..f145296 --- /dev/null +++ b/streams-util/src/test/resources/activities/give.json @@ -0,0 +1,28 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Joe's Boss" + }, + "verb": "give", + "object": { + "objectType": "note", + "displayName": "Notice of Employment Termination" + }, + "target": { + "objectType": "collection", + "items": [ + { + "objectType": "person", + "displayName": "Joe" + }, + { + "objectType": "person", + "displayName": "Sally" + } + ] + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/host.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/host.json b/streams-util/src/test/resources/activities/host.json new file mode 100644 index 0000000..3331353 --- /dev/null +++ b/streams-util/src/test/resources/activities/host.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Bob" + }, + "verb": "host", + "object": { + "objectType": "event", + "displayName": "Job Interview" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/ignore.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/ignore.json b/streams-util/src/test/resources/activities/ignore.json new file mode 100644 index 0000000..012013a --- /dev/null +++ b/streams-util/src/test/resources/activities/ignore.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "ignore", + "object": { + "objectType": "note", + "displayName": "Joe's request for his job back." + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/insert.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/insert.json b/streams-util/src/test/resources/activities/insert.json new file mode 100644 index 0000000..57bda66 --- /dev/null +++ b/streams-util/src/test/resources/activities/insert.json @@ -0,0 +1,19 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Bob" + }, + "verb": "insert", + "object": { + "objectType": "note", + "displayName": "Notes about Employee Disciplinary Actions" + }, + "target": { + "objectType": "file", + "displayName": "2013 Corporate Policy Updates.doc" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/install.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/install.json b/streams-util/src/test/resources/activities/install.json new file mode 100644 index 0000000..1ecdecd --- /dev/null +++ b/streams-util/src/test/resources/activities/install.json @@ -0,0 +1,18 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "install", + "object": { + "objectType": "application", + "displayName": "Approved Software Scanning Tool", + "location": { + "displayName": "All computers in Building A" + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/interact.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/interact.json b/streams-util/src/test/resources/activities/interact.json new file mode 100644 index 0000000..f427513 --- /dev/null +++ b/streams-util/src/test/resources/activities/interact.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Bob" + }, + "verb": "interact", + "object": { + "objectType": "person", + "displayName": "Laura" + }, + "title": "Bob called Laura." +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/invite.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/invite.json b/streams-util/src/test/resources/activities/invite.json new file mode 100644 index 0000000..7c84b78 --- /dev/null +++ b/streams-util/src/test/resources/activities/invite.json @@ -0,0 +1,19 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "invite", + "object": { + "objectType": "person", + "displayName": "Mark" + }, + "target": { + "objectType": "event", + "displayName": "Job Interview" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/join.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/join.json b/streams-util/src/test/resources/activities/join.json new file mode 100644 index 0000000..7996a9b --- /dev/null +++ b/streams-util/src/test/resources/activities/join.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "join", + "object": { + "objectType": "organization", + "displayName": "Acme, Co" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/leave.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/leave.json b/streams-util/src/test/resources/activities/leave.json new file mode 100644 index 0000000..08516c5 --- /dev/null +++ b/streams-util/src/test/resources/activities/leave.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "leave", + "object": { + "objectType": "organization", + "displayName": "Other, Co" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/like.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/like.json b/streams-util/src/test/resources/activities/like.json new file mode 100644 index 0000000..853676f --- /dev/null +++ b/streams-util/src/test/resources/activities/like.json @@ -0,0 +1,22 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "like", + "object": { + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "join", + "object": { + "objectType": "organization", + "displayName": "Acme, Co" + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/listen.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/listen.json b/streams-util/src/test/resources/activities/listen.json new file mode 100644 index 0000000..1268060 --- /dev/null +++ b/streams-util/src/test/resources/activities/listen.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "listen", + "object": { + "objectType": "audio", + "displayName": "Welcome to the Company (Podcast).mp3" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/lose.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/lose.json b/streams-util/src/test/resources/activities/lose.json new file mode 100644 index 0000000..073e914 --- /dev/null +++ b/streams-util/src/test/resources/activities/lose.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "organization", + "displayName": "New York Yankees" + }, + "verb": "lose", + "object": { + "objectType": "game", + "displayName": "World Series" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/make-friend.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/make-friend.json b/streams-util/src/test/resources/activities/make-friend.json new file mode 100644 index 0000000..1acf539 --- /dev/null +++ b/streams-util/src/test/resources/activities/make-friend.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "make-friend", + "object": { + "objectType": "person", + "displayName": "Laura" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/open.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/open.json b/streams-util/src/test/resources/activities/open.json new file mode 100644 index 0000000..4bf47cd --- /dev/null +++ b/streams-util/src/test/resources/activities/open.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "open", + "object": { + "objectType": "issue", + "displayName": "Issue #126" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/play.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/play.json b/streams-util/src/test/resources/activities/play.json new file mode 100644 index 0000000..0605662 --- /dev/null +++ b/streams-util/src/test/resources/activities/play.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "play", + "object": { + "objectType": "audio", + "displayName": "Call Me Maybe" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/post.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/post.json b/streams-util/src/test/resources/activities/post.json new file mode 100644 index 0000000..73cfff7 --- /dev/null +++ b/streams-util/src/test/resources/activities/post.json @@ -0,0 +1,25 @@ +{ + "published": "2011-02-10T15:04:55Z", + "actor": { + "url": "http://example.org/martin", + "objectType" : "person", + "id": "tag:example.org,2011:martin", + "image": { + "url": "http://example.org/martin/image", + "width": 250, + "height": 250 + }, + "displayName": "Martin Smith" + }, + "verb": "post", + "object" : { + "url": "http://example.org/blog/2011/02/entry", + "id": "tag:example.org,2011:abc123/xyz" + }, + "target" : { + "url": "http://example.org/blog/", + "objectType": "blog", + "id": "tag:example.org,2011:abc123", + "displayName": "Martin's Blog" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/present.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/present.json b/streams-util/src/test/resources/activities/present.json new file mode 100644 index 0000000..8f4df12 --- /dev/null +++ b/streams-util/src/test/resources/activities/present.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "present", + "object": { + "objectType": "file", + "displayName": "1Q2013 Sales Forecast.ppt" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/purchase.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/purchase.json b/streams-util/src/test/resources/activities/purchase.json new file mode 100644 index 0000000..3354597 --- /dev/null +++ b/streams-util/src/test/resources/activities/purchase.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "purchase", + "object": { + "objectType": "video", + "displayName": "The Avengers" + }, + "title": "Mark purchased the movie, The Avengers" +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/qualify.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/qualify.json b/streams-util/src/test/resources/activities/qualify.json new file mode 100644 index 0000000..630bda0 --- /dev/null +++ b/streams-util/src/test/resources/activities/qualify.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "qualify", + "object": { + "objectType": "offer", + "displayName": "Free Money!" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/read.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/read.json b/streams-util/src/test/resources/activities/read.json new file mode 100644 index 0000000..3509886 --- /dev/null +++ b/streams-util/src/test/resources/activities/read.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "read", + "object": { + "objectType": "book", + "displayName": "Cloud Atlas" + } +} + http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/receive.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/receive.json b/streams-util/src/test/resources/activities/receive.json new file mode 100644 index 0000000..d61245e --- /dev/null +++ b/streams-util/src/test/resources/activities/receive.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "receive", + "object": { + "objectType": "badge", + "displayName": "Most Checkins in 24 hours" + }, + "title": "Laura was awarded a badge for \"Most Checkins in 24 hours\"" +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/reject.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/reject.json b/streams-util/src/test/resources/activities/reject.json new file mode 100644 index 0000000..84d1ab1 --- /dev/null +++ b/streams-util/src/test/resources/activities/reject.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "reject", + "object": { + "objectType": "issue", + "displayName": "Issue #126" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/remove-friend.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/remove-friend.json b/streams-util/src/test/resources/activities/remove-friend.json new file mode 100644 index 0000000..0a593e9 --- /dev/null +++ b/streams-util/src/test/resources/activities/remove-friend.json @@ -0,0 +1,15 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "remove-friend", + "object": { + "objectType": "person", + "displayName": "Laura" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/remove.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/remove.json b/streams-util/src/test/resources/activities/remove.json new file mode 100644 index 0000000..1f386e9 --- /dev/null +++ b/streams-util/src/test/resources/activities/remove.json @@ -0,0 +1,23 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Laura" + }, + "verb": "remove", + "object": { + "objectType": "image", + "displayName": "Cat Photo", + "fullImage": { + "url": "http://example.org/cats.jpg" + } + }, + "target": { + "objectType": "collection", + "displayName": "Cat Photo Album", + "objectTypes": ["image"] + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/replace.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/replace.json b/streams-util/src/test/resources/activities/replace.json new file mode 100644 index 0000000..f19a35c --- /dev/null +++ b/streams-util/src/test/resources/activities/replace.json @@ -0,0 +1,19 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "replace", + "object": { + "objectType": "file", + "displayName": "Updated 1Q2014 Sales Forecast.xls" + }, + "target": { + "objectType": "file", + "displayName": "1Q2014 Sales Forecast.xls" + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6187265f/streams-util/src/test/resources/activities/request-friend.json ---------------------------------------------------------------------- diff --git a/streams-util/src/test/resources/activities/request-friend.json b/streams-util/src/test/resources/activities/request-friend.json new file mode 100644 index 0000000..3e571ee --- /dev/null +++ b/streams-util/src/test/resources/activities/request-friend.json @@ -0,0 +1,16 @@ +{ + "$license": [ + "http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "actor": { + "objectType": "person", + "displayName": "Mark" + }, + "verb": "request-friend", + "object": { + "objectType": "person", + "displayName": "Laura" + } +} +
