Search in sources :

Example 1 with JsonSchemaValidationInterceptor

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));
}
Also used : JsonSchemaValidationInterceptor(uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor) TextMessage(javax.jms.TextMessage)

Example 2 with JsonSchemaValidationInterceptor

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;
}
Also used : Field(java.lang.reflect.Field) JsonSchemaValidationInterceptor(uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor)

Example 3 with JsonSchemaValidationInterceptor

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));
}
Also used : JsonSchemaValidationInterceptor(uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor) TextMessage(javax.jms.TextMessage)

Aggregations

JsonSchemaValidationInterceptor (uk.gov.justice.services.adapter.messaging.JsonSchemaValidationInterceptor)3 TextMessage (javax.jms.TextMessage)2 Field (java.lang.reflect.Field)1