Make ContractVerifierMessaging independent of the builder interface
The builder is really an internal detail of the messaging support, so it' sbetter if users just use the send method directly.
This commit is contained in:
@@ -76,7 +76,7 @@ public class CamelMessagingApplicationSpec extends Specification {
|
||||
def response = contractVerifierMessaging.receiveMessage('activemq:output')
|
||||
response.headers.get('BOOK-NAME') == 'foo'
|
||||
and:
|
||||
DocumentContext parsedJson = JsonPath.parse(contractVerifierObjectMapper.writeValueAsString(response.payload))
|
||||
DocumentContext parsedJson = JsonPath.parse(contractVerifierObjectMapper.writeValueAsString(response.body))
|
||||
JsonAssertion.assertThat(parsedJson).field('bookName').isEqualTo('foo')
|
||||
}
|
||||
|
||||
@@ -107,18 +107,15 @@ public class CamelMessagingApplicationSpec extends Specification {
|
||||
|
||||
// generated test should look like this:
|
||||
|
||||
//given:
|
||||
Message inputMessage = contractVerifierMessaging.create(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header']
|
||||
)
|
||||
when:
|
||||
contractVerifierMessaging.send(inputMessage, 'jms:input')
|
||||
contractVerifierMessaging.send(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header'], 'jms:input')
|
||||
then:
|
||||
def response = contractVerifierMessaging.receiveMessage('jms:output')
|
||||
response.headers.get('BOOK-NAME') == 'foo'
|
||||
and:
|
||||
DocumentContext parsedJson = JsonPath.parse(contractVerifierObjectMapper.writeValueAsString(response.payload))
|
||||
DocumentContext parsedJson = JsonPath.parse(contractVerifierObjectMapper.writeValueAsString(response.body))
|
||||
JsonAssertion.assertThat(parsedJson).field('bookName').isEqualTo('foo')
|
||||
}
|
||||
|
||||
@@ -140,13 +137,9 @@ public class CamelMessagingApplicationSpec extends Specification {
|
||||
|
||||
// generated test should look like this:
|
||||
|
||||
//given:
|
||||
Message inputMessage = contractVerifierMessaging.create(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header']
|
||||
)
|
||||
when:
|
||||
contractVerifierMessaging.send(inputMessage, 'jms:delete')
|
||||
contractVerifierMessaging.send(contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header'], 'jms:delete')
|
||||
then:
|
||||
noExceptionThrown()
|
||||
bookWasDeleted()
|
||||
|
||||
@@ -113,13 +113,10 @@ public class IntegrationMessagingApplicationSpec extends Specification {
|
||||
|
||||
// generated test should look like this:
|
||||
|
||||
//given:
|
||||
Message<?> inputMessage = contractVerifierMessaging.create(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header']
|
||||
)
|
||||
when:
|
||||
contractVerifierMessaging.send(inputMessage, 'input')
|
||||
contractVerifierMessaging.send(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header'], 'input')
|
||||
then:
|
||||
def response = contractVerifierMessaging.receiveMessage('output')
|
||||
response.headers.get('BOOK-NAME') == 'foo'
|
||||
@@ -146,13 +143,9 @@ public class IntegrationMessagingApplicationSpec extends Specification {
|
||||
|
||||
// generated test should look like this:
|
||||
|
||||
//given:
|
||||
Message<?> inputMessage = contractVerifierMessaging.create(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header']
|
||||
)
|
||||
when:
|
||||
contractVerifierMessaging.send(inputMessage, 'delete')
|
||||
contractVerifierMessaging.send(contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header'], 'delete')
|
||||
then:
|
||||
noExceptionThrown()
|
||||
bookWasDeleted()
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.example
|
||||
import javax.inject.Inject
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.IntegrationTest
|
||||
import org.springframework.boot.test.context.SpringBootContextLoader
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging
|
||||
@@ -100,13 +100,10 @@ public class StreamMessagingApplicationSpec extends Specification {
|
||||
|
||||
// generated test should look like this:
|
||||
|
||||
//given:
|
||||
Message<?> inputMessage = contractVerifierMessaging.create(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header']
|
||||
)
|
||||
when:
|
||||
contractVerifierMessaging.send(inputMessage, 'input')
|
||||
contractVerifierMessaging.send(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header'], 'input')
|
||||
then:
|
||||
def response = contractVerifierMessaging.receiveMessage('output')
|
||||
response.headers.get('BOOK-NAME') == 'foo'
|
||||
@@ -133,13 +130,9 @@ public class StreamMessagingApplicationSpec extends Specification {
|
||||
|
||||
// generated test should look like this:
|
||||
|
||||
//given:
|
||||
Message<?> inputMessage = contractVerifierMessaging.create(
|
||||
contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header']
|
||||
)
|
||||
when:
|
||||
contractVerifierMessaging.send(inputMessage, 'delete')
|
||||
contractVerifierMessaging.send(contractVerifierObjectMapper.writeValueAsString([bookName: 'foo']),
|
||||
[sample: 'header'], 'delete')
|
||||
then:
|
||||
noExceptionThrown()
|
||||
bookWasDeleted()
|
||||
|
||||
@@ -118,13 +118,8 @@ class StubRunnerExecutorSpec extends Specification {
|
||||
|
||||
@Override
|
||||
void send(Object o, Map headers, String destination) {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object create(Object o, Map headers) {
|
||||
assert !(JsonOutput.toJson(o).contains("serverValue"))
|
||||
assert headers.entrySet().every { !(it.value.toString().contains("serverValue")) }
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,10 +91,4 @@ public class ContractVerifierCamelMessaging implements
|
||||
return receiveMessage(destination, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Message create(T t, Map<String, Object> headers) {
|
||||
return builder.create(t, headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ContractVerifierIntegrationMessaging implements
|
||||
|
||||
@Override
|
||||
public <T> void send(T payload, Map<String, Object> headers, String destination) {
|
||||
send(create(payload, headers), destination);
|
||||
send(builder.create(payload, headers), destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,9 +83,4 @@ public class ContractVerifierIntegrationMessaging implements
|
||||
return receiveMessage(destination, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Message<?> create(T t, Map<String, Object> headers) {
|
||||
return builder.create(t, headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public interface ContractVerifierMessaging<M> extends
|
||||
ContractVerifierMessageBuilder<M> {
|
||||
public interface ContractVerifierMessaging<M> {
|
||||
/**
|
||||
* Sends the {@link ContractVerifierMessage} to the given destination.
|
||||
*/
|
||||
|
||||
@@ -43,9 +43,4 @@ public class NoOpContractVerifierMessaging implements ContractVerifierMessaging<
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Object create(T o, Map<String, Object> headers) {
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,9 +97,4 @@ public class ContractVerifierStreamMessaging implements
|
||||
return receiveMessage(destination, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Message<?> create(T t, Map<String, Object> headers) {
|
||||
return builder.create(t, headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user