Ejemplo n.º 1
0
 protected internal virtual Response createResponse(IList <MessageCorrelationResultDto> resultDtos, CorrelationMessageDto messageDto)
 {
     Response.ResponseBuilder response = Response.noContent();
     if (messageDto.ResultEnabled)
     {
         response = Response.ok(resultDtos, MediaType.APPLICATION_JSON);
     }
     return(response.build());
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private javax.ws.rs.core.Response.ResponseBuilder mockResponseBuilder(javax.ws.rs.core.Response response, final java.util.concurrent.atomic.AtomicReference<javax.ws.rs.core.StreamingOutput> ref)
        private Response.ResponseBuilder MockResponseBuilder(Response response, AtomicReference <StreamingOutput> @ref)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.Response.ResponseBuilder responseBuilder = mock(javax.ws.rs.core.Response.ResponseBuilder.class);
            Response.ResponseBuilder responseBuilder = mock(typeof(Response.ResponseBuilder));
            when(responseBuilder.entity(ArgumentMatchers.isA(typeof(StreamingOutput)))).thenAnswer(invocationOnMock =>
            {
                @ref.set(invocationOnMock.getArgument(0));
                return(responseBuilder);
            });
            when(responseBuilder.type(ArgumentMatchers.any <MediaType>())).thenReturn(responseBuilder);
            when(responseBuilder.build()).thenReturn(response);
            return(responseBuilder);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private javax.ws.rs.core.Response.ResponseBuilder formatRepresentation(javax.ws.rs.core.Response.ResponseBuilder response, final Representation representation)
        private Response.ResponseBuilder FormatRepresentation(Response.ResponseBuilder response, Representation representation)
        {
            _representationWriteHandler.onRepresentationStartWriting();

            bool mustFail = representation is ExceptionRepresentation;

            if (_format is StreamingFormat)
            {
                return(response.entity(Stream(representation, ( StreamingFormat )_format, mustFail)));
            }
            else
            {
                return(response.entity(ToBytes(Assemble(representation), mustFail)));
            }
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotProvideStreamingForOtherMediaTypes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CannotProvideStreamingForOtherMediaTypes()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.Response.ResponseBuilder responseBuilder = mock(javax.ws.rs.core.Response.ResponseBuilder.class);
            Response.ResponseBuilder responseBuilder = mock(typeof(Response.ResponseBuilder));
            // no streaming
            when(responseBuilder.entity(any(typeof(sbyte[])))).thenReturn(responseBuilder);
            Mockito.verify(responseBuilder, never()).entity(isA(typeof(StreamingOutput)));
            when(responseBuilder.type(ArgumentMatchers.any <MediaType>())).thenReturn(responseBuilder);
            when(responseBuilder.build()).thenReturn(null);
            OutputFormat format = _repository.outputFormat(new IList <MediaType> {
                MediaType.TEXT_HTML_TYPE
            }, new URI("http://some.host"), StreamingHeader());

            assertNotNull(format);
            format.Response(responseBuilder, new ExceptionRepresentation(new Exception()));
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canProvideStreamingJsonOutputFormat() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanProvideStreamingJsonOutputFormat()
        {
            Response response = mock(typeof(Response));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<javax.ws.rs.core.StreamingOutput> ref = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <StreamingOutput> @ref = new AtomicReference <StreamingOutput>();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.Response.ResponseBuilder responseBuilder = mockResponseBuilder(response, ref);
            Response.ResponseBuilder responseBuilder = MockResponseBuilder(response, @ref);
            OutputFormat             format          = _repository.outputFormat(new IList <MediaType> {
                MediaType.APPLICATION_JSON_TYPE
            }, null, StreamingHeader());

            assertNotNull(format);
            Response returnedResponse = format.Response(responseBuilder, new MapRepresentation(map("a", "test")));

            assertSame(response, returnedResponse);
            StreamingOutput streamingOutput = @ref.get();
            MemoryStream    baos            = new MemoryStream();

            streamingOutput.write(baos);
            assertEquals("{\"a\":\"test\"}", baos.ToString());
        }
Ejemplo n.º 6
0
 protected internal virtual Response Response(Response.ResponseBuilder response, Representation representation)
 {
     return(FormatRepresentation(response, representation).type(HttpHeaderUtils.mediaTypeWithCharsetUtf8(MediaType)).build());
 }
Ejemplo n.º 7
0
        protected internal override Response Response(Response.ResponseBuilder response, Representation representation)
        {
            this._representation = representation;

            return(base.Response(response, representation));
        }