Skip to content

Commit

Permalink
ScalaAkkaClientCodegenTest: refactor assertions (#3893)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored and wing328 committed Sep 16, 2019
1 parent a882681 commit 3f9d1b1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openapitools.codegen.scalaakka;

import com.google.common.collect.Sets;
import com.google.common.io.Resources;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.parser.util.SchemaTypeUtil;
Expand All @@ -28,6 +29,7 @@
import org.testng.annotations.Test;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -303,28 +305,8 @@ public void codeGenerationTest() throws Exception {
Assert.assertEquals(generatedFiles.size(), 13);

final String someObjFilename = new File(output, "src/main/scala/hello/world/model/SomeObj.scala").getAbsolutePath().replace("\\", "/");
final String someObjFileContents = generatedFiles.get(someObjFilename);
Assert.assertTrue(someObjFileContents.contains("package hello.world.model"));
Assert.assertTrue(someObjFileContents.contains("case class SomeObj"));
Assert.assertTrue(someObjFileContents.contains("id: Long,"));
Assert.assertTrue(someObjFileContents.contains("name: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`val`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`var`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`class`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`trait`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`object`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`try`: String,"));
Assert.assertTrue(someObjFileContents.contains("`catch`: String,"));
Assert.assertTrue(someObjFileContents.contains("`finally`: String,"));
Assert.assertTrue(someObjFileContents.contains("`def`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`for`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`implicit`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`match`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`case`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`import`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`lazy`: String,"));
Assert.assertTrue(someObjFileContents.contains("`private`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("`type`: Option[String] = None,"));
Assert.assertTrue(someObjFileContents.contains("foobar: Boolean"));
Assert.assertEquals(
generatedFiles.get(someObjFilename),
Resources.toString(Resources.getResource("codegen/scala/SomeObj.scala.txt"), StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* ping some object
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package hello.world.model

import hello.world.core.ApiModel
import org.joda.time.DateTime
import java.util.UUID

case class SomeObj (
`type`: Option[SomeObjEnums.`Type`] = None,
id: Long,
name: Option[String] = None,
`val`: Option[String] = None,
`var`: Option[String] = None,
`class`: Option[String] = None,
`trait`: Option[String] = None,
`object`: Option[String] = None,
`try`: String,
`catch`: String,
`finally`: String,
`def`: Option[String] = None,
`for`: Option[String] = None,
`implicit`: Option[String] = None,
`match`: Option[String] = None,
`case`: Option[String] = None,
`import`: Option[String] = None,
`lazy`: String,
`private`: Option[String] = None,
`type`: Option[String] = None,
foobar: Boolean
) extends ApiModel

object SomeObjEnums {

type `Type` = `Type`.Value
object `Type` extends Enumeration {
val SomeObjIdentifier = Value("SomeObjIdentifier")
}

}

0 comments on commit 3f9d1b1

Please sign in to comment.