From b3bf4fae0dba2ac0a737999779c8ac669210f7b1 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Thu, 29 Feb 2024 18:07:29 +0530 Subject: [PATCH 1/4] Make test functions isolated --- .../tests/constriant_error_message_test.bal | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/ballerina/tests/constriant_error_message_test.bal b/ballerina/tests/constriant_error_message_test.bal index 4ae67cf..65fa242 100644 --- a/ballerina/tests/constriant_error_message_test.bal +++ b/ballerina/tests/constriant_error_message_test.bal @@ -143,7 +143,7 @@ type Trainee record {| Badge[] badges; |}; -Trainee TRAINEE = { +const Trainee TRAINEE = { TraineeName: "JohnDoe", dob: { year: 1999, @@ -161,8 +161,8 @@ Trainee TRAINEE = { }; @test:Config {} -function testErrorMessageInRecordTypePositive() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypePositive() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); Trainee|error validation = validate(trainee); if validation is error { test:assertFail("Unexpected error found."); @@ -172,8 +172,8 @@ function testErrorMessageInRecordTypePositive() { } @test:Config {} -function testErrorMessageInRecordTypeNegative1() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative1() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.TraineeName = "abc"; Trainee|error validation = validate(trainee); if validation is error { @@ -192,8 +192,8 @@ function testErrorMessageInRecordTypeNegative1() { } @test:Config {} -function testErrorMessageInRecordTypeNegative2() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative2() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.dob = { year: 2055, month: 10, @@ -208,8 +208,8 @@ function testErrorMessageInRecordTypeNegative2() { } @test:Config {} -function testErrorMessageInRecordTypeNegative3() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative3() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.weight = -50.5; Trainee|error validation = validate(trainee); if validation is error { @@ -220,8 +220,8 @@ function testErrorMessageInRecordTypeNegative3() { } @test:Config {} -function testErrorMessageInRecordTypeNegative4() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative4() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.height = -150.5; Trainee|error validation = validate(trainee); if validation is error { @@ -232,8 +232,8 @@ function testErrorMessageInRecordTypeNegative4() { } @test:Config {} -function testErrorMessageInRecordTypeNegative5() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative5() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.dateOfJoining = { year: 2022, month: 2, @@ -248,8 +248,8 @@ function testErrorMessageInRecordTypeNegative5() { } @test:Config {} -function testErrorMessageInRecordTypeNegative6() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative6() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.badges = ["badge1", "badge2", "badge3", "badge4", "badge5", "badge6"]; Trainee|error validation = validate(trainee); if validation is error { @@ -260,8 +260,8 @@ function testErrorMessageInRecordTypeNegative6() { } @test:Config {} -function testErrorMessageInRecordTypeNegative7() { - Trainee trainee = TRAINEE.clone(); +function testErrorMessageInRecordTypeNegative7() returns error? { + Trainee trainee = check TRAINEE.cloneWithType(); trainee.badges = ["badge1", "badge2", "bad"]; Trainee|error validation = validate(trainee); if validation is error { @@ -321,8 +321,8 @@ type Trainee0 record {| |}; @test:Config {} -function testErrorMessageInMixedRecordTypePositive() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypePositive() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); Trainee0|error validation = validate(trainee); if validation is error { test:assertFail("Unexpected error found."); @@ -332,8 +332,8 @@ function testErrorMessageInMixedRecordTypePositive() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative1() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative1() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.TraineeName = "abc"; Trainee0|error validation = validate(trainee); if validation is error { @@ -352,8 +352,8 @@ function testErrorMessageInMixedRecordTypeNegative1() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative2() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative2() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.dob = { year: 2055, month: 10, @@ -368,8 +368,8 @@ function testErrorMessageInMixedRecordTypeNegative2() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative3() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative3() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.weight = -50.5; Trainee0|error validation = validate(trainee); if validation is error { @@ -380,8 +380,8 @@ function testErrorMessageInMixedRecordTypeNegative3() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative4() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative4() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.height = -150.5; Trainee0|error validation = validate(trainee); if validation is error { @@ -392,8 +392,8 @@ function testErrorMessageInMixedRecordTypeNegative4() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative5() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative5() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.height = 300; Trainee0|error validation = validate(trainee); if validation is error { @@ -404,8 +404,8 @@ function testErrorMessageInMixedRecordTypeNegative5() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative6() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative6() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.dateOfJoining = { year: 2022, month: 2, @@ -420,8 +420,8 @@ function testErrorMessageInMixedRecordTypeNegative6() { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative7() { - Trainee0 trainee = TRAINEE.clone(); +function testErrorMessageInMixedRecordTypeNegative7() returns error? { + Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.badges = ["badge1", "badge2", "bad"]; Trainee0|error validation = validate(trainee); if validation is error { From 17453c7fbbc55c9cd71524bc3186dc70d42d4239 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 1 Mar 2024 08:50:22 +0530 Subject: [PATCH 2/4] Make tests explicitly isolated --- ballerina/tests/advanced_constraint_test.bal | 26 +++--- .../constraint_on_array_members_test.bal | 12 +-- .../constraint_on_readonly_type_test.bal | 28 +++---- ...constraint_validation_return_type_test.bal | 12 +-- .../tests/constriant_error_message_test.bal | 40 ++++----- .../date_constraint_on_record_field_test.bal | 62 +++++++------- .../tests/date_constraint_on_type_test.bal | 82 +++++++++---------- ballerina/tests/example_constraint_test.bal | 2 +- .../tests/float_constraint_on_type_test.bal | 8 +- .../tests/int_constraint_on_type_test.bal | 6 +- .../tests/number_constraint_on_type_test.bal | 8 +- .../tests/string_constraint_on_type_test.bal | 8 +- 12 files changed, 147 insertions(+), 147 deletions(-) diff --git a/ballerina/tests/advanced_constraint_test.bal b/ballerina/tests/advanced_constraint_test.bal index 4614e75..6d12cf8 100644 --- a/ballerina/tests/advanced_constraint_test.bal +++ b/ballerina/tests/advanced_constraint_test.bal @@ -542,7 +542,7 @@ int b = 0; type StringA string; @test:Config {} -function testInvalidLengthConstraintOnStringType() { +isolated function testInvalidLengthConstraintOnStringType() { StringA stringA = "s3cr3t"; StringA|error validation = validate(stringA); if validation is error { @@ -562,7 +562,7 @@ type RecordB record { }; @test:Config {} -function testInvalidLengthConstraintOnStringTypeAsRecordField() { +isolated function testInvalidLengthConstraintOnStringTypeAsRecordField() { RecordB recordB = {stringB: "s3cr3t"}; RecordB|error validation = validate(recordB); if validation is error { @@ -580,7 +580,7 @@ type RecordA record { }; @test:Config {} -function testInvalidLengthConstraintOnArrayRecordField() { +isolated function testInvalidLengthConstraintOnArrayRecordField() { RecordA recordA = {arrayA: ["s3cr3t"]}; RecordA|error validation = validate(recordA); if validation is error { @@ -689,7 +689,7 @@ type OrderNew record {| |}; @test:Config {} -function testCustomAnnotationSuccess() { +isolated function testCustomAnnotationSuccess() { OrderNew rec = { id: "1000", productId: "23", @@ -703,7 +703,7 @@ function testCustomAnnotationSuccess() { } @test:Config {} -function testCustomAnnotationFailure() { +isolated function testCustomAnnotationFailure() { OrderNew rec = { id: "1000", productId: "23", @@ -736,7 +736,7 @@ type NickName Name; type Id int:Signed32; @test:Config {} -function testConstraintAnnotationOnSubtypeSuccess1() { +isolated function testConstraintAnnotationOnSubtypeSuccess1() { NickName|error validation = validate("J"); if validation is error { test:assertFail("Unexpected error found."); @@ -744,7 +744,7 @@ function testConstraintAnnotationOnSubtypeSuccess1() { } @test:Config {} -function testConstraintAnnotationOnSubtypeSuccess2() { +isolated function testConstraintAnnotationOnSubtypeSuccess2() { Id|error validation = validate(100); if validation is error { test:assertFail("Unexpected error found."); @@ -752,7 +752,7 @@ function testConstraintAnnotationOnSubtypeSuccess2() { } @test:Config {} -function testConstraintAnnotationOnSubtypeFailure1() { +isolated function testConstraintAnnotationOnSubtypeFailure1() { NickName|error validation = validate("James Maccurdy"); if validation is error { test:assertEquals(validation.message(), "Validation failed for '$:maxLength' constraint(s)."); @@ -762,7 +762,7 @@ function testConstraintAnnotationOnSubtypeFailure1() { } @test:Config {} -function testConstraintAnnotationOnSubtypeFailure2() { +isolated function testConstraintAnnotationOnSubtypeFailure2() { Id|error validation = validate(1001); if validation is error { test:assertEquals(validation.message(), "Validation failed for '$:maxValue' constraint(s)."); @@ -793,7 +793,7 @@ type UserNew record { }; @test:Config {} -function testConstraintAnnotationOnSubtypeAsRecordFieldSuccess() { +isolated function testConstraintAnnotationOnSubtypeAsRecordFieldSuccess() { UserNew user = { id: 1, name: { @@ -810,7 +810,7 @@ function testConstraintAnnotationOnSubtypeAsRecordFieldSuccess() { } @test:Config {} -function testConstraintAnnotationOnSubtypeAsRecordFieldFailure() { +isolated function testConstraintAnnotationOnSubtypeAsRecordFieldFailure() { UserNew user = { id: 1, name: { @@ -836,7 +836,7 @@ type UserDetails record {| |}; @test:Config {} -function testConstraintOnFieldsWithEscapeCharsSuccess() { +isolated function testConstraintOnFieldsWithEscapeCharsSuccess() { UserDetails user = { x\-name: "John Doe", x\-age\$: [18, 19] @@ -848,7 +848,7 @@ function testConstraintOnFieldsWithEscapeCharsSuccess() { } @test:Config {} -function testConstraintOnFieldsWithEscapeCharsFailure() { +isolated function testConstraintOnFieldsWithEscapeCharsFailure() { UserDetails user = { x\-name: "J", x\-age\$: [17, 19, 20, 15] diff --git a/ballerina/tests/constraint_on_array_members_test.bal b/ballerina/tests/constraint_on_array_members_test.bal index 5747d57..49cc982 100644 --- a/ballerina/tests/constraint_on_array_members_test.bal +++ b/ballerina/tests/constraint_on_array_members_test.bal @@ -34,7 +34,7 @@ type App2 record {| type Users User[]; @test:Config {} -function testConstraintsOnArrayBasicMembersSuccess() { +isolated function testConstraintsOnArrayBasicMembersSuccess() { UserId[] ids = ["1234", "4356", "9834", "3214"]; do { ids = check validate(ids); @@ -49,7 +49,7 @@ function testConstraintsOnArrayBasicMembersSuccess() { } @test:Config {} -function testConstraintsOnArrayBasicMembersFailure() { +isolated function testConstraintsOnArrayBasicMembersFailure() { UserId[] ids = ["1234", "43", "9834", "3214"]; do { ids = check validate(ids); @@ -74,7 +74,7 @@ function testConstraintsOnArrayBasicMembersFailure() { } @test:Config {} -function testConstraintsOnRecordFieldArrayMembersSuccess() { +isolated function testConstraintsOnRecordFieldArrayMembersSuccess() { UserId[] ids = ["1234", "4356", "9834", "3214"]; App1|error validation1 = validate({ids: ids}); @@ -89,7 +89,7 @@ function testConstraintsOnRecordFieldArrayMembersSuccess() { } @test:Config {} -function testConstraintsOnRecordFieldArrayMembersFailure() { +isolated function testConstraintsOnRecordFieldArrayMembersFailure() { UserId[] ids = ["1234", "43", "9834", "3214"]; App1|error validation1 = validate({ids: ids}); @@ -108,7 +108,7 @@ function testConstraintsOnRecordFieldArrayMembersFailure() { } @test:Config {} -function testConstraintsOnRecordArrayMemberSuccess() { +isolated function testConstraintsOnRecordArrayMemberSuccess() { User[] users = [ {id: 1, name: "John"}, {id: 2, name: "Joyce"} @@ -127,7 +127,7 @@ function testConstraintsOnRecordArrayMemberSuccess() { } @test:Config {} -function testConstraintsOnRecordArrayMemberFailure() { +isolated function testConstraintsOnRecordArrayMemberFailure() { User[] users = [ {id: 1, name: "John"}, {id: 2, name: "a"} diff --git a/ballerina/tests/constraint_on_readonly_type_test.bal b/ballerina/tests/constraint_on_readonly_type_test.bal index 35e8151..34f4a17 100644 --- a/ballerina/tests/constraint_on_readonly_type_test.bal +++ b/ballerina/tests/constraint_on_readonly_type_test.bal @@ -29,7 +29,7 @@ type ReadOnlyAlbumWithoutConstraints readonly & record {| |}; @test:Config {} -function testReadOnlyAlbumWithoutConstraints() { +isolated function testReadOnlyAlbumWithoutConstraints() { Album album = {title: "Blue Train", artist: "John Coltrane"}; ReadOnlyAlbum|error validation1 = validate(album); if validation1 is error { @@ -75,7 +75,7 @@ type ReadOnlyAlbumWithConstraints readonly & record {| |}; @test:Config {} -function testReadOnlyAlbumWithConstraintsSuccess() { +isolated function testReadOnlyAlbumWithConstraintsSuccess() { Album album = {title: "Jeru", artist: "Gerry Mulligan"}; ReadOnlyConstrainedAlbum|error validation1 = validate(album); if validation1 is error { @@ -101,7 +101,7 @@ function testReadOnlyAlbumWithConstraintsSuccess() { } @test:Config {} -function testReadOnlyAlbumWithConstraintsFailure() { +isolated function testReadOnlyAlbumWithConstraintsFailure() { Album album = {title: "Blue Train", artist: "John Coltrane"}; ReadOnlyConstrainedAlbum|error validation1 = validate(album); if validation1 is error { @@ -143,7 +143,7 @@ type AlbumWithReadOnlyConstraints record {| |}; @test:Config {} -function testAlbumWithReadOnlyConstraintsSuccess() { +isolated function testAlbumWithReadOnlyConstraintsSuccess() { Album album = {title: "Jeru", artist: "Gerry Mulligan"}; AlbumWithReadOnlyConstraints|error validation = validate(album); if validation is error { @@ -152,7 +152,7 @@ function testAlbumWithReadOnlyConstraintsSuccess() { } @test:Config {} -function testAlbumWithReadOnlyConstraintsFailure() { +isolated function testAlbumWithReadOnlyConstraintsFailure() { Album album = {title: "Blue Train", artist: "John Coltrane"}; AlbumWithReadOnlyConstraints|error validation = validate(album); if validation is error { @@ -174,7 +174,7 @@ type ReadOnlyAlbumWithConstraintType readonly & record {| |}; @test:Config {} -function testReadOnlyAlbumWithConstraintTypeSuccess() { +isolated function testReadOnlyAlbumWithConstraintTypeSuccess() { Album album = {title: "Jeru", artist: "Gerry Mulligan"}; ReadOnlyAlbumWithConstraintType|error validation = validate(album); if validation is error { @@ -183,7 +183,7 @@ function testReadOnlyAlbumWithConstraintTypeSuccess() { } @test:Config {} -function testReadOnlyAlbumWithConstraintTypeFailure() { +isolated function testReadOnlyAlbumWithConstraintTypeFailure() { Album album = {title: "Blue Train", artist: "John Coltrane"}; ReadOnlyAlbumWithConstraintType|error validation = validate(album); if validation is error { @@ -205,7 +205,7 @@ type AlbumWithReadOnlyConstraintType record {| |}; @test:Config {} -function testAlbumWithReadOnlyConstraintTypeSuccess() { +isolated function testAlbumWithReadOnlyConstraintTypeSuccess() { Album album = {title: "Jeru", artist: "Gerry Mulligan"}; AlbumWithReadOnlyConstraintType|error validation = validate(album); if validation is error { @@ -214,7 +214,7 @@ function testAlbumWithReadOnlyConstraintTypeSuccess() { } @test:Config {} -function testAlbumWithReadOnlyConstraintTypeFailure() { +isolated function testAlbumWithReadOnlyConstraintTypeFailure() { Album album = {title: "Blue Train", artist: "John Coltrane"}; AlbumWithReadOnlyConstraintType|error validation = validate(album); if validation is error { @@ -237,7 +237,7 @@ type Artist record {| |}; @test:Config {} -function testArtistSuccess() { +isolated function testArtistSuccess() { Artist artist = { name: "Gerry Mulligan", rating: 4, @@ -253,7 +253,7 @@ function testArtistSuccess() { } @test:Config {} -function testArtistFailure() { +isolated function testArtistFailure() { Artist artist = { name: "John Coltrane", rating: 4, @@ -273,7 +273,7 @@ function testArtistFailure() { type ReadOnlyArtist readonly & Artist; @test:Config {} -function testReadOnlyArtistSuccess() { +isolated function testReadOnlyArtistSuccess() { Artist artist = { name: "Gerry Mulligan", rating: 4, @@ -301,7 +301,7 @@ function testReadOnlyArtistSuccess() { } @test:Config {} -function testReadOnlyArtistFailure1() { +isolated function testReadOnlyArtistFailure1() { Artist artist = { name: "Gerry Mulligan", rating: 10, @@ -334,7 +334,7 @@ function testReadOnlyArtistFailure1() { } @test:Config {} -function testReadOnlyArtistFailure2() { +isolated function testReadOnlyArtistFailure2() { Artist artist = { name: "John Coltrane", rating: 10, diff --git a/ballerina/tests/constraint_validation_return_type_test.bal b/ballerina/tests/constraint_validation_return_type_test.bal index c63e250..a93fb08 100644 --- a/ballerina/tests/constraint_validation_return_type_test.bal +++ b/ballerina/tests/constraint_validation_return_type_test.bal @@ -25,7 +25,7 @@ type User record {| |}; @test:Config {} -function testValidationWithCloneWithTypeSuccess1() { +isolated function testValidationWithCloneWithTypeSuccess1() { json rec = {"id": 1, "name": "Joy"}; User|error validation = validate(rec); if validation is error { @@ -38,7 +38,7 @@ function testValidationWithCloneWithTypeSuccess1() { } @test:Config {} -function testValidationWithCloneWithTypeSuccess2() { +isolated function testValidationWithCloneWithTypeSuccess2() { json rec = {"id": 1, "name": "Joy"}; do { User validation = check validate(rec); @@ -51,7 +51,7 @@ function testValidationWithCloneWithTypeSuccess2() { } @test:Config {} -function testValidationWithCloneWithTypeFailure1() { +isolated function testValidationWithCloneWithTypeFailure1() { json rec = {"id": 1, "username": "Joy"}; User|error validation = validate(rec); if validation is error { @@ -62,7 +62,7 @@ function testValidationWithCloneWithTypeFailure1() { } @test:Config {} -function testValidationWithCloneWithTypeFailure2() { +isolated function testValidationWithCloneWithTypeFailure2() { json rec = {"id": 1, "username": "Joy"}; do { User _ = check validate(rec); @@ -73,7 +73,7 @@ function testValidationWithCloneWithTypeFailure2() { } @test:Config {} -function testValidationWithoutCloneSuccess1() { +isolated function testValidationWithoutCloneSuccess1() { User rec = {"id": 1, "name": "Joy"}; User|error validation = validate(rec); if validation is error { @@ -86,7 +86,7 @@ function testValidationWithoutCloneSuccess1() { } @test:Config {} -function testValidationWithoutCloneSuccess2() { +isolated function testValidationWithoutCloneSuccess2() { User rec = {"id": 1, "name": "Joy"}; do { User validation = check validate(rec); diff --git a/ballerina/tests/constriant_error_message_test.bal b/ballerina/tests/constriant_error_message_test.bal index 65fa242..babc5fc 100644 --- a/ballerina/tests/constriant_error_message_test.bal +++ b/ballerina/tests/constriant_error_message_test.bal @@ -34,7 +34,7 @@ import ballerina/time; type TraineeName string; @test:Config {} -function testErrorMessageInStringType() { +isolated function testErrorMessageInStringType() { TraineeName str = "abc"; TraineeName|error validation = validate(str); if validation is error { @@ -79,7 +79,7 @@ function testErrorMessageInStringType() { type DateOfBirth time:Date; @test:Config {} -function testErrorMessageInDateType() { +isolated function testErrorMessageInDateType() { DateOfBirth dob = { year: 2055, month: 10, @@ -161,7 +161,7 @@ const Trainee TRAINEE = { }; @test:Config {} -function testErrorMessageInRecordTypePositive() returns error? { +isolated function testErrorMessageInRecordTypePositive() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); Trainee|error validation = validate(trainee); if validation is error { @@ -172,7 +172,7 @@ function testErrorMessageInRecordTypePositive() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative1() returns error? { +isolated function testErrorMessageInRecordTypeNegative1() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.TraineeName = "abc"; Trainee|error validation = validate(trainee); @@ -192,7 +192,7 @@ function testErrorMessageInRecordTypeNegative1() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative2() returns error? { +isolated function testErrorMessageInRecordTypeNegative2() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.dob = { year: 2055, @@ -208,7 +208,7 @@ function testErrorMessageInRecordTypeNegative2() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative3() returns error? { +isolated function testErrorMessageInRecordTypeNegative3() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.weight = -50.5; Trainee|error validation = validate(trainee); @@ -220,7 +220,7 @@ function testErrorMessageInRecordTypeNegative3() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative4() returns error? { +isolated function testErrorMessageInRecordTypeNegative4() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.height = -150.5; Trainee|error validation = validate(trainee); @@ -232,7 +232,7 @@ function testErrorMessageInRecordTypeNegative4() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative5() returns error? { +isolated function testErrorMessageInRecordTypeNegative5() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.dateOfJoining = { year: 2022, @@ -248,7 +248,7 @@ function testErrorMessageInRecordTypeNegative5() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative6() returns error? { +isolated function testErrorMessageInRecordTypeNegative6() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.badges = ["badge1", "badge2", "badge3", "badge4", "badge5", "badge6"]; Trainee|error validation = validate(trainee); @@ -260,7 +260,7 @@ function testErrorMessageInRecordTypeNegative6() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeNegative7() returns error? { +isolated function testErrorMessageInRecordTypeNegative7() returns error? { Trainee trainee = check TRAINEE.cloneWithType(); trainee.badges = ["badge1", "badge2", "bad"]; Trainee|error validation = validate(trainee); @@ -272,7 +272,7 @@ function testErrorMessageInRecordTypeNegative7() returns error? { } @test:Config {} -function testErrorMessageInRecordTypeAllNegative() { +isolated function testErrorMessageInRecordTypeAllNegative() { Trainee trainee = { TraineeName: "abc", dob: { @@ -321,7 +321,7 @@ type Trainee0 record {| |}; @test:Config {} -function testErrorMessageInMixedRecordTypePositive() returns error? { +isolated function testErrorMessageInMixedRecordTypePositive() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); Trainee0|error validation = validate(trainee); if validation is error { @@ -332,7 +332,7 @@ function testErrorMessageInMixedRecordTypePositive() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative1() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative1() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.TraineeName = "abc"; Trainee0|error validation = validate(trainee); @@ -352,7 +352,7 @@ function testErrorMessageInMixedRecordTypeNegative1() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative2() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative2() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.dob = { year: 2055, @@ -368,7 +368,7 @@ function testErrorMessageInMixedRecordTypeNegative2() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative3() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative3() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.weight = -50.5; Trainee0|error validation = validate(trainee); @@ -380,7 +380,7 @@ function testErrorMessageInMixedRecordTypeNegative3() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative4() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative4() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.height = -150.5; Trainee0|error validation = validate(trainee); @@ -392,7 +392,7 @@ function testErrorMessageInMixedRecordTypeNegative4() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative5() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative5() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.height = 300; Trainee0|error validation = validate(trainee); @@ -404,7 +404,7 @@ function testErrorMessageInMixedRecordTypeNegative5() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative6() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative6() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.dateOfJoining = { year: 2022, @@ -420,7 +420,7 @@ function testErrorMessageInMixedRecordTypeNegative6() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeNegative7() returns error? { +isolated function testErrorMessageInMixedRecordTypeNegative7() returns error? { Trainee0 trainee = check TRAINEE.cloneWithType(); trainee.badges = ["badge1", "badge2", "bad"]; Trainee0|error validation = validate(trainee); @@ -432,7 +432,7 @@ function testErrorMessageInMixedRecordTypeNegative7() returns error? { } @test:Config {} -function testErrorMessageInMixedRecordTypeAllNegative() { +isolated function testErrorMessageInMixedRecordTypeAllNegative() { Trainee0 trainee = { TraineeName: "abc", dob: { diff --git a/ballerina/tests/date_constraint_on_record_field_test.bal b/ballerina/tests/date_constraint_on_record_field_test.bal index ddb96fc..36521bf 100644 --- a/ballerina/tests/date_constraint_on_record_field_test.bal +++ b/ballerina/tests/date_constraint_on_record_field_test.bal @@ -23,7 +23,7 @@ type NoDateConstraintsOnRecordField record { }; @test:Config {} -function testNoDateConstraintsOnRecordField() { +isolated function testNoDateConstraintsOnRecordField() { NoDateConstraintsOnRecordField rec = { name: "John", dob: { @@ -72,7 +72,7 @@ type SimpleDateConstraintOnRecordField record { }; @test:Config {} -function testSimpleDateConstraintOnRecordFieldSuccess1() { +isolated function testSimpleDateConstraintOnRecordFieldSuccess1() { SimpleDateConstraintOnRecordField rec = { name: "John", dob: { @@ -90,7 +90,7 @@ function testSimpleDateConstraintOnRecordFieldSuccess1() { } @test:Config {} -function testSimpleDateConstraintOnRecordFieldSuccess2() { +isolated function testSimpleDateConstraintOnRecordFieldSuccess2() { SimpleDateConstraintOnRecordField rec = { name: "Alexander the Great", dob: { @@ -108,7 +108,7 @@ function testSimpleDateConstraintOnRecordFieldSuccess2() { } @test:Config {} -function testSimpleDateConstraintOnRecordFieldSuccess3() { +isolated function testSimpleDateConstraintOnRecordFieldSuccess3() { SimpleDateConstraintOnRecordField rec = { name: "Alex", dob: time:utcToCivil(time:utcNow()) @@ -122,7 +122,7 @@ function testSimpleDateConstraintOnRecordFieldSuccess3() { } @test:Config {} -function testSimpleDateConstraintOnRecordFieldFailure1() { +isolated function testSimpleDateConstraintOnRecordFieldFailure1() { SimpleDateConstraintOnRecordField rec = { name: "John", dob: { @@ -140,7 +140,7 @@ function testSimpleDateConstraintOnRecordFieldFailure1() { } @test:Config {} -function testSimpleDateConstraintOnRecordFieldFailure2() { +isolated function testSimpleDateConstraintOnRecordFieldFailure2() { SimpleDateConstraintOnRecordField rec = { name: "John", dob: { @@ -166,7 +166,7 @@ type PastDateConstraintOnRecordField record { }; @test:Config {} -function testPastDateConstraintOnRecordFieldSuccess1() { +isolated function testPastDateConstraintOnRecordFieldSuccess1() { PastDateConstraintOnRecordField rec = { name: "John", dob: { @@ -184,7 +184,7 @@ function testPastDateConstraintOnRecordFieldSuccess1() { } @test:Config {} -function testPastDateConstraintOnRecordFieldSuccess2() { +isolated function testPastDateConstraintOnRecordFieldSuccess2() { PastDateConstraintOnRecordField rec = { name: "Alexander the Great", dob: { @@ -202,7 +202,7 @@ function testPastDateConstraintOnRecordFieldSuccess2() { } @test:Config {} -function testPastDateConstraintOnRecordFieldFailure1() { +isolated function testPastDateConstraintOnRecordFieldFailure1() { PastDateConstraintOnRecordField rec = { name: "John", dob: time:utcToCivil(time:utcNow()) @@ -216,7 +216,7 @@ function testPastDateConstraintOnRecordFieldFailure1() { } @test:Config {} -function testPastDateConstraintOnRecordFieldFailure2() { +isolated function testPastDateConstraintOnRecordFieldFailure2() { PastDateConstraintOnRecordField rec = { name: "John", dob: { @@ -242,7 +242,7 @@ type FutureOrPresentDateConstraintOnRecordField record { }; @test:Config {} -function testFutureOrPresentDateConstraintOnRecordFieldSuccess1() { +isolated function testFutureOrPresentDateConstraintOnRecordFieldSuccess1() { FutureOrPresentDateConstraintOnRecordField rec = { name: "John", dob: time:utcToCivil(time:utcNow()) @@ -256,7 +256,7 @@ function testFutureOrPresentDateConstraintOnRecordFieldSuccess1() { } @test:Config {} -function testFutureOrPresentDateConstraintOnRecordFieldSuccess2() { +isolated function testFutureOrPresentDateConstraintOnRecordFieldSuccess2() { FutureOrPresentDateConstraintOnRecordField rec = { name: "Alex", dob: { @@ -274,7 +274,7 @@ function testFutureOrPresentDateConstraintOnRecordFieldSuccess2() { } @test:Config {} -function testFutureOrPresentDateConstraintOnRecordFieldFailure1() { +isolated function testFutureOrPresentDateConstraintOnRecordFieldFailure1() { FutureOrPresentDateConstraintOnRecordField rec = { name: "John", dob: { @@ -292,7 +292,7 @@ function testFutureOrPresentDateConstraintOnRecordFieldFailure1() { } @test:Config {} -function testFutureOrPresentDateConstraintOnRecordFieldFailure2() { +isolated function testFutureOrPresentDateConstraintOnRecordFieldFailure2() { FutureOrPresentDateConstraintOnRecordField rec = { name: "Alexander the Great", dob: { @@ -325,7 +325,7 @@ type DateConstraintOnRecordRecordField record { }; @test:Config {} -function testDateConstraintOnRecordRecordFieldSuccess1() { +isolated function testDateConstraintOnRecordRecordFieldSuccess1() { DateConstraintOnRecordRecordField rec = { name: "John", dob: { @@ -343,7 +343,7 @@ function testDateConstraintOnRecordRecordFieldSuccess1() { } @test:Config {} -function testDateConstraintOnRecordRecordFieldSuccess2() { +isolated function testDateConstraintOnRecordRecordFieldSuccess2() { time:Date today = time:utcToCivil(time:utcNow()); DateConstraintOnRecordRecordField rec = { name: "Alexander the Great", @@ -362,7 +362,7 @@ function testDateConstraintOnRecordRecordFieldSuccess2() { } @test:Config {} -function testDateConstraintOnRecordRecordFieldFailure1() { +isolated function testDateConstraintOnRecordRecordFieldFailure1() { DateConstraintOnRecordRecordField rec = { name: "John", dob: { @@ -380,7 +380,7 @@ function testDateConstraintOnRecordRecordFieldFailure1() { } @test:Config {} -function testDateConstraintOnRecordRecordFieldFailure2() { +isolated function testDateConstraintOnRecordRecordFieldFailure2() { DateConstraintOnRecordRecordField rec = { name: "Alex", dob: { @@ -398,7 +398,7 @@ function testDateConstraintOnRecordRecordFieldFailure2() { } @test:Config {} -function testDateConstraintOnRecordRecordFieldFailure3() { +isolated function testDateConstraintOnRecordRecordFieldFailure3() { DateConstraintOnRecordRecordField rec = { name: "George", dob: { @@ -416,7 +416,7 @@ function testDateConstraintOnRecordRecordFieldFailure3() { } @test:Config {} -function testDateConstraintOnRecordRecordFieldFailure4() { +isolated function testDateConstraintOnRecordRecordFieldFailure4() { DateConstraintOnRecordRecordField rec = { name: "David", dob: { @@ -448,7 +448,7 @@ type DateConstraintOnTypedRecordField record { }; @test:Config {} -function testDateConstraintOnTypedRecordFieldSuccess1() { +isolated function testDateConstraintOnTypedRecordFieldSuccess1() { DateConstraintOnTypedRecordField rec = { name: "John", dob: { @@ -466,7 +466,7 @@ function testDateConstraintOnTypedRecordFieldSuccess1() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldSuccess2() { +isolated function testDateConstraintOnTypedRecordFieldSuccess2() { time:Date yesterday = time:utcToCivil(time:utcAddSeconds(time:utcNow(), -86400)); DateConstraintOnTypedRecordField rec = { name: "Alex", @@ -481,7 +481,7 @@ function testDateConstraintOnTypedRecordFieldSuccess2() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldFailure1() { +isolated function testDateConstraintOnTypedRecordFieldFailure1() { DateConstraintOnTypedRecordField rec = { name: "John", dob: { @@ -499,7 +499,7 @@ function testDateConstraintOnTypedRecordFieldFailure1() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldFailure2() { +isolated function testDateConstraintOnTypedRecordFieldFailure2() { DateConstraintOnTypedRecordField rec = { name: "Alex", dob: { @@ -517,7 +517,7 @@ function testDateConstraintOnTypedRecordFieldFailure2() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldFailure3() { +isolated function testDateConstraintOnTypedRecordFieldFailure3() { time:Date tomorrow = time:utcToCivil(time:utcAddSeconds(time:utcNow(), 86400)); DateConstraintOnTypedRecordField rec = { name: "George", @@ -532,7 +532,7 @@ function testDateConstraintOnTypedRecordFieldFailure3() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldFailure4() { +isolated function testDateConstraintOnTypedRecordFieldFailure4() { time:Date today = time:utcToCivil(time:utcNow()); DateConstraintOnTypedRecordField rec = { name: "David", @@ -566,7 +566,7 @@ type DateConstraintOnTypedRecordFieldWithCustomValidDate record { }; @test:Config {} -function testDateConstraintOnTypedRecordFieldWithCustomValidDateSuccess() { +isolated function testDateConstraintOnTypedRecordFieldWithCustomValidDateSuccess() { DateConstraintOnTypedRecordFieldWithCustomValidDate rec = { name: "John", dob: { @@ -584,7 +584,7 @@ function testDateConstraintOnTypedRecordFieldWithCustomValidDateSuccess() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure1() { +isolated function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure1() { DateConstraintOnTypedRecordFieldWithCustomValidDate rec = { name: "John", dob: { @@ -602,7 +602,7 @@ function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure1() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure2() { +isolated function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure2() { DateConstraintOnTypedRecordFieldWithCustomValidDate rec = { name: "John", dob: { @@ -620,7 +620,7 @@ function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure2() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure3() { +isolated function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure3() { time:Date tomorrow = time:utcToCivil(time:utcAddSeconds(time:utcNow(), 86400)); DateConstraintOnTypedRecordFieldWithCustomValidDate rec = { name: "John", @@ -635,7 +635,7 @@ function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure3() { } @test:Config {} -function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure4() { +isolated function testDateConstraintOnTypedRecordFieldWithCustomValidDateFailure4() { DateConstraintOnTypedRecordFieldWithCustomValidDate rec = { name: "John", dob: { diff --git a/ballerina/tests/date_constraint_on_type_test.bal b/ballerina/tests/date_constraint_on_type_test.bal index 7514297..f26e45e 100644 --- a/ballerina/tests/date_constraint_on_type_test.bal +++ b/ballerina/tests/date_constraint_on_type_test.bal @@ -20,7 +20,7 @@ import ballerina/test; type NoDateConstraintOnTimeDateType time:Date; @test:Config {} -function testNoDateConstraintsOnType() { +isolated function testNoDateConstraintsOnType() { NoDateConstraintOnTimeDateType date = { year: 2018, month: 10, @@ -46,7 +46,7 @@ function testNoDateConstraintsOnType() { type DateConstraintSimpleOnTimeDateType time:Date; @test:Config {} -function testDateConstraintSimpleOnTypeSuccess1() { +isolated function testDateConstraintSimpleOnTypeSuccess1() { DateConstraintSimpleOnTimeDateType date = { year: 2018, month: 10, @@ -61,7 +61,7 @@ function testDateConstraintSimpleOnTypeSuccess1() { } @test:Config {} -function testDateConstraintSimpleOnTypeSuccess2() { +isolated function testDateConstraintSimpleOnTypeSuccess2() { DateConstraintSimpleOnTimeDateType date = { year: -2018, // BC year month: 1, @@ -76,7 +76,7 @@ function testDateConstraintSimpleOnTypeSuccess2() { } @test:Config {} -function testDateConstraintSimpleOnTypeSuccess3() { +isolated function testDateConstraintSimpleOnTypeSuccess3() { DateConstraintSimpleOnTimeDateType date = { year: 2016, // leap year month: 2, @@ -91,7 +91,7 @@ function testDateConstraintSimpleOnTypeSuccess3() { } @test:Config {} -function testDateConstraintSimpleOnTypeFailure1() { +isolated function testDateConstraintSimpleOnTypeFailure1() { DateConstraintSimpleOnTimeDateType date = { year: 2018, month: 10, @@ -106,7 +106,7 @@ function testDateConstraintSimpleOnTypeFailure1() { } @test:Config {} -function testDateConstraintSimpleOnTypeFailure2() { +isolated function testDateConstraintSimpleOnTypeFailure2() { DateConstraintSimpleOnTimeDateType date = { year: 2018, month: 15, @@ -121,7 +121,7 @@ function testDateConstraintSimpleOnTypeFailure2() { } @test:Config {} -function testDateConstraintSimpleOnTypeFailure3() { +isolated function testDateConstraintSimpleOnTypeFailure3() { DateConstraintSimpleOnTimeDateType date = { year: 1000000000, // limit is 999999999 month: 1, @@ -136,7 +136,7 @@ function testDateConstraintSimpleOnTypeFailure3() { } @test:Config {} -function testDateConstraintSimpleOnTypeFailure4() { +isolated function testDateConstraintSimpleOnTypeFailure4() { DateConstraintSimpleOnTimeDateType date = { year: 2022, month: 6, @@ -151,7 +151,7 @@ function testDateConstraintSimpleOnTypeFailure4() { } @test:Config {} -function testDateConstraintSimpleOnTypeFailure5() { +isolated function testDateConstraintSimpleOnTypeFailure5() { DateConstraintSimpleOnTimeDateType date = { year: 2022, month: 2, @@ -166,7 +166,7 @@ function testDateConstraintSimpleOnTypeFailure5() { } @test:Config {} -function testDateConstraintSimpleOnTypeMultipleFailure1() { +isolated function testDateConstraintSimpleOnTypeMultipleFailure1() { DateConstraintSimpleOnTimeDateType date = { year: 2022, month: 20, @@ -181,7 +181,7 @@ function testDateConstraintSimpleOnTypeMultipleFailure1() { } @test:Config {} -function testDateConstraintSimpleOnTypeMultipleFailure2() { +isolated function testDateConstraintSimpleOnTypeMultipleFailure2() { DateConstraintSimpleOnTimeDateType date = { year: 1000000000000000, // Arithmetic overflow for java:Integer month: 12, @@ -196,7 +196,7 @@ function testDateConstraintSimpleOnTypeMultipleFailure2() { } @test:Config {} -function testDateConstraintSimpleOnTypeMultipleFailure3() { +isolated function testDateConstraintSimpleOnTypeMultipleFailure3() { DateConstraintSimpleOnTimeDateType date = { year: 1000000000, month: 0, @@ -216,7 +216,7 @@ function testDateConstraintSimpleOnTypeMultipleFailure3() { type DateConstraintPastOnTimeDateType time:Date; @test:Config {} -function testDateConstraintPastOnTypeSuccess1() { +isolated function testDateConstraintPastOnTypeSuccess1() { DateConstraintPastOnTimeDateType date = { year: 2018, month: 10, @@ -231,7 +231,7 @@ function testDateConstraintPastOnTypeSuccess1() { } @test:Config {} -function testDateConstraintPastOnTypeSuccess2() { +isolated function testDateConstraintPastOnTypeSuccess2() { DateConstraintPastOnTimeDateType date = { year: -2018, // BC year month: 1, @@ -246,7 +246,7 @@ function testDateConstraintPastOnTypeSuccess2() { } @test:Config {} -function testDateConstraintPastOnTypeSuccess3() { +isolated function testDateConstraintPastOnTypeSuccess3() { time:Utc utcNow = time:utcNow(); // Decrement by a day DateConstraintPastOnTimeDateType date = time:utcToCivil(time:utcAddSeconds(utcNow, -86400)); @@ -259,7 +259,7 @@ function testDateConstraintPastOnTypeSuccess3() { } @test:Config {} -function testDateConstraintPastOnTypeFailure1() { +isolated function testDateConstraintPastOnTypeFailure1() { DateConstraintPastOnTimeDateType date = { year: 10000, month: 10, @@ -274,7 +274,7 @@ function testDateConstraintPastOnTypeFailure1() { } @test:Config {} -function testDateConstraintPastOnTypeFailure2() { +isolated function testDateConstraintPastOnTypeFailure2() { DateConstraintPastOnTimeDateType date = time:utcToCivil(time:utcNow()); DateConstraintPastOnTimeDateType|error validation = validate(date); if validation is error { @@ -285,7 +285,7 @@ function testDateConstraintPastOnTypeFailure2() { } @test:Config {} -function testDateConstraintPastOnTypeFailure3() { +isolated function testDateConstraintPastOnTypeFailure3() { time:Utc utcNow = time:utcNow(); // Increment by a day from today DateConstraintPastOnTimeDateType date = time:utcToCivil(time:utcAddSeconds(utcNow, 86640)); @@ -303,7 +303,7 @@ function testDateConstraintPastOnTypeFailure3() { type DateConstraintFutureOnTimeDateType time:Date; @test:Config {} -function testDateConstraintFutureOnTypeSuccess1() { +isolated function testDateConstraintFutureOnTypeSuccess1() { DateConstraintFutureOnTimeDateType date = { year: 10000, month: 10, @@ -318,7 +318,7 @@ function testDateConstraintFutureOnTypeSuccess1() { } @test:Config {} -function testDateConstraintFutureOnTypeSuccess2() { +isolated function testDateConstraintFutureOnTypeSuccess2() { time:Utc utcNow = time:utcNow(); // Increment by a day from today DateConstraintFutureOnTimeDateType date = time:utcToCivil(time:utcAddSeconds(utcNow, 86640)); @@ -331,7 +331,7 @@ function testDateConstraintFutureOnTypeSuccess2() { } @test:Config {} -function testDateConstraintFutureOnTypeFailure1() { +isolated function testDateConstraintFutureOnTypeFailure1() { DateConstraintFutureOnTimeDateType date = { year: 2018, month: 10, @@ -346,7 +346,7 @@ function testDateConstraintFutureOnTypeFailure1() { } @test:Config {} -function testDateConstraintFutureOnTypeFailure2() { +isolated function testDateConstraintFutureOnTypeFailure2() { DateConstraintFutureOnTimeDateType date = time:utcToCivil(time:utcNow()); DateConstraintFutureOnTimeDateType|error validation = validate(date); if validation is error { @@ -362,7 +362,7 @@ function testDateConstraintFutureOnTypeFailure2() { type DateConstraintPastOrPresentOnTimeDateType time:Date; @test:Config {} -function testDateConstraintPastOrPresentOnTypeSuccess1() { +isolated function testDateConstraintPastOrPresentOnTypeSuccess1() { DateConstraintPastOrPresentOnTimeDateType date = { year: 2018, month: 10, @@ -377,7 +377,7 @@ function testDateConstraintPastOrPresentOnTypeSuccess1() { } @test:Config {} -function testDateConstraintPastOrPresentOnTypeSuccess2() { +isolated function testDateConstraintPastOrPresentOnTypeSuccess2() { DateConstraintPastOrPresentOnTimeDateType date = time:utcToCivil(time:utcNow()); DateConstraintPastOrPresentOnTimeDateType|error validation = validate(date); if validation is error { @@ -388,7 +388,7 @@ function testDateConstraintPastOrPresentOnTypeSuccess2() { } @test:Config {} -function testDateConstraintPastOrPresentOnTypeFailure1() { +isolated function testDateConstraintPastOrPresentOnTypeFailure1() { DateConstraintPastOrPresentOnTimeDateType date = { year: 10000, month: 1, @@ -403,7 +403,7 @@ function testDateConstraintPastOrPresentOnTypeFailure1() { } @test:Config {} -function testDateConstraintPastOrPresentOnTypeFailure2() { +isolated function testDateConstraintPastOrPresentOnTypeFailure2() { time:Utc utcNow = time:utcNow(); // Increment by a day from today DateConstraintPastOrPresentOnTimeDateType date = time:utcToCivil(time:utcAddSeconds(utcNow, 86640)); @@ -421,7 +421,7 @@ function testDateConstraintPastOrPresentOnTypeFailure2() { type DateConstraintFutureOrPresentOnTimeDateType time:Date; @test:Config {} -function testDateConstraintFutureOrPresentOnTypeSuccess1() { +isolated function testDateConstraintFutureOrPresentOnTypeSuccess1() { DateConstraintFutureOrPresentOnTimeDateType date = { year: 10000, month: 1, @@ -436,7 +436,7 @@ function testDateConstraintFutureOrPresentOnTypeSuccess1() { } @test:Config {} -function testDateConstraintFutureOrPresentOnTypeSuccess2() { +isolated function testDateConstraintFutureOrPresentOnTypeSuccess2() { DateConstraintFutureOrPresentOnTimeDateType date = time:utcToCivil(time:utcNow()); DateConstraintFutureOrPresentOnTimeDateType|error validation = validate(date); if validation is error { @@ -447,7 +447,7 @@ function testDateConstraintFutureOrPresentOnTypeSuccess2() { } @test:Config {} -function testDateConstraintFutureOrPresentOnTypeSuccess3() { +isolated function testDateConstraintFutureOrPresentOnTypeSuccess3() { time:Utc utcNow = time:utcNow(); // Increment by a day from today DateConstraintFutureOrPresentOnTimeDateType date = time:utcToCivil(time:utcAddSeconds(utcNow, 86640)); @@ -460,7 +460,7 @@ function testDateConstraintFutureOrPresentOnTypeSuccess3() { } @test:Config {} -function testDateConstraintFutureOrPresentOnTypeFailure() { +isolated function testDateConstraintFutureOrPresentOnTypeFailure() { DateConstraintFutureOrPresentOnTimeDateType date = { year: 2018, month: 10, @@ -482,7 +482,7 @@ type DateSimple record {| |}; @test:Config {} -function testDateSimpleSuccess() { +isolated function testDateSimpleSuccess() { DateSimple date = { year: 2018, month: 10, @@ -497,7 +497,7 @@ function testDateSimpleSuccess() { } @test:Config {} -function testDateSimpleFailure() { +isolated function testDateSimpleFailure() { DateSimple date = { year: 2018, month: 10, @@ -521,7 +521,7 @@ type DatePast record {| |}; @test:Config {} -function testDatePastSuccess() { +isolated function testDatePastSuccess() { DatePast date = { year: 2018, month: 1, @@ -536,7 +536,7 @@ function testDatePastSuccess() { } @test:Config {} -function testDatePastFailure() { +isolated function testDatePastFailure() { DatePast date = { year: 10000, month: 10, @@ -563,7 +563,7 @@ type DateFuture record {| |}; @test:Config {} -function testDateFutureSuccess() { +isolated function testDateFutureSuccess() { DateFuture date = { year: 2500, month: 1, @@ -578,7 +578,7 @@ function testDateFutureSuccess() { } @test:Config {} -function testDateFutureFailure1() { +isolated function testDateFutureFailure1() { DateFuture date = { year: 10000, month: 10, @@ -593,7 +593,7 @@ function testDateFutureFailure1() { } @test:Config {} -function testDateFutureFailure2() { +isolated function testDateFutureFailure2() { DateFuture date = { year: 2000, month: 10, @@ -620,7 +620,7 @@ type DatePastOrPresent record { }; @test:Config {} -function testDatePastOrPresentSuccess1() { +isolated function testDatePastOrPresentSuccess1() { DatePastOrPresent date = time:utcToCivil(time:utcNow()); DatePastOrPresent|error validation = validate(date); if validation is error { @@ -631,7 +631,7 @@ function testDatePastOrPresentSuccess1() { } @test:Config {} -function testDatePastOrPresentSuccess2() { +isolated function testDatePastOrPresentSuccess2() { DatePastOrPresent date = { year: 1980, month: 1, @@ -646,7 +646,7 @@ function testDatePastOrPresentSuccess2() { } @test:Config {} -function testDatePastOrPresentFailure1() { +isolated function testDatePastOrPresentFailure1() { DatePastOrPresent date = { year: 100, month: 10, @@ -661,7 +661,7 @@ function testDatePastOrPresentFailure1() { } @test:Config {} -function testDatePastOrPresentFailure2() { +isolated function testDatePastOrPresentFailure2() { DatePastOrPresent date = { year: 3000, month: 10, diff --git a/ballerina/tests/example_constraint_test.bal b/ballerina/tests/example_constraint_test.bal index 3319ffe..cf23a8c 100644 --- a/ballerina/tests/example_constraint_test.bal +++ b/ballerina/tests/example_constraint_test.bal @@ -503,7 +503,7 @@ isolated function testSampleFailure11() returns error? { } @test:Config {} -function testSampleFailure12() returns error? { +isolated function testSampleFailure12() returns error? { Order rec = check SAMPLE_PAYLOAD.cloneWithType(); rec.phone = "1234abcd90"; rec.email = "invalid_email?address@"; diff --git a/ballerina/tests/float_constraint_on_type_test.bal b/ballerina/tests/float_constraint_on_type_test.bal index 681360b..8c5fd4b 100644 --- a/ballerina/tests/float_constraint_on_type_test.bal +++ b/ballerina/tests/float_constraint_on_type_test.bal @@ -231,7 +231,7 @@ isolated function testFloatConstraintOnTypeFailure2() { type MaxDigitFloatType float; @test:Config {} -function testMaxDigitFloatPositive() { +isolated function testMaxDigitFloatPositive() { MaxDigitFloatType|error validation = validate(12934.8065); if validation is error { test:assertFail("Unexpected error found."); @@ -346,7 +346,7 @@ function testMaxDigitFloatPositive() { } @test:Config {} -function testMaxDigitFloatNegative() { +isolated function testMaxDigitFloatNegative() { MaxDigitFloatType|error validation = validate(1234567.435); if validation is error { test:assertEquals(validation.message(), "Validation failed for '$:maxIntegerDigits' constraint(s)."); @@ -415,7 +415,7 @@ type DigitFloat float; type MaxIntegerDigitFloatRefType DigitFloat; @test:Config {} -function testMaxIntegerDigitsRefType() { +isolated function testMaxIntegerDigitsRefType() { MaxIntegerDigitFloatRefType|error validation = validate(-1234.12345); if validation is error { test:assertFail("Unexpected error found."); @@ -454,7 +454,7 @@ function testMaxIntegerDigitsRefType() { type MaxFractionDigitFloatRefType DigitFloat; @test:Config {} -function testMaxFractionDigitsRefType() { +isolated function testMaxFractionDigitsRefType() { MaxFractionDigitFloatRefType|error validation = validate(1234.12); if validation is error { test:assertFail("Unexpected error found."); diff --git a/ballerina/tests/int_constraint_on_type_test.bal b/ballerina/tests/int_constraint_on_type_test.bal index 6abe25a..8962eb9 100644 --- a/ballerina/tests/int_constraint_on_type_test.bal +++ b/ballerina/tests/int_constraint_on_type_test.bal @@ -230,7 +230,7 @@ isolated function testIntConstraintOnTypeFailure2() { type MaxDigitIntType int; @test:Config {} -function testMaxDigitIntPositive() { +isolated function testMaxDigitIntPositive() { MaxDigitIntType|error validation = validate(123425); if validation is error { test:assertFail("Unexpected error found."); @@ -282,7 +282,7 @@ function testMaxDigitIntPositive() { } @test:Config {} -function testMaxDigitIntNegative() { +isolated function testMaxDigitIntNegative() { MaxDigitIntType|error validation = validate(12342567890); if validation is error { test:assertEquals(validation.message(), "Validation failed for '$:maxDigits' constraint(s)."); @@ -337,7 +337,7 @@ type DigitInteger int; type MaxDigitIntRefType DigitInteger; @test:Config {} -function testMaxDigitIntRefType() { +isolated function testMaxDigitIntRefType() { MaxDigitIntRefType|error validation = validate(1234); if validation is error { test:assertFail("Unexpected error found."); diff --git a/ballerina/tests/number_constraint_on_type_test.bal b/ballerina/tests/number_constraint_on_type_test.bal index 87ff587..f47533e 100644 --- a/ballerina/tests/number_constraint_on_type_test.bal +++ b/ballerina/tests/number_constraint_on_type_test.bal @@ -641,7 +641,7 @@ isolated function testNumberConstraintOnUnionTypeFailure8() { type MaxDigitNumberType decimal; @test:Config {} -function testMaxDigitNumberPositive() { +isolated function testMaxDigitNumberPositive() { MaxDigitNumberType|error validation = validate(1.234d); if validation is error { test:assertFail("Unexpected error found."); @@ -700,7 +700,7 @@ function testMaxDigitNumberPositive() { } @test:Config {} -function testMaxDigitNumberNegative() { +isolated function testMaxDigitNumberNegative() { MaxDigitNumberType|error validation = validate(1.234568d); if validation is error { test:assertEquals(validation.message(), "Validation failed for '$:maxFractionDigits' constraint(s)."); @@ -748,7 +748,7 @@ type DigitNumber decimal; type MaxIntegerDigitNumberRefType DigitNumber; @test:Config {} -function testMaxIntegerDigitsNumberRefType() { +isolated function testMaxIntegerDigitsNumberRefType() { MaxIntegerDigitNumberRefType|error validation = validate(-1234.12345d); if validation is error { test:assertFail("Unexpected error found."); @@ -787,7 +787,7 @@ function testMaxIntegerDigitsNumberRefType() { type MaxFractionDigitNumberRefType DigitNumber; @test:Config {} -function testMaxFractionDigitsNumberRefType() { +isolated function testMaxFractionDigitsNumberRefType() { MaxFractionDigitNumberRefType|error validation = validate(1234.12d); if validation is error { test:assertFail("Unexpected error found."); diff --git a/ballerina/tests/string_constraint_on_type_test.bal b/ballerina/tests/string_constraint_on_type_test.bal index fed32fe..65b3f51 100644 --- a/ballerina/tests/string_constraint_on_type_test.bal +++ b/ballerina/tests/string_constraint_on_type_test.bal @@ -139,7 +139,7 @@ isolated function testStringConstraintMaxLengthOnTypeFailure() { type StringConstraintPatternOnType string; @test:Config {} -function testStringConstraintPatternOnTypeSuccess1() { +isolated function testStringConstraintPatternOnTypeSuccess1() { StringConstraintPatternOnType typ = "964537342V"; StringConstraintPatternOnType|error validation = validate(typ); if validation is error { @@ -148,7 +148,7 @@ function testStringConstraintPatternOnTypeSuccess1() { } @test:Config {} -function testStringConstraintPatternOnTypeSuccess2() { +isolated function testStringConstraintPatternOnTypeSuccess2() { StringConstraintPatternOnType typ = "199645370342"; StringConstraintPatternOnType|error validation = validate(typ); if validation is error { @@ -157,7 +157,7 @@ function testStringConstraintPatternOnTypeSuccess2() { } @test:Config {} -function testStringConstraintPatternOnTypeFailure1() { +isolated function testStringConstraintPatternOnTypeFailure1() { StringConstraintPatternOnType typ = "19964537034234"; StringConstraintPatternOnType|error validation = validate(typ); if validation is error { @@ -168,7 +168,7 @@ function testStringConstraintPatternOnTypeFailure1() { } @test:Config {} -function testStringConstraintPatternOnTypeFailure2() { +isolated function testStringConstraintPatternOnTypeFailure2() { StringConstraintPatternOnType typ = "199645345A"; StringConstraintPatternOnType|error validation = validate(typ); if validation is error { From d3a7d0343bde5218773c9bfcd7ddac0752fabcf2 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 1 Mar 2024 08:53:34 +0530 Subject: [PATCH 3/4] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 6 +++--- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 6fdcdad..2ad2007 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.5.1" authors = ["Ballerina"] keywords = ["constraint", "validation"] repository = "https://github.com/ballerina-platform/module-ballerina-constraint" @@ -15,5 +15,5 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "constraint-native" -version = "1.5.0" -path = "../native/build/libs/constraint-native-1.5.0.jar" +version = "1.5.1" +path = "../native/build/libs/constraint-native-1.5.1-SNAPSHOT.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 8acb3e6..8e80df6 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "constraint-compiler-plugin" class = "io.ballerina.stdlib.constraint.compiler.ConstraintCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/constraint-compiler-plugin-1.5.0.jar" +path = "../compiler-plugin/build/libs/constraint-compiler-plugin-1.5.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index d12c174..8cdc2b1 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -10,7 +10,7 @@ distribution-version = "2201.8.0" [[package]] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "test"}, From 175d48fda6703a8f238cee5bb78c2f971106953a Mon Sep 17 00:00:00 2001 From: Krishnananthalingam Tharmigan <63336800+TharmiganK@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:05:37 +0530 Subject: [PATCH 4/4] Avoid cloning the record --- ballerina/tests/constriant_error_message_test.bal | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ballerina/tests/constriant_error_message_test.bal b/ballerina/tests/constriant_error_message_test.bal index babc5fc..f225cc7 100644 --- a/ballerina/tests/constriant_error_message_test.bal +++ b/ballerina/tests/constriant_error_message_test.bal @@ -161,13 +161,12 @@ const Trainee TRAINEE = { }; @test:Config {} -isolated function testErrorMessageInRecordTypePositive() returns error? { - Trainee trainee = check TRAINEE.cloneWithType(); - Trainee|error validation = validate(trainee); +isolated function testErrorMessageInRecordTypePositive() { + Trainee|error validation = validate(TRAINEE); if validation is error { test:assertFail("Unexpected error found."); } else { - test:assertEquals(validation, trainee); + test:assertEquals(validation, TRAINEE); } }