Search in sources :

Example 1 with SchemaFormat

use of org.apache.servicecomb.inspector.internal.swagger.SchemaFormat in project java-chassis by ServiceComb.

the class TestInspectorImpl method downloadSchemas_failed.

@Test
public void downloadSchemas_failed() {
    SchemaFormat format = SchemaFormat.SWAGGER;
    new Expectations(format) {

        {
            format.getSuffix();
            result = new RuntimeExceptionWithoutStackTrace("zip failed.");
        }
    };
    try (LogCollector logCollector = new LogCollector()) {
        Response response = inspector.downloadSchemas(format);
        Assert.assertEquals("failed to create schemas zip file, format=SWAGGER.", logCollector.getLastEvents().getMessage());
        InvocationException invocationException = response.getResult();
        Assert.assertEquals(Status.INTERNAL_SERVER_ERROR, invocationException.getStatus());
        Assert.assertEquals("failed to create schemas zip file, format=SWAGGER.", ((CommonExceptionData) invocationException.getErrorData()).getMessage());
        Assert.assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode());
        Assert.assertEquals(Status.INTERNAL_SERVER_ERROR.getReasonPhrase(), response.getReasonPhrase());
    }
}
Also used : Expectations(mockit.Expectations) RuntimeExceptionWithoutStackTrace(org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace) LogCollector(org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector) Response(org.apache.servicecomb.swagger.invocation.Response) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) SchemaFormat(org.apache.servicecomb.inspector.internal.swagger.SchemaFormat) Test(org.junit.Test)

Aggregations

Expectations (mockit.Expectations)1 RuntimeExceptionWithoutStackTrace (org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace)1 LogCollector (org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector)1 SchemaFormat (org.apache.servicecomb.inspector.internal.swagger.SchemaFormat)1 Response (org.apache.servicecomb.swagger.invocation.Response)1 InvocationException (org.apache.servicecomb.swagger.invocation.exception.InvocationException)1 Test (org.junit.Test)1