Data Module

Recipe Test

Add a data module to smile project by altering the <projectName>.ksmile file

section basic{
        data-module Alldatatype at com.iteration3.alldatatype
}
  • type-alias
type-alias Date as "java.util.Date"
  • enum
enum Status "Account Status all the way till doc generation" =>
OPEN("open") "This is open status"|
DORMANT("dormant")|
ACTIVE("active")|
CLOSE("close")|
UPDATE("update")
  • adt
adt PaymentType(amount:Int)  =>
        Cheque(amount:Int,dateIssued:CalendarDate) | CreditCard(amount:Int,txnDate:CalendarDate)
  • data
data AllDataype(status:Status,
        defaultStatus :Status = ` Status.DORMANT`,
        optEnum: Status? ,
        allStatuses: Status* ,
        defaultAllStatuses : Status* = `List(Status.ACTIVE,Status.DORMANT,Status.CLOSE)`,
        optAllStatuses:Status*,
        paymentType:PaymentType "can pass Cheque/CreditCard both"
) {
        let a:Status = `status`
        let b:Status?  = `Some(status)`
        let c:Status* = `List(Status.ACTIVE,Status.DORMANT,Status.CLOSE,status) `
        let d:Status* = `List(status,Status.CLOSE)`
}
  • data-tag
data-tag

Recipes

Type-alias : place to make third party class alias , once defined, can be used as a data type.

Enum : withId and withName

Adt : Abstract Data type

Data :Scala class gets generated under src-gen for data defined here

Data-tag:

Test

For each data module one test file gets generated under test dir. Write code there to test the module

class <moduleName>TestSuite extends FunSuite with SmilePerTest {
        test("test1", Tag("tag1")) {
}
> test //This will run entire test cases
> test-only *.<ClassName>.scala -- -n <tagName>

Can add your own test files in this directory , Test scala file must extend FunSuite and SmilePerTest