Skip to content

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

Merged
merged 1 commit into from
Jun 29, 2015
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
5 changes: 5 additions & 0 deletions modules/swagger-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
<artifactId>validation-api</artifactId>
<version>${validation-api-version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<!-- TODO increase coverage -->
Expand Down
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 {
Copy link
Contributor

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... :-)

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

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.


@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());
}
}
5 changes: 5 additions & 0 deletions modules/swagger-hibernate-validations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<version>${scala-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<hibernate-validator-version>5.1.3.Final</hibernate-validator-version>
Expand Down
5 changes: 5 additions & 0 deletions modules/swagger-jaxrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
<version>${scala-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<coverage.complexity.minimum>0.29</coverage.complexity.minimum>
Expand Down
5 changes: 5 additions & 0 deletions modules/swagger-jersey2-jaxrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey2-version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<!-- TODO increase coverage and remove these overrides-->
Expand Down
41 changes: 40 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<outputDirectory>target/classes</outputDirectory>
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ScalaTest compiles tests from the src/test/scala path by default.
We compile tests from both paths: src/test/scala, src/test/java.
Please look at build.log file - https://travis-ci.org/swagger-api/swagger-core/builds/68503343#L3622-L3623

<testOutputDirectory>target/test-classes</testOutputDirectory>
<resources>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down