You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2017/12/28 02:05:01 UTC

[GitHub] wujimin commented on a change in pull request #471: [JAV-575] Exception to response converter

wujimin commented on a change in pull request #471: [JAV-575] Exception to response converter
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/471#discussion_r158888462
 
 

 ##########
 File path: swagger/swagger-invocation/invocation-core/src/test/java/io/servicecomb/swagger/engine/TestSwaggerProducerOperation.java
 ##########
 @@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.servicecomb.swagger.engine;
+
+import javax.ws.rs.core.Response.Status;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import io.servicecomb.swagger.invocation.Response;
+import io.servicecomb.swagger.invocation.SwaggerInvocation;
+import mockit.Mocked;
+
+public class TestSwaggerProducerOperation {
+  SwaggerProducerOperation swaggerProducerOperation = new SwaggerProducerOperation();
+
+  @Test
+  public void processException_convert(@Mocked SwaggerInvocation invocation) {
+    Error error = new Error("abc");
+
+    Response response = swaggerProducerOperation.processException(invocation, error);
+    Assert.assertSame(Status.OK, response.getStatus());
 
 Review comment:
   this is just a test demo.
   converter will not limit the convert logic, some customers(eg: music) will convert a exception to normal response, and error information be setted to body model.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services