use of uk.gov.justice.services.core.interceptor.InterceptorChain in project microservice_framework by CJSCommonPlatform.
the class EventFilterInterceptorCodeGeneratorTest method nowTestTheFailureCase.
private void nowTestTheFailureCase(final Class<?> generatedClass) throws Exception {
final String eventName = "an.event.name";
final String aDifferentventName = "a.different.event.name";
final Interceptor interceptor = buildTheClassForTest(generatedClass, new MyCustomEventFilter(eventName));
final InterceptorContext interceptorContext_1 = mock(InterceptorContext.class, "interceptorContext_1");
final InterceptorContext interceptorContext_2 = mock(InterceptorContext.class, "interceptorContext_2");
final InterceptorChain interceptorChain = mock(InterceptorChain.class);
final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class);
final Metadata metadata = mock(Metadata.class);
when(interceptorContext_1.inputEnvelope()).thenReturn(jsonEnvelope);
when(jsonEnvelope.metadata()).thenReturn(metadata);
when(metadata.name()).thenReturn(aDifferentventName);
when(interceptorChain.processNext(interceptorContext_1)).thenReturn(interceptorContext_2);
assertThat(interceptor.process(interceptorContext_1, interceptorChain), is(interceptorContext_1));
}
use of uk.gov.justice.services.core.interceptor.InterceptorChain in project microservice_framework by CJSCommonPlatform.
the class LocalAccessControlInterceptorTest method setup.
@Before
public void setup() throws Exception {
final Deque<Interceptor> interceptors = new LinkedList<>();
interceptors.add(localAccessControlInterceptor);
final Target target = context -> context;
interceptorChain = new DefaultInterceptorChain(interceptors, target);
}
use of uk.gov.justice.services.core.interceptor.InterceptorChain in project microservice_framework by CJSCommonPlatform.
the class LocalAuditInterceptorTest method setup.
@Before
public void setup() throws Exception {
final Deque<Interceptor> interceptors = new LinkedList<>();
interceptors.add(localAuditInterceptor);
final Target target = context -> context.copyWithOutput(outputEnvelope);
interceptorChain = new DefaultInterceptorChain(interceptors, target);
}
use of uk.gov.justice.services.core.interceptor.InterceptorChain in project microservice_framework by CJSCommonPlatform.
the class EventFilterInterceptorCodeGeneratorTest method nowTestTheGeneratedClass.
private void nowTestTheGeneratedClass(final Class<?> generatedClass) throws Exception {
final String eventName = "an.event.name";
final Interceptor interceptor = buildTheClassForTest(generatedClass, new MyCustomEventFilter(eventName));
final InterceptorContext interceptorContext_1 = mock(InterceptorContext.class, "interceptorContext_1");
final InterceptorContext interceptorContext_2 = mock(InterceptorContext.class, "interceptorContext_2");
final InterceptorChain interceptorChain = mock(InterceptorChain.class);
final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class);
final Metadata metadata = mock(Metadata.class);
when(interceptorContext_1.inputEnvelope()).thenReturn(jsonEnvelope);
when(jsonEnvelope.metadata()).thenReturn(metadata);
when(metadata.name()).thenReturn(eventName);
when(interceptorChain.processNext(interceptorContext_1)).thenReturn(interceptorContext_2);
assertThat(interceptor.process(interceptorContext_1, interceptorChain), is(interceptorContext_2));
}
Aggregations