Search in sources :

Example 26 with InterceptorContext

use of uk.gov.justice.services.core.interceptor.InterceptorContext in project microservice_framework by CJSCommonPlatform.

the class FileBasedInterceptorContextFactory method create.

public InterceptorContext create(final List<FileInputDetails> fileInputDetails, final JsonEnvelope envelope) {
    final InterceptorContext interceptorContext = interceptorContextWithInput(envelope);
    interceptorContext.setInputParameter(FILE_INPUT_DETAILS_LIST, fileInputDetails);
    return interceptorContext;
}
Also used : InterceptorContext(uk.gov.justice.services.core.interceptor.InterceptorContext)

Example 27 with InterceptorContext

use of uk.gov.justice.services.core.interceptor.InterceptorContext in project microservice_framework by CJSCommonPlatform.

the class LocalAuditInterceptorTest method shouldUseUnknownComponentIfComponentNotSet.

@Test
public void shouldUseUnknownComponentIfComponentNotSet() throws Exception {
    final InterceptorContext inputContext = interceptorContextWithInput(inputEnvelope);
    interceptorChain.processNext(inputContext);
    verify(auditService).audit(inputEnvelope, UNKNOWN_COMPONENT);
    verify(auditService).audit(outputEnvelope, UNKNOWN_COMPONENT);
}
Also used : InterceptorContext(uk.gov.justice.services.core.interceptor.InterceptorContext) Test(org.junit.Test)

Example 28 with InterceptorContext

use of uk.gov.justice.services.core.interceptor.InterceptorContext in project microservice_framework by CJSCommonPlatform.

the class LocalAuditInterceptorTest method shouldApplyAccessControlToInputIfLocalComponent.

@Test
public void shouldApplyAccessControlToInputIfLocalComponent() throws Exception {
    final InterceptorContext inputContext = interceptorContextWithInput(inputEnvelope);
    inputContext.setInputParameter("component", COMPONENT);
    interceptorChain.processNext(inputContext);
    verify(auditService).audit(inputEnvelope, COMPONENT);
    verify(auditService).audit(outputEnvelope, COMPONENT);
}
Also used : InterceptorContext(uk.gov.justice.services.core.interceptor.InterceptorContext) Test(org.junit.Test)

Example 29 with InterceptorContext

use of uk.gov.justice.services.core.interceptor.InterceptorContext in project microservice_framework by CJSCommonPlatform.

the class EventBufferInterceptorTest method shouldCallEventBufferServiceAndProcessStreamOfMultipleEventsReturned.

@Test
public void shouldCallEventBufferServiceAndProcessStreamOfMultipleEventsReturned() throws Exception {
    final InterceptorContext inputContext = interceptorContextWithInput(envelope_1);
    final Stream<JsonEnvelope> envelopes = Stream.of(envelope_1, envelope_2);
    when(eventBufferService.currentOrderedEventsWith(envelope_1)).thenReturn(envelopes);
    final InterceptorContext resultContext = interceptorChain.processNext(inputContext);
    assertThat(resultContext.inputEnvelope(), is(envelope_1));
    assertThat(target.envelopesRecieved, contains(envelope_1, envelope_2));
}
Also used : InterceptorContext(uk.gov.justice.services.core.interceptor.InterceptorContext) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Example 30 with InterceptorContext

use of uk.gov.justice.services.core.interceptor.InterceptorContext in project microservice_framework by CJSCommonPlatform.

the class EventBufferInterceptorTest method shouldCallEventBufferServiceAndProcessEmptyStreamReturned.

@Test
public void shouldCallEventBufferServiceAndProcessEmptyStreamReturned() throws Exception {
    final Stream<JsonEnvelope> envelopeStream = Stream.empty();
    final InterceptorContext interceptorContext = interceptorContextWithInput(envelope_1);
    when(eventBufferService.currentOrderedEventsWith(envelope_1)).thenReturn(envelopeStream);
    final InterceptorContext resultContext = interceptorChain.processNext(interceptorContext);
    assertThat(resultContext, is(interceptorContext));
    assertThat(target.envelopesRecieved, empty());
}
Also used : InterceptorContext(uk.gov.justice.services.core.interceptor.InterceptorContext) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Aggregations

InterceptorContext (uk.gov.justice.services.core.interceptor.InterceptorContext)35 Test (org.junit.Test)29 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)28 Collection (java.util.Collection)7 Function (java.util.function.Function)7 JsonObject (javax.json.JsonObject)7 HttpHeaders (javax.ws.rs.core.HttpHeaders)7 Method (java.lang.reflect.Method)6 Optional (java.util.Optional)6 CommonGeneratorProperties (uk.gov.justice.services.generators.commons.config.CommonGeneratorProperties)6 FileInputDetails (uk.gov.justice.services.adapter.rest.multipart.FileInputDetails)5 Matchers.anyString (org.mockito.Matchers.anyString)4 Response (javax.ws.rs.core.Response)3 ThreadLocalHttpHeaders (org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpHeaders)3 Parameter (uk.gov.justice.services.adapter.rest.parameter.Parameter)3 Interceptor (uk.gov.justice.services.core.interceptor.Interceptor)3 OptimisticLockingRetryException (uk.gov.justice.services.eventsourcing.repository.jdbc.exception.OptimisticLockingRetryException)3 List (java.util.List)2 UUID (java.util.UUID)2 DefaultParameter (uk.gov.justice.services.adapter.rest.parameter.DefaultParameter)2