Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCB-2475] migrate generator-core module to junit5 #3425

Merged
merged 1 commit into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import org.apache.commons.io.IOUtils;
import org.apache.servicecomb.foundation.common.exceptions.ServiceCombException;
import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Response;
import io.swagger.models.Swagger;
import io.swagger.util.Yaml;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

Expand Down Expand Up @@ -158,11 +158,13 @@ public void correctResponsesHavePaths() {
Assertions.assertEquals("response of 200", response.getDescription());
}

@Test(expected = ServiceCombException.class)
@Test
public void testInvalidate() {
URL resource = TestSwaggerUtils.class.getResource("/swagger1.yaml");
Swagger swagger = SwaggerUtils.parseSwagger(resource);
SwaggerUtils.validateSwagger(swagger);
Assertions.assertThrows(ServiceCombException.class, () -> {
SwaggerUtils.validateSwagger(swagger);
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.servicecomb.foundation.test.scaffolding.model.Color;
import org.apache.servicecomb.foundation.test.scaffolding.model.User;
import org.apache.servicecomb.swagger.SwaggerUtils;
import org.junit.Test;

import com.fasterxml.jackson.databind.type.TypeFactory;

Expand All @@ -35,6 +34,7 @@
import io.swagger.models.parameters.BodyParameter;
import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.Property;
import org.junit.jupiter.api.Test;

public class ConverterMgrTest {
static Swagger swagger = SwaggerUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

import io.swagger.models.properties.FileProperty;
import org.junit.jupiter.api.Test;


public class TestPartPropertyCreator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations;
import org.hamcrest.MatcherAssert;
import org.junit.AfterClass;
import org.junit.Test;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Extension;
Expand All @@ -42,12 +40,14 @@
import io.swagger.models.Response;
import io.swagger.models.Scheme;
import io.swagger.models.Swagger;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestApiOperation {
static SwaggerOperations swaggerOperations = SwaggerOperations.generate(ApiOperationAnnotation.class);

@AfterClass
@AfterAll
public static void teardown() {
swaggerOperations = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@

import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation;
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations;
import org.junit.AfterClass;
import org.junit.Test;

import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader;
import io.swagger.models.ModelImpl;
import io.swagger.models.Response;
import io.swagger.models.properties.Property;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestApiResponse {
static SwaggerOperations swaggerOperations = SwaggerOperations.generate(ApiResponseAnnotation.class);

@AfterClass
@AfterAll
public static void teardown() {
swaggerOperations = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import org.apache.servicecomb.swagger.generator.core.schema.ArrayType;
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation;
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations;
import org.junit.Test;

import io.swagger.models.ModelImpl;
import io.swagger.models.parameters.BodyParameter;
import io.swagger.models.properties.ByteArrayProperty;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestArrayType {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

import org.apache.servicecomb.swagger.SwaggerUtils;
import org.apache.servicecomb.swagger.generator.SwaggerConst;
import org.junit.Test;

import io.swagger.annotations.SwaggerDefinition;
import io.swagger.models.parameters.PathParameter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

@SwaggerDefinition
public class TestClassUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import org.apache.servicecomb.swagger.generator.core.schema.InvalidType;
import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class TestInvalidType {
@Test
Expand All @@ -42,7 +42,7 @@ public void testAbstractClass() {
"testAbstractClass");
}

@Ignore("need to discuss in JVA-422")
@Disabled("need to discuss in JVA-422")
@Test
public void testObject() {
UnitTestSwaggerUtils.testException(
Expand All @@ -52,7 +52,7 @@ public void testObject() {
"testObject");
}

@Ignore("need to discuss in JVA-422")
@Disabled("need to discuss in JVA-422")
@Test
public void testNotClearList() {
UnitTestSwaggerUtils.testException(
Expand All @@ -62,7 +62,7 @@ public void testNotClearList() {
"testNotClearList");
}

@Ignore("need to discuss in JVA-422")
@Disabled("need to discuss in JVA-422")
@Test
public void testNotClearSet() {
UnitTestSwaggerUtils.testException(
Expand All @@ -72,7 +72,7 @@ public void testNotClearSet() {
"testNotClearSet");
}

@Ignore("need to discuss in JVA-422")
@Disabled("need to discuss in JVA-422")
@Test
public void testNotClearMap() {
UnitTestSwaggerUtils.testException(
Expand All @@ -82,7 +82,7 @@ public void testNotClearMap() {
"testNotClearMap");
}

@Ignore("need to discuss in JVA-422")
@Disabled("need to discuss in JVA-422")
@Test
public void testInvalidFieldClass() {
UnitTestSwaggerUtils.testException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation;
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations;
import org.hamcrest.MatcherAssert;
import org.junit.AfterClass;
import org.junit.Test;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Expand All @@ -34,12 +32,14 @@
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.ResponseHeader;
import io.swagger.models.Response;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestOperationGenerator {
static SwaggerOperations swaggerOperations = SwaggerOperations.generate(TestClass.class);

@AfterClass
@AfterAll
public static void teardown() {
swaggerOperations = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.apache.servicecomb.swagger.generator.SwaggerConst;
import org.apache.servicecomb.swagger.generator.SwaggerGenerator;
import org.junit.Test;

import io.swagger.annotations.Contact;
import io.swagger.annotations.Extension;
Expand All @@ -34,6 +33,7 @@
import io.swagger.annotations.Tag;
import io.swagger.models.Swagger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestSwaggerDefinition {
@SwaggerDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.hamcrest.MatcherAssert;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestSwaggerGenerator {
@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.apache.servicecomb.swagger.generator.core.schema.Schema;
import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import io.swagger.models.Swagger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package org.apache.servicecomb.swagger.generator.core.model;

import org.apache.servicecomb.swagger.SwaggerUtils;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import io.swagger.models.Swagger;
import org.junit.jupiter.api.Test;

public class TestSwaggerOperations {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.Test;

import io.swagger.annotations.ApiOperation;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

public class ApiOperationProcessorTest {
static SwaggerOperations swaggerOperations = SwaggerOperations.generate(TestClass.class);

@AfterClass
@AfterAll
public static void teardown() {
swaggerOperations = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

import io.swagger.annotations.Api;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.models.Swagger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class ApiProcessorTest {
@Api(tags = {"tag1", "tag2", "", "tag1"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiKeyAuthDefinition;
Expand All @@ -44,6 +43,7 @@
import io.swagger.annotations.Tag;
import io.swagger.models.Swagger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class SwaggerDefinitionProcessorTest {
@Api(consumes = MediaType.APPLICATION_XML, produces = MediaType.APPLICATION_XML)
Expand Down