Skip to content

Commit

Permalink
Merge pull request #5 from HLTech/feature/vaunt-serializer-usage
Browse files Browse the repository at this point in the history
Use VauntSerializer from vaunt-core instead of own mapper
  • Loading branch information
matek2305 authored Aug 12, 2019
2 parents 752bca6 + c0200ba commit fe06ee2
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = "com.hltech"
version = "1.0.1"
version = "1.0.2"

repositories {
mavenCentral()
Expand All @@ -29,7 +29,7 @@ dependencies {
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7")
implementation("io.github.openfeign:feign-core:9.7.0")
implementation("io.github.openfeign:feign-jackson:9.7.0")
implementation("com.hltech:vaunt-core:1.0.16")
implementation("com.hltech:vaunt-core:1.0.24")

testImplementation(gradleTestKit())
testImplementation("org.spockframework:spock-core:1.2-groovy-2.5")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.hltech.judged.contracts.publisher.capabilities

import com.hltech.judged.contracts.publisher.vaunt.VauntFileReader
import com.hltech.judged.contracts.publisher.vaunt.vauntObjectMapper
import com.hltech.vaunt.core.VauntSerializer
import org.gradle.api.Project

class VauntCapabilitiesReader : CapabilitiesReader {

private val fileReader = VauntFileReader()
private val mapper = vauntObjectMapper()
private val serializer = VauntSerializer()

override fun read(project: Project): Capabilities {
val contracts = fileReader.read(project)
.flatMap { it.capabilities.contracts }
.toList()

return Capabilities("jms", mapper.writeValueAsString(contracts), "application/json")
return Capabilities("jms", serializer.serialize(contracts), "application/json")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.hltech.judged.contracts.publisher.expectations

import com.google.common.collect.ArrayListMultimap
import com.hltech.judged.contracts.publisher.vaunt.VauntFileReader
import com.hltech.judged.contracts.publisher.vaunt.vauntObjectMapper
import com.hltech.vaunt.core.VauntSerializer
import com.hltech.vaunt.core.domain.model.Contract
import org.gradle.api.Project

class VauntExpectationsReader : ExpectationsReader {

private val fileReader = VauntFileReader()
private val mapper = vauntObjectMapper()
private val serializer = VauntSerializer()

override fun read(project: Project): List<Expectations> {
val providerNameToContracts = fileReader.read(project)
Expand All @@ -21,6 +21,6 @@ class VauntExpectationsReader : ExpectationsReader {

return providerNameToContracts
.keySet()
.map { Expectations(it, "jms", mapper.writeValueAsString(providerNameToContracts[it]), "application/json") }
.map { Expectations(it, "jms", serializer.serialize(providerNameToContracts[it]), "application/json") }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class PublisherPlugin : Plugin<Project> {

override fun apply(project: Project) {
project.task("publishContracts") { task ->
task.description = "Publish contracts to remote judge-dredd instance."

task.doLast {
println("serviceName=${project.name}")
println("serviceVersion=${project.version}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.hltech.judged.contracts.publisher.vaunt

import com.hltech.vaunt.core.VauntSerializer
import com.hltech.vaunt.core.domain.model.Service
import org.gradle.api.Project
import java.io.File

class VauntFileReader {

private val mapper = vauntObjectMapper()
private val serializer = VauntSerializer()

fun read(project: Project): List<Service> =
when (val vauntLocation = project.properties[VAUNT_LOCATION_KEY]) {
Expand All @@ -25,7 +26,7 @@ class VauntFileReader {

println("Found ${vauntFiles.size} vaunt files")

return vauntFiles.map { mapper.readValue(it, Service::class.java) }
return vauntFiles.map { serializer.readServiceDefinition(it) }
}

private companion object {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PublisherPluginSpec extends Specification {
{
"destinationType": "QUEUE",
"destinationName": "request_for_information_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:RequestMessage",
"properties": {
Expand All @@ -128,7 +128,7 @@ class PublisherPluginSpec extends Specification {
{
"destinationType": "TOPIC",
"destinationName": "something_changed_topic",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:ChangedEvent",
"properties": {
Expand Down Expand Up @@ -173,7 +173,7 @@ class PublisherPluginSpec extends Specification {
{
"destinationType": "QUEUE",
"destinationName": "audit_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:AuditMessage",
"properties": {
Expand All @@ -193,7 +193,7 @@ class PublisherPluginSpec extends Specification {
{
"destinationType": "QUEUE",
"destinationName": "reject_information_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:RejectMessage",
"properties": {
Expand All @@ -209,7 +209,7 @@ class PublisherPluginSpec extends Specification {
{
"destinationType": "QUEUE",
"destinationName": "accept_information_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:AcceptMessage",
"properties": {
Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/vaunt/information-service.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"destinationType": "QUEUE",
"destinationName": "request_for_information_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:RequestMessage",
"properties": {
Expand All @@ -18,7 +18,7 @@
{
"destinationType": "TOPIC",
"destinationName": "something_changed_topic",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:ChangedEvent",
"properties": {
Expand All @@ -36,7 +36,7 @@
{
"destinationType": "QUEUE",
"destinationName": "audit_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:AuditMessage",
"properties": {
Expand All @@ -51,7 +51,7 @@
{
"destinationType": "QUEUE",
"destinationName": "reject_information_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:RejectMessage",
"properties": {
Expand All @@ -67,7 +67,7 @@
{
"destinationType": "QUEUE",
"destinationName": "accept_information_queue",
"body": {
"message": {
"type": "object",
"id": "urn:jsonschema:com:hltech:vaunt:generator:domain:representation:RepresentationWriterSpec:AcceptMessage",
"properties": {
Expand Down

0 comments on commit fe06ee2

Please sign in to comment.