示例#1
0
        private static ClientResponse MockEntityClientResponse(TimelineClientImpl client,
                                                               ClientResponse.Status status, bool hasError, bool hasRuntimeError)
        {
            ClientResponse response = Org.Mockito.Mockito.Mock <ClientResponse>();

            if (hasRuntimeError)
            {
                Org.Mockito.Mockito.DoThrow(new ClientHandlerException(new ConnectException())).When
                    (client).DoPostingObject(Matchers.Any <TimelineEntities>(), Matchers.Any <string>(
                                                 ));
                return(response);
            }
            Org.Mockito.Mockito.DoReturn(response).When(client).DoPostingObject(Matchers.Any <
                                                                                    TimelineEntities>(), Matchers.Any <string>());
            Org.Mockito.Mockito.When(response.GetClientResponseStatus()).ThenReturn(status);
            TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError
                                                             ();
            error.SetEntityId("test entity id");
            error.SetEntityType("test entity type");
            error.SetErrorCode(TimelinePutResponse.TimelinePutError.IoException);
            TimelinePutResponse putResponse = new TimelinePutResponse();

            if (hasError)
            {
                putResponse.AddError(error);
            }
            Org.Mockito.Mockito.When(response.GetEntity <TimelinePutResponse>()).ThenReturn(putResponse
                                                                                            );
            return(response);
        }
示例#2
0
        private static ClientResponse MockDomainClientResponse(TimelineClientImpl client,
                                                               ClientResponse.Status status, bool hasRuntimeError)
        {
            ClientResponse response = Org.Mockito.Mockito.Mock <ClientResponse>();

            if (hasRuntimeError)
            {
                Org.Mockito.Mockito.DoThrow(new ClientHandlerException(new ConnectException())).When
                    (client).DoPostingObject(Matchers.Any <TimelineDomain>(), Matchers.Any <string>());
                return(response);
            }
            Org.Mockito.Mockito.DoReturn(response).When(client).DoPostingObject(Matchers.Any <
                                                                                    TimelineDomain>(), Matchers.Any <string>());
            Org.Mockito.Mockito.When(response.GetClientResponseStatus()).ThenReturn(status);
            return(response);
        }
示例#3
0
        /// <summary>
        /// Set the expected status of the response. The test will fail if the
        /// response has a different status. Defaults to HTTP 200 OK.
        /// </summary>
        /// <param name="expectedStatus"> the expected response status </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public RESTRequestGenerator expectedStatus(final com.sun.jersey.api.client.ClientResponse.Status expectedStatus)
        public virtual RESTRequestGenerator ExpectedStatus(ClientResponse.Status expectedStatus)
        {
            this._expectedResponseStatus = expectedStatus.StatusCode;
            return(this);
        }