-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fixed #1203: Migrate tests from the Scala to the plain Java #1204
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.swagger; | ||
|
||
import io.swagger.converter.ModelConverters; | ||
import io.swagger.models.Model; | ||
import io.swagger.models.properties.DoubleProperty; | ||
import io.swagger.models.properties.IntegerProperty; | ||
import io.swagger.models.properties.Property; | ||
import io.swagger.models.properties.StringProperty; | ||
import models.BeanValidationsModel; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Map; | ||
|
||
public class BeanValidatorTestNG extends Assert { | ||
|
||
@Test(testName = "read bean validations") | ||
public void readBeanValidatorTest() { | ||
final Map<String, Model> schemas = ModelConverters.getInstance().readAll(BeanValidationsModel.class); | ||
final Model model = schemas.get("BeanValidationsModel"); | ||
final Map<String, Property> properties = model.getProperties(); | ||
|
||
final IntegerProperty age = (IntegerProperty) properties.get("age"); | ||
assertEquals(age.getMinimum(), 13.0); | ||
assertEquals(age.getMaximum(), 99.0); | ||
|
||
final StringProperty password = (StringProperty) properties.get("password"); | ||
assertEquals((int) password.getMinLength(), 6); | ||
assertEquals((int) password.getMaxLength(), 20); | ||
|
||
final DoubleProperty minBalance = (DoubleProperty) properties.get("minBalance"); | ||
assertTrue(minBalance.getExclusiveMinimum()); | ||
|
||
final DoubleProperty maxBalance = (DoubleProperty) properties.get("maxBalance"); | ||
assertTrue(maxBalance.getExclusiveMaximum()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ | |
<build> | ||
<sourceDirectory>src/main/scala</sourceDirectory> | ||
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> | ||
<testSourceDirectory>src/test/scala</testSourceDirectory> | ||
<outputDirectory>target/classes</outputDirectory> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really want to remove the scala tests before all of them are migrated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ScalaTest compiles tests from the src/test/scala path by default. |
||
<testOutputDirectory>target/test-classes</testOutputDirectory> | ||
<resources> | ||
|
@@ -131,6 +130,38 @@ | |
</launchers> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-version}</version> | ||
<configuration> | ||
<testNGArtifactName>none:none</testNGArtifactName> | ||
<reportsDirectory>${project.build.directory}/surefire-reports/scala</reportsDirectory> | ||
<excludes> | ||
<exclude>**/*TestNG.java</exclude> | ||
</excludes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>test-testng</id> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<junitArtifactName>none:none</junitArtifactName> | ||
<testNGArtifactName>org.testng:testng</testNGArtifactName> | ||
<reportsDirectory>${project.build.directory}/surefire-reports/java</reportsDirectory> | ||
<includes> | ||
<include>**/*TestNG.java</include> | ||
</includes> | ||
<excludes> | ||
<exclude>**/*Test.java</exclude> | ||
</excludes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
|
@@ -468,6 +499,12 @@ | |
<version>${junit-version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>${testng-version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
|
@@ -517,6 +554,8 @@ | |
<logback-version>1.0.1</logback-version> | ||
|
||
<junit-version>4.8.2</junit-version> | ||
<testng-version>6.9.4</testng-version> | ||
<surefire-version>2.18.1</surefire-version> | ||
<maven-plugin-version>1.0.0</maven-plugin-version> | ||
<commons-lang-version>3.2.1</commons-lang-version> | ||
<slf4j-version>1.6.3</slf4j-version> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just "BeanValidatorTest" is fine... :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we have some java tests in scala (i.e. SimpleGenerationTest, ModelPropertyOverrideTest, etc.). And these tests will be run two times (first run by the ScalaTest and second run by the TestNG).
It's best workaround when we have two types of tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok - we can rename them once the Scala tests have removed... thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the idea with renaming and TestNG ending. There is nothing wrong if some tests will run twice (of course until they will not fail). This just means that these tests are first candidates for migration.
But my main concern here that we introduce implicit naming convention for Java tests for other community members.