use of uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor in project microservice_framework by CJSCommonPlatform.
the class EventValidationInterceptorCodeGeneratorTest method nowTestTheGeneratedClass.
private void nowTestTheGeneratedClass(final Class<?> compiledClass) throws Exception {
final String eventName = "an.event.name";
final JsonSchemaValidationInterceptor eventValidationInterceptor = buildTheClassForTest(compiledClass, new MyCustomEventFilter(eventName));
final TextMessage textMessage = mock(TextMessage.class);
when(textMessage.getStringProperty(JMS_HEADER_CPPNAME)).thenReturn(eventName);
assertThat(eventValidationInterceptor.shouldValidate(textMessage), is(true));
}
use of uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor in project microservice_framework by CJSCommonPlatform.
the class EventValidationInterceptorCodeGeneratorTest method buildTheClassForTest.
private JsonSchemaValidationInterceptor buildTheClassForTest(final Class<?> generatedClass, final MyCustomEventFilter myCustomEventFilter) throws Exception {
final Object myCustomEventFilterInterceptor = generatedClass.newInstance();
final Field eventFilterField = generatedClass.getDeclaredField("eventFilter");
eventFilterField.setAccessible(true);
eventFilterField.set(myCustomEventFilterInterceptor, myCustomEventFilter);
return (JsonSchemaValidationInterceptor) myCustomEventFilterInterceptor;
}
use of uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor in project microservice_framework by CJSCommonPlatform.
the class EventValidationInterceptorCodeGeneratorTest method nowTestTheFailureCase.
private void nowTestTheFailureCase(final Class<?> compiledClass) throws Exception {
final String eventName = "an.event.name";
final String messageName = "a.different.event.name";
final JsonSchemaValidationInterceptor eventValidationInterceptor = buildTheClassForTest(compiledClass, new MyCustomEventFilter(eventName));
final TextMessage textMessage = mock(TextMessage.class);
when(textMessage.getStringProperty(JMS_HEADER_CPPNAME)).thenReturn(messageName);
assertThat(eventValidationInterceptor.shouldValidate(textMessage), is(false));
}
Aggregations