├── project ├── build.properties ├── config │ └── eclipse │ │ ├── .gitignore │ │ ├── dictionary.txt │ │ └── sort-settings.bat ├── plugins.sbt ├── Developers.scala ├── J2SEVersionCheck.scala └── BytecodePickler.scala ├── core ├── src │ ├── test │ │ ├── resources │ │ │ ├── roundtripTests │ │ │ │ ├── xml │ │ │ │ │ ├── source │ │ │ │ │ │ ├── singleNull.xml │ │ │ │ │ │ ├── namespacedEmptyElement.xml │ │ │ │ │ │ ├── attributedEmptyElement.xml │ │ │ │ │ │ ├── textElement.xml │ │ │ │ │ │ ├── elementWithCdata.xml │ │ │ │ │ │ ├── cdatatest.xml │ │ │ │ │ │ ├── samlRequest.xml │ │ │ │ │ │ ├── purchaseOrderInstance.xml │ │ │ │ │ │ ├── hello.xml │ │ │ │ │ │ └── purchaseOrder.xml │ │ │ │ │ ├── reference │ │ │ │ │ │ ├── singleNull.xml.json │ │ │ │ │ │ ├── singleNull.xml.json.xml │ │ │ │ │ │ ├── namespacedEmptyElement.xml.json.xml │ │ │ │ │ │ ├── textElement.xml.json │ │ │ │ │ │ ├── namespacedEmptyElement.xml.json │ │ │ │ │ │ ├── attributedEmptyElement.xml.json.xml │ │ │ │ │ │ ├── attributedEmptyElement.xml.json │ │ │ │ │ │ ├── textElement.xml.json.xml │ │ │ │ │ │ ├── elementWithCdata.xml.json │ │ │ │ │ │ ├── elementWithCdata.xml.json.xml │ │ │ │ │ │ ├── cdatatest.xml.json │ │ │ │ │ │ ├── cdatatest.xml.json.xml │ │ │ │ │ │ ├── purchaseOrderInstance.xml.json │ │ │ │ │ │ ├── purchaseOrderInstance.xml.json.xml │ │ │ │ │ │ ├── samlRequest.xml.json │ │ │ │ │ │ ├── samlRequest.xml.json.xml │ │ │ │ │ │ ├── hello.xml.json.xml │ │ │ │ │ │ ├── hello.xml.json │ │ │ │ │ │ ├── purchaseOrder.xml.json │ │ │ │ │ │ └── purchaseOrder.xml.json.xml │ │ │ │ │ ├── unsupported_use_cases │ │ │ │ │ │ ├── source │ │ │ │ │ │ │ ├── comments.xml │ │ │ │ │ │ │ └── mixed.xml │ │ │ │ │ │ └── reference │ │ │ │ │ │ │ ├── reference │ │ │ │ │ │ │ ├── comments.xml.json.xml │ │ │ │ │ │ │ ├── comments.xml.json │ │ │ │ │ │ │ ├── mixed.xml.json │ │ │ │ │ │ │ └── mixed.xml.json.xml │ │ │ │ │ │ │ └── README.md │ │ │ │ │ └── generate_reference_conversions.sh │ │ │ │ ├── json │ │ │ │ │ ├── reference │ │ │ │ │ │ ├── comments.json.xml.json │ │ │ │ │ │ ├── cdatatest.json.xml.json │ │ │ │ │ │ ├── cdatatest.json.xml │ │ │ │ │ │ ├── comments.json.xml │ │ │ │ │ │ ├── mixed.json.xml.json │ │ │ │ │ │ ├── purchaseOrderInstance.json.xml.json │ │ │ │ │ │ ├── mixed.json.xml │ │ │ │ │ │ ├── purchaseOrderInstance.json.xml │ │ │ │ │ │ ├── samlRequest.json.xml.json │ │ │ │ │ │ ├── samlRequest.json.xml │ │ │ │ │ │ ├── hello.json.xml │ │ │ │ │ │ ├── hello.json.xml.json │ │ │ │ │ │ ├── purchaseOrder.json.xml.json │ │ │ │ │ │ └── purchaseOrder.json.xml │ │ │ │ │ ├── source │ │ │ │ │ │ ├── cdatatest.json │ │ │ │ │ │ ├── purchaseOrderInstance.json │ │ │ │ │ │ ├── samlRequest.json │ │ │ │ │ │ ├── hello.json │ │ │ │ │ │ └── purchaseOrder.json │ │ │ │ │ ├── unsupported_use_cases │ │ │ │ │ │ ├── reference │ │ │ │ │ │ │ ├── comments.json.xml │ │ │ │ │ │ │ ├── comments.json.xml.json │ │ │ │ │ │ │ ├── mixed.json.xml.json │ │ │ │ │ │ │ └── mixed.json.xml │ │ │ │ │ │ ├── source │ │ │ │ │ │ │ ├── comments.json │ │ │ │ │ │ │ └── mixed.json │ │ │ │ │ │ └── README.md │ │ │ │ │ └── generate_reference_conversions.sh │ │ │ │ └── README.md │ │ │ ├── projectprops │ │ │ │ ├── mockproject.properties │ │ │ │ └── mocks3project.properties │ │ │ └── logback-test.xml │ │ ├── java-generated │ │ │ └── com │ │ │ │ └── dslplatform │ │ │ │ ├── client │ │ │ │ ├── StaticJson.java │ │ │ │ └── json │ │ │ │ │ ├── Boolean │ │ │ │ │ ├── OneBooleanDefaultValueTurtle.java │ │ │ │ │ ├── NullableBooleanDefaultValueTurtle.java │ │ │ │ │ ├── OneArrayOfOneBooleansDefaultValueTurtle.java │ │ │ │ │ ├── NullableArrayOfOneBooleansDefaultValueTurtle.java │ │ │ │ │ ├── NullableListOfOneBooleansDefaultValueTurtle.java │ │ │ │ │ └── OneListOfOneBooleansDefaultValueTurtle.java │ │ │ │ │ ├── Guid │ │ │ │ │ ├── OneGuidDefaultValueTurtle.java │ │ │ │ │ ├── NullableGuidDefaultValueTurtle.java │ │ │ │ │ ├── OneArrayOfOneGuidsDefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneGuidsDefaultValueTurtle.java │ │ │ │ │ ├── Ip │ │ │ │ │ ├── NullableArrayOfOneIpsDefaultValueTurtle.java │ │ │ │ │ ├── OneArrayOfOneIpsDefaultValueTurtle.java │ │ │ │ │ ├── NullableListOfOneIpsDefaultValueTurtle.java │ │ │ │ │ └── OneListOfOneIpsDefaultValueTurtle.java │ │ │ │ │ ├── Binary │ │ │ │ │ ├── OneBinaryDefaultValueTurtle.java │ │ │ │ │ ├── OneArrayOfOneBinariesDefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneBinariesDefaultValueTurtle.java │ │ │ │ │ ├── Integer │ │ │ │ │ ├── OneArrayOfOneIntegersDefaultValueTurtle.java │ │ │ │ │ ├── NullableArrayOfOneIntegersDefaultValueTurtle.java │ │ │ │ │ └── NullableListOfOneIntegersDefaultValueTurtle.java │ │ │ │ │ ├── Long │ │ │ │ │ ├── OneArrayOfOneLongsDefaultValueTurtle.java │ │ │ │ │ ├── NullableArrayOfOneLongsDefaultValueTurtle.java │ │ │ │ │ ├── NullableListOfOneLongsDefaultValueTurtle.java │ │ │ │ │ └── OneListOfOneLongsDefaultValueTurtle.java │ │ │ │ │ ├── Float │ │ │ │ │ ├── OneArrayOfOneFloatsDefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneFloatsDefaultValueTurtle.java │ │ │ │ │ ├── Double │ │ │ │ │ ├── OneArrayOfOneDoublesDefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneDoublesDefaultValueTurtle.java │ │ │ │ │ ├── StringWithMaxLengthOf9 │ │ │ │ │ ├── OneArrayOfOneStringsWithMaxLengthOf9DefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneStringsWithMaxLengthOf9DefaultValueTurtle.java │ │ │ │ │ ├── Timestamp │ │ │ │ │ └── OneTimestampDefaultValueTurtle.java │ │ │ │ │ ├── Url │ │ │ │ │ ├── OneArrayOfOneUrlsDefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneUrlsDefaultValueTurtle.java │ │ │ │ │ └── Xml │ │ │ │ │ ├── OneArrayOfOneXmlsDefaultValueTurtle.java │ │ │ │ │ └── NullableArrayOfOneXmlsDefaultValueTurtle.java │ │ │ │ └── ocd │ │ │ │ └── test │ │ │ │ ├── Utils.java │ │ │ │ └── TypeFactory.java │ │ └── java │ │ │ └── com │ │ │ └── dslplatform │ │ │ ├── client │ │ │ ├── JsonStatic.java │ │ │ ├── DomainProxyTest.java │ │ │ ├── JacksonTest.java │ │ │ ├── MapServiceLocatorTest.java │ │ │ ├── TestLogging.java │ │ │ ├── BootstrapTest.java │ │ │ └── S3Test.java │ │ │ └── json │ │ │ └── TreePathConverterTest.java │ └── main │ │ ├── resources │ │ └── com │ │ │ └── dslplatform │ │ │ └── client │ │ │ └── dsl-client.properties │ │ └── java │ │ └── com │ │ └── dslplatform │ │ ├── client │ │ ├── HttpHeaderProvider.java │ │ ├── exceptions │ │ │ ├── HttpServerErrorException.java │ │ │ ├── HttpSecurityException.java │ │ │ ├── HttpException.java │ │ │ └── HttpUnexpectedCodeException.java │ │ ├── HttpApplicationProxy.java │ │ ├── ClientDomainEventStore.java │ │ ├── SettingsHeaderProvider.java │ │ ├── ClientRepository.java │ │ ├── ClientTemplaterService.java │ │ ├── HttpCrudProxy.java │ │ ├── MapServiceLocator.java │ │ └── TreePath.java │ │ └── json │ │ └── TreePathConverter.java └── test-lib │ └── java-client.jar ├── .gitignore ├── interface └── src │ └── main │ └── java │ └── com │ └── dslplatform │ ├── patterns │ ├── EitherCallback.java │ ├── Searchable.java │ ├── Identifiable.java │ ├── ServiceLocator.java │ ├── Either.java │ ├── AggregateRoot.java │ ├── Specification.java │ ├── AggregateDomainEvent.java │ ├── Report.java │ ├── DomainEvent.java │ ├── Repository.java │ ├── Snapshot.java │ ├── History.java │ ├── Bytes.java │ └── DomainEventStore.java │ ├── storage │ └── S3Repository.java │ └── client │ ├── ApplicationProxy.java │ ├── CrudProxy.java │ └── JsonSerialization.java ├── README.md └── LICENSE /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.12 2 | -------------------------------------------------------------------------------- /project/config/eclipse/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | *.sorted 3 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/singleNull.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/singleNull.xml.json: -------------------------------------------------------------------------------- 1 | {"singlenullelement":null} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/singleNull.xml.json.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/src/main/resources/com/dslplatform/client/dsl-client.properties: -------------------------------------------------------------------------------- 1 | version=1.5.0 2 | date=2016-12-07 -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/comments.json.xml.json: -------------------------------------------------------------------------------- 1 | {"root":{"#comment":[]}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/namespacedEmptyElement.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/namespacedEmptyElement.xml.json.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/textElement.xml.json: -------------------------------------------------------------------------------- 1 | {"TextElement":"some text & "} -------------------------------------------------------------------------------- /core/test-lib/java-client.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ngs-doo/dsl-client-java/HEAD/core/test-lib/java-client.jar -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/namespacedEmptyElement.xml.json: -------------------------------------------------------------------------------- 1 | {"ns3000:NamespacedElement":null} 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/attributedEmptyElement.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/attributedEmptyElement.xml.json.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/textElement.xml: -------------------------------------------------------------------------------- 1 | some text & <stuff> 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/attributedEmptyElement.xml.json: -------------------------------------------------------------------------------- 1 | {"AtributedElement":{"@foo":"bar","@qwe":"poi"}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/textElement.xml.json.xml: -------------------------------------------------------------------------------- 1 | some text & <stuff> -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/elementWithCdata.xml.json: -------------------------------------------------------------------------------- 1 | {"ElementWithCData":{"#cdata-section":""}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/elementWithCdata.xml: -------------------------------------------------------------------------------- 1 | ]]> 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/elementWithCdata.xml.json.xml: -------------------------------------------------------------------------------- 1 | ]]> -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .classpath 3 | .history 4 | .idea 5 | .idea_modules 6 | .project 7 | .settings 8 | .target 9 | 10 | target 11 | 12 | *.orig 13 | *~ 14 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/EitherCallback.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | public interface EitherCallback { 4 | void onCompleted(Either result); 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/source/cdatatest.json: -------------------------------------------------------------------------------- 1 | {"root":{"#cdata-section":"\nfunction matchwo(a,b)\n{\nif (a < b && a < 0) then\n {\n return 1;\n }\nelse\n {\n return 0;\n }\n}\n"}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/cdatatest.xml.json: -------------------------------------------------------------------------------- 1 | {"root":{"#cdata-section":"\nfunction matchwo(a,b)\n{\nif (a < b && a < 0) then\n {\n return 1;\n }\nelse\n {\n return 0;\n }\n}\n"}} -------------------------------------------------------------------------------- /core/src/test/resources/projectprops/mockproject.properties: -------------------------------------------------------------------------------- 1 | username=user@domain.com 2 | project-id=0e13d168-1e2d-6ced-82f0-b9e693acde3e 3 | api-url=https://api_server/application_name/ 4 | package-name=com.example 5 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/cdatatest.json.xml.json: -------------------------------------------------------------------------------- 1 | {"root":{"#cdata-section":"\nfunction matchwo(a,b)\n{\nif (a < b && a < 0) then\n {\n return 1;\n }\nelse\n {\n return 0;\n }\n}\n"}} -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/StaticJson.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | public class StaticJson { 4 | public static JsonSerialization getSerialization() { 5 | return Utils.STATIC_JSON; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/cdatatest.json.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/comments.json.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/cdatatest.xml.json.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/HttpHeaderProvider.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public interface HttpHeaderProvider { 7 | public List> getHeaders(); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/cdatatest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/source/comments.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/reference/comments.json.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/reference/reference/comments.xml.json.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/source/comments.json: -------------------------------------------------------------------------------- 1 | { 2 | "root":{ 3 | "#comment":"Though specified in the documentation," 4 | , "#comment":"Comments are not implemented in Json.Net" 5 | , "#comment":"Instead they are serialized as JavaScript comments" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/projectprops/mocks3project.properties: -------------------------------------------------------------------------------- 1 | username=user@domain.com 2 | project-id=0e13d168-1e2d-6ced-82f0-b9e693acde3e 3 | api-url=https://api_server/application_name/ 4 | package-name=com.example 5 | s3-user=access key 6 | s3-secret=secret 7 | s3-bucket=bucket 8 | s3-region=eu-central-1 9 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/reference/comments.json.xml.json: -------------------------------------------------------------------------------- 1 | { 2 | "root":{ 3 | "#comment":"Though specified in the documentation," 4 | , "#comment":"Comments are not implemented in Json.Net" 5 | , "#comment":"Instead they are serialized as JavaScript comments" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/JsonStatic.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | public enum JsonStatic { 4 | INSTANCE; 5 | 6 | public final JacksonJsonSerialization jackson = new JacksonJsonSerialization(null); 7 | public final DslJsonSerialization manual = new DslJsonSerialization(null); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/reference/reference/comments.xml.json: -------------------------------------------------------------------------------- 1 | { 2 | "root":{ 3 | "#comment":"Though specified in the documentation," 4 | , "#comment":"Comments are not implemented in Json.Net" 5 | , "#comment":"Instead they are serialized as JavaScript comments" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /project/config/eclipse/dictionary.txt: -------------------------------------------------------------------------------- 1 | async 2 | deserialization 3 | deserialize 4 | deserialized 5 | int 6 | json 7 | metadata 8 | mime 9 | offload 10 | olap 11 | payload 12 | pdf 13 | persistable 14 | proxy 15 | roundtrip 16 | searchable 17 | snowflake 18 | sourcing 19 | sql 20 | templater 21 | timestamp 22 | todo 23 | unapplied 24 | uri 25 | uris 26 | xml 27 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/README.md: -------------------------------------------------------------------------------- 1 | # Unsupported use cases: 2 | 3 | Use cases we currently do not support: 4 | - multiple key:value pairs with equal key values 5 | - Xml comments 6 | - serializing #cdata-section and #text nodes as Json arrays (currently they are merged) 7 | - Xml prologs and processing instructions 8 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "2.10.6" 2 | scalacOptions ++= Seq("feature", "-language:_") 3 | 4 | libraryDependencies ++= Seq( 5 | "joda-time" % "joda-time" % "2.9.4" 6 | , "org.joda" % "joda-convert" % "1.2" 7 | ) 8 | 9 | addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0") 10 | addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") 11 | -------------------------------------------------------------------------------- /core/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | [%4p] [%d{HH:mm:ss}] %c{36}: %m%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/generate_reference_conversions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Convert source XMLs to JSON, and vice versa - conversion scripts xml2json and json2xml need to be on the path 3 | cd source 4 | for f in *.xml 5 | do 6 | xml2json $f > ../reference/$f.json 7 | done 8 | cd ../reference 9 | # Convert resulting JSONs to XML again 10 | for g in *.json 11 | do 12 | json2xml $g > $g.xml 13 | done 14 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/generate_reference_conversions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Convert source XMLs to JSON, and vice versa - conversion scripts xml2json and json2xml need to be on the path 3 | cd source 4 | for f in *.json 5 | do 6 | json2xml $f > ../reference/$f.xml 7 | done 8 | cd ../reference 9 | # Convert resulting JSONs to XML again 10 | for g in *.xml 11 | do 12 | xml2json $g > $g.json 13 | done 14 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/README.md: -------------------------------------------------------------------------------- 1 | # Round trip tests xml->json and vice versa. 2 | 3 | 4 | ## Directories: 5 | 6 | - json - json source and reference files 7 | - source - source json files 8 | - reference - reference files converted using Json.Net 9 | - xml - xml source and reference files 10 | - source - source XML files 11 | - reference - reference files converted using Json.Net 12 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/reference/README.md: -------------------------------------------------------------------------------- 1 | # Round trip tests xml->json and vice versa. 2 | 3 | 4 | ## Directories: 5 | 6 | - json - json source and reference files 7 | - source - source json files 8 | - reference - reference files converted using Json.Net 9 | - xml - xml source and reference files 10 | - source - source XML files 11 | - reference - reference files converted using Json.Net 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/exceptions/HttpServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.exceptions; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public class HttpServerErrorException extends HttpException { 7 | public HttpServerErrorException(final String response, final int receivedCode, final Map> headers) { 8 | super(response, receivedCode, headers); 9 | } 10 | 11 | private static final long serialVersionUID = 0x0097000a; 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/mixed.json.xml.json: -------------------------------------------------------------------------------- 1 | {"root":{"array":["a","b","c","d"],"#text":["some text","some text1some text2","some text3"],"#cdata-section":["some CDATA","some CDATA"],"a":["a0","a1","a2"],"object":{"array":["a","b","c","d","a","b","c","d","a","b","c","#text"],"object":{"array":["a","b","c","d","a","b","c","d","a","b","c","#text"],"#text":["some text","some textsome text"],"#cdata-section":"some CDATA"},"#text":["some text","some textsome text"],"#cdata-section":"some CDATA"}}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/reference/mixed.json.xml.json: -------------------------------------------------------------------------------- 1 | {"root":{"array":["a","b","c","d"],"#text":["some text","some text1some text2","some text3"],"#cdata-section":["some CDATA","some CDATA"],"a":["a0","a1","a2"],"object":{"array":["a","b","c","d","a","b","c","d","a","b","c","#text"],"object":{"array":["a","b","c","d","a","b","c","d","a","b","c","#text"],"#text":["some text","some textsome text"],"#cdata-section":"some CDATA"},"#text":["some text","some textsome text"],"#cdata-section":"some CDATA"}}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/reference/reference/mixed.xml.json: -------------------------------------------------------------------------------- 1 | {"root":{"array":["a","b","c","d"],"#text":["some text","some text1some text2","some text3"],"#cdata-section":["some CDATA","some CDATA"],"a":["a0","a1","a2"],"object":{"array":["a","b","c","d","a","b","c","d","a","b","c","#text"],"object":{"array":["a","b","c","d","a","b","c","d","a","b","c","#text"],"#text":["some text","some textsome text"],"#cdata-section":"some CDATA"},"#text":["some text","some textsome text"],"#cdata-section":"some CDATA"}}} -------------------------------------------------------------------------------- /project/Developers.scala: -------------------------------------------------------------------------------- 1 | object Developers { 2 | lazy val members = Map( 3 | "hperadin" -> "Hrvoje Peradin" 4 | , "rinmalavi" -> "Marin Vila" 5 | , "melezov" -> "Marko Elezović" 6 | , "zapov" -> "Rikard Pavelić" 7 | ) 8 | 9 | def toXml = 10 | 11 | {members map { case (nick, name) => 12 | 13 | { nick } 14 | { name } 15 | https://github.com/{ nick } 16 | 17 | }} 18 | 19 | } 20 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Searchable.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * Domain object that can be queried from the remote server. 5 | * Server supports custom objects, such as SQL and LINQ objects 6 | * which are not entities, but can be searched using specifications 7 | * and other methods 8 | *

9 | * DSL example: 10 | *

11 |  * module Legacy {
12 |  *   sql Town 'SELECT id, name FROM town' {
13 |  *     int id;
14 |  *     String name;
15 |  *   }
16 |  * }
17 |  * 
18 | */ 19 | public interface Searchable {} 20 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Identifiable.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * A domain object is uniquely represented by its URI. 5 | * Entity and snowflake are example of domain objects which are 6 | * identified by their identity, instead of their attributes. 7 | * While entity does not implement {@link Identifiable}, an aggregate root does. 8 | */ 9 | public interface Identifiable extends Searchable { 10 | /** 11 | * Domain object identity. 12 | * This identity can be used to lookup a domain object. 13 | * 14 | * @return domain object identity 15 | */ 16 | public String getURI(); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/ocd/test/Utils.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.ocd.test; 2 | 3 | import org.w3c.dom.Element; 4 | 5 | public abstract class Utils { 6 | public static Element stringToElement(final String element) { 7 | try { 8 | return XMLConverter.INSTANCE.stringToDocument(element).getDocumentElement(); 9 | } catch (final Exception e) { 10 | throw new RuntimeException(e); 11 | } 12 | } 13 | 14 | public static String elementToString(final Element element) { 15 | try { 16 | return XMLConverter.INSTANCE.nodeToString(element); 17 | } catch (final Exception e) { 18 | throw new RuntimeException(e); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/source/purchaseOrderInstance.json: -------------------------------------------------------------------------------- 1 | {"purchaseOrder":{"@xmlns":"http://tempuri.org/po.xsd","@orderDate":"1999-10-20","shipTo":{"@country":"US","name":"Alice Smith","street":"123 Maple Street","city":"Mill Valley","state":"CA","zip":"90952"},"billTo":{"@country":"US","name":"Robert Smith","street":"8 Oak Avenue","city":"Old Town","state":"PA","zip":"95819"},"comment":"Hurry, my lawn is going wild!","items":{"item":[{"@partNum":"872-AA","productName":"Lawnmower","quantity":"1","USPrice":"148.95","comment":"Confirm this is electric"},{"@partNum":"926-AA","productName":"Baby Monitor","quantity":"1","USPrice":"39.98","shipDate":"1999-05-21"}]}}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/purchaseOrderInstance.xml.json: -------------------------------------------------------------------------------- 1 | {"purchaseOrder":{"@xmlns":"http://tempuri.org/po.xsd","@orderDate":"1999-10-20","shipTo":{"@country":"US","name":"Alice Smith","street":"123 Maple Street","city":"Mill Valley","state":"CA","zip":"90952"},"billTo":{"@country":"US","name":"Robert Smith","street":"8 Oak Avenue","city":"Old Town","state":"PA","zip":"95819"},"comment":"Hurry, my lawn is going wild!","items":{"item":[{"@partNum":"872-AA","productName":"Lawnmower","quantity":"1","USPrice":"148.95","comment":"Confirm this is electric"},{"@partNum":"926-AA","productName":"Baby Monitor","quantity":"1","USPrice":"39.98","shipDate":"1999-05-21"}]}}} -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/exceptions/HttpSecurityException.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.exceptions; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public class HttpSecurityException extends HttpException { 7 | private final int receivedCode; 8 | 9 | public HttpSecurityException(final String response, final int receivedCode, final Map> headers) { 10 | super(response, receivedCode, headers); 11 | 12 | this.receivedCode = receivedCode; 13 | } 14 | 15 | @Override 16 | public int getReceivedCode() { 17 | return receivedCode; 18 | } 19 | 20 | private static final long serialVersionUID = 0x0097000a; 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/purchaseOrderInstance.json.xml.json: -------------------------------------------------------------------------------- 1 | {"purchaseOrder":{"@xmlns":"http://tempuri.org/po.xsd","@orderDate":"1999-10-20","shipTo":{"@country":"US","name":"Alice Smith","street":"123 Maple Street","city":"Mill Valley","state":"CA","zip":"90952"},"billTo":{"@country":"US","name":"Robert Smith","street":"8 Oak Avenue","city":"Old Town","state":"PA","zip":"95819"},"comment":"Hurry, my lawn is going wild!","items":{"item":[{"@partNum":"872-AA","productName":"Lawnmower","quantity":"1","USPrice":"148.95","comment":"Confirm this is electric"},{"@partNum":"926-AA","productName":"Baby Monitor","quantity":"1","USPrice":"39.98","shipDate":"1999-05-21"}]}}} -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/DomainProxyTest.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import org.junit.Test; 4 | 5 | import com.dslplatform.patterns.AggregateRoot; 6 | import com.dslplatform.patterns.ServiceLocator; 7 | import com.dslplatform.patterns.Specification; 8 | 9 | public class DomainProxyTest { 10 | @Test(expected = java.lang.IllegalArgumentException.class) 11 | public void withNullSpecification() throws Exception { 12 | final ServiceLocator locator = Bootstrap.init(getClass().getResourceAsStream("/projectprops/mockproject.properties")); 13 | final DomainProxy dp = locator.resolve(DomainProxy.class); 14 | dp.search((Specification) null); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/ocd/test/TypeFactory.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.ocd.test; 2 | 3 | import java.net.InetAddress; 4 | import java.net.URI; 5 | import java.net.URISyntaxException; 6 | import java.net.UnknownHostException; 7 | 8 | public abstract class TypeFactory { 9 | public static URI buildURI(final String uri) { 10 | try { 11 | return new URI(uri); 12 | } catch (final URISyntaxException e) { 13 | throw new RuntimeException(e); 14 | } 15 | } 16 | 17 | public static InetAddress buildIP(final String ip) { 18 | try { 19 | return InetAddress.getByName(ip); 20 | } catch (final UnknownHostException e) { 21 | throw new RuntimeException(e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/ServiceLocator.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * Service for resolving other services. 5 | * One locator per project should be used. 6 | *

7 | * When multiple projects are used, locator must be passed around 8 | * to resolve appropriate service. 9 | *

10 | * Custom classes can be resolved if their dependencies can be satisfied. 11 | */ 12 | public interface ServiceLocator { 13 | /** 14 | * Resolve a service registered in the locator. 15 | * 16 | * @param type to be located 17 | * @param clazz class or interface 18 | * @return registered implementation 19 | */ 20 | public T resolve(Class clazz); 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/mixed.json.xml: -------------------------------------------------------------------------------- 1 | abcdsome textsome text1some text2a0some text3a1a2abcdabcdabc#textabcdabcdabc#textsome textsome textsome textsome textsome textsome text -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/source/mixed.xml: -------------------------------------------------------------------------------- 1 | abcdsome textsome text1some text2a0some text3a1a2abcdabcdabc#textabcdabcdabc#textsome textsome textsome textsome textsome textsome text -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/reference/mixed.json.xml: -------------------------------------------------------------------------------- 1 | abcdsome textsome text1some text2a0some text3a1a2abcdabcdabc#textabcdabcdabc#textsome textsome textsome textsome textsome textsome text -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/unsupported_use_cases/reference/reference/mixed.xml.json.xml: -------------------------------------------------------------------------------- 1 | abcdsome textsome text1some text2some text3a0a1a2abcdabcdabc#textabcdabcdabc#textsome textsome textsome textsome textsome textsome text -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/purchaseOrderInstance.json.xml: -------------------------------------------------------------------------------- 1 | Alice Smith123 Maple StreetMill ValleyCA90952Robert Smith8 Oak AvenueOld TownPA95819Hurry, my lawn is going wild!Lawnmower1148.95Confirm this is electricBaby Monitor139.981999-05-21 -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/purchaseOrderInstance.xml.json.xml: -------------------------------------------------------------------------------- 1 | Alice Smith123 Maple StreetMill ValleyCA90952Robert Smith8 Oak AvenueOld TownPA95819Hurry, my lawn is going wild!Lawnmower1148.95Confirm this is electricBaby Monitor139.981999-05-21 -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/exceptions/HttpException.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.exceptions; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class HttpException extends IOException { 8 | private final int receivedCode; 9 | private final Map> headers; 10 | 11 | public HttpException(final String response, final int receivedCode, final Map> headers) { 12 | super(response); 13 | 14 | this.receivedCode = receivedCode; 15 | this.headers = headers; 16 | } 17 | 18 | public int getReceivedCode() { 19 | return receivedCode; 20 | } 21 | public Map> getHeaders() { 22 | return headers; 23 | } 24 | 25 | private static final long serialVersionUID = 0x0097000a; 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/unsupported_use_cases/source/mixed.json: -------------------------------------------------------------------------------- 1 | { 2 | "root":{ 3 | "array":["a","b","c","d"] 4 | , "#text":"some text" 5 | , "#cdata-section":"some CDATA" 6 | , "#text":"some text1" 7 | , "#text":"some text2" 8 | , "a":"a0" 9 | , "#cdata-section":"some CDATA" 10 | , "#text":"some text3" 11 | , "a":"a1" 12 | , "a":"a2" 13 | , "object":{ 14 | "array":["a","b","c","d"] 15 | ,"array":["a","b","c","d"] 16 | ,"array":["a","b","c","#text"] 17 | , "object":{ 18 | "array":["a","b","c","d"] 19 | ,"array":["a","b","c","d"] 20 | ,"array":["a","b","c","#text"] 21 | , "#text":"some text" 22 | , "#cdata-section":"some CDATA" 23 | , "#text":"some text" 24 | , "#text":"some text" 25 | } , "#text":"some text" 26 | , "#cdata-section":"some CDATA" 27 | , "#text":"some text" 28 | , "#text":"some text" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/exceptions/HttpUnexpectedCodeException.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.exceptions; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class HttpUnexpectedCodeException extends HttpException { 8 | private final List expectedCode = new ArrayList(2); 9 | 10 | public HttpUnexpectedCodeException( 11 | final String response, 12 | final int[] expectedCode, 13 | final int receivedCode, 14 | final Map> headers) { 15 | super(response, receivedCode, headers); 16 | 17 | if (expectedCode != null) { 18 | for (final int ec : expectedCode) { 19 | this.expectedCode.add(ec); 20 | } 21 | } 22 | } 23 | 24 | public List getExpectedCode() { 25 | return expectedCode; 26 | } 27 | 28 | private static final long serialVersionUID = 0x0097000a; 29 | } 30 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Either.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | public class Either { 4 | private final T value; 5 | private final Throwable error; 6 | 7 | private Either(final T value, final Throwable error) { 8 | this.value = value; 9 | this.error = error; 10 | } 11 | 12 | public boolean isSuccess() { return error == null; } 13 | public T get() { return value; } 14 | public Throwable whyNot() { return error; } 15 | public String explainError() { return error.getMessage(); } 16 | 17 | public static Either success(final T value) { 18 | return new Either(value, null); 19 | } 20 | 21 | public static Either fail(final Throwable error) { 22 | return new Either(null, error != null ? error : new Throwable()); 23 | } 24 | 25 | public static Either fail(final String error) { 26 | return new Either(null, new Throwable(error != null ? error : "")); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/AggregateRoot.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * Aggregate root is a meaningful object in the domain. 5 | * It can be viewed as a write boundary for entities and value objects 6 | * that will maintain write consistency. 7 | *

8 | * Usually it represents a single table, but can span several tables 9 | * and can be used like a document or a similar data structure. 10 | * Since every aggregate is also an entity, it has a unique identification 11 | * represented by its URI. 12 | *

13 | * DSL example: 14 | *

15 |  * module Todo {
16 |  *   aggregate Task {
17 |  *     Timestamp startedAt;
18 |  *     Timestamp? finishedAt;
19 |  *     Int? priority;
20 |  *     List<Note> notes;
21 |  *   }
22 |  *   value Note {
23 |  *     Date entered;
24 |  *     String remark;
25 |  *   }
26 |  * }
27 |  * 
28 | */ 29 | public interface AggregateRoot extends Identifiable {} 30 | -------------------------------------------------------------------------------- /project/J2SEVersionCheck.scala: -------------------------------------------------------------------------------- 1 | case class J2SEVersion(majorVersion: Int, minorVersion: Int) 2 | 3 | object J2SEVersion { 4 | val `5` = J2SEVersion(49, 0) 5 | val `6` = J2SEVersion(50, 0) 6 | val `7` = J2SEVersion(51, 0) 7 | val `8` = J2SEVersion(52, 0) 8 | } 9 | 10 | object J2SEVersionCheck { 11 | def apply(bytecode: Array[Byte], versionCheck: J2SEVersion => Boolean) = 12 | new J2SEVersionCheck(bytecode).checkVersion(versionCheck) 13 | } 14 | 15 | private class J2SEVersionCheck(bytecode: Array[Byte]) 16 | extends BytecodePickler(bytecode) { 17 | 18 | def checkVersion(versionCheck: J2SEVersion => Boolean): Unit = { 19 | reset() 20 | require(u4() == 0xcafebabe, "Invalid header encountered!") 21 | 22 | val minorVersion = u2() 23 | val majorVersion = u2() 24 | 25 | val j2seVersion = new J2SEVersion(majorVersion, minorVersion) 26 | 27 | if (!versionCheck(j2seVersion)) { 28 | sys.error(s"""J2SE version check failed (got ${j2seVersion.majorVersion}.${j2seVersion.minorVersion})""") 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Specification.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * Search predicate which can be used to filter domain objects from the remote 5 | * server using {@link SearchableRepository searchable repository}. 6 | *

7 | * Specification is defined in DSL with keyword {@code specification} 8 | * and a predicate. 9 | * Server can convert specification to SQL query on the fly or call 10 | * database function created at compile time. Other optimization techniques 11 | * can be used too. 12 | *

13 | * DSL example: 14 | *

15 |  * module Todo {
16 |  *   aggregate Task {
17 |  *       Timestamp createdOn;
18 |  *       specification findBetween
19 |  *           'it => it.createdOn >= after && it.createdOn <= before' {
20 |  *         Date after;
21 |  *         Date before;
22 |  *       }
23 |  * }
24 |  * 
25 | * 26 | * @param domain object on which search will be performed 27 | */ 28 | public interface Specification {} 29 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/source/samlRequest.json: -------------------------------------------------------------------------------- 1 | {"samlp:AuthnRequest":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@ID":"_bec424fa5103428909a30ff1e31168327f79474984","@Version":"2.0","@IssueInstant":"2007-12-10T11:39:34Z","@ForceAuthn":"false","@IsPassive":"false","@ProtocolBinding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@AssertionConsumerServiceURL":"http://moodle.bridge.feide.no/simplesaml/saml2/sp/AssertionConsumerService.php","saml:Issuer":{"@xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","#text":"\n urn:mace:feide.no:services:no.feide.moodle\n "},"samlp:NameIDPolicy":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@Format":"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent","@SPNameQualifier":"moodle.bridge.feide.no","@AllowCreate":"true"},"samlp:RequestedAuthnContext":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@Comparison":"exact","saml:AuthnContextClassRef":{"@xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","#text":"\n urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport\n "}}}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/samlRequest.xml.json: -------------------------------------------------------------------------------- 1 | {"samlp:AuthnRequest":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@ID":"_bec424fa5103428909a30ff1e31168327f79474984","@Version":"2.0","@IssueInstant":"2007-12-10T11:39:34Z","@ForceAuthn":"false","@IsPassive":"false","@ProtocolBinding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@AssertionConsumerServiceURL":"http://moodle.bridge.feide.no/simplesaml/saml2/sp/AssertionConsumerService.php","saml:Issuer":{"@xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","#text":"\n urn:mace:feide.no:services:no.feide.moodle\n "},"samlp:NameIDPolicy":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@Format":"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent","@SPNameQualifier":"moodle.bridge.feide.no","@AllowCreate":"true"},"samlp:RequestedAuthnContext":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@Comparison":"exact","saml:AuthnContextClassRef":{"@xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","#text":"\n urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport\n "}}}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/samlRequest.json.xml.json: -------------------------------------------------------------------------------- 1 | {"samlp:AuthnRequest":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@ID":"_bec424fa5103428909a30ff1e31168327f79474984","@Version":"2.0","@IssueInstant":"2007-12-10T11:39:34Z","@ForceAuthn":"false","@IsPassive":"false","@ProtocolBinding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@AssertionConsumerServiceURL":"http://moodle.bridge.feide.no/simplesaml/saml2/sp/AssertionConsumerService.php","saml:Issuer":{"@xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","#text":"\n urn:mace:feide.no:services:no.feide.moodle\n "},"samlp:NameIDPolicy":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@Format":"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent","@SPNameQualifier":"moodle.bridge.feide.no","@AllowCreate":"true"},"samlp:RequestedAuthnContext":{"@xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@Comparison":"exact","saml:AuthnContextClassRef":{"@xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","#text":"\n urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport\n "}}}} -------------------------------------------------------------------------------- /project/config/eclipse/sort-settings.bat: -------------------------------------------------------------------------------- 1 | ::#! 2 | @echo off 3 | 4 | for %%a in (*.xml, *.ini, *.txt) do ( 5 | call scala -nocompdaemon -savecompiled "%~f0" "%%~fa" > "%%~fa.sorted" 6 | ) 7 | 8 | goto :EOF 9 | ::!# 10 | 11 | val filename = args.head 12 | val lines = scala.io.Source.fromFile(filename).getLines.toIndexedSeq 13 | 14 | val sorted = 15 | if (filename endsWith ".xml") { 16 | val marker = (_: String) startsWith " !marker(ev) 18 | 19 | val head = lines takeWhile marker_! 20 | val (body, tail) = (lines dropWhile marker_!) partition marker 21 | 22 | head ++ body.sortBy(identity) ++ tail 23 | } 24 | else if (filename endsWith ".ini") { 25 | val marker = (_: String) startsWith "#" 26 | 27 | val (head, body) = lines partition marker 28 | 29 | head ++ body.sortBy(identity) 30 | } 31 | else if (filename endsWith ".txt") { 32 | lines.sortBy(identity) 33 | } 34 | else { 35 | IndexedSeq.empty 36 | } 37 | 38 | print(sorted mkString("", "\n", "\n")) 39 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/JacksonTest.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import org.joda.time.DateTime; 4 | import org.junit.Test; 5 | 6 | import java.io.IOException; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | import static org.junit.Assert.assertTrue; 10 | 11 | public class JacksonTest { 12 | @Test 13 | public void customType() throws IOException { 14 | final JsonSerialization json = new JacksonJsonSerialization(null); 15 | DateTime now1 = DateTime.now(); 16 | byte[] res = json.serialize(now1).toByteArray(); 17 | DateTime now2 = json.deserialize(DateTime.class, res, res.length); 18 | assertEquals(now1.toDate().getTime(), now2.toDate().getTime()); 19 | } 20 | 21 | static class NoEmpty { 22 | public final int i; 23 | public NoEmpty(int i) { 24 | this.i = i; 25 | } 26 | } 27 | 28 | @Test 29 | public void nonDefaultCtor() throws IOException { 30 | final JsonSerialization json = new JacksonJsonSerialization(null); 31 | String res = json.serialize(new NoEmpty(556)).toUtf8(); 32 | assertTrue(res.contains("556")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DSL client - Java 2 | 3 | ## Introduction 4 | 5 | DSL client is a set of core Java files used as compile target for [DSL Platform] [1]. 6 | 7 | If you are new to the DSL Platform, take a look at [introduction] [3] and check out [the tutorials] [4]. 8 | You can even [try it online] [5] (but not in Java). 9 | 10 | ## Why? 11 | 12 | DSL client is compatible with [Revenj] [6] REST API. This means it can be used as Java/Android library for interaction with Revenj. 13 | 14 | DSL client can also be used as fastest [JSON serializer] [7] for JVM. 15 | 16 | ## Documentation 17 | 18 | List of documentation resources: 19 | 20 | - [Learn DSL online][5] 21 | - [Domain-Driven Design introduction][2] 22 | - [Java introduction][3] 23 | - [Tutorial][4] 24 | 25 | [1]: https://dsl-platform.com 26 | [2]: https://docs.dsl-platform.com/ddd-foundations 27 | [3]: https://docs.dsl-platform.com/java-introduction 28 | [4]: https://docs.dsl-platform.com/java-beginners-tutorial 29 | [5]: https://learn.dsl-platform.com 30 | [6]: https://github.com/ngs-doo/revenj 31 | [7]: https://github.com/ngs-doo/json-benchmark 32 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/samlRequest.json.xml: -------------------------------------------------------------------------------- 1 | 2 | urn:mace:feide.no:services:no.feide.moodle 3 | 4 | urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport 5 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/samlRequest.xml.json.xml: -------------------------------------------------------------------------------- 1 | 2 | urn:mace:feide.no:services:no.feide.moodle 3 | 4 | urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport 5 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/HttpApplicationProxy.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | class HttpApplicationProxy implements ApplicationProxy { 6 | private final static String APPLICATION_URI = "RestApplication.svc/"; 7 | 8 | private final HttpClient client; 9 | 10 | public HttpApplicationProxy(final HttpClient client) { 11 | this.client = client; 12 | } 13 | 14 | @Override 15 | public Future get( 16 | final Class manifest, 17 | final String command, 18 | final int[] expectedStatus) { 19 | return client.sendRequest( 20 | manifest, 21 | APPLICATION_URI + command, 22 | "GET", 23 | null, 24 | expectedStatus); 25 | } 26 | 27 | @Override 28 | public Future post( 29 | final Class manifest, 30 | final String command, 31 | final TArgument argument, 32 | final int[] expectedStatus) { 33 | return client.sendRequest( 34 | manifest, 35 | APPLICATION_URI + command, 36 | "POST", 37 | argument, 38 | expectedStatus); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/AggregateDomainEvent.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * {@link DomainEvent Domain event} which should be used when there is an action 5 | * to be applied on a single {@link AggregateRoot aggregate root}. 6 | *

7 | * When a {@link DomainEvent domain event} affects only a single aggregate, 8 | * a specialized aggregate domain event can be used. 9 | * This event can't have side effects outside the aggregate, which allows it to 10 | * be replayed when it's asynchronous. 11 | * This is useful in write-intensive scenarios to minimize write load in the 12 | * database, but will increase read load, because reading an aggregate will have 13 | * to read all its unapplied events and apply them during reconstruction. 14 | *

15 | * AggregateDomainEvent is defined in DSL with keyword {@code event}. 16 | *

17 |  * module Todo {
18 |  *   aggregate Task;
19 |  *   event<Task> MarkDone;
20 |  * }
21 |  * 
22 | * @param aggregate root type 23 | */ 24 | public interface AggregateDomainEvent extends Identifiable {} 25 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Report.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * Report object should be used for reducing round-trips from server. 5 | * When request from server should return multiple data sources 6 | * report concept with it's arguments and results is appropriate. 7 | *

8 | * DSL example: 9 | *

10 |  * module Web {
11 |  *   report GatherStartupPage {
12 |  *     int perPage;
13 |  *     int userID;
14 |  *     date after;
15 |  *     List<Question> popularQuestions 'it => it.date > after' limit perPage;
16 |  *     UserInfo userInfo 'it => it.id == userID';
17 |  *     List<Menu> menu 'it => it.active' order by index;
18 |  *     count<Question> totalQuestions;
19 |  *   }
20 |  *   aggregate Question {
21 |  *     date date;
22 |  *     string text;
23 |  *   }
24 |  *   aggregate UserInfo(id) {
25 |  *     int id;
26 |  *     string name;
27 |  *   }
28 |  *   SQL Menu 'SELECT name, active FROM StartupMenu' {
29 |  *       String name;
30 |  *       bool active;
31 |  *   }
32 |  * }
33 |  * 
34 | */ 35 | public interface Report {} 36 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/samlRequest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | urn:mace:feide.no:services:no.feide.moodle 4 | 5 | 6 | 7 | 8 | urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/MapServiceLocatorTest.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import static org.junit.Assert.assertSame; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.Executors; 9 | 10 | import org.junit.Test; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | public class MapServiceLocatorTest { 15 | @Test 16 | public void withDefaultLoggerAndEC() throws Exception { 17 | final Map, Object> initialComponents = new HashMap, Object>(); 18 | final ExecutorService executorService = Executors.newSingleThreadExecutor(); 19 | initialComponents.put(ExecutorService.class, executorService); 20 | final Logger logger = LoggerFactory.getLogger("test-logger"); 21 | initialComponents.put(Logger.class, logger); 22 | 23 | final MapServiceLocator mapServiceLocator = new MapServiceLocator(initialComponents); 24 | assertSame("Executor matches", executorService, mapServiceLocator.resolve(ExecutorService.class)); 25 | assertSame("Logger matches", logger, mapServiceLocator.resolve(Logger.class)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /project/BytecodePickler.scala: -------------------------------------------------------------------------------- 1 | 2 | class BytecodePickler(bytecode: Array[Byte]) { 3 | private var index = -1 4 | 5 | protected def reset(): Unit = { 6 | index = 0 7 | } 8 | 9 | protected def u1() = { 10 | val res = bytecode(index) & 0xff 11 | index = index + 1 12 | res 13 | } 14 | 15 | protected def u2() = { 16 | (u1() << 8) | u1() 17 | } 18 | 19 | protected def u4() = { 20 | (u2() << 16) | u2() 21 | } 22 | 23 | protected def u8() = { 24 | (u4().toLong << 16) | u4() 25 | } 26 | 27 | /** Returns number of tag indexes to skip */ 28 | protected def skipTag() = 29 | u1 match { 30 | case 1 => index += u2() + 2; 1 31 | 32 | case 3 33 | | 4 34 | | 9 35 | | 10 36 | | 11 37 | | 12 => index += 4; 1 38 | 39 | case 5 40 | | 6 => index += 8; 2 41 | 42 | case 7 43 | | 8 => index += 2; 1 44 | 45 | case tag => 46 | sys.error("Encountered unknown tag: " + tag) 47 | } 48 | 49 | protected def overwrite(value: Short): Unit = { 50 | bytecode(index -2) = (value >> 8).toByte 51 | bytecode(index -1) = value.toByte 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/TestLogging.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import com.dslplatform.client.xml.XMLHelpers; 4 | import org.w3c.dom.Document; 5 | 6 | public abstract class TestLogging { 7 | // private final Logger logger = LoggerFactory.getLogger(getClass().getSimpleName()); 8 | 9 | protected long now() { 10 | return System.currentTimeMillis(); 11 | } 12 | 13 | private void debugInner(final String message) { 14 | // logger.debug(message); 15 | // System.out.println(message); 16 | } 17 | 18 | private void infoInner(final String message) { 19 | // logger.info(message); 20 | System.out.println(message); 21 | } 22 | 23 | protected void debug(final String format, final Object... parts) { 24 | // if (logger.isDebugEnabled()) { 25 | debugInner(String.format(format, parts)); 26 | // } 27 | } 28 | 29 | protected void debug(final Document doc) { 30 | // if (logger.isInfoEnabled()) { 31 | debug(XMLHelpers.xmlDocumentToString(doc)); 32 | // } 33 | } 34 | 35 | protected void info(final String format, final Object... parts) { 36 | // if (logger.isInfoEnabled()) { 37 | infoInner(String.format(format, parts)); 38 | // } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/purchaseOrderInstance.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Alice Smith 4 | 123 Maple Street 5 | Mill Valley 6 | CA 7 | 90952 8 | 9 | 10 | Robert Smith 11 | 8 Oak Avenue 12 | Old Town 13 | PA 14 | 95819 15 | 16 | Hurry, my lawn is going wild! 17 | 18 | 19 | Lawnmower 20 | 1 21 | 148.95 22 | Confirm this is electric 23 | 24 | 25 | Baby Monitor 26 | 1 27 | 39.98 28 | 1999-05-21 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/DomainEvent.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | /** 4 | * Domain event represents an meaningful business event that occurred in the system. 5 | * It is a message that back-end system knows how to process and that will 6 | * change the state of the system. 7 | *

8 | * They are the preferred way of manipulating data instead of simple CUD 9 | * operations (create, update, delete). 10 | * Unlike the {@link AggregateDomainEvent aggregate domain event} which is tied 11 | * to a change in a single {@link AggregateRoot aggregate root}, domain event 12 | * should be used when an action will result in modifications to multiple 13 | * aggregates, an external call (like sending an email) or some other action. 14 | *

15 | * By default, events will be applied immediately. 16 | * If {@code async} is used, event will be stored immediately, but applied later. 17 | * 18 | * DomainEvent is defined in DSL with keyword {@code event}. 19 | * 20 | *

21 |  * module Todo {
22 |  *   aggregate Task;
23 |  *   event MarkDone {
24 |  *     Task task;
25 |  *   }
26 |  * }
27 |  * 
28 | */ 29 | public interface DomainEvent extends Identifiable {} 30 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Repository.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.Future; 5 | 6 | /** 7 | * Service for finding identifiable domain objects. 8 | * Finding domain objects using their URI identity is the fastest way 9 | * retrieve an object from the remote server. 10 | * 11 | * @param Identifiable domain object type 12 | */ 13 | public interface Repository extends SearchableRepository { 14 | /** 15 | * Returns a list of domain objects uniquely represented with their URIs. 16 | * Only found objects will be returned (list will be empty if no objects are found). 17 | * 18 | * @param uris sequence of unique identifiers 19 | * @return future to found domain objects 20 | */ 21 | public Future> find(Iterable uris); 22 | 23 | /** @see #find(Iterable) */ 24 | public Future> find(String[] uris); 25 | 26 | /** 27 | * Returns a domain object uniquely represented with its URI. 28 | * If object is not found, an exception will be thrown 29 | * 30 | * @param uri domain object identity 31 | * @return future to found domain object 32 | */ 33 | public Future find(String uri); 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/ClientDomainEventStore.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | import com.dslplatform.patterns.AggregateDomainEvent; 6 | import com.dslplatform.patterns.AggregateRoot; 7 | import com.dslplatform.patterns.DomainEvent; 8 | import com.dslplatform.patterns.DomainEventStore; 9 | 10 | class ClientDomainEventStore implements DomainEventStore { 11 | protected final DomainProxy domainProxy; 12 | 13 | public ClientDomainEventStore(final DomainProxy domainProxy) { 14 | this.domainProxy = domainProxy; 15 | } 16 | 17 | @Override 18 | public Future submit(final TEvent event) { 19 | return domainProxy.submit(event); 20 | } 21 | 22 | @Override 23 | public > Future submit( 24 | final TEvent event, 25 | final String uri) { 26 | return domainProxy.submit(event, uri); 27 | } 28 | 29 | @Override 30 | public > Future submit( 31 | final TEvent event, 32 | final TAggregate aggregate) { 33 | return submit(event, aggregate.getURI()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Snapshot.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | import org.joda.time.DateTime; 4 | 5 | /** 6 | * Snapshot of some past state of an {@link AggregateRoot aggregate root} 7 | * 8 | * @param type of aggregate root 9 | */ 10 | public class Snapshot { 11 | private final DateTime at; 12 | private final String action; 13 | private final T value; 14 | 15 | @SuppressWarnings("unused") 16 | private Snapshot() { 17 | this(null, null, null); 18 | } 19 | 20 | public Snapshot( 21 | final DateTime at, 22 | final String action, 23 | final T value) { 24 | this.at = at; 25 | this.action = action; 26 | this.value = value; 27 | } 28 | 29 | /** 30 | * Date and time when snapshot was created. 31 | * 32 | * @return DateTime of snapshot 33 | */ 34 | public DateTime getAt() { 35 | return at; 36 | } 37 | 38 | /** 39 | * Which action was performed (INSERT|UPDATE|DELETE) 40 | * 41 | * @return Action type 42 | */ 43 | public String getAction() { 44 | return action; 45 | } 46 | 47 | /** 48 | * Instance of an aggregate root at that time 49 | * 50 | * @return aggregate root snapshot 51 | */ 52 | public T getValue() { 53 | return value; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/hello.xml.json.xml: -------------------------------------------------------------------------------- 1 | WSDL File for HelloService -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/hello.xml.json: -------------------------------------------------------------------------------- 1 | {"definitions":{"@name":"HelloService","@targetNamespace":"http://www.examples.com/wsdl/HelloService.wsdl","@xmlns":"http://schemas.xmlsoap.org/wsdl/","@xmlns:soap":"http://schemas.xmlsoap.org/wsdl/soap/","@xmlns:tns":"http://www.examples.com/wsdl/HelloService.wsdl","@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","message":[{"@name":"SayHelloRequest","part":{"@name":"firstName","@type":"xsd:string"}},{"@name":"SayHelloResponse","part":{"@name":"greeting","@type":"xsd:string"}}],"portType":{"@name":"Hello_PortType","operation":{"@name":"sayHello","input":{"@message":"tns:SayHelloRequest"},"output":{"@message":"tns:SayHelloResponse"}}},"binding":{"@name":"Hello_Binding","@type":"tns:Hello_PortType","soap:binding":{"@style":"rpc","@transport":"http://schemas.xmlsoap.org/soap/http"},"operation":{"@name":"sayHello","soap:operation":{"@soapAction":"sayHello"},"input":{"soap:body":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","@namespace":"urn:examples:helloservice","@use":"encoded"}},"output":{"soap:body":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","@namespace":"urn:examples:helloservice","@use":"encoded"}}}},"service":{"@name":"Hello_Service","documentation":"WSDL File for HelloService","port":{"@binding":"tns:Hello_Binding","@name":"Hello_Port","soap:address":{"@location":"http://www.examples.com/SayHello/"}}}}} -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/History.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Aggregation of single {@link AggregateRoot aggregate root} snapshots. 7 | * If the history concept is enabled, a snapshot is created whenever an 8 | * aggregate root is created, modified or deleted. 9 | *

10 | * DSL example: 11 | *

12 |  * module Blog {
13 |  *   aggregate Post {
14 |  *     String content;
15 |  *     history;
16 |  *   }
17 |  * }
18 |  * 
19 | * 20 | * @param aggregate root type 21 | */ 22 | public final class History implements Identifiable { 23 | private final List> snapshots; 24 | 25 | @SuppressWarnings("unused") 26 | private History() { 27 | this.snapshots = null; 28 | } 29 | 30 | public History(final List> snapshots) { 31 | this.snapshots = snapshots; 32 | } 33 | 34 | /** 35 | * {@link AggregateRoot aggregate root} identity 36 | * 37 | * @return URI found in first snapshot 38 | */ 39 | @Override 40 | public String getURI() { 41 | return snapshots.get(0).getValue().getURI(); 42 | } 43 | 44 | /** 45 | * Sequence of persisted snapshots. 46 | * 47 | * @return list of snapshots captured for the provided {@link AggregateRoot aggregate root} 48 | */ 49 | public List> getSnapshots() { 50 | return snapshots; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/hello.json.xml: -------------------------------------------------------------------------------- 1 | text node in the middleWSDL File for HelloService -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/source/hello.json: -------------------------------------------------------------------------------- 1 | {"definitions":{"@name":"HelloService","@targetNamespace":"http://www.examples.com/wsdl/HelloService.wsdl","@xmlns":"http://schemas.xmlsoap.org/wsdl/","@xmlns:soap":"http://schemas.xmlsoap.org/wsdl/soap/","@xmlns:tns":"http://www.examples.com/wsdl/HelloService.wsdl","@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","message":[{"@name":"SayHelloRequest","part":{"@name":"firstName","@type":"xsd:string"}},{"@name":"SayHelloResponse","part":{"@name":"greeting","@type":"xsd:string"}}],"portType":{"@name":"Hello_PortType","operation":{"@name":"sayHello","input":{"@message":"tns:SayHelloRequest"},"output":{"@message":"tns:SayHelloResponse"}}},"binding":{"@name":"Hello_Binding","@type":"tns:Hello_PortType","soap:binding":{"@style":"rpc","@transport":"http://schemas.xmlsoap.org/soap/http"},"operation":{"@name":"sayHello","soap:operation":{"@soapAction":"sayHello"},"input":{"soap:body":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","@namespace":"urn:examples:helloservice","@use":"encoded"}},"#text":"text node in the middle", "#cdata-section":"cdata after text node","output":{"soap:body":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","@namespace":"urn:examples:helloservice","@use":"encoded"}}}},"service":{"@name":"Hello_Service","#cdata-section":"cdata in the middle","documentation":"WSDL File for HelloService","port":{"@binding":"tns:Hello_Binding","@name":"Hello_Port","soap:address":{"@location":"http://www.examples.com/SayHello/", "#cdata-section":"cdata somewha at the end"}}}}} 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/hello.json.xml.json: -------------------------------------------------------------------------------- 1 | {"definitions":{"@name":"HelloService","@targetNamespace":"http://www.examples.com/wsdl/HelloService.wsdl","@xmlns":"http://schemas.xmlsoap.org/wsdl/","@xmlns:soap":"http://schemas.xmlsoap.org/wsdl/soap/","@xmlns:tns":"http://www.examples.com/wsdl/HelloService.wsdl","@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","message":[{"@name":"SayHelloRequest","part":{"@name":"firstName","@type":"xsd:string"}},{"@name":"SayHelloResponse","part":{"@name":"greeting","@type":"xsd:string"}}],"portType":{"@name":"Hello_PortType","operation":{"@name":"sayHello","input":{"@message":"tns:SayHelloRequest"},"output":{"@message":"tns:SayHelloResponse"}}},"binding":{"@name":"Hello_Binding","@type":"tns:Hello_PortType","soap:binding":{"@style":"rpc","@transport":"http://schemas.xmlsoap.org/soap/http"},"operation":{"@name":"sayHello","soap:operation":{"@soapAction":"sayHello"},"input":{"soap:body":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","@namespace":"urn:examples:helloservice","@use":"encoded"}},"#text":"text node in the middle","#cdata-section":"cdata after text node","output":{"soap:body":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","@namespace":"urn:examples:helloservice","@use":"encoded"}}}},"service":{"@name":"Hello_Service","#cdata-section":"cdata in the middle","documentation":"WSDL File for HelloService","port":{"@binding":"tns:Hello_Binding","@name":"Hello_Port","soap:address":{"@location":"http://www.examples.com/SayHello/","#cdata-section":"cdata somewha at the end"}}}}} -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/storage/S3Repository.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.storage; 2 | 3 | import java.io.InputStream; 4 | import java.util.Map; 5 | import java.util.concurrent.Future; 6 | 7 | /** 8 | * S3 can be used to offload large binaries from the application server. 9 | * Bucket and key are saved in the application server. 10 | *

11 | * This service is used by S3 data type 12 | */ 13 | public interface S3Repository { 14 | /** 15 | * Load remote stream using bucket and key 16 | * 17 | * @param bucket bucket where stream is stored 18 | * @param key key in bucket for stream 19 | * @return future to stream 20 | */ 21 | Future get(String bucket, String key); 22 | 23 | /** 24 | * Upload stream defined by bucket and key. 25 | * Provide length of the stream and additional metadata. 26 | * 27 | * @param bucket bucket where stream will be stored 28 | * @param key key inside a bucket for stream 29 | * @param stream provided stream 30 | * @param length size of stream 31 | * @param metadata additional metadata 32 | * @return future for error checking 33 | */ 34 | Future upload( 35 | String bucket, 36 | String key, 37 | InputStream stream, 38 | long length, 39 | Map metadata); 40 | 41 | /** 42 | * Delete remote stream using bucket and key 43 | * 44 | * @param bucket bucket where stream is stored 45 | * @param key key in bucket for stream 46 | * @return future for error checking 47 | */ 48 | Future delete(String bucket, String key); 49 | } 50 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Boolean/OneBooleanDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Boolean; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneBooleanDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final boolean defaultValue = false; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final boolean defaultValueJsonDeserialized = jsonSerialization.deserialize(boolean.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final boolean borderValue1 = true; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final boolean borderValue1JsonDeserialized = jsonSerialization.deserialize(boolean.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Nova Generacija Softvera d.o.o. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of Nova Generacija Softvera d.o.o. nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/client/ApplicationProxy.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | /** 6 | * Proxy service to remote RPC-like API. 7 | *

8 | * Remote services can be called using their name. 9 | */ 10 | public interface ApplicationProxy { 11 | /** 12 | * When the remote service doesn't require any arguments it can be called 13 | * using the {@code get} method. The class needs to be provided for 14 | * deserialization. 15 | * 16 | * @param result type 17 | * @param manifest result class for deserialization 18 | * @param command remote service name 19 | * @param expectedStatus expected status from remote call 20 | * @return future with the deserialized result 21 | */ 22 | public Future get( 23 | Class manifest, 24 | String command, 25 | int[] expectedStatus); 26 | 27 | /** 28 | * When the remote service requires arguments a message with the serialized 29 | * payload will be sent. The class needs to be provided for deserialization. 30 | * 31 | * @param argument type 32 | * @param result type 33 | * @param manifest result class for deserialization 34 | * @param command remote service name 35 | * @param argument remote service argument 36 | * @param expectedStatus expected status from remote call 37 | * @return future with the deserialized result 38 | */ 39 | public Future post( 40 | Class manifest, 41 | String command, 42 | TArgument argument, 43 | int[] expectedStatus); 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/SettingsHeaderProvider.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.nio.charset.Charset; 4 | import java.util.AbstractMap; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.Properties; 9 | 10 | public class SettingsHeaderProvider implements HttpHeaderProvider { 11 | 12 | private final List> headers = new ArrayList>(); 13 | 14 | public SettingsHeaderProvider(final Properties properties) { 15 | final String basicAuth = properties.getProperty("basic-auth"); 16 | final String hashAuth = properties.getProperty("hash-auth"); 17 | final String authorization = properties.getProperty("authorization"); 18 | if (basicAuth != null) { 19 | headers.add(new AbstractMap.SimpleEntry("Authorization", "Basic " + basicAuth)); 20 | } else if (hashAuth != null) { 21 | headers.add(new AbstractMap.SimpleEntry("Authorization", "Hash " + hashAuth)); 22 | } else if (authorization != null) { 23 | headers.add(new AbstractMap.SimpleEntry("Authorization", authorization)); 24 | } else { 25 | final String username = properties.getProperty("username"); 26 | //TODO: remove this legacy 27 | final String password = properties.getProperty("project-id"); 28 | if (username != null && password != null) { 29 | final String authToken = Utils.base64Encode((username + ':' + password).getBytes(Charset.forName("UTF-8"))); 30 | headers.add(new AbstractMap.SimpleEntry("Authorization", "Basic " + authToken)); 31 | } 32 | } 33 | } 34 | 35 | @Override 36 | public List> getHeaders() { 37 | return headers; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/BootstrapTest.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertSame; 5 | 6 | import java.util.*; 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.Executors; 9 | 10 | import org.junit.Test; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | import com.dslplatform.patterns.ServiceLocator; 15 | 16 | public class BootstrapTest { 17 | 18 | @Test 19 | public void withDefaultLoggerAndEC() throws Exception { 20 | final ServiceLocator locator = Bootstrap.init(getClass().getResourceAsStream("/projectprops/mockproject.properties")); 21 | final Properties ps = locator.resolve(Properties.class); 22 | assertEquals("Project id matches", ps.getProperty("project-id"), "0e13d168-1e2d-6ced-82f0-b9e693acde3e"); 23 | } 24 | 25 | @Test 26 | public void withCustomLoggerAndEC() throws Exception { 27 | final String loggerName = "testLogger"; 28 | final Logger logger = LoggerFactory.getLogger(loggerName); 29 | final Map, Object> initialComponents = new HashMap, Object>(); 30 | final ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor(); 31 | initialComponents.put(ExecutorService.class, newSingleThreadExecutor); 32 | initialComponents.put(Logger.class, logger); 33 | 34 | final Properties p = new Properties(); 35 | p.load(getClass().getResourceAsStream("/projectprops/mockproject.properties")); 36 | final ServiceLocator locator = Bootstrap.init(p, initialComponents); 37 | 38 | assertSame("Logger instance matches.", locator.resolve(Logger.class), logger); 39 | assertSame("ExecutionService matches.", locator.resolve(ExecutorService.class), newSingleThreadExecutor); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/hello.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | WSDL File for HelloService 44 | 45 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/Bytes.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | import java.nio.charset.Charset; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Allow reuse of same byte[] by specifying custom length 10 | * Array is valid only up until specified length. 11 | */ 12 | public class Bytes { 13 | /** 14 | * Byte array which can be reused 15 | */ 16 | public final byte[] content; 17 | /** 18 | * Length which specifies valid data in array 19 | */ 20 | public final int length; 21 | 22 | /** 23 | * Create a new instance of Bytes object by providing used array and length which indicates end of valid data. 24 | * 25 | * @param content data 26 | * @param length actual length of array 27 | */ 28 | public Bytes(final byte[] content, final int length) { 29 | this.content = content; 30 | this.length = length; 31 | } 32 | 33 | /** 34 | * Helper object for providing zero length object (instead of null object) 35 | */ 36 | public static final Bytes EMPTY = new Bytes(new byte[0], 0); 37 | 38 | /** 39 | * Copy bytes to output stream. 40 | * 41 | * @param stream output stream 42 | * @throws IOException 43 | */ 44 | public void copyTo(final OutputStream stream) throws IOException { 45 | stream.write(content, 0, length); 46 | } 47 | 48 | private static final Charset utf8 = Charset.forName("UTF-8"); 49 | 50 | /** 51 | * Utility method for displaying byte[] as UTF-8 string. 52 | * 53 | * @return string value from UTF-8 charset 54 | */ 55 | public String toUtf8() { 56 | return new String(content, 0, length, utf8); 57 | } 58 | 59 | /** 60 | * Utility method for returning byte[] of the actual size. 61 | * 62 | * @return copy of original byte[] with expected length 63 | */ 64 | public byte[] toByteArray() { 65 | return Arrays.copyOf(content, length); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/source/purchaseOrder.json: -------------------------------------------------------------------------------- 1 | {"xs:schema":{"@xmlns:xs":"http://www.w3.org/2001/XMLSchema","@targetNamespace":"http://tempuri.org/po.xsd","@xmlns":"http://tempuri.org/po.xsd","@elementFormDefault":"qualified","xs:annotation":{"xs:documentation":{"@xml:lang":"en","#text":"\n Purchase order schema for Example.com.\n Copyright 2000 Example.com. All rights reserved.\n "}},"xs:element":[{"@name":"purchaseOrder","@type":"PurchaseOrderType"},{"@name":"comment","@type":"xs:string"}],"xs:complexType":[{"@name":"PurchaseOrderType","xs:sequence":{"xs:element":[{"@name":"shipTo","@type":"USAddress"},{"@name":"billTo","@type":"USAddress"},{"@ref":"comment","@minOccurs":"0"},{"@name":"items","@type":"Items"}]},"xs:attribute":{"@name":"orderDate","@type":"xs:date"}},{"@name":"USAddress","xs:annotation":{"xs:documentation":"\n Purchase order schema for Example.Microsoft.com.\n Copyright 2001 Example.Microsoft.com. All rights reserved.\n ","xs:appinfo":"\n Application info.\n "},"xs:sequence":{"xs:element":[{"@name":"name","@type":"xs:string"},{"@name":"street","@type":"xs:string"},{"@name":"city","@type":"xs:string"},{"@name":"state","@type":"xs:string"},{"@name":"zip","@type":"xs:decimal"}]},"xs:attribute":{"@name":"country","@type":"xs:NMTOKEN","@fixed":"US"}},{"@name":"Items","xs:sequence":{"xs:element":{"@name":"item","@minOccurs":"0","@maxOccurs":"unbounded","xs:complexType":{"xs:sequence":{"xs:element":[{"@name":"productName","@type":"xs:string"},{"@name":"quantity","xs:simpleType":{"xs:restriction":{"@base":"xs:positiveInteger","xs:maxExclusive":{"@value":"100"}}}},{"@name":"USPrice","@type":"xs:decimal"},{"@ref":"comment","@minOccurs":"0"},{"@name":"shipDate","@type":"xs:date","@minOccurs":"0"}]},"xs:attribute":{"@name":"partNum","@type":"SKU","@use":"required"}}}}}],"xs:simpleType":{"@name":"SKU","xs:restriction":{"@base":"xs:string","xs:pattern":{"@value":"\\d{3}-[A-Z]{2}"}}}}} 2 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/purchaseOrder.xml.json: -------------------------------------------------------------------------------- 1 | {"xs:schema":{"@xmlns:xs":"http://www.w3.org/2001/XMLSchema","@targetNamespace":"http://tempuri.org/po.xsd","@xmlns":"http://tempuri.org/po.xsd","@elementFormDefault":"qualified","xs:annotation":{"xs:documentation":{"@xml:lang":"en","#text":"\n Purchase order schema for Example.com.\n Copyright 2000 Example.com. All rights reserved.\n "}},"xs:element":[{"@name":"purchaseOrder","@type":"PurchaseOrderType"},{"@name":"comment","@type":"xs:string"}],"xs:complexType":[{"@name":"PurchaseOrderType","xs:sequence":{"xs:element":[{"@name":"shipTo","@type":"USAddress"},{"@name":"billTo","@type":"USAddress"},{"@ref":"comment","@minOccurs":"0"},{"@name":"items","@type":"Items"}]},"xs:attribute":{"@name":"orderDate","@type":"xs:date"}},{"@name":"USAddress","xs:annotation":{"xs:documentation":"\n Purchase order schema for Example.Microsoft.com.\n Copyright 2001 Example.Microsoft.com. All rights reserved.\n ","xs:appinfo":"\n Application info.\n "},"xs:sequence":{"xs:element":[{"@name":"name","@type":"xs:string"},{"@name":"street","@type":"xs:string"},{"@name":"city","@type":"xs:string"},{"@name":"state","@type":"xs:string"},{"@name":"zip","@type":"xs:decimal"}]},"xs:attribute":{"@name":"country","@type":"xs:NMTOKEN","@fixed":"US"}},{"@name":"Items","xs:sequence":{"xs:element":{"@name":"item","@minOccurs":"0","@maxOccurs":"unbounded","xs:complexType":{"xs:sequence":{"xs:element":[{"@name":"productName","@type":"xs:string"},{"@name":"quantity","xs:simpleType":{"xs:restriction":{"@base":"xs:positiveInteger","xs:maxExclusive":{"@value":"100"}}}},{"@name":"USPrice","@type":"xs:decimal"},{"@ref":"comment","@minOccurs":"0"},{"@name":"shipDate","@type":"xs:date","@minOccurs":"0"}]},"xs:attribute":{"@name":"partNum","@type":"SKU","@use":"required"}}}}}],"xs:simpleType":{"@name":"SKU","xs:restriction":{"@base":"xs:string","xs:pattern":{"@value":"\\d{3}-[A-Z]{2}"}}}}} -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/purchaseOrder.json.xml.json: -------------------------------------------------------------------------------- 1 | {"xs:schema":{"@xmlns:xs":"http://www.w3.org/2001/XMLSchema","@targetNamespace":"http://tempuri.org/po.xsd","@xmlns":"http://tempuri.org/po.xsd","@elementFormDefault":"qualified","xs:annotation":{"xs:documentation":{"@xml:lang":"en","#text":"\n Purchase order schema for Example.com.\n Copyright 2000 Example.com. All rights reserved.\n "}},"xs:element":[{"@name":"purchaseOrder","@type":"PurchaseOrderType"},{"@name":"comment","@type":"xs:string"}],"xs:complexType":[{"@name":"PurchaseOrderType","xs:sequence":{"xs:element":[{"@name":"shipTo","@type":"USAddress"},{"@name":"billTo","@type":"USAddress"},{"@ref":"comment","@minOccurs":"0"},{"@name":"items","@type":"Items"}]},"xs:attribute":{"@name":"orderDate","@type":"xs:date"}},{"@name":"USAddress","xs:annotation":{"xs:documentation":"\n Purchase order schema for Example.Microsoft.com.\n Copyright 2001 Example.Microsoft.com. All rights reserved.\n ","xs:appinfo":"\n Application info.\n "},"xs:sequence":{"xs:element":[{"@name":"name","@type":"xs:string"},{"@name":"street","@type":"xs:string"},{"@name":"city","@type":"xs:string"},{"@name":"state","@type":"xs:string"},{"@name":"zip","@type":"xs:decimal"}]},"xs:attribute":{"@name":"country","@type":"xs:NMTOKEN","@fixed":"US"}},{"@name":"Items","xs:sequence":{"xs:element":{"@name":"item","@minOccurs":"0","@maxOccurs":"unbounded","xs:complexType":{"xs:sequence":{"xs:element":[{"@name":"productName","@type":"xs:string"},{"@name":"quantity","xs:simpleType":{"xs:restriction":{"@base":"xs:positiveInteger","xs:maxExclusive":{"@value":"100"}}}},{"@name":"USPrice","@type":"xs:decimal"},{"@ref":"comment","@minOccurs":"0"},{"@name":"shipDate","@type":"xs:date","@minOccurs":"0"}]},"xs:attribute":{"@name":"partNum","@type":"SKU","@use":"required"}}}}}],"xs:simpleType":{"@name":"SKU","xs:restriction":{"@base":"xs:string","xs:pattern":{"@value":"\\d{3}-[A-Z]{2}"}}}}} -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/ClientRepository.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.concurrent.Future; 6 | 7 | import com.dslplatform.patterns.Identifiable; 8 | import com.dslplatform.patterns.Repository; 9 | import com.dslplatform.patterns.ServiceLocator; 10 | 11 | /** 12 | * Common base implementation for {@link Repository repository}. 13 | * It redirects calls to proxy services. 14 | * It shouldn't be used or resolved. 15 | * Instead domain model repositories should be resolved. 16 | *

17 | * DSL example: 18 | *

19 |  * module Todo {
20 |  *   aggregate Task;
21 |  *   snowflake<Task> TaskList;
22 |  * }
23 |  * 
24 | * Java usage: 25 | *
26 |  * ServiceLocator locator;
27 |  * Repository<Todo.TaskList> repository = locator.resolve(Todo.TaskListRepository.class);
28 |  * 
29 | * @param domain object type 30 | */ 31 | public abstract class ClientRepository 32 | extends ClientSearchableRepository 33 | implements Repository { 34 | protected final CrudProxy crudProxy; 35 | 36 | /** 37 | * Generated class will provide class manifest and locator 38 | * 39 | * @param manifest domain object type 40 | * @param locator context in which domain object lives 41 | */ 42 | public ClientRepository(final Class manifest, final ServiceLocator locator) { 43 | super(manifest, locator); 44 | crudProxy = locator.resolve(CrudProxy.class); 45 | } 46 | 47 | @Override 48 | public Future> find(final Iterable uris) { 49 | return domainProxy.find(manifest, uris); 50 | } 51 | 52 | @Override 53 | public Future> find(final String[] uris) { 54 | return find(Arrays.asList(uris)); 55 | } 56 | 57 | @Override 58 | public Future find(final String uri) { 59 | return crudProxy.read(manifest, uri); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Boolean/NullableBooleanDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Boolean; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableBooleanDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final Boolean defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final Boolean defaultValueJsonDeserialized = jsonSerialization.deserialize(Boolean.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final Boolean borderValue1 = false; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final Boolean borderValue1JsonDeserialized = jsonSerialization.deserialize(Boolean.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final Boolean borderValue2 = true; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final Boolean borderValue2JsonDeserialized = jsonSerialization.deserialize(Boolean.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/patterns/DomainEventStore.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.patterns; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | /** 6 | * Service for submitting domain events to the application server. 7 | *

8 | * It should be used when {@code Future} is the preferred way of interacting 9 | * with the remote server. 10 | */ 11 | public interface DomainEventStore { 12 | /** 13 | * Sends a domain event to the server. Server will return an identity under 14 | * which it was stored. Events can't be modified once they are submitted, 15 | * only new events can be created. 16 | * 17 | * @param domain event type 18 | * @param event event to raise 19 | * @return future with a string value of the event URI 20 | */ 21 | public Future submit(T event); 22 | 23 | /** 24 | * Applies a domain event to a single aggregate. Server will return the 25 | * modified aggregate root. Events can't be modified once they are submitted, only new events can be created. 26 | * 27 | * @param aggregate root type 28 | * @param aggregate domain event type 29 | * @param event event to apply 30 | * @param uri aggregate root uri 31 | * @return future with the modified aggregate root 32 | */ 33 | public > Future submit( 34 | TEvent event, 35 | String uri); 36 | 37 | /** 38 | * Helper method for sending domain event to the server. Server will return modified aggregate root. 39 | * Events can't be modified once they are submitted. Only new events can be created. 40 | * 41 | * @param aggregate root type 42 | * @param aggregate domain event type 43 | * @param event event to apply 44 | * @param aggregate aggregate root instance 45 | * @return future containing modified aggregate root 46 | */ 47 | public > Future submit( 48 | TEvent event, 49 | TAggregate aggregate); 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/json/reference/purchaseOrder.json.xml: -------------------------------------------------------------------------------- 1 | 2 | Purchase order schema for Example.com. 3 | Copyright 2000 Example.com. All rights reserved. 4 | 5 | Purchase order schema for Example.Microsoft.com. 6 | Copyright 2001 Example.Microsoft.com. All rights reserved. 7 | 8 | Application info. 9 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/reference/purchaseOrder.xml.json.xml: -------------------------------------------------------------------------------- 1 | 2 | Purchase order schema for Example.com. 3 | Copyright 2000 Example.com. All rights reserved. 4 | 5 | Purchase order schema for Example.Microsoft.com. 6 | Copyright 2001 Example.Microsoft.com. All rights reserved. 7 | 8 | Application info. 9 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/json/TreePathConverterTest.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.json; 2 | 3 | import com.dslplatform.client.TreePath; 4 | import org.junit.Assert; 5 | import org.junit.Rule; 6 | import org.junit.Test; 7 | import org.junit.rules.ExpectedException; 8 | 9 | import java.io.IOException; 10 | 11 | public class TreePathConverterTest { 12 | @Test 13 | public void testSerialization() throws IOException { 14 | final JsonWriter jw = new JsonWriter(null); 15 | 16 | final TreePath expectedPath = new TreePath("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); 17 | final String expectedJson = "\"" + expectedPath + "\""; 18 | 19 | TreePathConverter.serialize(expectedPath, jw); 20 | final String serializedJson = new String(jw.getByteBuffer(), 0, jw.size(), "UTF-8"); 21 | Assert.assertEquals(expectedJson, serializedJson); 22 | 23 | final JsonReader jr = new JsonReader(jw.getByteBuffer(), null); 24 | jr.getNextToken(); 25 | final TreePath deserializedPath = TreePathConverter.deserialize(jr); 26 | Assert.assertEquals(expectedPath, deserializedPath); 27 | } 28 | 29 | @Rule 30 | public ExpectedException thrown = ExpectedException.none(); 31 | 32 | @Test 33 | public void testDeserializationErrors() throws IOException { 34 | final String malformedTreePathJson = "\"opr.s\u0161t.uvz\""; 35 | final JsonReader jr = new JsonReader(malformedTreePathJson.getBytes("UTF-8"), null); 36 | jr.getNextToken(); 37 | thrown.expect(IllegalArgumentException.class); 38 | thrown.expectMessage("Invalid value for part: s\u0161t. Only [A-Za-z0-9] allowed for labels"); 39 | TreePathConverter.deserialize(jr); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/ClientTemplaterService.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | import com.dslplatform.patterns.Identifiable; 6 | import com.dslplatform.patterns.Searchable; 7 | import com.dslplatform.patterns.Specification; 8 | import com.dslplatform.patterns.TemplaterService; 9 | 10 | class ClientTemplaterService implements TemplaterService { 11 | protected final ReportingProxy proxy; 12 | 13 | public ClientTemplaterService(final ReportingProxy proxy) { 14 | this.proxy = proxy; 15 | } 16 | 17 | @Override 18 | public Future populate(final String file, final T aggregate) { 19 | if (aggregate == null) throw new IllegalArgumentException("aggregate can't be null"); 20 | return proxy.findTemplater(aggregate.getClass(), file, aggregate.getURI(), false); 21 | } 22 | 23 | @Override 24 | public Future populatePdf(final String file, final T aggregate) { 25 | if (aggregate == null) throw new IllegalArgumentException("aggregate can't be null"); 26 | return proxy.findTemplater(aggregate.getClass(), file, aggregate.getURI(), true); 27 | } 28 | 29 | @Override 30 | public Future populate(final Class manifest, final String file) { 31 | return proxy.searchTemplater(manifest, file, null, false); 32 | } 33 | 34 | @Override 35 | public Future populatePdf(final Class manifest, final String file) { 36 | return proxy.searchTemplater(manifest, file, null, true); 37 | } 38 | 39 | @Override 40 | public Future populate(final String file, final Specification specification) { 41 | if (specification == null) throw new IllegalArgumentException("specification can't be null"); 42 | return proxy.searchTemplater(null, file, specification, false); 43 | } 44 | 45 | @Override 46 | public Future populatePdf(final String file, final Specification specification) { 47 | if (specification == null) throw new IllegalArgumentException("specification can't be null"); 48 | return proxy.searchTemplater(null, file, specification, true); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Guid/OneGuidDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Guid; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneGuidDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.UUID defaultValue = java.util.UUID.randomUUID(); 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.UUID defaultValueJsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.UUID borderValue1 = java.util.UUID.fromString("1-2-3-4-5"); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.UUID borderValue1JsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.UUID borderValue2 = new java.util.UUID(0L, 0L); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.UUID borderValue2JsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/json/TreePathConverter.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.json; 2 | 3 | import com.dslplatform.client.TreePath; 4 | import com.dslplatform.json.JsonReader; 5 | import com.dslplatform.json.JsonWriter; 6 | 7 | import java.io.IOException; 8 | import java.util.ArrayList; 9 | import java.util.Collection; 10 | 11 | public abstract class TreePathConverter { 12 | public static final JsonReader.ReadObject Reader = new JsonReader.ReadObject() { 13 | @Override 14 | public TreePath read(JsonReader reader) throws IOException { 15 | return TreePathConverter.deserialize(reader); 16 | } 17 | }; 18 | public static final JsonWriter.WriteObject Writer = new JsonWriter.WriteObject() { 19 | @Override 20 | public void write(JsonWriter writer, TreePath value) { 21 | serializeNullable(value, writer);; 22 | } 23 | }; 24 | 25 | public static void serializeNullable(final TreePath value, final JsonWriter sw) { 26 | if (value == null) { 27 | sw.writeNull(); 28 | } else { 29 | serialize(value, sw); 30 | } 31 | } 32 | 33 | public static void serialize(final TreePath value, final JsonWriter sw) { 34 | sw.writeByte(JsonWriter.QUOTE); 35 | sw.writeAscii(value.toString()); 36 | sw.writeByte(JsonWriter.QUOTE); 37 | } 38 | 39 | public static TreePath deserialize(final JsonReader reader) throws IOException { 40 | try { 41 | return TreePath.create(reader.readString()); 42 | } catch(final IOException e) { 43 | throw new IOException("Can't parse JSON TreePath at position " + reader.positionInStream(), e); 44 | } 45 | } 46 | 47 | public static ArrayList deserializeCollection(final JsonReader reader) throws IOException { 48 | return reader.deserializeCollection(Reader); 49 | } 50 | 51 | public static void deserializeCollection(final JsonReader reader, final Collection res) throws IOException { 52 | reader.deserializeCollection(Reader, res); 53 | } 54 | 55 | public static ArrayList deserializeNullableCollection(final JsonReader reader) throws IOException { 56 | return reader.deserializeNullableCollection(Reader); 57 | } 58 | 59 | public static void deserializeNullableCollection(final JsonReader reader, final Collection res) throws IOException { 60 | reader.deserializeNullableCollection(Reader, res); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/HttpCrudProxy.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import static com.dslplatform.client.HttpClient.encode; 4 | 5 | import java.util.concurrent.Future; 6 | 7 | import com.dslplatform.patterns.AggregateRoot; 8 | import com.dslplatform.patterns.Identifiable; 9 | 10 | class HttpCrudProxy implements CrudProxy { 11 | private final static String CRUD_URI = "Crud.svc/"; 12 | 13 | private final HttpClient client; 14 | 15 | public HttpCrudProxy(final HttpClient client) { 16 | this.client = client; 17 | } 18 | 19 | @Override 20 | public Future read(final Class manifest, final String uri) { 21 | if (uri == null) throw new IllegalArgumentException("uri can't be null."); 22 | final String domainName = client.getDslName(manifest); 23 | return client.sendRequest( 24 | manifest, 25 | CRUD_URI + domainName + "?uri=" + encode(uri), 26 | "GET", 27 | null, 28 | new int[] { 200 }); 29 | } 30 | 31 | @Override 32 | public Future create(final TAggregate aggregate) { 33 | @SuppressWarnings("unchecked") 34 | final Class manifest = (Class) aggregate.getClass(); 35 | final String domainName = client.getDslName(manifest); 36 | return client.sendRequest( 37 | manifest, 38 | CRUD_URI + domainName, 39 | "POST", 40 | aggregate, 41 | new int[] { 201 }); 42 | } 43 | 44 | @Override 45 | public Future update(final TAggregate aggregate) { 46 | final String uri = aggregate.getURI(); 47 | if (uri == null) throw new IllegalArgumentException("uri can't be null."); 48 | @SuppressWarnings("unchecked") 49 | final Class manifest = (Class) aggregate.getClass(); 50 | final String domainName = client.getDslName(manifest); 51 | return client.sendRequest( 52 | manifest, 53 | CRUD_URI + domainName + "?uri=" + encode(uri), 54 | "PUT", 55 | aggregate, 56 | new int[] { 200 }); 57 | } 58 | 59 | @Override 60 | public Future delete( 61 | final Class manifest, 62 | final String uri) { 63 | if (uri == null) throw new IllegalArgumentException("uri can't be null."); 64 | final String domainName = client.getDslName(manifest); 65 | return client.sendRequest( 66 | manifest, 67 | CRUD_URI + domainName + "?uri=" + encode(uri), 68 | "DELETE", 69 | null, 70 | new int[] { 200 }); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Ip/NullableArrayOfOneIpsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Ip; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneIpsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.net.InetAddress[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.net.InetAddress[] defaultValueJsonDeserialized = jsonSerialization.deserialize(java.net.InetAddress[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IpAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.net.InetAddress[] borderValue1 = new java.net.InetAddress[] { com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff") }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.net.InetAddress[] borderValue1JsonDeserialized = jsonSerialization.deserialize(java.net.InetAddress[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IpAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.net.InetAddress[] borderValue2 = new java.net.InetAddress[] { com.dslplatform.ocd.test.TypeFactory.buildIP("127.0.0.1"), com.dslplatform.ocd.test.TypeFactory.buildIP("0"), com.dslplatform.ocd.test.TypeFactory.buildIP("255.255.255.255"), com.dslplatform.ocd.test.TypeFactory.buildIP("::1"), com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff") }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.net.InetAddress[] borderValue2JsonDeserialized = jsonSerialization.deserialize(java.net.InetAddress[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IpAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Ip/OneArrayOfOneIpsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Ip; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneIpsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.net.InetAddress[] defaultValue = new java.net.InetAddress[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.net.InetAddress[] defaultValueJsonDeserialized = jsonSerialization.deserialize(java.net.InetAddress[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IpAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.net.InetAddress[] borderValue1 = new java.net.InetAddress[] { com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff") }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.net.InetAddress[] borderValue1JsonDeserialized = jsonSerialization.deserialize(java.net.InetAddress[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IpAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.net.InetAddress[] borderValue2 = new java.net.InetAddress[] { com.dslplatform.ocd.test.TypeFactory.buildIP("127.0.0.1"), com.dslplatform.ocd.test.TypeFactory.buildIP("0"), com.dslplatform.ocd.test.TypeFactory.buildIP("255.255.255.255"), com.dslplatform.ocd.test.TypeFactory.buildIP("::1"), com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff") }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.net.InetAddress[] borderValue2JsonDeserialized = jsonSerialization.deserialize(java.net.InetAddress[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IpAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/client/CrudProxy.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | import com.dslplatform.patterns.AggregateRoot; 6 | import com.dslplatform.patterns.Identifiable; 7 | 8 | /** 9 | * Proxy service to remote CRUD REST-like API. 10 | * Single aggregate root instance can be used. 11 | * New object instance will be returned when doing modifications. 12 | * Use {@link StandardProxy standard proxy} if a response is not required from the server. 13 | *

14 | * It is preferred to use domain patterns instead of this proxy service. 15 | */ 16 | public interface CrudProxy { 17 | /** 18 | * Gets a domain object from the remote server using provided identity. 19 | * If a domain object is not found an exception will be thrown. 20 | * 21 | * @param identifiable domain type 22 | * @param manifest domain object class (for deserialization) 23 | * @param uri domain object identity 24 | * @return future with the found domain object 25 | */ 26 | public Future read( 27 | Class manifest, 28 | String uri); 29 | 30 | /** 31 | * Creates a new aggregate root on the remote server. 32 | * Created object will be returned with a new identity and all calculated 33 | * properties evaluated. 34 | * 35 | * @param aggregate root type 36 | * @param aggregate new aggregate root 37 | * @return future with the aggregate root with a new identity 38 | */ 39 | public Future create( 40 | TAggregate aggregate); 41 | 42 | /** 43 | * Modifies an existing aggregate root on the remote server. 44 | * Aggregate root will be saved and all calculated properties evaluated. 45 | * 46 | * @param aggregate root type 47 | * @param aggregate modified aggregate root 48 | * @return future with the aggregate root with updated attributes 49 | */ 50 | public Future update( 51 | TAggregate aggregate); 52 | 53 | /** 54 | * Deletes an existing aggregate root from the remote server. 55 | * If possible, aggregate root will be deleted and its instance returned. 56 | * 57 | * @param aggregate root type 58 | * @param manifest aggregate root class (for deserialization) 59 | * @param uri aggregate root identity 60 | * @return future with the deleted aggregate root instance 61 | */ 62 | public Future delete( 63 | Class manifest, 64 | String uri); 65 | } 66 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Binary/OneBinaryDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Binary; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneBinaryDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final byte[] defaultValue = new byte[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final byte[] defaultValueJsonDeserialized = jsonSerialization.deserialize(byte[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final byte[] borderValue1 = new byte[] { Byte.MIN_VALUE }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final byte[] borderValue1JsonDeserialized = jsonSerialization.deserialize(byte[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final byte[] borderValue2 = new byte[] { Byte.MIN_VALUE, 0 }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final byte[] borderValue2JsonDeserialized = jsonSerialization.deserialize(byte[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final byte[] borderValue3 = new byte[] { Byte.MIN_VALUE, 0, Byte.MAX_VALUE }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final byte[] borderValue3JsonDeserialized = jsonSerialization.deserialize(byte[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /interface/src/main/java/com/dslplatform/client/JsonSerialization.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import com.dslplatform.patterns.AggregateRoot; 4 | import com.dslplatform.patterns.Bytes; 5 | import com.dslplatform.patterns.History; 6 | 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.util.List; 10 | 11 | /** 12 | * JSON serialization library wrapper. 13 | */ 14 | public interface JsonSerialization { 15 | 16 | /** 17 | * Serialize object if possible. 18 | * Returning byte array and total length, to allow for byte array reuse. 19 | * 20 | * @param value object instance to serialize 21 | * @return JSON as byte array (actual length might differ) 22 | * @throws IOException 23 | */ 24 | Bytes serialize(Object value) throws IOException; 25 | 26 | /** 27 | * Serialize object if possible to an existing Writer. 28 | * 29 | * @param value object instance to serialize 30 | * @throws IOException 31 | */ 32 | void serialize(Writer writer, Object value) throws IOException; 33 | 34 | /** 35 | * Try to deserialize provided JSON byte array input into specified object. 36 | * Allow byte[] reuse by asking for content and size 37 | * 38 | * @param manifest object manifest 39 | * @param content JSON array 40 | * @param size specify length 41 | * @param expected object type 42 | * @return object instance 43 | * @throws IOException 44 | */ 45 | T deserialize( 46 | final Class manifest, 47 | final byte[] content, 48 | final int size) throws IOException; 49 | 50 | /** 51 | * To work around JVM erasure specify list element type. 52 | * Specified collection will be deserialized. 53 | * Allow byte[] reuse by asking for content and size 54 | * 55 | * @param manifest object manifest 56 | * @param content JSON array 57 | * @param size specify length 58 | * @param expected object type 59 | * @return list instance 60 | * @throws IOException 61 | */ 62 | List deserializeList( 63 | final Class manifest, 64 | final byte[] content, 65 | final int size) throws IOException; 66 | 67 | /** 68 | * To work around JVM erasure specify history element type. 69 | * Specified collection will be deserialized. 70 | * Allow byte[] reuse by asking for content and size 71 | * 72 | * @param manifest object manifest 73 | * @param content JSON array 74 | * @param size specify length 75 | * @param expected object type 76 | * @return list instance of history objects 77 | * @throws IOException 78 | */ 79 | List> deserializeHistoryList( 80 | final Class manifest, 81 | final byte[] content, 82 | final int size) throws IOException; 83 | } 84 | -------------------------------------------------------------------------------- /core/src/test/resources/roundtripTests/xml/source/purchaseOrder.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Purchase order schema for Example.com. 6 | Copyright 2000 Example.com. All rights reserved. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Purchase order schema for Example.Microsoft.com. 28 | Copyright 2001 Example.Microsoft.com. All rights reserved. 29 | 30 | 31 | Application info. 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Integer/OneArrayOfOneIntegersDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Integer; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneIntegersDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final int[] defaultValue = new int[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final int[] defaultValueJsonDeserialized = jsonSerialization.deserialize(int[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final int[] borderValue1 = new int[] { 0 }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final int[] borderValue1JsonDeserialized = jsonSerialization.deserialize(int[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final int[] borderValue2 = new int[] { 1000000000 }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final int[] borderValue2JsonDeserialized = jsonSerialization.deserialize(int[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final int[] borderValue3 = new int[] { 0, Integer.MIN_VALUE, Integer.MAX_VALUE, -1000000000, 1000000000 }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final int[] borderValue3JsonDeserialized = jsonSerialization.deserialize(int[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Boolean/OneArrayOfOneBooleansDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Boolean; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneBooleansDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final boolean[] defaultValue = new boolean[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final boolean[] defaultValueJsonDeserialized = jsonSerialization.deserialize(boolean[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final boolean[] borderValue1 = new boolean[] { false }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final boolean[] borderValue1JsonDeserialized = jsonSerialization.deserialize(boolean[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final boolean[] borderValue2 = new boolean[] { true }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final boolean[] borderValue2JsonDeserialized = jsonSerialization.deserialize(boolean[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final boolean[] borderValue3 = new boolean[] { false, true }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final boolean[] borderValue3JsonDeserialized = jsonSerialization.deserialize(boolean[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Long/OneArrayOfOneLongsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Long; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneLongsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final long[] defaultValue = new long[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final long[] defaultValueJsonDeserialized = jsonSerialization.deserialize(long[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final long[] borderValue1 = new long[] { 0L }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final long[] borderValue1JsonDeserialized = jsonSerialization.deserialize(long[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final long[] borderValue2 = new long[] { Long.MAX_VALUE }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final long[] borderValue2JsonDeserialized = jsonSerialization.deserialize(long[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final long[] borderValue3 = new long[] { 0L, 1L, 1000000000000000000L, -1000000000000000000L, Long.MIN_VALUE, Long.MAX_VALUE }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final long[] borderValue3JsonDeserialized = jsonSerialization.deserialize(long[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Guid/NullableGuidDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Guid; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableGuidDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.UUID defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.UUID defaultValueJsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.UUID borderValue1 = java.util.UUID.randomUUID(); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.UUID borderValue1JsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.UUID borderValue2 = java.util.UUID.fromString("1-2-3-4-5"); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.UUID borderValue2JsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.UUID borderValue3 = new java.util.UUID(0L, 0L); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.UUID borderValue3JsonDeserialized = jsonSerialization.deserialize(java.util.UUID.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Integer/NullableArrayOfOneIntegersDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Integer; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneIntegersDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final int[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final int[] defaultValueJsonDeserialized = jsonSerialization.deserialize(int[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final int[] borderValue1 = new int[] { 0 }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final int[] borderValue1JsonDeserialized = jsonSerialization.deserialize(int[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final int[] borderValue2 = new int[] { 1000000000 }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final int[] borderValue2JsonDeserialized = jsonSerialization.deserialize(int[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final int[] borderValue3 = new int[] { 0, Integer.MIN_VALUE, Integer.MAX_VALUE, -1000000000, 1000000000 }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final int[] borderValue3JsonDeserialized = jsonSerialization.deserialize(int[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Boolean/NullableArrayOfOneBooleansDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Boolean; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneBooleansDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final boolean[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final boolean[] defaultValueJsonDeserialized = jsonSerialization.deserialize(boolean[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final boolean[] borderValue1 = new boolean[] { false }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final boolean[] borderValue1JsonDeserialized = jsonSerialization.deserialize(boolean[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final boolean[] borderValue2 = new boolean[] { true }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final boolean[] borderValue2JsonDeserialized = jsonSerialization.deserialize(boolean[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final boolean[] borderValue3 = new boolean[] { false, true }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final boolean[] borderValue3JsonDeserialized = jsonSerialization.deserialize(boolean[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Long/NullableArrayOfOneLongsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Long; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneLongsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final long[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final long[] defaultValueJsonDeserialized = jsonSerialization.deserialize(long[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final long[] borderValue1 = new long[] { 0L }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final long[] borderValue1JsonDeserialized = jsonSerialization.deserialize(long[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final long[] borderValue2 = new long[] { Long.MAX_VALUE }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final long[] borderValue2JsonDeserialized = jsonSerialization.deserialize(long[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final long[] borderValue3 = new long[] { 0L, 1L, 1000000000000000000L, -1000000000000000000L, Long.MIN_VALUE, Long.MAX_VALUE }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final long[] borderValue3JsonDeserialized = jsonSerialization.deserialize(long[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Float/OneArrayOfOneFloatsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Float; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneFloatsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final float[] defaultValue = new float[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final float[] defaultValueJsonDeserialized = jsonSerialization.deserialize(float[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final float[] borderValue1 = new float[] { 0.0f }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final float[] borderValue1JsonDeserialized = jsonSerialization.deserialize(float[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final float[] borderValue2 = new float[] { Float.POSITIVE_INFINITY }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final float[] borderValue2JsonDeserialized = jsonSerialization.deserialize(float[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final float[] borderValue3 = new float[] { 0.0f, -1.2345E-10f, 1.2345E20f, -1E-5f, Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final float[] borderValue3JsonDeserialized = jsonSerialization.deserialize(float[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/dslplatform/client/S3Test.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import com.dslplatform.patterns.Bytes; 4 | import com.dslplatform.patterns.ServiceLocator; 5 | import com.dslplatform.storage.S3; 6 | import com.dslplatform.storage.S3Repository; 7 | import org.junit.*; 8 | import org.slf4j.Logger; 9 | 10 | import java.io.IOException; 11 | import java.util.UUID; 12 | 13 | public class S3Test { 14 | 15 | ServiceLocator locator; 16 | Logger logger; 17 | 18 | @Before 19 | public void initialize() throws IOException { 20 | locator = Bootstrap.init(getClass().getResourceAsStream("/projectprops/mocks3project.properties")); 21 | logger = locator.resolve(Logger.class); 22 | logger.info("Initialized"); 23 | } 24 | 25 | @Test 26 | public void testEmptyDependencyInjection() throws IOException{ 27 | try { 28 | Bootstrap.init(getClass().getResourceAsStream("/projectprops/mockproject.properties")) 29 | .resolve(S3Repository.class); 30 | Assert.fail("Method should have thrown a RuntimeException"); 31 | } catch (Throwable ex){ 32 | Assert.assertTrue(ex.getMessage().contains("could not locate")); 33 | } 34 | } 35 | 36 | @Test 37 | public void testDependencyInjection() throws IOException{ 38 | Assert.assertTrue(locator.resolve(S3Repository.class) instanceof AmazonS3Repository); 39 | } 40 | 41 | @Test 42 | public void testObjectConstruction() throws IOException{ 43 | String bucket = "test"; 44 | String key = "somekey" + UUID.randomUUID(); 45 | String mime = "image/png"; 46 | S3 s3 = new S3(bucket, key).setMimeType(mime); 47 | 48 | Assert.assertEquals(bucket, s3.getBucket()); 49 | Assert.assertEquals(mime, s3.getMimeType()); 50 | Assert.assertEquals(key, s3.getKey()); 51 | 52 | Assert.assertNotNull(new S3(key).getBucket()); 53 | } 54 | 55 | @Test 56 | public void testJackson() throws IOException{ 57 | String bucket = "test"; 58 | String key = "somekey" + UUID.randomUUID(); 59 | String mime = "image/png"; 60 | S3 s3 = new S3(bucket, key).setMimeType(mime); 61 | s3.getMetadata().put("a", "b"); 62 | 63 | Bytes res = JsonStatic.INSTANCE.jackson.serialize(s3); 64 | S3 s3_d = JsonStatic.INSTANCE.jackson.deserialize(S3.class, res.content, res.length); 65 | 66 | Assert.assertEquals(s3.getBucket(), s3_d.getBucket()); 67 | } 68 | 69 | @Test 70 | public void testManual() throws IOException{ 71 | String bucket = "test"; 72 | String key = "somekey" + UUID.randomUUID(); 73 | String mime = "image/png"; 74 | S3 s3 = new S3(bucket, key).setMimeType(mime); 75 | s3.getMetadata().put("a", "b"); 76 | 77 | Bytes res = JsonStatic.INSTANCE.manual.serialize(s3); 78 | S3 s3_d = JsonStatic.INSTANCE.manual.deserialize(S3.class, res.content, res.length); 79 | 80 | Assert.assertEquals(s3.getBucket(), s3_d.getBucket()); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Ip/NullableListOfOneIpsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Ip; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableListOfOneIpsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(java.net.InetAddress.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IpAsserts.assertNullableListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff"))); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(java.net.InetAddress.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IpAsserts.assertNullableListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(com.dslplatform.ocd.test.TypeFactory.buildIP("127.0.0.1"), com.dslplatform.ocd.test.TypeFactory.buildIP("0"), com.dslplatform.ocd.test.TypeFactory.buildIP("255.255.255.255"), com.dslplatform.ocd.test.TypeFactory.buildIP("::1"), com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff"))); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(java.net.InetAddress.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IpAsserts.assertNullableListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Float/NullableArrayOfOneFloatsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Float; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneFloatsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final float[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final float[] defaultValueJsonDeserialized = jsonSerialization.deserialize(float[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final float[] borderValue1 = new float[] { 0.0f }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final float[] borderValue1JsonDeserialized = jsonSerialization.deserialize(float[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final float[] borderValue2 = new float[] { Float.POSITIVE_INFINITY }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final float[] borderValue2JsonDeserialized = jsonSerialization.deserialize(float[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final float[] borderValue3 = new float[] { 0.0f, -1.2345E-10f, 1.2345E20f, -1E-5f, Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final float[] borderValue3JsonDeserialized = jsonSerialization.deserialize(float[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.FloatAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Ip/OneListOfOneIpsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Ip; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneListOfOneIpsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = new java.util.ArrayList(0); 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(java.net.InetAddress.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IpAsserts.assertOneListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff"))); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(java.net.InetAddress.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IpAsserts.assertOneListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(com.dslplatform.ocd.test.TypeFactory.buildIP("127.0.0.1"), com.dslplatform.ocd.test.TypeFactory.buildIP("0"), com.dslplatform.ocd.test.TypeFactory.buildIP("255.255.255.255"), com.dslplatform.ocd.test.TypeFactory.buildIP("::1"), com.dslplatform.ocd.test.TypeFactory.buildIP("ffff::ffff"))); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(java.net.InetAddress.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IpAsserts.assertOneListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Double/OneArrayOfOneDoublesDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Double; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneDoublesDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final double[] defaultValue = new double[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final double[] defaultValueJsonDeserialized = jsonSerialization.deserialize(double[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final double[] borderValue1 = new double[] { 0.0 }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final double[] borderValue1JsonDeserialized = jsonSerialization.deserialize(double[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final double[] borderValue2 = new double[] { Double.NaN }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final double[] borderValue2JsonDeserialized = jsonSerialization.deserialize(double[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final double[] borderValue3 = new double[] { 0.0, 1E-307, 9E307, -1.23456789012345E-10, 1.23456789012345E20, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final double[] borderValue3JsonDeserialized = jsonSerialization.deserialize(double[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Double/NullableArrayOfOneDoublesDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Double; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneDoublesDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final double[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final double[] defaultValueJsonDeserialized = jsonSerialization.deserialize(double[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final double[] borderValue1 = new double[] { 0.0 }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final double[] borderValue1JsonDeserialized = jsonSerialization.deserialize(double[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final double[] borderValue2 = new double[] { Double.NaN }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final double[] borderValue2JsonDeserialized = jsonSerialization.deserialize(double[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final double[] borderValue3 = new double[] { 0.0, 1E-307, 9E307, -1.23456789012345E-10, 1.23456789012345E20, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final double[] borderValue3JsonDeserialized = jsonSerialization.deserialize(double[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.DoubleAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/MapServiceLocator.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.util.ArrayList; 5 | import java.util.LinkedHashMap; 6 | import java.util.Map; 7 | 8 | import com.dslplatform.patterns.ServiceLocator; 9 | 10 | class MapServiceLocator implements ServiceLocator { 11 | private final Map, Object> components = new LinkedHashMap, Object>(); 12 | private final static boolean cacheResult = true; 13 | 14 | MapServiceLocator() { 15 | components.put(ServiceLocator.class, this); 16 | } 17 | 18 | MapServiceLocator(final Map, Object> initialComponents) { 19 | components.put(ServiceLocator.class, this); 20 | components.putAll(initialComponents); 21 | } 22 | 23 | static interface LazyInstance { 24 | public T create(); 25 | } 26 | 27 | T resolveOrRegister(final Class clazz, final LazyInstance factory) { 28 | if (components.containsKey(clazz)) { 29 | return resolve(clazz); 30 | } 31 | final T instance = factory.create(); 32 | components.put(clazz, instance); 33 | return instance; 34 | } 35 | 36 | @Override 37 | public T resolve(final Class clazz) { 38 | final Object component = resolve(clazz, true); 39 | return clazz.cast(component); 40 | } 41 | 42 | private void cacheIf(final Class clazz, final Object service) { 43 | if (cacheResult && service != null) { 44 | register(clazz, service); 45 | } 46 | } 47 | 48 | private Object resolve(final Class clazz, final boolean checkErrors) { 49 | final Object component = components.get(clazz); 50 | 51 | if (component != null) { 52 | return component instanceof Class 53 | ? tryResolve((Class) component) 54 | : component; 55 | } 56 | 57 | final Object instance = tryResolve(clazz); 58 | 59 | if (instance == null && checkErrors) 60 | throw new RuntimeException("Container could not locate class of type: " + clazz.getName()); 61 | 62 | cacheIf(clazz, instance); 63 | 64 | return instance; 65 | } 66 | 67 | private Object tryResolve(final Class target) { 68 | for (final Constructor c : target.getConstructors()) { 69 | final ArrayList args = new ArrayList(); 70 | boolean success = true; 71 | for (final Class p : c.getParameterTypes()) { 72 | final Object a = resolve(p, false); 73 | if (a == null) { 74 | success = false; 75 | break; 76 | } 77 | args.add(a); 78 | } 79 | 80 | if (success) { 81 | try { 82 | final Object instance = c.newInstance(args.toArray()); 83 | cacheIf(target, instance); 84 | return instance; 85 | } catch (final Exception ignored) { 86 | } 87 | } 88 | } 89 | return null; 90 | } 91 | 92 | public MapServiceLocator register(final Class target, final Object service) { 93 | components.put(target, service); 94 | return this; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Binary/OneArrayOfOneBinariesDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Binary; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneBinariesDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final byte[][] defaultValue = new byte[0][]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final byte[][] defaultValueJsonDeserialized = jsonSerialization.deserialize(byte[][].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final byte[][] borderValue1 = new byte[][] { new byte[0] }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final byte[][] borderValue1JsonDeserialized = jsonSerialization.deserialize(byte[][].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final byte[][] borderValue2 = new byte[][] { new byte[] { Byte.MIN_VALUE, 0, Byte.MAX_VALUE } }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final byte[][] borderValue2JsonDeserialized = jsonSerialization.deserialize(byte[][].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final byte[][] borderValue3 = new byte[][] { new byte[0], new byte[] { Byte.MIN_VALUE }, new byte[] { Byte.MIN_VALUE, 0 }, new byte[] { Byte.MIN_VALUE, 0, Byte.MAX_VALUE } }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final byte[][] borderValue3JsonDeserialized = jsonSerialization.deserialize(byte[][].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Binary/NullableArrayOfOneBinariesDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Binary; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneBinariesDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final byte[][] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final byte[][] defaultValueJsonDeserialized = jsonSerialization.deserialize(byte[][].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final byte[][] borderValue1 = new byte[][] { new byte[0] }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final byte[][] borderValue1JsonDeserialized = jsonSerialization.deserialize(byte[][].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final byte[][] borderValue2 = new byte[][] { new byte[] { Byte.MIN_VALUE, 0, Byte.MAX_VALUE } }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final byte[][] borderValue2JsonDeserialized = jsonSerialization.deserialize(byte[][].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final byte[][] borderValue3 = new byte[][] { new byte[0], new byte[] { Byte.MIN_VALUE }, new byte[] { Byte.MIN_VALUE, 0 }, new byte[] { Byte.MIN_VALUE, 0, Byte.MAX_VALUE } }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final byte[][] borderValue3JsonDeserialized = jsonSerialization.deserialize(byte[][].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BinaryAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/StringWithMaxLengthOf9/OneArrayOfOneStringsWithMaxLengthOf9DefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.StringWithMaxLengthOf9; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneStringsWithMaxLengthOf9DefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final String[] defaultValue = new String[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final String[] defaultValueJsonDeserialized = jsonSerialization.deserialize(String[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final String[] borderValue1 = new String[] { "" }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final String[] borderValue1JsonDeserialized = jsonSerialization.deserialize(String[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final String[] borderValue2 = new String[] { "xxxxxxxxx" }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final String[] borderValue2JsonDeserialized = jsonSerialization.deserialize(String[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final String[] borderValue3 = new String[] { "", "\"", "'/\\[](){}", "\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t", "xxxxxxxxx" }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final String[] borderValue3JsonDeserialized = jsonSerialization.deserialize(String[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/StringWithMaxLengthOf9/NullableArrayOfOneStringsWithMaxLengthOf9DefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.StringWithMaxLengthOf9; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneStringsWithMaxLengthOf9DefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final String[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final String[] defaultValueJsonDeserialized = jsonSerialization.deserialize(String[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final String[] borderValue1 = new String[] { "" }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final String[] borderValue1JsonDeserialized = jsonSerialization.deserialize(String[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final String[] borderValue2 = new String[] { "xxxxxxxxx" }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final String[] borderValue2JsonDeserialized = jsonSerialization.deserialize(String[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final String[] borderValue3 = new String[] { "", "\"", "'/\\[](){}", "\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t", "xxxxxxxxx" }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final String[] borderValue3JsonDeserialized = jsonSerialization.deserialize(String[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.StringWithMaxLengthOf9Asserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Timestamp/OneTimestampDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Timestamp; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneTimestampDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final org.joda.time.DateTime defaultValue = org.joda.time.DateTime.now(); 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final org.joda.time.DateTime defaultValueJsonDeserialized = jsonSerialization.deserialize(org.joda.time.DateTime.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.TimestampAsserts.assertOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final org.joda.time.DateTime borderValue1 = new org.joda.time.DateTime(0); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final org.joda.time.DateTime borderValue1JsonDeserialized = jsonSerialization.deserialize(org.joda.time.DateTime.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.TimestampAsserts.assertOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final org.joda.time.DateTime borderValue2 = new org.joda.time.DateTime(1, 1, 1, 0, 0, org.joda.time.DateTimeZone.UTC); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final org.joda.time.DateTime borderValue2JsonDeserialized = jsonSerialization.deserialize(org.joda.time.DateTime.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.TimestampAsserts.assertOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final org.joda.time.DateTime borderValue3 = new org.joda.time.DateTime(Integer.MAX_VALUE * 1001L); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final org.joda.time.DateTime borderValue3JsonDeserialized = jsonSerialization.deserialize(org.joda.time.DateTime.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.TimestampAsserts.assertOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Guid/OneArrayOfOneGuidsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Guid; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneGuidsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.UUID[] defaultValue = new java.util.UUID[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.UUID[] defaultValueJsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.UUID[] borderValue1 = new java.util.UUID[] { java.util.UUID.randomUUID() }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.UUID[] borderValue1JsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.UUID[] borderValue2 = new java.util.UUID[] { new java.util.UUID(0L, 0L) }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.UUID[] borderValue2JsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.UUID[] borderValue3 = new java.util.UUID[] { java.util.UUID.randomUUID(), java.util.UUID.fromString("1-2-3-4-5"), new java.util.UUID(0L, 0L) }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.UUID[] borderValue3JsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertOneArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Guid/NullableArrayOfOneGuidsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Guid; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneGuidsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.UUID[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.UUID[] defaultValueJsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.UUID[] borderValue1 = new java.util.UUID[] { java.util.UUID.randomUUID() }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.UUID[] borderValue1JsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.UUID[] borderValue2 = new java.util.UUID[] { new java.util.UUID(0L, 0L) }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.UUID[] borderValue2JsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.UUID[] borderValue3 = new java.util.UUID[] { java.util.UUID.randomUUID(), java.util.UUID.fromString("1-2-3-4-5"), new java.util.UUID(0L, 0L) }; 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.UUID[] borderValue3JsonDeserialized = jsonSerialization.deserialize(java.util.UUID[].class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.GuidAsserts.assertNullableArrayOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Url/OneArrayOfOneUrlsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Url; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneUrlsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.net.URI[] defaultValue = new java.net.URI[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.net.URI[] defaultValueJsonDeserialized = jsonSerialization.deserialize(java.net.URI[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.UrlAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.net.URI[] borderValue1 = new java.net.URI[] { com.dslplatform.ocd.test.TypeFactory.buildURI("failover:(tcp://localhost:8181,tcp://localhost:8080/)") }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.net.URI[] borderValue1JsonDeserialized = jsonSerialization.deserialize(java.net.URI[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.UrlAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.net.URI[] borderValue2 = new java.net.URI[] { com.dslplatform.ocd.test.TypeFactory.buildURI("http://127.0.0.1/"), com.dslplatform.ocd.test.TypeFactory.buildURI("http://www.xyz.com/"), com.dslplatform.ocd.test.TypeFactory.buildURI("https://www.abc.com/"), com.dslplatform.ocd.test.TypeFactory.buildURI("ftp://www.pqr.com/"), com.dslplatform.ocd.test.TypeFactory.buildURI("https://localhost:8080/"), com.dslplatform.ocd.test.TypeFactory.buildURI("mailto:snail@mail.hu"), com.dslplatform.ocd.test.TypeFactory.buildURI("file:///~/opt/somefile.md"), com.dslplatform.ocd.test.TypeFactory.buildURI("tcp://localhost:8181/"), com.dslplatform.ocd.test.TypeFactory.buildURI("failover:(tcp://localhost:8181,tcp://localhost:8080/)") }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.net.URI[] borderValue2JsonDeserialized = jsonSerialization.deserialize(java.net.URI[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.UrlAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Xml/OneArrayOfOneXmlsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Xml; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneArrayOfOneXmlsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final org.w3c.dom.Element[] defaultValue = new org.w3c.dom.Element[0]; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final org.w3c.dom.Element[] defaultValueJsonDeserialized = jsonSerialization.deserialize(org.w3c.dom.Element[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.XmlAsserts.assertOneArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final org.w3c.dom.Element[] borderValue1 = new org.w3c.dom.Element[] { com.dslplatform.ocd.test.Utils.stringToElement("") }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final org.w3c.dom.Element[] borderValue1JsonDeserialized = jsonSerialization.deserialize(org.w3c.dom.Element[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.XmlAsserts.assertOneArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final org.w3c.dom.Element[] borderValue2 = new org.w3c.dom.Element[] { com.dslplatform.ocd.test.Utils.stringToElement(""), com.dslplatform.ocd.test.Utils.stringToElement("some text & <stuff>"), com.dslplatform.ocd.test.Utils.stringToElement("<?xml?><xml><!xml!>"), com.dslplatform.ocd.test.Utils.stringToElement(""), com.dslplatform.ocd.test.Utils.stringToElement("bird"), com.dslplatform.ocd.test.Utils.stringToElement("") }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final org.w3c.dom.Element[] borderValue2JsonDeserialized = jsonSerialization.deserialize(org.w3c.dom.Element[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.XmlAsserts.assertOneArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Xml/NullableArrayOfOneXmlsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Xml; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneXmlsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final org.w3c.dom.Element[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final org.w3c.dom.Element[] defaultValueJsonDeserialized = jsonSerialization.deserialize(org.w3c.dom.Element[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.XmlAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final org.w3c.dom.Element[] borderValue1 = new org.w3c.dom.Element[] { com.dslplatform.ocd.test.Utils.stringToElement("") }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final org.w3c.dom.Element[] borderValue1JsonDeserialized = jsonSerialization.deserialize(org.w3c.dom.Element[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.XmlAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final org.w3c.dom.Element[] borderValue2 = new org.w3c.dom.Element[] { com.dslplatform.ocd.test.Utils.stringToElement(""), com.dslplatform.ocd.test.Utils.stringToElement("some text & <stuff>"), com.dslplatform.ocd.test.Utils.stringToElement("<?xml?><xml><!xml!>"), com.dslplatform.ocd.test.Utils.stringToElement(""), com.dslplatform.ocd.test.Utils.stringToElement("bird"), com.dslplatform.ocd.test.Utils.stringToElement("") }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final org.w3c.dom.Element[] borderValue2JsonDeserialized = jsonSerialization.deserialize(org.w3c.dom.Element[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.XmlAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Url/NullableArrayOfOneUrlsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Url; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableArrayOfOneUrlsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.net.URI[] defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.net.URI[] defaultValueJsonDeserialized = jsonSerialization.deserialize(java.net.URI[].class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.UrlAsserts.assertNullableArrayOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.net.URI[] borderValue1 = new java.net.URI[] { com.dslplatform.ocd.test.TypeFactory.buildURI("failover:(tcp://localhost:8181,tcp://localhost:8080/)") }; 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.net.URI[] borderValue1JsonDeserialized = jsonSerialization.deserialize(java.net.URI[].class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.UrlAsserts.assertNullableArrayOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.net.URI[] borderValue2 = new java.net.URI[] { com.dslplatform.ocd.test.TypeFactory.buildURI("http://127.0.0.1/"), com.dslplatform.ocd.test.TypeFactory.buildURI("http://www.xyz.com/"), com.dslplatform.ocd.test.TypeFactory.buildURI("https://www.abc.com/"), com.dslplatform.ocd.test.TypeFactory.buildURI("ftp://www.pqr.com/"), com.dslplatform.ocd.test.TypeFactory.buildURI("https://localhost:8080/"), com.dslplatform.ocd.test.TypeFactory.buildURI("mailto:snail@mail.hu"), com.dslplatform.ocd.test.TypeFactory.buildURI("file:///~/opt/somefile.md"), com.dslplatform.ocd.test.TypeFactory.buildURI("tcp://localhost:8181/"), com.dslplatform.ocd.test.TypeFactory.buildURI("failover:(tcp://localhost:8181,tcp://localhost:8080/)") }; 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.net.URI[] borderValue2JsonDeserialized = jsonSerialization.deserialize(java.net.URI[].class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.UrlAsserts.assertNullableArrayOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Boolean/NullableListOfOneBooleansDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Boolean; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableListOfOneBooleansDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(Boolean.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(false)); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(Boolean.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(true)); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(Boolean.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.List borderValue3 = new java.util.ArrayList(java.util.Arrays.asList(false, true)); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.List borderValue3JsonDeserialized = jsonSerialization.deserializeList(Boolean.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertNullableListOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Boolean/OneListOfOneBooleansDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Boolean; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneListOfOneBooleansDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = new java.util.ArrayList(0); 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(Boolean.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(false)); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(Boolean.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(true)); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(Boolean.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.List borderValue3 = new java.util.ArrayList(java.util.Arrays.asList(false, true)); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.List borderValue3JsonDeserialized = jsonSerialization.deserializeList(Boolean.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.BooleanAsserts.assertOneListOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Long/NullableListOfOneLongsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Long; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableListOfOneLongsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(Long.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(0L)); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(Long.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(Long.MAX_VALUE)); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(Long.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.List borderValue3 = new java.util.ArrayList(java.util.Arrays.asList(0L, 1L, 1000000000000000000L, -1000000000000000000L, Long.MIN_VALUE, Long.MAX_VALUE)); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.List borderValue3JsonDeserialized = jsonSerialization.deserializeList(Long.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.LongAsserts.assertNullableListOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Long/OneListOfOneLongsDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Long; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class OneListOfOneLongsDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = new java.util.ArrayList(0); 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(Long.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(0L)); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(Long.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(Long.MAX_VALUE)); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(Long.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.List borderValue3 = new java.util.ArrayList(java.util.Arrays.asList(0L, 1L, 1000000000000000000L, -1000000000000000000L, Long.MIN_VALUE, Long.MAX_VALUE)); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.List borderValue3JsonDeserialized = jsonSerialization.deserializeList(Long.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.LongAsserts.assertOneListOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/dslplatform/client/TreePath.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client; 2 | 3 | import java.util.Arrays; 4 | 5 | public final class TreePath { 6 | private final String value; 7 | private final String[] parts; 8 | 9 | public static final TreePath EMPTY = new TreePath("", new String[0]); 10 | 11 | public TreePath(String value) { 12 | if (value == null || value.length() == 0) { 13 | this.value = ""; 14 | this.parts = new String[0]; 15 | } else { 16 | this.value = value; 17 | this.parts = value.split("\\."); 18 | checkParts(parts); 19 | } 20 | } 21 | 22 | public static TreePath create(String value) { 23 | if (value == null || value.length() == 0) { 24 | return EMPTY; 25 | } 26 | String[] parts = value.split("\\."); 27 | checkParts(parts); 28 | return new TreePath(value, parts); 29 | } 30 | 31 | private TreePath(String value, String[] parts) { 32 | this.value = value; 33 | this.parts = parts; 34 | } 35 | 36 | private static void checkParts(String[] parts) { 37 | for (String p : parts) { 38 | for (int j = 0; j < p.length(); j++) { 39 | final char ch = p.charAt(j); 40 | if ((ch < 'a' || ch > 'z') && 41 | (ch < 'A' || ch > 'Z') && 42 | (ch < '0' || ch > '9')) { 43 | throw new IllegalArgumentException("Invalid value for part: " + p + ". Only [A-Za-z0-9] allowed for labels"); 44 | } 45 | } 46 | } 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | return value.hashCode(); 52 | } 53 | 54 | @Override 55 | public boolean equals(Object obj) { 56 | return obj instanceof TreePath && ((TreePath) obj).value.equals(this.value) 57 | || obj instanceof String && obj.equals(this.value); 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return value; 63 | } 64 | 65 | public TreePath plus(TreePath other) { 66 | if (other == null) return this; 67 | if (this.value.length() == 0) { 68 | return other; 69 | } else if (other.value.length() == 0) { 70 | return this; 71 | } 72 | String[] values = Arrays.copyOf(this.parts, this.parts.length + other.parts.length); 73 | for (int i = 0; i < other.parts.length; i++) { 74 | values[this.parts.length + i] = other.parts[i]; 75 | } 76 | return new TreePath(this.value + "." + other.value, values); 77 | } 78 | 79 | private static boolean compare(String[] left, String[] right, int count) { 80 | for (int i = 0; i < count; i++) { 81 | if (!left[i].equals(right[i])) return false; 82 | } 83 | return true; 84 | } 85 | 86 | public boolean isAncestor(TreePath other) { 87 | if (other == null) return false; 88 | if (this.value.equals(other.value)) return true; 89 | return this.parts.length < other.parts.length && compare(this.parts, other.parts, this.parts.length); 90 | } 91 | 92 | public boolean isDescendant(TreePath other) { 93 | if (other == null) return false; 94 | if (this.value.equals(other.value)) return true; 95 | return this.parts.length > other.parts.length && compare(this.parts, other.parts, other.parts.length); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /core/src/test/java-generated/com/dslplatform/client/json/Integer/NullableListOfOneIntegersDefaultValueTurtle.java: -------------------------------------------------------------------------------- 1 | package com.dslplatform.client.json.Integer; 2 | 3 | import com.dslplatform.client.JsonSerialization; 4 | import com.dslplatform.patterns.Bytes; 5 | import java.io.IOException; 6 | 7 | public class NullableListOfOneIntegersDefaultValueTurtle { 8 | private static JsonSerialization jsonSerialization; 9 | 10 | @org.junit.BeforeClass 11 | public static void initializeJsonSerialization() throws IOException { 12 | jsonSerialization = com.dslplatform.client.StaticJson.getSerialization(); 13 | } 14 | 15 | @org.junit.Test 16 | public void testDefaultValueEquality() throws IOException { 17 | final java.util.List defaultValue = null; 18 | final Bytes defaultValueJsonSerialized = jsonSerialization.serialize(defaultValue); 19 | final java.util.List defaultValueJsonDeserialized = jsonSerialization.deserializeList(Integer.class, defaultValueJsonSerialized.content, defaultValueJsonSerialized.length); 20 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableListOfOneEquals(defaultValue, defaultValueJsonDeserialized); 21 | } 22 | 23 | @org.junit.Test 24 | public void testBorderValue1Equality() throws IOException { 25 | final java.util.List borderValue1 = new java.util.ArrayList(java.util.Arrays.asList(0)); 26 | final Bytes borderValue1JsonSerialized = jsonSerialization.serialize(borderValue1); 27 | final java.util.List borderValue1JsonDeserialized = jsonSerialization.deserializeList(Integer.class, borderValue1JsonSerialized.content, borderValue1JsonSerialized.length); 28 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableListOfOneEquals(borderValue1, borderValue1JsonDeserialized); 29 | } 30 | 31 | @org.junit.Test 32 | public void testBorderValue2Equality() throws IOException { 33 | final java.util.List borderValue2 = new java.util.ArrayList(java.util.Arrays.asList(1000000000)); 34 | final Bytes borderValue2JsonSerialized = jsonSerialization.serialize(borderValue2); 35 | final java.util.List borderValue2JsonDeserialized = jsonSerialization.deserializeList(Integer.class, borderValue2JsonSerialized.content, borderValue2JsonSerialized.length); 36 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableListOfOneEquals(borderValue2, borderValue2JsonDeserialized); 37 | } 38 | 39 | @org.junit.Test 40 | public void testBorderValue3Equality() throws IOException { 41 | final java.util.List borderValue3 = new java.util.ArrayList(java.util.Arrays.asList(0, Integer.MIN_VALUE, Integer.MAX_VALUE, -1000000000, 1000000000)); 42 | final Bytes borderValue3JsonSerialized = jsonSerialization.serialize(borderValue3); 43 | final java.util.List borderValue3JsonDeserialized = jsonSerialization.deserializeList(Integer.class, borderValue3JsonSerialized.content, borderValue3JsonSerialized.length); 44 | com.dslplatform.ocd.javaasserts.IntegerAsserts.assertNullableListOfOneEquals(borderValue3, borderValue3JsonDeserialized); 45 | } 46 | } 47 | --------------------------------------------------------------------------------